@yongdall/web 0.5.6 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Signal as e,Signal as t}from"signal-polyfill";import{ArrayStore as n,ArrayStore as r,BindObjectStore as i,ObjectStore as a,ObjectStore as o,Store as s,Store as c,renderStore as l,renderStore as u}from"@neeloong/form";import d,{default as f}from"dot-request";import{ArrayStore as p,createState as m,modelService as h}from"@yongdall/web";import g from"dompurify";var _=Object.defineProperty,v=(e,t)=>{let n={};for(var r in e)_(n,r,{get:e[r],enumerable:!0});return t||_(n,Symbol.toStringTag,{value:`Module`}),n};function y(e,n){let r=!0;if(n?.aborted)return;let i=new t.subtle.Watcher(()=>{r&&(r=!1,queueMicrotask(()=>{r=!0;for(let e of i.getPending())e.get();i.watch()}))}),a=new t.Computed(e);i.watch(a),a.get(),n?.addEventListener(`abort`,()=>{i.unwatch(a)},{once:!0})}function b(e,t,{immediate:n,signal:r}={}){let i=Array.isArray(e),a=i?e:[e],o=null,s=null;y(()=>{let e=a.map(e=>e()),c=o;if(o=e,c){if(c.findIndex((t,n)=>!Object.is(t,e[n]))<0)return}else if(!n)return;s?.abort(),s=new AbortController;let l=r?AbortSignal.any([r,s.signal]):s.signal;function u(e){if(!e)return l;l.addEventListener(`abort`,()=>e(),{once:!0})}t(i?[...e]:e[0],c?i?[...c]:c[0]:void 0,u)},r)}function x(e){return new t.State(e)}function S(e,n){let r=new t.Computed(e);return{get(){return r.get()},set:typeof n==`function`?n:()=>{}}}function ee(e,n,r){let i=new t.Computed(n),a=!1,o=e;return{get(){if(a)return o;try{return a=!0,o=i.get(),o}finally{a=!1}},set:typeof r==`function`?r:()=>{}}}function C(e,t){let n=Object.entries(t).map(([t,n])=>{let r=S(()=>e.get()?.[t],n=>e.set({...e.get(),[t]:n})),i=()=>r.get(),a=e=>r.set(e);if(n&&typeof n==`object`&&!Array.isArray(n)){let e=null;i=()=>e||=C(r,n),a=e=>r.set(structuredClone(e))}return[t,{get:i,set:a,enumerable:!0,configurable:!0}]});return Object.defineProperties({},Object.fromEntries(n))}const w=new Map;function te(e,t){if(t?.aborted)return S(()=>0);let n=w.get(e);if(!n){let t=x(0),r=performance.now(),i=setTimeout(function n(){let a=performance.now()-r,o=Math.floor(a/e);t.set(o);let s=(o+1)*e-a;i=setTimeout(n,Math.max(0,s))},e);n={tick:S(()=>t.get()),count:0,stop(){clearTimeout(i),w.get(e)===n&&w.delete(e)}},w.set(e,n)}return n.count++,t?.addEventListener(`abort`,()=>{n.count--,!n.count&&n.stop()},{once:!0}),n.tick}function ne(e,t,n){let r=n;for(;;){let n=e.next(r);if(n.done)return n.value;r=t(n.value)}}async function re(e,t,n){let r=n;for(;;){let n=e.next(r);if(n.done)return n.value;r=await t(n.value)}}function ie(e,t){let n=e;for(let e of t){let[t,...r]=typeof e==`string`?[e]:e;if(!n.length)continue;let i=[];it:for(let e of n){if(!e||typeof e!=`object`||!Object.hasOwn(e,t))continue;let n=e[t];for(let e of r){if(!Array.isArray(n))continue it;n=n[e]}i.push(n)}n=i.flat(1/0).filter(e=>e&&typeof e==`object`)}return n}function ae(e,t){let n=[];for(let r of e)!r||typeof r!=`object`||Object.hasOwn(r,t)&&n.push(r[t]);return n}function*oe(e,t,n){let r=[...n[0]],i=[...t,...r],a=r.pop();if(!a)return null;let o=typeof a==`string`?a:a[0],s=ie(e,r);if(!s.length)return!1;let[,c,l,u]=n;if(l===null){let e=ae(s,o);return u?e.find(e=>e===null):e.find(e=>e!==null)}if(typeof c!=`object`||!c||Array.isArray(c)){let e=ae(s,o);return e.length?yield{fields:i,operator:l,sign:u,value:c,values:e}:!1}if(c.filter||c.table||c.placeholder)return null;let d=c.field;if(!d)return null;let f=!1;for(let e of s){if(!e||typeof e!=`object`||!Object.hasOwn(e,d)||!Object.hasOwn(e,o))continue;f=null;let t=yield{fields:i,operator:l,sign:u,value:e[d],field:d,values:[e[o]]};if(t!==null)return t}return f}function*T(e,t,n){if(!Array.isArray(n)){let{and:r,or:i}=n;return yield*se(e,t,r,i)}if(n.length!==2)return yield*oe(e,t,n);let r=null,i=ie(e,n[0]);if(!i.length)return!1;let a=[...t,...n[0]];for(let e of n[1]){let t=yield*T(i,a,e);if(t!==null){if(!t)return!1;r=!0}}return r}function*se(e,t,n,r){let i=null;if(Array.isArray(n))for(let r of n){let n=yield*T(e,t,r);if(n!==null){if(!n)return!1;i=!0}}if(Array.isArray(r))for(let n of r){let r=yield*T(e,t,n);if(r!==null){if(r)return!0;i=!1}}return i}function ce(e,t,n,r){return ne(se([e].flat(),[],n,r),t,null)}async function le(e,t,n,r){return re(se([e].flat(),[],n,r),t,null)}function*ue(e){let t=[],n=!1;for(let r of e){let e=yield*de(r);t.push(e||r),e&&(n=!0)}return n?t:null}function*de(e){if(!Array.isArray(e)){let t=e.and&&(yield*fe(e.and)),n=e.or&&(yield*fe(e.or));return!t&&!n?null:{and:t||e.and,or:n||e.or}}if(e.length===2)return(yield*fe(e[1]))?[e[0],e[1]]:null;let t=yield e[1];return t===null?null:[e[0],t,e[2],e[3]]}function*fe(e){let t=[],n=!1;for(let r of e){let e=yield*de(r);t.push(e||r),e&&(n=!0)}return n?t:null}function pe(e,t){if(!e)return[];function n(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let n=e.placeholder;return!n||typeof n!=`string`?null:t(n)}return ne(ue(e),n,null)||e}function me(e){return e.map(({field:e,sub:t})=>t.length?[e,...t]:e)}function he(e){if(e.children)return[me(e.fields),e.children.map(he)];let{fields:t,operator:n,value:r,sign:i}=e;return[me(t),r,n,i]}const ge=/^([-_\d\p{L}]+)((?:\[-?\d+\])*)$/u;function _e(e){let t=[];for(let n of e.split(`.`)){if(!n||n[0]===`?`)return null;let e=n.indexOf(`?`),r=ge.exec(e>0?n.slice(0,e):n);if(!r)return null;let i=r[2]?.split(/\[|\]/).filter(Boolean).map(e=>parseInt(e)||0)||[],a=e>0?n.slice(e):void 0;t.push({field:r[1],group:a,sub:i})}return t}const E=e=>decodeURIComponent(e.replaceAll(`+`,` `));function ve(e){let t=[],n=[],r=t,i=[],a=!1,o=!0;function s(){r.push(E(i.join())),i=[]}for(let t of e){if(t===`,`){a?a=!1:s(),o=!0;continue}if(t===`)`){(o||i.length)&&(s(),o=!1);let e=n.pop();if(!e)return null;e.push(r),r=e,a=!0;continue}if(a)return null;if(o=!1,t!==`(`){i.push(t);continue}if(i.length)return null;n.push(r),r=[]}return(o||i.length)&&s(),n.length?null:t.length===1?t[0]:t}const ye=/^([-_\d\p{L}]+)@([-_\d\p{L}]+)/u;function be(e){if(e===null)return!0;if(e[0]===`?`)return{placeholder:E(e.slice(1))};if(e[0]===`:`)return{field:E(e.slice(1))};if(e[0]===`@`||ye.test(e))return null;if(e.includes(`(`)||e.includes(`)`)){let t=ve(e);if(t)return t}return e.includes(`,`)?e.split(`,`).map(e=>E(e.replaceAll(`+`,` `))):E(e)}function*xe(e){let t=e.map(e=>{let t=e.fields,n=t.findLastIndex(e=>e.group);if(n<0||n>=t.length-1)return[e,[],[]];let r=t[n];return r?[{...e,fields:t.slice(n+1)},t.slice(0,n+1),[...t.slice(0,n),{...r,group:void 0}]]:[e,[],[]]}),n=Object.groupBy(t,e=>JSON.stringify(e[1]));yield*n[`[]`]?.map(e=>he(e[0]))||[],delete n[`[]`];let r=Object.values(n).filter(Boolean).map((e=[])=>e?.length?{fields:e[0][2]||[],children:e.map(e=>e[0])}:{fields:[],children:[]}).filter(e=>e.fields.length);r.length&&(yield*xe(r))}function Se(e){let t=Map.groupBy(e,e=>e.groups.shift()??null),n=t.get(null)||[],r=t.get(``)||[];return t.delete(null),t.delete(``),{or:[...r.map(e=>he(e)),...[...t.values()].map(e=>Se(e))],and:[...xe(n)]}}function Ce(e,t=`&`){let n=[],r=[],i=[],a={},o=[],s=0,c=0,l=0,u=!1,d={},f=[];for(let p of typeof e==`string`?e.split(t):[]){if(p[0]===`=`){n.push(p.slice(1));continue}let e=p.indexOf(`=`),t=e<0?p:p.slice(0,e),m=e<0?null:p.slice(e+1);if(e<=0||`.!@^*<>{}[]()+|;,"'\`\\/`.includes(t[0]))continue;if(t[0]===`?`){d[E(t.slice(1))]=E(m||``);continue}if(t[0]===`:`){let e=t.slice(1);if(!m)continue;e===`sort`?o.push(...m.split(`,`).filter(Boolean).map(e=>{let t=e[0]===`-`;return[E(t?e.slice(1):e),t]}).filter(Boolean)):e===`select`?r.push(...m.split(`,`).map(E).filter(Boolean)):e===`primary`?i.push(...m.split(`,`).map(E).filter(Boolean)):e===`limit`?m&&/^\d+$/.test(m)&&(s=parseInt(m)):e===`offset`?m&&/^\d+$/.test(m)&&(c=parseInt(m)):e===`page`?m&&/^\d+$/.test(m)&&(l=parseInt(m)):e===`total`?m&&(u=!0):Object.hasOwn(a,e)?a[e].push(m):a[e]=[m];continue}let h=t.split(`~`),g=h.pop()||``,_=``;`!`.includes(g[g.length-1])&&(_=`!`,g=g.slice(0,-1));let v=g.split(`:`,3);if(v.length>2)continue;let y=_e(v[0]);if(!y)continue;let b=be(m);if(b===null)continue;let x=E(v[1]||``),S=h.indexOf(``),ee=S<0?h:h.slice(0,S+1);f.push({groups:ee,fields:y,operator:!x&&b===!0?null:x,sign:_,value:b===!0?null:b})}let{and:p,or:m}=Se(f),h={others:a};n?.length&&(h.values=n),u&&(h.total=u),s&&s>0&&(h.limit=s),l&&l>0&&(h.page=l),c&&c>0&&(h.offset=c),r?.length&&(h.select=r),i?.length&&(h.primary=i),o?.length&&(h.sort=o);let g=p;g?.length&&(h.where=g);let _=m;return _?.length&&(h.orWhere=_),Array.isArray(d)&&d.length&&(h.placeholders=d),h}function we(e,t){let n=t.limit||e.limit||0,r=t.page??e.page,i=[e.primary||[],t.primary||[]].flat().filter(Boolean),a=t.offset??(t.limit&&(t.page||t.page===0)?(Math.floor(Math.max(t.page||0,1))-1)*t.limit:null)??e.offset??(e.limit&&(e.page||e.page===0)?(Math.floor(Math.max(e.page||0,1))-1)*e.limit:null)??(Math.floor(Math.max(r||0,1))-1)*(n||10),o=[...e.values||[],...t.values||[]],s=[...e.sort||[],...t.sort||[]],c=[...e.select||[],...t.select||[]],l=[...e.where||[],...t.where||[]],u=[...e.orWhere||[],...t.orWhere||[]],d=[...e.or||[],...t.or||[]],f={};return o?.length&&(f.values=o),n&&n>0&&(f.limit=n),(e.total||t.total)&&(f.total=!0),r&&r>0&&(f.page=r),a&&a>0&&(f.offset=a),c?.length&&(f.select=c),s?.length&&(f.sort=s),l?.length&&(f.where=l),u?.length&&(f.orWhere=u),d?.length&&(f.or=d),i.length&&(f.primary=i),f}const D=e=>encodeURIComponent(e).replaceAll(`%20`,`+`);function Te(e){if(Array.isArray(e)){function t(e){return Array.isArray(e)?`(${e.map(t).join(`,`)})`:D(e)}let n=e.map(t).join(`,`);return e.length>1?n:`(${n})`}if(typeof e==`number`)return`${e}`;if(typeof e==`boolean`)return e?`1`:0;if(typeof e!=`object`)return D(e);let{field:t,placeholder:n}=e;return n?`?${D(n)}`:t?`:${D(t)}`:``}function Ee(e){return e.map(e=>{let[t,...n]=typeof e==`string`?[e]:e;return`${D(t)}${n.map(()=>`[k]`).join(``)}`}).join(`.`)}function De([e,t,n,r]){let i=n?`${Ee(e)}:${D(n)}${r||``}`:`${Ee(e)}${r||``}`;return n===null?i:t===null||typeof t==`function`?``:`${i}=${Te(t)}`}function Oe(e){let t=0;return e.flatMap(e=>{if(e.length!==2)return De(e);let n=Oe(e[1]);if(!n.length)return[];let r=Ee(e[0]);return n.length>1&&(r+=`?${(t++).toString(36)}`),n.map(e=>`${r}.${e}`)}).filter(Boolean)}function ke(e){let t=0;return e.map(e=>Array.isArray(e)?Oe([e]):[...Oe(e.and||[]),...ke(e.or||[])]).flatMap(e=>{if(!e)return[];let n=e.length===1?`~`:`${(t++).toString(36)}~`;return e.map(e=>`${n}${e}`)})}function Ae({values:e,where:t,orWhere:n,sort:r,select:i,primary:a,limit:o,offset:s,page:c,total:l,placeholders:u},d){let f=[];for(let t of e||[])t&&f.push(`=${D(t)}`);o&&o>0&&f.push(`:limit=${o}`),l&&f.push(`:total=${l}`),d?c&&c>0&&f.push(`:page=${c}`):s&&s>0&&f.push(`:offset=${s}`);let p=i?.filter(Boolean).map(D).join(`,`);p&&f.push(`:select=${p}`);let m=a?.filter(Boolean).map(D).join(`,`);if(m&&f.push(`:primary=${m}`),r){let e=r.filter(Boolean).map(e=>{if(Array.isArray(e)){let[t,n]=e;if(t)return`${n?`-`:``}${D(t)}`}else if(e)return D(e);return``}).filter(Boolean).join(`,`);e&&f.push(`:sort=${e}`)}if(u&&typeof u==`object`&&!Array.isArray(u))for(let[e,t]of Object.entries(u))f.push(`?${D(e)}=${D(t)}`);for(let e of Oe(t||[]))f.push(e);for(let e of ke(n||[]))f.push(e);return f.join(`&`)}function je(e,t,n,...r){function*i(t,n,...r){let a=[];if(n)for(let r of n){let n=yield*e.build(i,t,r);if(n!=null){if(e.value?.(n)===!1)return n;a.push(n)}}orFor:for(let n of r){if(!n)continue;let r=[];for(let o of n){let n=Array.isArray(o)?yield*e.build(i,t,o):yield*i(t,o.and,o.or);if(n!=null){if(e.value?.(n)===!0){a.push(n);continue orFor}r.push(n)}}let o=r.length?e.or(r):null;if(o!=null){if(e.value?.(o)===!1)return o;a.push(o)}}return a.length?e.and(a):null}return i(t,n,...r)}var Me=v({asyncExec:()=>le,asyncRunGenerator:()=>re,exec:()=>ce,fill:()=>pe,fillMatches:()=>fe,merge:()=>we,parse:()=>Ce,runGenerator:()=>ne,stringify:()=>Ae,toWhere:()=>je}),Ne=v({CST:()=>Pe,TZ:()=>Le,TZO:()=>Fe,parse:()=>Ve,parseTimeZone:()=>Be,toDate:()=>Ke,toDatetime:()=>Ge,toDatetimeTz:()=>We,toTime:()=>He,toTimeTz:()=>Ue});const Pe=Intl.DateTimeFormat().resolvedOptions().timeZone===`Asia/Shanghai`,Fe=new Date().getTimezoneOffset();function Ie(){let e=Fe;if(!e)return`Z`;let t=e<0?`+`:`-`;return e=Math.abs(e),t+[Math.floor(e/60),e%60].map(e=>`${e}`.padStart(2,`0`)).join(`:`)}const Le=Ie(),Re=/^(?:(?<Y>\d+)-(?<M>\d+)-(?<D>\d+)[t| ])?(?<h>2[0-3]|[01]?\d):(?<m>[0-5]?\d)(?::(?<s>[0-5]?\d)(?:(?:\.(?<ms>\d{1,3})?)?))?(?<tz>z|[+-]\d\d(:?\d\d)?)?$/i,ze=/^(?<Y>\d+)-(?<M>\d+)-(?<D>\d+)(?:[t| ](?<h>2[0-3]|[01]?\d):(?<m>[0-5]?\d)(?::(?<s>[0-5]?\d)(?:(?:\.(?<ms>\d{1,3})?)?))?(?<tz>z|[+-]\d\d(:?\d\d)?)?)?$/i;function Be(e){return e===`z`||e===`Z`?`Z`:!e||typeof e!=`string`?Le:e.includes(`:`)?e:`${e}:00`}function Ve(e){if(e instanceof Date)return e.valueOf()?new Date(e):null;if(typeof e==`number`){let t=new Date(e);return t.valueOf()?t:null}if(typeof e!=`string`)return null;let t=Re.exec(e)?.groups||ze.exec(e)?.groups;if(!t)return null;let{Y:n,M:r,D:i,h:a,m:o,s,ms:c,tz:l=``}=t,u=[`${n||2e3}`.padStart(4,`0`),`-`,`${r||1}`.padStart(2,`0`),`-`,`${i||1}`.padStart(2,`0`),`T`,`${a||0}`.padStart(2,`0`),`:`,`${o||0}`.padStart(2,`0`),`:`,`${s||0}`.padStart(2,`0`),`.`,`${c||0}`.padEnd(3,`0`),`${Be(l)}`].join(``),d=new Date(u);return d.valueOf()?d:null}function He(e){let t=new Date(e.valueOf()-Fe*6e4);return[t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds()].map(e=>`${e}`.padStart(2,`0`)).join(`:`)}function Ue(e){let t=new Date(e.valueOf()-Fe*6e4);return`${`${t.getUTCHours()}`.padStart(2,`0`)}:${`${t.getUTCMinutes()}`.padStart(2,`0`)}:${`${t.getUTCSeconds()}`.padStart(2,`0`)}.${`${t.getUTCMilliseconds()}`.padStart(3,`0`)}${Le}`}function We(e){let t=new Date(e.valueOf()-Fe*6e4);return`${`${t.getUTCFullYear()}`.padStart(4,`0`)}-${`${t.getUTCMonth()+1}`.padStart(2,`0`)}-${`${t.getUTCDate()}`.padStart(2,`0`)}T${`${t.getUTCHours()}`.padStart(2,`0`)}:${`${t.getUTCMinutes()}`.padStart(2,`0`)}:${`${t.getUTCSeconds()}`.padStart(2,`0`)}.${`${t.getUTCMilliseconds()}`.padStart(3,`0`)}${Le}`}function Ge(e){let t=new Date(e.valueOf()-Fe*6e4);return`${`${t.getUTCFullYear()}`.padStart(4,`0`)}-${`${t.getUTCMonth()+1}`.padStart(2,`0`)}-${`${t.getUTCDate()}`.padStart(2,`0`)}T${`${t.getUTCHours()}`.padStart(2,`0`)}:${`${t.getUTCMinutes()}`.padStart(2,`0`)}:${`${t.getUTCSeconds()}`.padStart(2,`0`)}`}function Ke(e){let t=new Date(e.valueOf()-Fe*6e4);return[t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate()].map(e=>`${e}`.padStart(2,`0`)).join(`-`)}const qe=/^(.*)\{(.*)\}(.*)$/,Je=/^\{(?<seq>#*(?<min>0*))\}$/;function Ye(e){let t=Je.exec(e)?.groups;if(t){let{seq:e,min:n}=t;return{name:null,max:e.length,min:n.length}}let n=qe.exec(e),r=e,i=!1,a=``,o=``;n&&([,a,r,o]=n,i=!0);let[s,...c]=r.split(`|`);return c.filter(Boolean).map(e=>{let t=e.indexOf(`:`);return t<0?[e,``]:[e.slice(0,t),e.slice(t+1)]}),{name:s,pipes:c.filter(Boolean).map(e=>{let t=e.indexOf(`:`);return t<0?[e,``]:[e.slice(0,t),e.slice(t+1)]}),optional:i,prefix:a,suffix:o}}function Xe(e){if(typeof e!=`string`)return[];let t=/\{([^{}]*\{[^{}]+\}[^{}]*|[^{}]+)\}/g,n=0,r=[];for(let i=t.exec(e);i;i=t.exec(e)){let t=i.index,[a,o]=i;t>n&&r.push(e.slice(n,t)),n=t+a.length,r.push(Ye(o))}return e.length>n&&r.push(e.slice(n)),r}function Ze(e,t){if((e??null)===null)return``;if(typeof e==`string`)return e;if(typeof e==`bigint`)return String(e);if(typeof e==`boolean`)return e?`1`:`0`;if(typeof e==`number`){if(!Number.isFinite(e))return``;let t=e.toPrecision(100);if(!t.includes(`.`))return t;let n=t.indexOf(`.`);return t.slice(0,n+5).replace(/\.?0+$/,``)}if(!(e instanceof Date))return`${e}`;let n=e;if(!n?.valueOf())return``;let r={Y:n.getFullYear(),M:n.getMonth()+1,d:n.getDate(),h:n.getHours(),m:n.getMinutes(),s:n.getSeconds()};return`YYYY-MM-DD hh:mm:ss`.replace(/([a-zA-Z])\1*/g,(e,t)=>{let n=`${Object.hasOwn(r,t)?r[t]:0}`,i=e.length;return`${n}`.padStart(i,`0`).slice(-i)})}function Qe(e,t,n,r){let i=Object.hasOwn(e,t)&&e[t];if(!i)return()=>{};let a=i.parseParam(n);return e=>i.generate(e,a,{optional:r})}function $e(e,t){let n=(Array.isArray(e)?e:Xe(e)).map(e=>!e||typeof e!=`object`?e:e.name==null?{...e,name:null}:t?{...e,pipes:e.pipes.map(([n,r])=>Qe(t,n,r,e.optional))}:{...e,pipes:[]});return n.length?(e,t)=>{let r=typeof e==`object`&&e||{},i=[];for(let e of n){if(!e||typeof e!=`object`){i.push(e);continue}if(e.name===null){let{min:n,max:r}=e,a=(Math.floor(t||0)||0).toPrecision(100).replace(/\.\d*$/,``).padStart(n,`0`).slice(-r);i.push(a);continue}let{name:n,prefix:a,suffix:o,optional:s,pipes:c}=e,l=Object.hasOwn(r,n)?r[n]??null:null;for(let e of c)l=e(l);let u=Ze(l,s);u&&i.push(a,u,o)}return i.join(``)}:()=>``}var et=v({date:()=>it,datetime:()=>ot,float:()=>ct,int:()=>lt,list:()=>ut,map:()=>dt,number:()=>st,time:()=>at});function tt(e,t,{optional:n}){if(!t)return``;let r=Ve(e)||(n?null:new Date);if(!r?.valueOf())return``;let i={Y:r.getFullYear(),M:r.getMonth()+1,D:r.getDate(),h:r.getHours(),m:r.getMinutes(),s:r.getSeconds()};return t.replace(/#*([a-zA-Z])\1*/g,(e,t)=>{let n=`${Object.hasOwn(i,t)?i[t]:0}`,r=e.length,a=e.replaceAll(`#`,``).length;return`${n}`.padStart(a,`0`).slice(-r)})}function nt(e,t){t||=e===`int`?`#############0`:e===`float`?`#############0.0###`:`#############0.####`;let[n,r=``]=t.split(`.`),i=n.length||1,a=n.replaceAll(`#`,``).length||1,o=e===`int`?0:r.length;return[a,i,e===`int`?0:r.replaceAll(`#`,``).length,o]}function rt(e,[t,n,r,i],{optional:a}){let o=``,s=``;return typeof e==`bigint`?o=String(e):typeof e==`number`?Number.isFinite(e)&&([o,s=``]=e.toPrecision(100).split(`.`)):typeof e==`string`&&/^\s*[+-]?\s*(\d_)*\.?(\d_)*/.test(e)&&([o,s=``]=e.replace(/[^\d.-]/g,``).split(`.`)),!o&&!s&&a?``:(o=o.padStart(t,`0`).slice(-n),s=s.replace(/0+$/,``).padEnd(r,`0`).slice(0,i),s?`${o}.${s}`:o)}const it={parseParam:e=>e||`YYYY-MM-DD`,generate:tt},at={parseParam:e=>e||`hh:mm:ss`,generate:tt},ot={parseParam:e=>e||`YYYY-MM-DD hh:mm:ss`,generate:tt},st={parseParam:e=>nt(`number`,e),generate:rt},ct={parseParam:e=>nt(`float`,e),generate:rt},lt={parseParam:e=>nt(`int`,e),generate:rt},ut={parseParam(e){return e.split(`;`)},generate(e,t,{optional:n}){let r=-1;if(typeof e==`bigint`)r=Number(e);else if(typeof e==`number`)r=Math.floor(e);else if(typeof e==`boolean`)r=e?1:0;else if(typeof e==`string`){if(!/^\s*[+-]\s*(\d_)*/.test(e))return``;r=Number.parseInt(e.replace(/[^\d.+-]/g,``))}return r<0||r>=t.length?n?``:t[0]:t[r]}},dt={parseParam:e=>Object.fromEntries(e.split(`;`).map(e=>{let t=e.indexOf(`=`);return t<0?[e,e]:[e.slice(0,t),e.slice(t+1)]})),generate(e,t,{optional:n}){let r=``;return typeof e==`bigint`||typeof e==`number`?r=String(e):typeof e==`boolean`?r=e?`1`:`0`:typeof e==`string`&&(r=e),Object.hasOwn(t,r)?t[r]:n?``:Object.values(t)[0]}};function O(e,t,n,r){let i=typeof n==`number`?n:0;return $e(e,[n,r].filter(Boolean).find(e=>typeof e==`object`)||et)(t,i)}var ft=v({generate:()=>O,generators:()=>et,parse:()=>Xe,toGenerate:()=>$e});const pt=Error.prototype;function mt(e,t){if(!(t instanceof Error))throw t;for(let n=Object.getPrototypeOf(t);n;n=Object.getPrototypeOf(n)){let r=e.get(n);if(typeof r==`function`)return r(t);if(n===pt)break}throw t}const ht=()=>!0;function gt(e,t){let n=[e].flat();for(let e of t.filter(Boolean)){let t=[];for(let r of n)!r||typeof r!=`object`||Object.hasOwn(r,e)&&t.push(r[e]);if(!t.length)return[];n=t.flat()}return n}function _t(e,t){if(!t.length)return e;if(!e||typeof e!=`object`)return;let[n,...r]=t;for(let t of[e].flat()){let e=_t(t[n],r);if(e!==void 0)return e}}function*vt(e,t){for(let n of Object.values(e))for(let e of gt(n,t))yield e}var yt=class e{static build(t){let n=new e;return e.update(n,t)}static update(t,n){let r=!1;return typeof n==`function`?(Object.defineProperty(t.#e,`hooks`,{configurable:!0,get(){let e=n();return typeof e==`object`&&e||{}}}),r=!0):n&&typeof n==`object`&&(Object.defineProperty(t.#e,`hooks`,{configurable:!0,value:n}),r=!0),r&&e.reset(t),t}static reset(e){let t=e.#r,n=e.#e.resetFn;n.sort(([,e],[,t])=>e-t);let r=n.filter(([,e])=>e<=0),i=n.filter(([,e])=>e>0);for(let[e]of r)e();for(let e of vt(t,[`reset`]))typeof e==`function`&&e();for(let[e]of i)e()}#e={hooks:Object.create(null),resetFn:[]};#t=[];#n=`Hook`;[Symbol.iterator](){return this.entries()}[Symbol.toStringTag](){return this.#n}[Symbol.toPrimitive](e){return e===`number`?NaN:`[${this[Symbol.toStringTag]()}]`}get#r(){return this.#e.hooks}get(t){let n=[...this.#t,t],r=new e;return r.#e=this.#e,r.#t=n,r.#n=`Hook(${n.join(`.`)})`,r}call(...e){for(let t of this.values())typeof t==`function`&&t(...e)}first(e){let t=this.#r;if(Object.hasOwn(t,e))return _t(t[e],this.#t.filter(Boolean))}*plugin(e){let t=this.#r;Object.hasOwn(t,e)&&(yield*gt(t[e],this.#t.filter(Boolean)))}values(){return vt(this.#r,this.#t)}*entries(){let e=this.#r,t=this.#t;for(let[n,r]of Object.entries(e))for(let e of gt(r,t))yield[n,e]}*entriesObject(e=ht){for(let[t,n]of this.entries())if(!(!n||typeof n!=`object`))for(let[r,i]of Object.entries(n))e(i)&&(yield[t,r,i])}named(e=ht){let t=Object.create(null);for(let n of this.values())if(!(!n||typeof n!=`object`))for(let[r,i]of Object.entries(n))e(i)&&(t[r]=i);return t}listen(e,t){if(typeof e!=`function`)return()=>{};let n=this.#e.resetFn,r=[e,Number.isFinite(t)&&t||0];return n.push(r),n.sort(([,e],[,t])=>t-e),()=>{let e=n.findIndex(e=>e===r);e>=0&&n.splice(e,1)}}};const bt=Error.prototype;var xt=class{#e=new WeakMap;register(e,t){if(typeof t!=`function`)throw TypeError(`Handler must be a function`);if(typeof e!=`function`)throw TypeError(`Registered error class must be a subclass of Error`);let n=e.prototype;if(!(n instanceof Error))throw TypeError(`Registered error class must be a subclass of Error`);this.#e.set(n,t)}async convert(e){if(!(e instanceof Error))throw e;let t=this.#e;for(let n=Object.getPrototypeOf(e);n&&n!==bt;n=Object.getPrototypeOf(n)){let r=t.get(n);if(!r)continue;let i=await r(e)??null;if(i!==null)return i}let n=t.get(bt);return n?await n(e)??null:null}},St=class e extends Promise{static get[Symbol.species](){return Promise}#e;constructor(e){let t=null;super((n,r)=>{t=()=>{try{e(n,r)}catch(e){r(e)}}}),this.#e=()=>{let e=t;t=null,e&&e()}}then(e,t){return this.#e(),super.then(e,t)}lazyThen(t,n){return new e((e,r)=>{this.then(n=>{if(typeof t==`function`)try{e(t(n))}catch(e){r(e)}else e(n)},t=>{if(typeof n==`function`)try{e(n(t))}catch(e){r(e)}else r(t)})})}lazyCatch(e){return this.finally,this.lazyThen(void 0,e)}lazyFinally(e){return typeof e==`function`?this.lazyThen(async t=>(await e(),t),async t=>{throw await e(),t}):this}static resolve(t){return new e(e=>{e(t)})}static reject(t){return new e((e,n)=>{n(t)})}static all(t){return new e((e,n)=>{Promise.all(t).then(e,n)})}static allSettled(t){return new e(e=>{Promise.allSettled(t).then(e)})}static any(t){return new e((e,n)=>{Promise.any(t).then(e,n)})}static race(t){return new e((e,n)=>{Promise.race(t).then(e,n)})}static try(t,...n){return new e((e,r)=>{try{e(t(...n))}catch(e){r(e)}})}static withResolvers(){return Promise.withResolvers()}};const Ct=/\{([^}{}]+)\}/g;function wt(e){if(!e||typeof e!=`string`)return[];let t=[];for(let n=Ct.exec(e);n;n=Ct.exec(e))t.push(n[1]);return t}function Tt(e,t){return O(e,t)}function*Et({constraints:e,organizationField:t}){if(t&&(yield t),e)for(let[t,n]of Object.entries(e)){if(!n)continue;let{value:e,values:r,user:i}=n;e===void 0?(Array.isArray(r)&&r.length||r instanceof Set&&r.size||i)&&(yield t):yield t}}const Dt=/^(?:(?<scope>@[a-zA-Z\d_.-]+)\/)?(?<name>[a-zA-Z\d_.-]+)$/,Ot=/^(?<pluginId>(?:(?<scope>@[a-zA-Z\d_.-]+)\/)?(?<name>[a-zA-Z\d_.-]+))(?:\/(?<path>[^#]*))?(?:#(?<hash>.*))?$/;function kt(e){return typeof e==`function`}const At=x({}),k=yt.build(()=>At.get());function jt(e){At.set(e),yt.reset(k)}function Mt(e,t,n){let r=typeof t==`string`?t:``,i=t===!0||n===!0?`[]`:``;return!e||e===`.`?r?`:${r}${i}`:void 0:r?`${e}:${r}${i}`:`${e}${i}`}function Nt(e){return typeof e==`boolean`?!e:e}const Pt=S(()=>{let e=new Map;for(let t of k.get(`formFields`).values()){let{type:n,array:r,renderer:i,input:a}=t,o=Mt(typeof n==`string`?n:``,typeof i==`string`?i:``,!!r);o&&typeof a==`function`&&e.set(o,a)}return e}),Ft=S(()=>{let e={},t={};function n(e,t,{not:n,value:r,notValue:i,named:a,notNamed:o,field:s,notField:c},l=``){n&&(typeof r==`function`&&(i=(...e)=>Nt(r(...e))),typeof s==`function`&&(c=(...e)=>Nt(s(...e))),typeof a==`function`&&(o=(...e)=>Nt(a(...e))));let u=Object.hasOwn(e,l)&&e[l]||{value:[],named:[],field:[],notValue:[],notNamed:[],notField:[]};e[l]=u,typeof r==`function`&&u.value.push(r),typeof i==`function`&&u.notValue.push(i),typeof a==`function`&&u.named.push(a),typeof o==`function`&&u.notNamed.push(o),typeof s==`function`&&u.field.push(s),typeof c==`function`&&u.notField.push(c);let d=typeof n==`string`&&n||``;if(!d)return;let f=Object.hasOwn(t,d)&&t[d]||{value:[],named:[],field:[],notValue:[],notNamed:[],notField:[]};t[d]=u,typeof r==`function`&&f.notValue.push(r),typeof i==`function`&&f.value.push(i),typeof a==`function`&&f.notNamed.push(a),typeof o==`function`&&f.named.push(o),typeof s==`function`&&f.notField.push(s),typeof c==`function`&&f.field.push(c)}for(let r of k.get(`formFields`).values()){let{type:i,array:a,renderer:o,filters:s}=r,c=Mt(typeof i==`string`?i:``,typeof o==`string`?o:``,!!a)||(a?`[]`:``),l=Object.hasOwn(e,c)&&e[c]||{},u=Object.hasOwn(t,c)&&t[c]||{};n(l,u,r);for(let[e,t]of Object.entries(s||{}))!t||Array.isArray(t)||typeof t!=`object`||n(l,u,t,e);e[c]=l,t[c]=u}for(let n of Object.keys({...e,...t})){let r=Object.hasOwn(t,n)&&t[n];if(!r)continue;let i=Object.hasOwn(e,n)&&e[n]||{};e[n]=i;for(let e of Object.keys({...i,...r})){let t=Object.hasOwn(r,e)&&r[e];if(!t)continue;let n=Object.hasOwn(i,e)&&i[e]||{value:[],named:[],field:[],notValue:[],notNamed:[],notField:[]};if(i[e]=n,t){for(let e of t.value)n.value.push(e);for(let e of t.notValue)n.notValue.push(e);for(let e of t.named)n.named.push(e);for(let e of t.notNamed)n.notNamed.push(e);for(let e of t.field)n.field.push(e);for(let e of t.notField)n.notField.push(e)}}}return e}),It=S(()=>{let e=new Map;for(let t of k.get(`formFields`).values()){let{type:n,array:r,renderer:i,filter:a,filters:o}=t,s=Mt(typeof n==`string`?n:``,typeof i==`string`?i:``,!!r);if(!s)continue;let c=e.get(s)||new Map;if(typeof a==`function`){let e=c.get(``);e?e.component=a:c.set(``,{component:a,label:`=`})}for(let[e,t]of Object.entries(o||{})){if(!t)continue;let n=Array.isArray(t)?t[0]:typeof t==`function`?t:t.filter;if(typeof n!=`function`)continue;let r=Array.isArray(t)?t[1]:typeof t==`object`?t.label:null,i=c.get(e);if(!i){c.set(e,{component:n,label:typeof r==`string`?r:``});continue}i.component=n,typeof r==`string`&&(i.label=r)}c.size&&e.set(s,c)}return e});function Lt(){return Ft.get()}function*Rt(e){if(e)for(let t of Array.isArray(e)?e:[e]){if(!t)continue;if(typeof t==`string`){yield[t];continue}if(typeof t!=`object`)continue;let e=t.component;!e||typeof e!=`string`||(yield[e,t])}}function*zt(e){if(!e)return;let t=typeof e==`string`?e:e.type,n=typeof e==`string`?``:e.renderer,r=typeof e==`string`?``:e.array?`[]`:``;if(!t){for(let[e,t]of Rt(n))yield[`:${e}${r}`,t],yield[`${e}${r}`,t];return}if(typeof t==`object`){for(let[e,t]of Rt(n))yield[`submodel:${e}${r}`,t],yield[`${e}${r}`,t];yield[`submodel${r}`];return}for(let[e,i]of Rt(n))yield[`${t}:${e}${r}`,i],yield[`:${e}${r}`,i],yield[`${e}${r}`,i];yield[`${t}${r}`]}function Bt(e,t){let n=Pt.get();for(let[t,r]of zt(e)){let e=n.get(t);if(e)return t=>e(t,r)}return t?null:(typeof e==`string`||e.type,()=>document.createElement(`div`))}function Vt(e){let t=Pt.get();for(let[n]of zt(e))if(t.get(n))return!0;return typeof e==`string`||e.type,!1}const Ht=()=>document.createElement(`div`);function Ut(e,t){let n=It.get();for(let[r,i]of zt(e)){let e=n.get(r)?.get(t);if(!e)continue;let a=e.component;return e=>a(e,i)}return Ht}function Wt(e){let t=It.get(),n=Object.create(null);for(let[r]of zt(e)){let e=t.get(r);if(e)for(let[t,{label:r}]of e)n[t]||(n[t]=r)}return n}function Gt(e,t){let n=It.get();for(let[r]of zt(e))if(n.get(r)?.has(t))return!0;return!1}function*Kt(e,t){let n=Ft.get();for(let[r]of typeof e==`boolean`?e?[[`[]`],[``]]:[[``]]:zt(e)){let e=Object.hasOwn(n,r)&&n[r];if(!e)continue;let i=Object.hasOwn(e,t)&&e[t];i&&(yield i)}let r=Object.hasOwn(n,``)&&n[``];if(!r)return;let i=Object.hasOwn(r,t)&&r[t];i&&(yield i)}const qt={api:`/api`,file:`/fileCabinets`};var Jt=qt;function Yt(e=new Date){let t=e.getTimezoneOffset();if(!t)return`Z`;let n=t<0?`+`:`-`;return t=Math.abs(t),n+[Math.floor(t/60),t%60].map(e=>`${e}`.padStart(2,`0`)).join(`:`)}function Xt(e){return[e.getHours(),e.getMinutes(),e.getSeconds()].map(e=>`${e}`.padStart(2,`0`)).join(`:`)}function Zt(e){return[`${e.getFullYear()}`.padStart(4,`0`),`${e.getMonth()+1}`.padStart(2,`0`),`${e.getDate()}`.padStart(2,`0`)].join(`-`)}function Qt(e){return Xt(e)+`.${e.getMilliseconds()}`.padStart(3,`0`)+Yt(e)}function $t(e){return Zt(e)+`T`+Qt(e)}var en=class e extends f{build(){return new e}method(e,t){return super.method(`POST`,t).header(`X-Method`,e)}};async function tn(e){let t=e.headers.get(`content-type`)?.split(`;`)[0].replace(/\s+/g,``).toLowerCase()||``;return t===`application/json`||t===`text/json`?await e.json().then(e=>Promise.reject(e?.error),e=>Promise.reject(null)):t===`text/plain`?await e.text().then(e=>Promise.reject(e)):Promise.reject(e)}function nn(e){return e.status,tn(e)}function rn(e){if(!e||e instanceof Response)return alert(`未知`);if(typeof e==`string`)return alert(e);if(typeof e!=`object`)return;let{message:t,code:n}=e;typeof t!=`string`&&(t=``),typeof n!=`string`&&(n=``),!(!t&&!n)&&alert([t||`为止错误`,n?`[${n}]`:``].filter(Boolean).join(` `))}let an=rn;function on(e){return nn(e).catch(async e=>(await an(e),Promise.reject(e)))}const sn=new en().get().prefix(Jt.api).stringifyJSON(e=>JSON.stringify(e,(e,t)=>t instanceof Date?$t(t):typeof t==`bigint`?String(t):t instanceof Set?[...t]:t)).errorHandler(tn);var A=sn.clone().errorHandler(on);function cn(e){typeof e==`function`&&(an=e)}const j=await sn.clone().get`application`.query({domain:location.hostname,port:location.port,path:location.pathname}).json(),ln=window.yongdallPlugins,un=j.id,dn=new URL(j.path||`/workbench/`,location.origin),fn=dn.href,pn=dn.pathname,mn=x(j.menus||[]),hn=x(j.userMenus||[]),gn=x(!1);async function _n(){if(!gn.get()){gn.set(!0);try{let e=await sn.clone().get`applications`.append(`${un}`).json();if(!j||typeof e!=`object`)return;mn.set(e.menus||[]),hn.set(e.userMenus||[])}finally{gn.set(!1)}}}const M={get id(){return un},get path(){return pn},get root(){return fn},get theme(){return j.theme},get route(){return j.route},get authenticator(){return j.authenticator},get type(){return j.type},get skin(){return j.skin},get menus(){return mn.get()},get userMenus(){return hn.get()},get logo(){return j.logo},get title(){return j.title},get company(){return j.company},get help(){return j.help},get refreshing(){return gn.get()},refresh:_n};function vn(e,t,n){let r={};function i(...i){let a=t(...i);if(Object.hasOwn(r,a)&&!n?.(...i))return r[a];let o=e(...i);return r[a]=o,o}return i}const{authRequired:yn,multiUser:bn,userType:xn}=j,N=xn===`visitor`,Sn=x(null),Cn=x(null),wn=x(null),Tn=S(()=>wn.get()||Sn.get()),En=vn(e=>{if(N)return{get session(){return null},get target(){return null},get current(){return null}};let t=S(()=>Sn.get()?.plugins?.[e]||null),n=S(()=>wn.get()?.plugins?.[e]||null),r=S(()=>Tn.get()?.plugins?.[e]||null);return{get session(){return t.get()},get target(){return n.get()},get current(){return r.get()}}},e=>e||``),P=x(!1),Dn=x(!1),On=S(()=>Dn.get()?!0:!(!yn||P.get()||Sn.get()));function kn(e){return new Set(e.filter(e=>e&&typeof e==`string`))}function An(e){let t=e.plugins;if(t&&typeof t==`object`)for(let[n,r]of k.get(`user`).get(`permissions`)){if(typeof r!=`function`||!Object.hasOwn(t,n))continue;let i=t[n];if(!i||typeof i!=`object`)continue;let a=r(i,e);if(a instanceof Set)return a}let n=e.permissions;return Array.isArray(n)?kn(n):new Set}function jn(e){let t=e.plugins;if(t&&typeof t==`object`)for(let[n,r]of k.get(`user`).get(`organizationPermissions`)){if(typeof r!=`function`||!Object.hasOwn(t,n))continue;let i=t[n];if(!i||typeof i!=`object`)continue;let a=r(i,e);if(a)return Object.assign(Object.create(null),a)}let n=e.organizationPermissions;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=Object.entries(n).filter(e=>Array.isArray(e[1]));if(e.length)return Object.assign(Object.create(null),Object.fromEntries(e.map(([e,t])=>[e,kn(t)])))}let{organizationRolePermissions:r,organizationRoles:i}=e;return!i||typeof i!=`object`||Array.isArray(i)||!r||typeof r!=`object`||Array.isArray(r)?null:Object.assign(Object.create(null),Object.fromEntries(Object.entries(i).map(([e,t])=>[e,kn(t.flatMap(e=>Object.hasOwn(r,e)&&r[e]||[]))])))}const Mn=S(()=>{let e=Tn.get();return e?An(e):null}),Nn=S(()=>{let e=Tn.get();return e?jn(e):null}),Pn=S(()=>{let e=Nn.get();return e?new Set(Object.values(e).flatMap(e=>[...e])):null});function Fn(){return P.get()?{has:()=>!0,get size(){return-1}}:new Set}const F={get visitor(){return N},get multi(){return N||!!bn},get single(){return P.get()},get session(){return N?Cn.get():Sn.get()},get target(){return N?null:wn.get()},get current(){return N?Cn.get():Tn.get()},hasPermission(e){return N?!1:Mn.get()?.has(e)??P.get()},hasOrganizationPermission(e,t){if(N)return!1;if(typeof t!=`string`)return Pn.get()?.has(e)??P.get();let n=Nn.get();return n?Object.hasOwn(n,t)?n[t]?.has(e)??!1:!1:P.get()},get permissions(){return N?new Set:Mn.get()||Fn()},get organizationPermissions(){return N?Object.create(null):Nn.get()||new Proxy({},{get(){return Fn()}})},get allOrganizationPermissions(){return N?new Set:Pn.get()||Fn()},get waitLogin(){return On.get()},plugin(e){return En(e)},async load(){if(N){let{visitor:e}=await sn.clone().get`visitor`.json().then(e=>e||{},()=>({}));return P.set(!1),Cn.set(e||null),e&&Dn.set(!1),!!e}let{session:e,target:t}=await sn.clone().get`user`.json().then(e=>e||{},()=>({}));return wn.set(t||null),e===!0?(P.set(!0),Sn.set(null)):(P.set(!1),Sn.set(e||null)),e&&Dn.set(!1),!!e},exit(){if(N){Cn.set(null),sn.clone().delete`visitor`.done();return}wn.set(null),Sn.set(null),sn.clone().delete`user`.done()},login(e=!0){Dn.set(!!e)}};function In(e){if(!e)return[];let t=typeof e==`string`?e.split(`
|
|
1
|
+
import{Signal as e,Signal as t}from"signal-polyfill";import{ArrayStore as n,ArrayStore as r,BindObjectStore as i,ObjectStore as a,ObjectStore as o,Store as s,Store as c,renderStore as l,renderStore as u}from"@neeloong/form";import d,{default as f}from"dot-request";import{ArrayStore as p,createState as m,modelService as h}from"@yongdall/web";import g from"dompurify";var _=Object.defineProperty,v=(e,t)=>{let n={};for(var r in e)_(n,r,{get:e[r],enumerable:!0});return t||_(n,Symbol.toStringTag,{value:`Module`}),n};function y(e,n){let r=!0;if(n?.aborted)return;let i=new t.subtle.Watcher(()=>{r&&(r=!1,queueMicrotask(()=>{r=!0;for(let e of i.getPending())e.get();i.watch()}))}),a=new t.Computed(e);i.watch(a),a.get(),n?.addEventListener(`abort`,()=>{i.unwatch(a)},{once:!0})}function b(e,t,{immediate:n,signal:r}={}){let i=Array.isArray(e),a=i?e:[e],o=null,s=null;y(()=>{let e=a.map(e=>e()),c=o;if(o=e,c){if(c.findIndex((t,n)=>!Object.is(t,e[n]))<0)return}else if(!n)return;s?.abort(),s=new AbortController;let l=r?AbortSignal.any([r,s.signal]):s.signal;function u(e){if(!e)return l;l.addEventListener(`abort`,()=>e(),{once:!0})}t(i?[...e]:e[0],c?i?[...c]:c[0]:void 0,u)},r)}function x(e){return new t.State(e)}function S(e,n){let r=new t.Computed(e);return{get(){return r.get()},set:typeof n==`function`?n:()=>{}}}function ee(e,n,r){let i=new t.Computed(n),a=!1,o=e;return{get(){if(a)return o;try{return a=!0,o=i.get(),o}finally{a=!1}},set:typeof r==`function`?r:()=>{}}}function C(e,t){let n=Object.entries(t).map(([t,n])=>{let r=S(()=>e.get()?.[t],n=>e.set({...e.get(),[t]:n})),i=()=>r.get(),a=e=>r.set(e);if(n&&typeof n==`object`&&!Array.isArray(n)){let e=null;i=()=>e||=C(r,n),a=e=>r.set(structuredClone(e))}return[t,{get:i,set:a,enumerable:!0,configurable:!0}]});return Object.defineProperties({},Object.fromEntries(n))}const w=new Map;function te(e,t){if(t?.aborted)return S(()=>0);let n=w.get(e);if(!n){let t=x(0),r=performance.now(),i=setTimeout(function n(){let a=performance.now()-r,o=Math.floor(a/e);t.set(o);let s=(o+1)*e-a;i=setTimeout(n,Math.max(0,s))},e);n={tick:S(()=>t.get()),count:0,stop(){clearTimeout(i),w.get(e)===n&&w.delete(e)}},w.set(e,n)}return n.count++,t?.addEventListener(`abort`,()=>{n.count--,!n.count&&n.stop()},{once:!0}),n.tick}function ne(e,t,n){let r=n;for(;;){let n=e.next(r);if(n.done)return n.value;r=t(n.value)}}async function re(e,t,n){let r=n;for(;;){let n=e.next(r);if(n.done)return n.value;r=await t(n.value)}}function ie(e,t){let n=e;for(let e of t){let[t,...r]=typeof e==`string`?[e]:e;if(!n.length)continue;let i=[];it:for(let e of n){if(!e||typeof e!=`object`||!Object.hasOwn(e,t))continue;let n=e[t];for(let e of r){if(!Array.isArray(n))continue it;n=n[e]}i.push(n)}n=i.flat(1/0).filter(e=>e&&typeof e==`object`)}return n}function ae(e,t){let n=[];for(let r of e)!r||typeof r!=`object`||Object.hasOwn(r,t)&&n.push(r[t]);return n}function*oe(e,t,n){let r=[...n[0]],i=[...t,...r],a=r.pop();if(!a)return null;let o=typeof a==`string`?a:a[0],s=ie(e,r);if(!s.length)return!1;let[,c,l,u]=n;if(l===null){let e=ae(s,o);return u?e.find(e=>e===null):e.find(e=>e!==null)}if(typeof c!=`object`||!c||Array.isArray(c)){let e=ae(s,o);return e.length?yield{fields:i,operator:l,sign:u,value:c,values:e}:!1}if(c.filter||c.table||c.placeholder)return null;let d=c.field;if(!d)return null;let f=!1;for(let e of s){if(!e||typeof e!=`object`||!Object.hasOwn(e,d)||!Object.hasOwn(e,o))continue;f=null;let t=yield{fields:i,operator:l,sign:u,value:e[d],field:d,values:[e[o]]};if(t!==null)return t}return f}function*T(e,t,n){if(!Array.isArray(n)){let{and:r,or:i}=n;return yield*se(e,t,r,i)}if(n.length!==2)return yield*oe(e,t,n);let r=null,i=ie(e,n[0]);if(!i.length)return!1;let a=[...t,...n[0]];for(let e of n[1]){let t=yield*T(i,a,e);if(t!==null){if(!t)return!1;r=!0}}return r}function*se(e,t,n,r){let i=null;if(Array.isArray(n))for(let r of n){let n=yield*T(e,t,r);if(n!==null){if(!n)return!1;i=!0}}if(Array.isArray(r))for(let n of r){let r=yield*T(e,t,n);if(r!==null){if(r)return!0;i=!1}}return i}function ce(e,t,n,r){return ne(se([e].flat(),[],n,r),t,null)}async function le(e,t,n,r){return re(se([e].flat(),[],n,r),t,null)}function*ue(e){let t=[],n=!1;for(let r of e){let e=yield*de(r);t.push(e||r),e&&(n=!0)}return n?t:null}function*de(e){if(!Array.isArray(e)){let t=e.and&&(yield*fe(e.and)),n=e.or&&(yield*fe(e.or));return!t&&!n?null:{and:t||e.and,or:n||e.or}}if(e.length===2)return(yield*fe(e[1]))?[e[0],e[1]]:null;let t=yield e[1];return t===null?null:[e[0],t,e[2],e[3]]}function*fe(e){let t=[],n=!1;for(let r of e){let e=yield*de(r);t.push(e||r),e&&(n=!0)}return n?t:null}function pe(e,t){if(!e)return[];function n(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let n=e.placeholder;return!n||typeof n!=`string`?null:t(n)}return ne(ue(e),n,null)||e}function me(e){return e.map(({field:e,sub:t})=>t.length?[e,...t]:e)}function he(e){if(e.children)return[me(e.fields),e.children.map(he)];let{fields:t,operator:n,value:r,sign:i}=e;return[me(t),r,n,i]}const ge=/^([-_\d\p{L}]+)((?:\[-?\d+\])*)$/u;function _e(e){let t=[];for(let n of e.split(`.`)){if(!n||n[0]===`?`)return null;let e=n.indexOf(`?`),r=ge.exec(e>0?n.slice(0,e):n);if(!r)return null;let i=r[2]?.split(/\[|\]/).filter(Boolean).map(e=>parseInt(e)||0)||[],a=e>0?n.slice(e):void 0;t.push({field:r[1],group:a,sub:i})}return t}const E=e=>decodeURIComponent(e.replaceAll(`+`,` `));function ve(e){let t=[],n=[],r=t,i=[],a=!1,o=!0;function s(){r.push(E(i.join())),i=[]}for(let t of e){if(t===`,`){a?a=!1:s(),o=!0;continue}if(t===`)`){(o||i.length)&&(s(),o=!1);let e=n.pop();if(!e)return null;e.push(r),r=e,a=!0;continue}if(a)return null;if(o=!1,t!==`(`){i.push(t);continue}if(i.length)return null;n.push(r),r=[]}return(o||i.length)&&s(),n.length?null:t.length===1?t[0]:t}const ye=/^([-_\d\p{L}]+)@([-_\d\p{L}]+)/u;function be(e){if(e===null)return!0;if(e[0]===`?`)return{placeholder:E(e.slice(1))};if(e[0]===`:`)return{field:E(e.slice(1))};if(e[0]===`@`||ye.test(e))return null;if(e.includes(`(`)||e.includes(`)`)){let t=ve(e);if(t)return t}return e.includes(`,`)?e.split(`,`).map(e=>E(e.replaceAll(`+`,` `))):E(e)}function*xe(e){let t=e.map(e=>{let t=e.fields,n=t.findLastIndex(e=>e.group);if(n<0||n>=t.length-1)return[e,[],[]];let r=t[n];return r?[{...e,fields:t.slice(n+1)},t.slice(0,n+1),[...t.slice(0,n),{...r,group:void 0}]]:[e,[],[]]}),n=Object.groupBy(t,e=>JSON.stringify(e[1]));yield*n[`[]`]?.map(e=>he(e[0]))||[],delete n[`[]`];let r=Object.values(n).filter(Boolean).map((e=[])=>e?.length?{fields:e[0][2]||[],children:e.map(e=>e[0])}:{fields:[],children:[]}).filter(e=>e.fields.length);r.length&&(yield*xe(r))}function Se(e){let t=Map.groupBy(e,e=>e.groups.shift()??null),n=t.get(null)||[],r=t.get(``)||[];return t.delete(null),t.delete(``),{or:[...r.map(e=>he(e)),...[...t.values()].map(e=>Se(e))],and:[...xe(n)]}}function Ce(e,t=`&`){let n=[],r=[],i=[],a={},o=[],s=0,c=0,l=0,u=!1,d={},f=[];for(let p of typeof e==`string`?e.split(t):[]){if(p[0]===`=`){n.push(p.slice(1));continue}let e=p.indexOf(`=`),t=e<0?p:p.slice(0,e),m=e<0?null:p.slice(e+1);if(e<=0||`.!@^*<>{}[]()+|;,"'\`\\/`.includes(t[0]))continue;if(t[0]===`?`){d[E(t.slice(1))]=E(m||``);continue}if(t[0]===`:`){let e=t.slice(1);if(!m)continue;e===`sort`?o.push(...m.split(`,`).filter(Boolean).map(e=>{let t=e[0]===`-`;return[E(t?e.slice(1):e),t]}).filter(Boolean)):e===`select`?r.push(...m.split(`,`).map(E).filter(Boolean)):e===`primary`?i.push(...m.split(`,`).map(E).filter(Boolean)):e===`limit`?m&&/^\d+$/.test(m)&&(s=parseInt(m)):e===`offset`?m&&/^\d+$/.test(m)&&(c=parseInt(m)):e===`page`?m&&/^\d+$/.test(m)&&(l=parseInt(m)):e===`total`?m&&(u=!0):Object.hasOwn(a,e)?a[e].push(m):a[e]=[m];continue}let h=t.split(`~`),g=h.pop()||``,_=``;`!`.includes(g[g.length-1])&&(_=`!`,g=g.slice(0,-1));let v=g.split(`:`,3);if(v.length>2)continue;let y=_e(v[0]);if(!y)continue;let b=be(m);if(b===null)continue;let x=E(v[1]||``),S=h.indexOf(``),ee=S<0?h:h.slice(0,S+1);f.push({groups:ee,fields:y,operator:!x&&b===!0?null:x,sign:_,value:b===!0?null:b})}let{and:p,or:m}=Se(f),h={others:a};n?.length&&(h.values=n),u&&(h.total=u),s&&s>0&&(h.limit=s),l&&l>0&&(h.page=l),c&&c>0&&(h.offset=c),r?.length&&(h.select=r),i?.length&&(h.primary=i),o?.length&&(h.sort=o);let g=p;g?.length&&(h.where=g);let _=m;return _?.length&&(h.orWhere=_),Array.isArray(d)&&d.length&&(h.placeholders=d),h}function we(e,t){let n=t.limit||e.limit||0,r=t.page??e.page,i=[e.primary||[],t.primary||[]].flat().filter(Boolean),a=t.offset??(t.limit&&(t.page||t.page===0)?(Math.floor(Math.max(t.page||0,1))-1)*t.limit:null)??e.offset??(e.limit&&(e.page||e.page===0)?(Math.floor(Math.max(e.page||0,1))-1)*e.limit:null)??(Math.floor(Math.max(r||0,1))-1)*(n||10),o=[...e.values||[],...t.values||[]],s=[...e.sort||[],...t.sort||[]],c=[...e.select||[],...t.select||[]],l=[...e.where||[],...t.where||[]],u=[...e.orWhere||[],...t.orWhere||[]],d=[...e.or||[],...t.or||[]],f={};return o?.length&&(f.values=o),n&&n>0&&(f.limit=n),(e.total||t.total)&&(f.total=!0),r&&r>0&&(f.page=r),a&&a>0&&(f.offset=a),c?.length&&(f.select=c),s?.length&&(f.sort=s),l?.length&&(f.where=l),u?.length&&(f.orWhere=u),d?.length&&(f.or=d),i.length&&(f.primary=i),f}const D=e=>encodeURIComponent(e).replaceAll(`%20`,`+`);function Te(e){if(Array.isArray(e)){function t(e){return Array.isArray(e)?`(${e.map(t).join(`,`)})`:D(e)}let n=e.map(t).join(`,`);return e.length>1?n:`(${n})`}if(typeof e==`number`)return`${e}`;if(typeof e==`boolean`)return e?`1`:0;if(typeof e!=`object`)return D(e);let{field:t,placeholder:n}=e;return n?`?${D(n)}`:t?`:${D(t)}`:``}function Ee(e){return e.map(e=>{let[t,...n]=typeof e==`string`?[e]:e;return`${D(t)}${n.map(()=>`[k]`).join(``)}`}).join(`.`)}function De([e,t,n,r]){let i=n?`${Ee(e)}:${D(n)}${r||``}`:`${Ee(e)}${r||``}`;return n===null?i:t===null||typeof t==`function`?``:`${i}=${Te(t)}`}function Oe(e){let t=0;return e.flatMap(e=>{if(e.length!==2)return De(e);let n=Oe(e[1]);if(!n.length)return[];let r=Ee(e[0]);return n.length>1&&(r+=`?${(t++).toString(36)}`),n.map(e=>`${r}.${e}`)}).filter(Boolean)}function ke(e){let t=0;return e.map(e=>Array.isArray(e)?Oe([e]):[...Oe(e.and||[]),...ke(e.or||[])]).flatMap(e=>{if(!e)return[];let n=e.length===1?`~`:`${(t++).toString(36)}~`;return e.map(e=>`${n}${e}`)})}function Ae({values:e,where:t,orWhere:n,sort:r,select:i,primary:a,limit:o,offset:s,page:c,total:l,placeholders:u},d){let f=[];for(let t of e||[])t&&f.push(`=${D(t)}`);o&&o>0&&f.push(`:limit=${o}`),l&&f.push(`:total=${l}`),d?c&&c>0&&f.push(`:page=${c}`):s&&s>0&&f.push(`:offset=${s}`);let p=i?.filter(Boolean).map(D).join(`,`);p&&f.push(`:select=${p}`);let m=a?.filter(Boolean).map(D).join(`,`);if(m&&f.push(`:primary=${m}`),r){let e=r.filter(Boolean).map(e=>{if(Array.isArray(e)){let[t,n]=e;if(t)return`${n?`-`:``}${D(t)}`}else if(e)return D(e);return``}).filter(Boolean).join(`,`);e&&f.push(`:sort=${e}`)}if(u&&typeof u==`object`&&!Array.isArray(u))for(let[e,t]of Object.entries(u))f.push(`?${D(e)}=${D(t)}`);for(let e of Oe(t||[]))f.push(e);for(let e of ke(n||[]))f.push(e);return f.join(`&`)}function je(e,t,n,...r){function*i(t,n,...r){let a=[];if(n)for(let r of n){let n=yield*e.build(i,t,r);if(n!=null){if(e.value?.(n)===!1)return n;a.push(n)}}orFor:for(let n of r){if(!n)continue;let r=[];for(let o of n){let n=Array.isArray(o)?yield*e.build(i,t,o):yield*i(t,o.and,o.or);if(n!=null){if(e.value?.(n)===!0){a.push(n);continue orFor}r.push(n)}}let o=r.length?e.or(r):null;if(o!=null){if(e.value?.(o)===!1)return o;a.push(o)}}return a.length?e.and(a):null}return i(t,n,...r)}var Me=v({asyncExec:()=>le,asyncRunGenerator:()=>re,exec:()=>ce,fill:()=>pe,fillMatches:()=>fe,merge:()=>we,parse:()=>Ce,runGenerator:()=>ne,stringify:()=>Ae,toWhere:()=>je}),Ne=v({CST:()=>Pe,TZ:()=>Le,TZO:()=>Fe,parse:()=>Ve,parseTimeZone:()=>Be,toDate:()=>Ke,toDatetime:()=>Ge,toDatetimeTz:()=>We,toTime:()=>He,toTimeTz:()=>Ue});const Pe=Intl.DateTimeFormat().resolvedOptions().timeZone===`Asia/Shanghai`,Fe=new Date().getTimezoneOffset();function Ie(){let e=Fe;if(!e)return`Z`;let t=e<0?`+`:`-`;return e=Math.abs(e),t+[Math.floor(e/60),e%60].map(e=>`${e}`.padStart(2,`0`)).join(`:`)}const Le=Ie(),Re=/^(?:(?<Y>\d+)-(?<M>\d+)-(?<D>\d+)[t| ])?(?<h>2[0-3]|[01]?\d):(?<m>[0-5]?\d)(?::(?<s>[0-5]?\d)(?:(?:\.(?<ms>\d{1,3})?)?))?(?<tz>z|[+-]\d\d(:?\d\d)?)?$/i,ze=/^(?<Y>\d+)-(?<M>\d+)-(?<D>\d+)(?:[t| ](?<h>2[0-3]|[01]?\d):(?<m>[0-5]?\d)(?::(?<s>[0-5]?\d)(?:(?:\.(?<ms>\d{1,3})?)?))?(?<tz>z|[+-]\d\d(:?\d\d)?)?)?$/i;function Be(e){return e===`z`||e===`Z`?`Z`:!e||typeof e!=`string`?Le:e.includes(`:`)?e:`${e}:00`}function Ve(e){if(e instanceof Date)return e.valueOf()?new Date(e):null;if(typeof e==`number`){let t=new Date(e);return t.valueOf()?t:null}if(typeof e!=`string`)return null;let t=Re.exec(e)?.groups||ze.exec(e)?.groups;if(!t)return null;let{Y:n,M:r,D:i,h:a,m:o,s,ms:c,tz:l=``}=t,u=[`${n||2e3}`.padStart(4,`0`),`-`,`${r||1}`.padStart(2,`0`),`-`,`${i||1}`.padStart(2,`0`),`T`,`${a||0}`.padStart(2,`0`),`:`,`${o||0}`.padStart(2,`0`),`:`,`${s||0}`.padStart(2,`0`),`.`,`${c||0}`.padEnd(3,`0`),`${Be(l)}`].join(``),d=new Date(u);return d.valueOf()?d:null}function He(e){let t=new Date(e.valueOf()-Fe*6e4);return[t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds()].map(e=>`${e}`.padStart(2,`0`)).join(`:`)}function Ue(e){let t=new Date(e.valueOf()-Fe*6e4);return`${`${t.getUTCHours()}`.padStart(2,`0`)}:${`${t.getUTCMinutes()}`.padStart(2,`0`)}:${`${t.getUTCSeconds()}`.padStart(2,`0`)}.${`${t.getUTCMilliseconds()}`.padStart(3,`0`)}${Le}`}function We(e){let t=new Date(e.valueOf()-Fe*6e4);return`${`${t.getUTCFullYear()}`.padStart(4,`0`)}-${`${t.getUTCMonth()+1}`.padStart(2,`0`)}-${`${t.getUTCDate()}`.padStart(2,`0`)}T${`${t.getUTCHours()}`.padStart(2,`0`)}:${`${t.getUTCMinutes()}`.padStart(2,`0`)}:${`${t.getUTCSeconds()}`.padStart(2,`0`)}.${`${t.getUTCMilliseconds()}`.padStart(3,`0`)}${Le}`}function Ge(e){let t=new Date(e.valueOf()-Fe*6e4);return`${`${t.getUTCFullYear()}`.padStart(4,`0`)}-${`${t.getUTCMonth()+1}`.padStart(2,`0`)}-${`${t.getUTCDate()}`.padStart(2,`0`)}T${`${t.getUTCHours()}`.padStart(2,`0`)}:${`${t.getUTCMinutes()}`.padStart(2,`0`)}:${`${t.getUTCSeconds()}`.padStart(2,`0`)}`}function Ke(e){let t=new Date(e.valueOf()-Fe*6e4);return[t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate()].map(e=>`${e}`.padStart(2,`0`)).join(`-`)}const qe=/^(.*)\{(.*)\}(.*)$/,Je=/^\{(?<seq>#*(?<min>0*))\}$/;function Ye(e){let t=Je.exec(e)?.groups;if(t){let{seq:e,min:n}=t;return{name:null,max:e.length,min:n.length}}let n=qe.exec(e),r=e,i=!1,a=``,o=``;n&&([,a,r,o]=n,i=!0);let[s,...c]=r.split(`|`);return c.filter(Boolean).map(e=>{let t=e.indexOf(`:`);return t<0?[e,``]:[e.slice(0,t),e.slice(t+1)]}),{name:s,pipes:c.filter(Boolean).map(e=>{let t=e.indexOf(`:`);return t<0?[e,``]:[e.slice(0,t),e.slice(t+1)]}),optional:i,prefix:a,suffix:o}}function Xe(e){if(typeof e!=`string`)return[];let t=/\{([^{}]*\{[^{}]+\}[^{}]*|[^{}]+)\}/g,n=0,r=[];for(let i=t.exec(e);i;i=t.exec(e)){let t=i.index,[a,o]=i;t>n&&r.push(e.slice(n,t)),n=t+a.length,r.push(Ye(o))}return e.length>n&&r.push(e.slice(n)),r}function Ze(e,t){if((e??null)===null)return``;if(typeof e==`string`)return e;if(typeof e==`bigint`)return String(e);if(typeof e==`boolean`)return e?`1`:`0`;if(typeof e==`number`){if(!Number.isFinite(e))return``;let t=e.toPrecision(100);if(!t.includes(`.`))return t;let n=t.indexOf(`.`);return t.slice(0,n+5).replace(/\.?0+$/,``)}if(!(e instanceof Date))return`${e}`;let n=e;if(!n?.valueOf())return``;let r={Y:n.getFullYear(),M:n.getMonth()+1,d:n.getDate(),h:n.getHours(),m:n.getMinutes(),s:n.getSeconds()};return`YYYY-MM-DD hh:mm:ss`.replace(/([a-zA-Z])\1*/g,(e,t)=>{let n=`${Object.hasOwn(r,t)?r[t]:0}`,i=e.length;return`${n}`.padStart(i,`0`).slice(-i)})}function Qe(e,t,n,r){let i=Object.hasOwn(e,t)&&e[t];if(!i)return()=>{};let a=i.parseParam(n);return e=>i.generate(e,a,{optional:r})}function $e(e,t){let n=(Array.isArray(e)?e:Xe(e)).map(e=>!e||typeof e!=`object`?e:e.name==null?{...e,name:null}:t?{...e,pipes:e.pipes.map(([n,r])=>Qe(t,n,r,e.optional))}:{...e,pipes:[]});return n.length?(e,t)=>{let r=typeof e==`object`&&e||{},i=[];for(let e of n){if(!e||typeof e!=`object`){i.push(e);continue}if(e.name===null){let{min:n,max:r}=e,a=(Math.floor(t||0)||0).toPrecision(100).replace(/\.\d*$/,``).padStart(n,`0`).slice(-r);i.push(a);continue}let{name:n,prefix:a,suffix:o,optional:s,pipes:c}=e,l=Object.hasOwn(r,n)?r[n]??null:null;for(let e of c)l=e(l);let u=Ze(l,s);u&&i.push(a,u,o)}return i.join(``)}:()=>``}var et=v({date:()=>it,datetime:()=>ot,float:()=>ct,int:()=>lt,list:()=>ut,map:()=>dt,number:()=>st,time:()=>at});function tt(e,t,{optional:n}){if(!t)return``;let r=Ve(e)||(n?null:new Date);if(!r?.valueOf())return``;let i={Y:r.getFullYear(),M:r.getMonth()+1,D:r.getDate(),h:r.getHours(),m:r.getMinutes(),s:r.getSeconds()};return t.replace(/#*([a-zA-Z])\1*/g,(e,t)=>{let n=`${Object.hasOwn(i,t)?i[t]:0}`,r=e.length,a=e.replaceAll(`#`,``).length;return`${n}`.padStart(a,`0`).slice(-r)})}function nt(e,t){t||=e===`int`?`#############0`:e===`float`?`#############0.0###`:`#############0.####`;let[n,r=``]=t.split(`.`),i=n.length||1,a=n.replaceAll(`#`,``).length||1,o=e===`int`?0:r.length;return[a,i,e===`int`?0:r.replaceAll(`#`,``).length,o]}function rt(e,[t,n,r,i],{optional:a}){let o=``,s=``;return typeof e==`bigint`?o=String(e):typeof e==`number`?Number.isFinite(e)&&([o,s=``]=e.toPrecision(100).split(`.`)):typeof e==`string`&&/^\s*[+-]?\s*(\d_)*\.?(\d_)*/.test(e)&&([o,s=``]=e.replace(/[^\d.-]/g,``).split(`.`)),!o&&!s&&a?``:(o=o.padStart(t,`0`).slice(-n),s=s.replace(/0+$/,``).padEnd(r,`0`).slice(0,i),s?`${o}.${s}`:o)}const it={parseParam:e=>e||`YYYY-MM-DD`,generate:tt},at={parseParam:e=>e||`hh:mm:ss`,generate:tt},ot={parseParam:e=>e||`YYYY-MM-DD hh:mm:ss`,generate:tt},st={parseParam:e=>nt(`number`,e),generate:rt},ct={parseParam:e=>nt(`float`,e),generate:rt},lt={parseParam:e=>nt(`int`,e),generate:rt},ut={parseParam(e){return e.split(`;`)},generate(e,t,{optional:n}){let r=-1;if(typeof e==`bigint`)r=Number(e);else if(typeof e==`number`)r=Math.floor(e);else if(typeof e==`boolean`)r=e?1:0;else if(typeof e==`string`){if(!/^\s*[+-]\s*(\d_)*/.test(e))return``;r=Number.parseInt(e.replace(/[^\d.+-]/g,``))}return r<0||r>=t.length?n?``:t[0]:t[r]}},dt={parseParam:e=>Object.fromEntries(e.split(`;`).map(e=>{let t=e.indexOf(`=`);return t<0?[e,e]:[e.slice(0,t),e.slice(t+1)]})),generate(e,t,{optional:n}){let r=``;return typeof e==`bigint`||typeof e==`number`?r=String(e):typeof e==`boolean`?r=e?`1`:`0`:typeof e==`string`&&(r=e),Object.hasOwn(t,r)?t[r]:n?``:Object.values(t)[0]}};function O(e,t,n,r){let i=typeof n==`number`?n:0;return $e(e,[n,r].filter(Boolean).find(e=>typeof e==`object`)||et)(t,i)}var ft=v({generate:()=>O,generators:()=>et,parse:()=>Xe,toGenerate:()=>$e});const pt=Error.prototype;function mt(e,t){if(!(t instanceof Error))throw t;for(let n=Object.getPrototypeOf(t);n;n=Object.getPrototypeOf(n)){let r=e.get(n);if(typeof r==`function`)return r(t);if(n===pt)break}throw t}const ht=()=>!0;function gt(e,t){let n=[e].flat();for(let e of t.filter(Boolean)){let t=[];for(let r of n)!r||typeof r!=`object`||Object.hasOwn(r,e)&&t.push(r[e]);if(!t.length)return[];n=t.flat()}return n}function _t(e,t){if(!t.length)return e;if(!e||typeof e!=`object`)return;let[n,...r]=t;for(let t of[e].flat()){let e=_t(t[n],r);if(e!==void 0)return e}}function*vt(e,t){for(let n of Object.values(e))for(let e of gt(n,t))yield e}var yt=class e{static build(t){let n=new e;return e.update(n,t)}static update(t,n){let r=!1;return typeof n==`function`?(Object.defineProperty(t.#e,`hooks`,{configurable:!0,get(){let e=n();return typeof e==`object`&&e||{}}}),r=!0):n&&typeof n==`object`&&(Object.defineProperty(t.#e,`hooks`,{configurable:!0,value:n}),r=!0),r&&e.reset(t),t}static reset(e){let t=e.#r,n=e.#e.resetFn;n.sort(([,e],[,t])=>e-t);let r=n.filter(([,e])=>e<=0),i=n.filter(([,e])=>e>0);for(let[e]of r)e();for(let e of vt(t,[`reset`]))typeof e==`function`&&e();for(let[e]of i)e()}#e={hooks:Object.create(null),resetFn:[]};#t=[];#n=`Hook`;[Symbol.iterator](){return this.entries()}[Symbol.toStringTag](){return this.#n}[Symbol.toPrimitive](e){return e===`number`?NaN:`[${this[Symbol.toStringTag]()}]`}get#r(){return this.#e.hooks}get(t){let n=[...this.#t,t],r=new e;return r.#e=this.#e,r.#t=n,r.#n=`Hook(${n.join(`.`)})`,r}call(...e){for(let t of this.values())typeof t==`function`&&t(...e)}first(e){let t=this.#r;if(Object.hasOwn(t,e))return _t(t[e],this.#t.filter(Boolean))}*plugin(e){let t=this.#r;Object.hasOwn(t,e)&&(yield*gt(t[e],this.#t.filter(Boolean)))}values(){return vt(this.#r,this.#t)}*entries(){let e=this.#r,t=this.#t;for(let[n,r]of Object.entries(e))for(let e of gt(r,t))yield[n,e]}*entriesObject(e=ht){for(let[t,n]of this.entries())if(!(!n||typeof n!=`object`))for(let[r,i]of Object.entries(n))e(i)&&(yield[t,r,i])}named(e=ht){let t=Object.create(null);for(let n of this.values())if(!(!n||typeof n!=`object`))for(let[r,i]of Object.entries(n))e(i)&&(t[r]=i);return t}listen(e,t){if(typeof e!=`function`)return()=>{};let n=this.#e.resetFn,r=[e,Number.isFinite(t)&&t||0];return n.push(r),n.sort(([,e],[,t])=>t-e),()=>{let e=n.findIndex(e=>e===r);e>=0&&n.splice(e,1)}}};const bt=Error.prototype;var xt=class{#e=new WeakMap;register(e,t){if(typeof t!=`function`)throw TypeError(`Handler must be a function`);if(typeof e!=`function`)throw TypeError(`Registered error class must be a subclass of Error`);let n=e.prototype;if(!(n instanceof Error))throw TypeError(`Registered error class must be a subclass of Error`);this.#e.set(n,t)}async convert(e){if(!(e instanceof Error))throw e;let t=this.#e;for(let n=Object.getPrototypeOf(e);n&&n!==bt;n=Object.getPrototypeOf(n)){let r=t.get(n);if(!r)continue;let i=await r(e)??null;if(i!==null)return i}let n=t.get(bt);return n?await n(e)??null:null}},St=class e extends Promise{static get[Symbol.species](){return Promise}#e;constructor(e){let t=null;super((n,r)=>{t=()=>{try{e(n,r)}catch(e){r(e)}}}),this.#e=()=>{let e=t;t=null,e&&e()}}then(e,t){return this.#e(),super.then(e,t)}lazyThen(t,n){return new e((e,r)=>{this.then(n=>{if(typeof t==`function`)try{e(t(n))}catch(e){r(e)}else e(n)},t=>{if(typeof n==`function`)try{e(n(t))}catch(e){r(e)}else r(t)})})}lazyCatch(e){return this.finally,this.lazyThen(void 0,e)}lazyFinally(e){return typeof e==`function`?this.lazyThen(async t=>(await e(),t),async t=>{throw await e(),t}):this}static resolve(t){return new e(e=>{e(t)})}static reject(t){return new e((e,n)=>{n(t)})}static all(t){return new e((e,n)=>{Promise.all(t).then(e,n)})}static allSettled(t){return new e(e=>{Promise.allSettled(t).then(e)})}static any(t){return new e((e,n)=>{Promise.any(t).then(e,n)})}static race(t){return new e((e,n)=>{Promise.race(t).then(e,n)})}static try(t,...n){return new e((e,r)=>{try{e(t(...n))}catch(e){r(e)}})}static withResolvers(){return Promise.withResolvers()}};const Ct=/\{([^}{}]+)\}/g;function wt(e){if(!e||typeof e!=`string`)return[];let t=[];for(let n=Ct.exec(e);n;n=Ct.exec(e))t.push(n[1]);return t}function Tt(e,t){return O(e,t)}function*Et({constraints:e,organizationField:t}){if(t&&(yield t),e)for(let[t,n]of Object.entries(e)){if(!n)continue;let{value:e,values:r,user:i}=n;e===void 0?(Array.isArray(r)&&r.length||r instanceof Set&&r.size||i)&&(yield t):yield t}}const Dt=/^(?:(?<scope>@[a-zA-Z\d_.-]+)\/)?(?<name>[a-zA-Z\d_.-]+)$/,Ot=/^(?<pluginId>(?:(?<scope>@[a-zA-Z\d_.-]+)\/)?(?<name>[a-zA-Z\d_.-]+))(?:\/(?<path>[^#]*))?(?:#(?<hash>.*))?$/;function kt(e){return typeof e==`function`}const At=x({}),k=yt.build(()=>At.get());function jt(e){At.set(e),yt.reset(k)}function Mt(e,t,n){let r=typeof t==`string`?t:``,i=t===!0||n===!0?`[]`:``;return!e||e===`.`?r?`:${r}${i}`:void 0:r?`${e}:${r}${i}`:`${e}${i}`}function Nt(e){return typeof e==`boolean`?!e:e}const Pt=S(()=>{let e=new Map;for(let t of k.get(`formFields`).values()){let{type:n,array:r,renderer:i,input:a}=t,o=Mt(typeof n==`string`?n:``,typeof i==`string`?i:``,!!r);o&&typeof a==`function`&&e.set(o,a)}return e}),Ft=S(()=>{let e={},t={};function n(e,t,{not:n,value:r,notValue:i,named:a,notNamed:o,field:s,notField:c},l=``){n&&(typeof r==`function`&&(i=(...e)=>Nt(r(...e))),typeof s==`function`&&(c=(...e)=>Nt(s(...e))),typeof a==`function`&&(o=(...e)=>Nt(a(...e))));let u=Object.hasOwn(e,l)&&e[l]||{value:[],named:[],field:[],notValue:[],notNamed:[],notField:[]};e[l]=u,typeof r==`function`&&u.value.push(r),typeof i==`function`&&u.notValue.push(i),typeof a==`function`&&u.named.push(a),typeof o==`function`&&u.notNamed.push(o),typeof s==`function`&&u.field.push(s),typeof c==`function`&&u.notField.push(c);let d=typeof n==`string`&&n||``;if(!d)return;let f=Object.hasOwn(t,d)&&t[d]||{value:[],named:[],field:[],notValue:[],notNamed:[],notField:[]};t[d]=u,typeof r==`function`&&f.notValue.push(r),typeof i==`function`&&f.value.push(i),typeof a==`function`&&f.notNamed.push(a),typeof o==`function`&&f.named.push(o),typeof s==`function`&&f.notField.push(s),typeof c==`function`&&f.field.push(c)}for(let r of k.get(`formFields`).values()){let{type:i,array:a,renderer:o,filters:s}=r,c=Mt(typeof i==`string`?i:``,typeof o==`string`?o:``,!!a)||(a?`[]`:``),l=Object.hasOwn(e,c)&&e[c]||{},u=Object.hasOwn(t,c)&&t[c]||{};n(l,u,r);for(let[e,t]of Object.entries(s||{}))!t||Array.isArray(t)||typeof t!=`object`||n(l,u,t,e);e[c]=l,t[c]=u}for(let n of Object.keys({...e,...t})){let r=Object.hasOwn(t,n)&&t[n];if(!r)continue;let i=Object.hasOwn(e,n)&&e[n]||{};e[n]=i;for(let e of Object.keys({...i,...r})){let t=Object.hasOwn(r,e)&&r[e];if(!t)continue;let n=Object.hasOwn(i,e)&&i[e]||{value:[],named:[],field:[],notValue:[],notNamed:[],notField:[]};if(i[e]=n,t){for(let e of t.value)n.value.push(e);for(let e of t.notValue)n.notValue.push(e);for(let e of t.named)n.named.push(e);for(let e of t.notNamed)n.notNamed.push(e);for(let e of t.field)n.field.push(e);for(let e of t.notField)n.notField.push(e)}}}return e}),It=S(()=>{let e=new Map;for(let t of k.get(`formFields`).values()){let{type:n,array:r,renderer:i,filter:a,filters:o}=t,s=Mt(typeof n==`string`?n:``,typeof i==`string`?i:``,!!r);if(!s)continue;let c=e.get(s)||new Map;if(typeof a==`function`){let e=c.get(``);e?e.component=a:c.set(``,{component:a,label:`=`})}for(let[e,t]of Object.entries(o||{})){if(!t)continue;let n=Array.isArray(t)?t[0]:typeof t==`function`?t:t.filter;if(typeof n!=`function`)continue;let r=Array.isArray(t)?t[1]:typeof t==`object`?t.label:null,i=c.get(e);if(!i){c.set(e,{component:n,label:typeof r==`string`?r:``});continue}i.component=n,typeof r==`string`&&(i.label=r)}c.size&&e.set(s,c)}return e});function Lt(){return Ft.get()}function*Rt(e){if(e)for(let t of Array.isArray(e)?e:[e]){if(!t)continue;if(typeof t==`string`){yield[t];continue}if(typeof t!=`object`)continue;let e=t.component;!e||typeof e!=`string`||(yield[e,t])}}function*zt(e){if(!e)return;let t=typeof e==`string`?e:e.type,n=typeof e==`string`?``:e.renderer,r=typeof e==`string`?``:e.array?`[]`:``;if(!t){for(let[e,t]of Rt(n))yield[`:${e}${r}`,t],yield[`${e}${r}`,t];return}if(typeof t==`object`){for(let[e,t]of Rt(n))yield[`submodel:${e}${r}`,t],yield[`${e}${r}`,t];yield[`submodel${r}`];return}for(let[e,i]of Rt(n))yield[`${t}:${e}${r}`,i],yield[`:${e}${r}`,i],yield[`${e}${r}`,i];yield[`${t}${r}`]}function Bt(e,t){let n=Pt.get();for(let[t,r]of zt(e)){let e=n.get(t);if(e)return t=>e(t,r)}return t?null:(typeof e==`string`||e.type,()=>document.createElement(`div`))}function Vt(e){let t=Pt.get();for(let[n]of zt(e))if(t.get(n))return!0;return typeof e==`string`||e.type,!1}const Ht=()=>document.createElement(`div`);function Ut(e,t){let n=It.get();for(let[r,i]of zt(e)){let e=n.get(r)?.get(t);if(!e)continue;let a=e.component;return e=>a(e,i)}return Ht}function Wt(e){let t=It.get(),n=Object.create(null);for(let[r]of zt(e)){let e=t.get(r);if(e)for(let[t,{label:r}]of e)n[t]||(n[t]=r)}return n}function Gt(e,t){let n=It.get();for(let[r]of zt(e))if(n.get(r)?.has(t))return!0;return!1}function*Kt(e,t){let n=Ft.get();for(let[r]of typeof e==`boolean`?e?[[`[]`],[``]]:[[``]]:zt(e)){let e=Object.hasOwn(n,r)&&n[r];if(!e)continue;let i=Object.hasOwn(e,t)&&e[t];i&&(yield i)}let r=Object.hasOwn(n,``)&&n[``];if(!r)return;let i=Object.hasOwn(r,t)&&r[t];i&&(yield i)}const qt={api:`/api`,file:`/fileCabinets`};var Jt=qt;function Yt(e=new Date){let t=e.getTimezoneOffset();if(!t)return`Z`;let n=t<0?`+`:`-`;return t=Math.abs(t),n+[Math.floor(t/60),t%60].map(e=>`${e}`.padStart(2,`0`)).join(`:`)}function Xt(e){return[e.getHours(),e.getMinutes(),e.getSeconds()].map(e=>`${e}`.padStart(2,`0`)).join(`:`)}function Zt(e){return[`${e.getFullYear()}`.padStart(4,`0`),`${e.getMonth()+1}`.padStart(2,`0`),`${e.getDate()}`.padStart(2,`0`)].join(`-`)}function Qt(e){return Xt(e)+`.${e.getMilliseconds()}`.padStart(3,`0`)+Yt(e)}function $t(e){return Zt(e)+`T`+Qt(e)}var en=class e extends f{build(){return new e}method(e,t){return super.method(`POST`,t).header(`X-Method`,e)}};async function tn(e){let t=e.headers.get(`content-type`)?.split(`;`)[0].replace(/\s+/g,``).toLowerCase()||``;return t===`application/json`||t===`text/json`?await e.json().then(e=>Promise.reject(e?.error),e=>Promise.reject(null)):t===`text/plain`?await e.text().then(e=>Promise.reject(e)):Promise.reject(e)}function nn(e){return e.status,tn(e)}function rn(e){if(!e||e instanceof Response)return alert(`未知`);if(typeof e==`string`)return alert(e);if(typeof e!=`object`)return;let{message:t,code:n}=e;typeof t!=`string`&&(t=``),typeof n!=`string`&&(n=``),!(!t&&!n)&&alert([t||`未知错误`,n?`[${n}]`:``].filter(Boolean).join(` `))}let an=rn;function on(e){return nn(e).catch(async e=>(await an(e),Promise.reject(e)))}const sn=new en().get().prefix(Jt.api).stringifyJSON(e=>JSON.stringify(e,(e,t)=>t instanceof Date?$t(t):typeof t==`bigint`?String(t):t instanceof Set?[...t]:t)).errorHandler(tn);var A=sn.clone().errorHandler(on);function cn(e){typeof e==`function`&&(an=e)}const j=await sn.clone().get`application`.query({domain:location.hostname,port:location.port,path:location.pathname}).json(),ln=window.yongdallPlugins,un=j.id,dn=new URL(j.path||`/workbench/`,location.origin),fn=dn.href,pn=dn.pathname,mn=x(j.menus||[]),hn=x(j.userMenus||[]),gn=x(!1);async function _n(){if(!gn.get()){gn.set(!0);try{let e=await sn.clone().get`applications`.append(`${un}`).json();if(!j||typeof e!=`object`)return;mn.set(e.menus||[]),hn.set(e.userMenus||[])}finally{gn.set(!1)}}}const M={get id(){return un},get path(){return pn},get root(){return fn},get theme(){return j.theme},get route(){return j.route},get authenticator(){return j.authenticator},get type(){return j.type},get skin(){return j.skin},get menus(){return mn.get()},get userMenus(){return hn.get()},get logo(){return j.logo},get title(){return j.title},get company(){return j.company},get help(){return j.help},get refreshing(){return gn.get()},refresh:_n};function vn(e,t,n){let r={};function i(...i){let a=t(...i);if(Object.hasOwn(r,a)&&!n?.(...i))return r[a];let o=e(...i);return r[a]=o,o}return i}const{authRequired:yn,multiUser:bn,userType:xn}=j,N=xn===`visitor`,Sn=x(null),Cn=x(null),wn=x(null),Tn=S(()=>wn.get()||Sn.get()),En=vn(e=>{if(N)return{get session(){return null},get target(){return null},get current(){return null}};let t=S(()=>Sn.get()?.plugins?.[e]||null),n=S(()=>wn.get()?.plugins?.[e]||null),r=S(()=>Tn.get()?.plugins?.[e]||null);return{get session(){return t.get()},get target(){return n.get()},get current(){return r.get()}}},e=>e||``),P=x(!1),Dn=x(!1),On=S(()=>Dn.get()?!0:!(!yn||P.get()||Sn.get()));function kn(e){return new Set(e.filter(e=>e&&typeof e==`string`))}function An(e){let t=e.plugins;if(t&&typeof t==`object`)for(let[n,r]of k.get(`user`).get(`permissions`)){if(typeof r!=`function`||!Object.hasOwn(t,n))continue;let i=t[n];if(!i||typeof i!=`object`)continue;let a=r(i,e);if(a instanceof Set)return a}let n=e.permissions;return Array.isArray(n)?kn(n):new Set}function jn(e){let t=e.plugins;if(t&&typeof t==`object`)for(let[n,r]of k.get(`user`).get(`organizationPermissions`)){if(typeof r!=`function`||!Object.hasOwn(t,n))continue;let i=t[n];if(!i||typeof i!=`object`)continue;let a=r(i,e);if(a)return Object.assign(Object.create(null),a)}let n=e.organizationPermissions;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=Object.entries(n).filter(e=>Array.isArray(e[1]));if(e.length)return Object.assign(Object.create(null),Object.fromEntries(e.map(([e,t])=>[e,kn(t)])))}let{organizationRolePermissions:r,organizationRoles:i}=e;return!i||typeof i!=`object`||Array.isArray(i)||!r||typeof r!=`object`||Array.isArray(r)?null:Object.assign(Object.create(null),Object.fromEntries(Object.entries(i).map(([e,t])=>[e,kn(t.flatMap(e=>Object.hasOwn(r,e)&&r[e]||[]))])))}const Mn=S(()=>{let e=Tn.get();return e?An(e):null}),Nn=S(()=>{let e=Tn.get();return e?jn(e):null}),Pn=S(()=>{let e=Nn.get();return e?new Set(Object.values(e).flatMap(e=>[...e])):null});function Fn(){return P.get()?{has:()=>!0,get size(){return-1}}:new Set}const F={get visitor(){return N},get multi(){return N||!!bn},get single(){return P.get()},get session(){return N?Cn.get():Sn.get()},get target(){return N?null:wn.get()},get current(){return N?Cn.get():Tn.get()},hasPermission(e){return N?!1:Mn.get()?.has(e)??P.get()},hasOrganizationPermission(e,t){if(N)return!1;if(typeof t!=`string`)return Pn.get()?.has(e)??P.get();let n=Nn.get();return n?Object.hasOwn(n,t)?n[t]?.has(e)??!1:!1:P.get()},get permissions(){return N?new Set:Mn.get()||Fn()},get organizationPermissions(){return N?Object.create(null):Nn.get()||new Proxy({},{get(){return Fn()}})},get allOrganizationPermissions(){return N?new Set:Pn.get()||Fn()},get waitLogin(){return On.get()},plugin(e){return En(e)},async load(){if(N){let{visitor:e}=await sn.clone().get`visitor`.json().then(e=>e||{},()=>({}));return P.set(!1),Cn.set(e||null),e&&Dn.set(!1),!!e}let{session:e,target:t}=await sn.clone().get`user`.json().then(e=>e||{},()=>({}));return wn.set(t||null),e===!0?(P.set(!0),Sn.set(null)):(P.set(!1),Sn.set(e||null)),e&&Dn.set(!1),!!e},exit(){if(N){Cn.set(null),sn.clone().delete`visitor`.done();return}wn.set(null),Sn.set(null),sn.clone().delete`user`.done()},login(e=!0){Dn.set(!!e)}};function In(e){if(!e)return[];let t=typeof e==`string`?e.split(`
|
|
2
2
|
`):e;return Array.isArray(t)?t.filter(e=>e&&typeof e==`string`):[]}function Ln({permissions:e,organizationPermissions:t,allOrganizationPermissions:n,authorizations:r}={}){return i=>{if(i[0]===`#`)return r?.has(i.slice(1))||!1;let a=i.indexOf(`&`);if(a<0)return e?.has(i)||!1;let o=i.slice(0,a);if(!o)return!1;let s=i.slice(a+1);return s?t?.[s]?.has(o)||!1:n?.has(o)||!1}}function Rn(e,t,n){if(!e)return!0;let r=In(e);if(!r.length)return!0;let i=Ln({permissions:t,authorizations:n});return!!r.find(i)}function zn(e,t){if(!e||!t||typeof t!=`object`)return!0;for(let[n,r]of Object.entries(e)){if(!r)continue;let{value:e,values:i,user:a}=r,o=t[n];if(e!==void 0){if(o!==e)return!1}else if(Array.isArray(i)&&i.length){if(!i.includes(o))return!1}else if(i instanceof Set&&i.size){if(!i.has(o))return!1}else if(a&&!F.single&&o!==F.current?.id)return!1}return!0}function Bn({permission:e,organizationField:t,constraints:n},r,i,a){if(!zn(n,r))return!1;if(!e)return!0;if(!t)return F.hasPermission(e);if(t===`_`)return!!(i&&F.hasOrganizationPermission(e));if(i||t===a)return!0;let o=String(r?.[t]||``);return(!i||o)&&F.hasOrganizationPermission(e,o||``),!0}function Vn(e,t,n){let r=e.filter(({authorizations:e})=>{if(e instanceof Set||Array.isArray(e))return!0}).filter(e=>Bn(e,t,n)).flatMap(({authorizations:e})=>e?[...e]:[]);return new Set(r)}function Hn(e,t,n,r,i){return!!t.filter(({authorizations:t})=>{if(t instanceof Set)return t.has(e);if(Array.isArray(t))return t.includes(e)}).find(e=>Bn(e,n,r,i))}function Un(e,t,n){let r=t.filter(({authorizations:t})=>{if(t instanceof Set)return t.has(e);if(Array.isArray(t))return t.includes(e)}).filter(({permission:e,organizationField:t})=>e?t?F.hasOrganizationPermission(e):F.hasPermission(e):!0);if(!r?.length)return new Set;let i=new Set(r.flatMap(e=>e.group||``)),a=new Set(r.flatMap(e=>e.fields||``));if(i.delete(``),a.delete(``),!(i.size+a.size))return new Set;function*o(e,t){for(let[n,r]of e){if(!r)continue;let e=[...t,n],s=e.join(`.`);if(!r.primary&&!i.has(r.group||``)&&!a.has(s)&&!a.has(`*`))continue;yield s;let{type:c}=r;!c||typeof c!=`object`||(yield*o(Object.entries(c),e))}}return new Set(o(Object.entries(n.fields),[]))}function Wn(e){return new Proxy({},{get(t,n,r){return e.value?.[n]},set(){return!1}})}function Gn(e,t,n,r){let i=n?.length?t=>{let r=t.root,i=r.new;return!Hn(i?`create`:`update`,n,Wn(r),i,e)}:null;return typeof r==`function`&&i?e=>i(e)||!!r(e):i||(typeof r==`function`?e=>!!r(e):typeof t==`boolean`?t:null)}function Kn(e,t,n,r,i){let a=[];if(typeof i==`function`)a.push(i);else if(n===!0)return!0;return t.uncreatable&&a.push(e=>e.root.new),r&&a.push(r.length?t=>{let n=t.root,i=n.new;return!Hn(`read`,r,Wn(n),i,e)}:()=>!F.single),a.length?e=>{for(let t of a)if(t(e))return!0;return!1}:null}function qn(e,t){return typeof t==`function`?e=>!!t(e):typeof e==`boolean`?e:null}function Jn(e,t){return typeof t==`function`?n=>{let r=t(n);return typeof r==`string`&&r||e||``}:typeof e==`string`&&e||``}function Yn(e,t,n){let r=e.group||``,i=e.script||{},a=n?.filter(({group:e,fields:n})=>{if(e===r||Array.isArray(e)&&e.includes(r)||n===t||n===`*`)return!0;if(!Array.isArray(n))return!1;if(n.includes(t)||n.includes(`*`))return!0});return{meta:e,hidden:Kn(t,e,e.layout?.hidden,a,i?.hidden),readonly:Gn(t,e.readonly,a,i.readonly),required:qn(e.required,i.required),clearable:qn(e.clearable,i.clearable),disabled:qn(e.disabled,i.disabled),creatable:!e.uncreatable,immutable:e.immutable,label:Jn(e.label||t,i.label),description:Jn(e.description,i.description),placeholder:Jn(e.placeholder,i.placeholder),step:e.step,max:e.max,min:e.min,default:i.default||e.default,validator:i.validator,validators:i.validators,events:{input:i.input,change:i.change,click:i.click,focus:i.focus,blur:i.blur}}}function Xn(e,t,n){let r=Object.create(null);for(let[i,a]of Object.entries(e)){let e=t[i],o=a.type,s=a.layout||{};if(typeof o!=`object`||!o){r[i]={...Yn(a,i,n),type:o,array:!!a.array,component:typeof e==`function`?e:a.script?.component,layout:{field:i,colStart:s.colStart,colSpan:s.colSpan,colEnd:s.colEnd,rowStart:s.rowStart,rowSpan:s.rowSpan,rowEnd:s.rowEnd}};continue}let c=Object.entries(o).filter((([,e])=>!!e)),l=s.levelKey||``,u=[];if(l){if(Array.isArray(s.columns))for(let{action:e,actions:t,field:n,placeholder:r,width:i}of s.columns)if(n||i||r)(n||i)&&u.push({field:n,width:i}),r&&!i&&u.push({placeholder:r});else{let n=[e,t].flat().filter(Boolean);n&&u.push({actions:n})}if(!u.length){u.push({actions:[`collapse`,`move`]});let e=c.filter(([,e])=>e.layout?.head).sort(([,e],[,t])=>(e.layout?.head||0)-(t.layout?.head||0)).map(([e,t])=>e);for(let t of e)u.push({field:t});u.push({placeholder:1}),u.push({actions:[`add`,`remove`]})}}else{if(Array.isArray(s.columns))for(let{action:e,actions:t,field:n}of s.columns)if(n)u.push({field:n});else{let n=[e,t].flat().filter(Boolean);n&&u.push({actions:n})}if(!u.length){u.push({actions:[`add`,`trigger`,`move`,`remove`,`serial`]});let e=c.filter(([,e])=>e.layout?.head).sort(([,e],[,t])=>(e.layout?.head||0)-(t.layout?.head||0)).map(([e,t])=>e);for(let t of e)u.push({field:t})}}let d=Xn(o,typeof e!=`function`&&e||{},n);r[i]={...Yn(a,i,n),layout:{field:i,fields:Object.entries(d).sort(([e],[t])=>(o[e]?.layoutOrder||0)-(o[t]?.layoutOrder||0)).map(([e,t])=>({...t.layout,field:e})),columns:u,arrayStyle:l?`tree`:`table`,levelKey:l,colStart:s.colStart,colSpan:s.colSpan,colEnd:s.colEnd,rowStart:s.rowStart,rowSpan:s.rowSpan,rowEnd:s.rowEnd},type:d,array:!!a.array,component:typeof e==`function`?e:a.script?.component}}return r}let Zn={imports:{},scopes:{}};try{let{imports:e={},scopes:t={}}=JSON.parse(document.querySelector(`script[type=importmap]`)?.textContent||``);Zn={imports:e,scopes:t}}catch{}async function I(e,t,n){if(!e)return;e[0];let r=e.indexOf(`#`),i=r<0?e:e.slice(0,r);t&&typeof t==`string`&&(!i||i===`@`?i=t:i.startsWith(`@/`)&&(i=t+i.slice(1)));let a=await([t,n].find((e=>typeof e==`function`))||(e=>import(e)))(i).catch(e=>{console.error(e)});if(r<0)return a;let o=e.slice(r+1);if(!o)return a.default;let s=a;for(let e of o.split(`.`)){if(!s||typeof s!=`object`)return;s=s[e]}return s}function Qn(e,t){if(!t)return null;let n=t[e];if(n)return n;let r=0,i=``;for(let n of Object.entries(t)){let[t,a]=n;t[t.length-1]===`/`&&e.startsWith(t)&&t.length>r&&(r=t.length,i=a)}return r?(i[i.length-1]!==`/`&&(i+=`/`),i+e.slice(r)):null}function $n(e,t){let n=``,r=null;for(let[e,i]of Object.entries(Zn.scopes))t.startsWith(e)&&e.length>n.length&&(n=e,r=i);return Qn(e,r)||Qn(e,Zn.imports)}function er(e,t,n){let r=!(n&&t)&&Ot.exec(e)?.groups;if(r){let{pluginId:t,path:n}=r,i=Object.hasOwn(ln,t)&&ln[t]||{},a=`/assets/plugins/${t}/${i.version||`VERSION`}/`,o=location.origin+a,s=i.assets?.[n]||$n(e,a);if(s)return new URL(s,o).href}let i=t&&ln[t]||{},a=i.version||`VERSION`,o=t?`/assets/plugins/${t}/${a}/`:``,s=t?location.origin+o:location.href;t&&e[0]!==`.`&&e[0];let c=i.assets?.[e]||o&&$n(e,o)||e;return new URL(c,s).href}const tr=Object.create(null);function nr(e,t,n){let r=er(e,t,n),i=tr[r];if(i)return i;let a=new Promise((e,t)=>{let n=document.createElement(`link`);n.addEventListener(`load`,()=>e(n)),n.addEventListener(`error`,e=>t(e.error)),n.href=r,n.rel=`stylesheet`,document.head.appendChild(n)});return tr[r]=a,a.catch(()=>{a===tr[r]&&delete tr[r]}),a}const rr=Object.create(null);function ir(e){let t=new URL(e,location.href);t.hash=``;let n=t.href,r=rr[n];if(r)return r;let i=new Promise((e,t)=>{let r=document.createElement(`script`);r.type=`text/javascript`,r.addEventListener(`load`,()=>e()),r.addEventListener(`error`,e=>t(e.error)),r.src=n,document.head.appendChild(r)});return rr[n]=i,i.catch(()=>{i===rr[n]&&delete rr[n]}),i}var L=class extends Error{constructor(e){super(`${e}`),this.status=e}};function R(e,t,...n){let r=Object.create(null),i=new Set,a=Object.create(null),o=Object.create(null),s=[],c=new Set;function l(t,n){let i=e(...n);return r[t]=i,i.then(e=>{let n=a[t];if(n)return n.set(e);a[t]=x(e);for(let e of s)e(t)},()=>{r[t]===i&&delete r[t]}),i}function u(e){c.has(e)||(c.add(e),requestIdleCallback(()=>{if(!c.has(e))return;c.delete(e);let t=o[e];t&&l(e,t)}))}for(let e of n)e.listen(u);function d(e,...n){let s=Array.isArray(e)?e.join(`
|
|
3
3
|
`):e;o[s]=n;function c(e){return!e&&Object.hasOwn(r,s)&&r[s]||l(s,n)}function u(){(!Object.hasOwn(r,s)||!r[s]||i.has(s))&&(l(s,n),i.delete(s));let e=a[s];return e||(e=x(t),a[s]=e),e.get()}function d(){o[s]===n&&(delete o[s],delete a[s],delete r[s])}return{get:u,load:c,destroy:d}}function f(e){s.push(e)}return{create:d,listen:f}}function ar(e){return{then(t,n){return e().then(t,n)},catch(t){return e().catch(t)},finally(t){return e().finally(t)}}}function or(e){return Promise.all(Array.isArray(e)?e.map(async e=>{let t=typeof e==`string`?e:e[0];if(!t||typeof t!=`string`)return;let n=await I(t);if(typeof n!=`function`)return n;let r=typeof e==`string`?null:e[1];return n(typeof r==`object`&&r||{})}):[])}async function sr({type:e,scripts:t,...n},r){let i=Object.create(null),a=Object.create(null);for(let e of[await or(t),r].flat()){if(!e||typeof e!=`object`)continue;let{subFields:t,...n}=e;for(let[e,t]of Object.entries(n)){let n=a[e];n?n.push(t):a[e]=[t]}if(t)for(let[e,n]of Object.entries(t)){let t=i[e];t?t.push(n):i[e]=[n]}}return{...n,script:dr(a),type:typeof e==`object`&&e?await cr(e,i):e}}async function cr(e,t){let n=Object.entries(e).map(([e,n])=>Promise.all([e,sr(n,t[e])]));return Object.fromEntries(await Promise.all(n))}function z(e,t){if(!e)return null;let n=e.filter(e=>typeof e==`function`);return n.length?t?(...e)=>{for(let t of n)t(...e)}:async(...e)=>{for(let t of n)await t(...e)}:null}function B(e,t,n){if(!e)return null;let r=e.filter(e=>typeof e==`function`);return r.length?(...e)=>{for(let n of r){let r=n(...e);if(r===t||typeof t==`function`&&t(r))return r}return n}:null}function lr(e){if(!e)return null;let t=e.filter(e=>typeof e==`function`);return t.length?function*(...e){for(let n of t)yield*n(...e)}:null}function ur(e){if(!e)return null;let t=e.filter(e=>typeof e==`function`);return t.length?(...e)=>{for(let n of t){let t=n(...e);if(t===!1)return t}return!1}:null}function dr(e){return{input:z(e.input),change:z(e.change),click:z(e.click),focus:z(e.focus),blur:z(e.blur),add:e.add?.find(e=>typeof e==`function`),remove:z(e.remove),move:z(e.move),readonly:B(e.readonly,!0,!1),hidden:B(e.hidden,!0,!1),required:B(e.required,!0,!1),clearable:B(e.clearable,!0,!1),disabled:B(e.disabled,!0,!1),default:B(e.default,(e=null)=>e!==null,null),label:B(e.label,e=>e&&typeof e==`string`,``),description:B(e.description,e=>e&&typeof e==`string`,``),placeholder:B(e.clearable,e=>e&&typeof e==`string`,``),validator:[e.validator].flat().filter(Boolean),source:lr(e.source),filter:ur(e.disabled)}}function fr({listScripts:e,documentScripts:t,...n}){return{input:z(n.input),change:z(n.change),beforeCreate:z(n.beforeCreate),beforeUpdate:z(n.beforeUpdate),beforeSave:z(n.beforeSave),beforeDestroy:z(n.beforeDestroy),beforeUpsert:z(n.beforeUpsert),listScripts:e?Object.assign({},...e):{},documentScripts:t?Object.assign({},...t):{}}}async function pr({fields:e,scripts:t,...n}){let r=Object.create(null),i=Object.create(null);for(let e of await or(t)){if(!e||typeof e!=`object`)continue;let{fields:t,...n}=e;for(let[e,t]of Object.entries(n)){let n=i[e];n?n.push(t):i[e]=[t]}if(t)for(let[e,n]of Object.entries(t)){let t=r[e];t?t.push(n):r[e]=[n]}}return{...n,script:fr(i),fields:await cr(e,r)}}const mr=R(e=>e.clone().body({}).json().then(e=>e.options),[]);function hr(e,t){let n=e.clone().append(`/documents`),r=e.clone().append(`/options`),{get:i,load:a}=mr.create(t,r);return{async query({values:e,where:t,orWhere:r,sort:i,limit:a=20,page:o,offset:s,select:c,total:l,primary:u}={}){return n.clone().body({values:e,where:t,orWhere:r,sort:i,limit:a,page:o,offset:s,select:c,total:l,primary:u}).json()},getOptions(){return i()},async options(e){if(!e||typeof e==`boolean`)return a(e);let{values:t,where:n,orWhere:i,sort:o,limit:s=20,page:c,offset:l,select:u,total:d,primary:f}=e;return r.clone().body({values:t,where:n,orWhere:i,sort:o,limit:s,page:c,offset:l,select:u,total:d,primary:f}).json()},async option(e){return r.clone().append(`/${encodeURIComponent(e)}`).get().errorHandler(nn).json()},async create(e){return n.clone().post().body({document:e}).json()},document(e){let t=n.clone().append(`/${encodeURIComponent(e)}`);async function r(){return t.get().json().then(e=>e.document)}return{get:r,async update(e){return t.clone().put().body({document:e}).json()},async delete(){return t.delete().done()},field(e){let n=t.clone().append`fields/${e}`;async function r(){return n.get().json().then(e=>e.value)}return{get:r,...ar(r)}},...ar(r)}}}}const gr=R(e=>e.result().then(e=>typeof e==`object`&&e||null,e=>Promise.reject(new L(e instanceof Response?e.status:100))),null),_r=R(e=>e().then(async e=>e&&pr(e)),null,gr);function vr(e){let t=A.clone().path`models/${e||``}`,{get:n,load:r}=gr.create(e,t),{get:i,load:a}=_r.create(e,r);return{loadModel:r,loadScript:a,getModel:n,getScript:i,...hr(t,[e,``].join(`
|
|
4
4
|
`)),...ar(r)}}const yr=R(e=>e.json().then(e=>typeof e==`object`&&e.values||[],()=>[]),[]);function br(e){let t=A.clone().path`enumerations/${e||``}`,{get:n,load:r}=yr.create(e,t);return{load:r,get:n,...ar(r)}}const xr=R(e=>e.result().then(e=>typeof e==`object`&&e||null,e=>Promise.reject(new L(e instanceof Response?e.status:100))),null);function Sr(e){let t=A.clone().path`formLayouts/${e||``}`,{get:n,load:r}=xr.create(e,t);return{load:r,get:n,...ar(r)}}const Cr=A.clone().path`permissions`;let wr=null,Tr=!1;const Er=x([]);function Dr(){let e=Cr.json().then(e=>Array.isArray(e)&&e||[]);return wr=e,e.then(e=>Er.set(e),()=>{wr===e&&(wr=null)}),e}function Or(e){return!e&&wr?wr:Dr()}function kr(){return(!wr||Tr)&&(Dr(),Tr=!1),Er.get()}var Ar={load:Or,get:kr,...ar(Or)};async function jr(e,t){let n=A.clone();n=t?n.get`menus/${e}/groups/${t}`:n.get`menus/${e}`;let{menus:r}=await n.json();return r}const Mr=Object.create(null);function Nr(e,t,n){let r=Mr[e];r||(Mr[e]=r=Object.create(null));let i=typeof t==`string`?t:``;if(t!==!0&&n!==!0){let e=r[i];if(e)return e}let a=jr(e,i);return r[i]=a,a.catch(()=>{r[i]===a&&(r[i]=null)}),a}function Pr(e,t){let n=x(t),r=x(!1),i=null;function a(){let t=e();return i=t,r.set(!0),t.then(e=>{if(n)return n.set(e)},()=>{i===t&&(i=null)}).finally(()=>{i===t&&r.set(!1)}),t}return{get(){return i||a(),n.get()},load:e=>!e&&i||a(),get loading(){return r.get()}}}const Fr=M.id,{get:Ir,load:Lr}=Pr(async()=>{let e=await A.clone().get`applications`.append(`${Fr}`).json();return typeof e==`object`?e:null},null),Rr=S(()=>Ir()?.logo||``),zr=S(()=>Ir()?.title||``),Br=S(()=>Ir()?.company||``),Vr=S(()=>Ir()?.help||``),{get:Hr,load:Ur}=Pr(async()=>{if(!Fr)return[];let e=await A.clone().path`applications/${Fr}/menus`.result().then(e=>typeof e==`object`&&e||null,e=>Promise.reject(new L(e instanceof Response?e.status:100)));return!e||typeof e!=`object`?[]:e?.menus||[]},[]),{get:Wr,load:Gr}=Pr(async()=>{if(!Fr)return[];let e=await A.clone().path`applications/${Fr}/userMenus`.result().then(e=>typeof e==`object`&&e||null,e=>Promise.reject(new L(e instanceof Response?e.status:100)));return!e||typeof e!=`object`?[]:e?.userMenus||[]},[]),Kr=R(e=>A.clone().path`applications/${Fr}/pages/${e}`.result().catch(()=>null),null),qr=R(e=>A.clone().path`applications/${Fr}/continuations/${e}`.result().catch(()=>null),null),V={get logo(){return Rr.get()},get title(){return zr.get()},get company(){return Br.get()},get help(){return Vr.get()},refresh(){Lr()},get menus(){return Hr()},loadMenus(e){return Ur(e)},get userMenus(){return Wr()},loadUserMenus(e){return Gr(e)},loadPage(e){return Kr.create(e,e).load().then(e=>{let t=e?.widget;return!t||typeof t!=`string`?null:()=>I(t)},()=>null)},loadContinuation(e){return qr.create(e,e).load().then(e=>{let t=e?.widget;return!t||typeof t!=`string`?null:()=>I(t)},()=>null)}};function Jr(e,t){let n=e,r=t.fields.map(e=>Array.isArray(e)?e[0]:e);if(!r.length)return null;let i=r.pop()||``;for(let e of r){let t=Object.hasOwn(n,e)&&n[e]?.type;if(!t||typeof t!=`object`)return null;n=t}let a=Object.hasOwn(n,i)&&n[i];if(!a)return null;let o=t.field,s=o&&Object.hasOwn(n,o)&&n[o]||null,c=!!t.sign,{value:l,values:u}=t;for(let e of Kt(a,t.operator))if(s){for(let t of c?e.notField:e.field){let e=t(u,l,a,s);if(typeof e==`boolean`)return e}if(c)for(let t of e.field){let e=t(u,l,a,s);if(typeof e==`boolean`)return!e}}else{for(let t of c?e.notValue:e.value){let e=t(u,l,a);if(typeof e==`boolean`)return e}if(c)for(let t of e.value){let e=t(u,l,a);if(typeof e==`boolean`)return!e}}return null}function Yr({operator:e,sign:t,value:n,values:r}){let i=!!t;for(let t of Kt(!r.find(e=>!Array.isArray(e)),e)){for(let e of i?t.notValue:t.value){let t=e(r,n);if(typeof t==`boolean`)return t}if(i)for(let e of t.value){let t=e(r,n);if(typeof t==`boolean`)return!t}}if(!e){for(let e of r)if(e==n)return!i;return i}return null}function Xr(e,t,n){if(typeof e==`function`)return e;if(t!==`model`||!n)return Yr;let r=vr(n);return e=>{let t=r.getModel();return t?Jr(t.fields,e):Yr(e)}}function Zr(e,t,n,r){let i=[];for(let a of e){let e=Zr(a.children,t,n,r),o=a.disabled||!(ce(a.data,t,n,r)??!0);!e.length&&o||i.push({...a,children:e,disabled:o})}return i}function Qr(e,t){let n=[];for(let r of e){let e=Qr(r.children,t),i=!r.data||!t(r.data);!e.length&&i||n.push({...r,children:e,disabled:i})}return n}function $r(e,{id:t,label:n,value:r,parent:i,children:a,sequence:o,disabled:s}={}){let c=t||`{id}`,l=r||`{value}`,u=n||`{label}`,d=s;if(i){let t=i.includes(`{`)?i:`{${i}}`;return S(()=>{let n=e.get().map(e=>{let n=typeof e==`object`&&e?O(c,e):e,r=typeof e==`object`&&e?O(l,e):e,i=String(typeof e==`object`&&e&&O(u,e)||r),a=!!(typeof e==`object`&&d&&e?.[d]);return{id:n,value:r,label:i,data:e,parentId:typeof e==`object`&&e?O(t,e):``,disabled:a,children:[]}}),r=new Set(n.map(e=>String(e.value))),i=Object.groupBy(n,e=>e.parentId??``),a=Object.keys(i).filter(e=>!r.has(e)),o=a.flatMap(e=>i[e]||[]);for(let e of a)delete i[e];let s=[...o];for(let e;e=s.shift();){let t=i[e.id];if(delete i[e.id],t?.length){e.children=t;for(let e of t)s.push(e)}}for(let e=Object.keys(i);e.length;e=Object.keys(i)){let t=e[0],n=i[t];if(delete i[t],n?.length){for(let e of n)o.push(e),s.push(e);for(let e;e=s.shift();){let t=i[e.id];if(delete i[e.id],t?.length){e.children=t;for(let e of t)s.push(e)}}}}return o})}let f=a;function p(e){return e.map(e=>{if(typeof e!=`object`||!e)return{id:e,value:e,label:String(e),data:e,children:[]};let t=O(c,e),n=O(l,e),r=String(O(u,e)||n),i=!!(d&&e[d]);if(!f)return{id:t,value:n,label:r,data:e,disabled:i,children:[]};let a=e[f];return{id:t,value:n,label:r,data:e,disabled:i,children:p(a)}})}return S(()=>p(e.get()))}const ei=vn(e=>S(()=>{let t=[];for(let[n,r]of k.get(`enumerations`).get(e))for(let e of typeof r==`function`?r():[r])t.push({...e,plugin:n});return t}),e=>e);function ti(e){return ei(e).get()}const ni=vn((e,t)=>{if(!t)return S(()=>[]);if(e===`model`){let e=vr(t);return S(()=>e.getOptions())}if(e===`serverEnumeration`){let e=br(t);return S(()=>e.get())}if(e===`webEnumeration`)return S(()=>ti(t));if(e===`enumeration`){let e=br(t),n=S(()=>e.get()),r=S(()=>ti(t));return S(()=>[...n.get(),...r.get()])}return S(()=>[])},(e,t)=>t?[e,t].join(`
|