@poadio/app-vue 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/app-vue.css +102 -23
  3. package/dist/browser.d.ts +3 -1
  4. package/dist/browser.d.ts.map +1 -1
  5. package/dist/browser.js +18 -1
  6. package/dist/browser.js.map +1 -1
  7. package/dist/draft-toolbar.d.ts +65 -0
  8. package/dist/draft-toolbar.d.ts.map +1 -0
  9. package/dist/draft-toolbar.js +62 -0
  10. package/dist/draft-toolbar.js.map +1 -0
  11. package/dist/front-view.d.ts +5 -1
  12. package/dist/front-view.d.ts.map +1 -1
  13. package/dist/front-view.js +103 -44
  14. package/dist/front-view.js.map +1 -1
  15. package/dist/index.d.ts +2 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +2 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/items.d.ts +33 -0
  20. package/dist/items.d.ts.map +1 -0
  21. package/dist/items.js +369 -0
  22. package/dist/items.js.map +1 -0
  23. package/dist/lazy.d.ts +16 -0
  24. package/dist/lazy.d.ts.map +1 -1
  25. package/dist/lazy.js +34 -1
  26. package/dist/lazy.js.map +1 -1
  27. package/dist/messages.d.ts +19 -2
  28. package/dist/messages.d.ts.map +1 -1
  29. package/dist/messages.js +38 -4
  30. package/dist/messages.js.map +1 -1
  31. package/dist/sections/grid.d.ts +25 -1
  32. package/dist/sections/grid.d.ts.map +1 -1
  33. package/dist/sections/grid.js +31 -3
  34. package/dist/sections/grid.js.map +1 -1
  35. package/package.json +4 -3
  36. package/runtime-dist/app.css +102 -23
  37. package/runtime-dist/app.js +2 -2
  38. package/runtime-dist/c-031pq7qf.js +2 -0
  39. package/runtime-dist/c-0vbs937h.js +18 -0
  40. package/runtime-dist/c-1h49vkah.js +2 -0
  41. package/runtime-dist/c-1hzd2pqr.js +2 -0
  42. package/runtime-dist/c-1q9r6ndn.js +1 -0
  43. package/runtime-dist/c-1re10yb3.js +1 -0
  44. package/runtime-dist/c-1v1v69qs.js +1 -0
  45. package/runtime-dist/c-1yjbg3yb.js +1 -0
  46. package/runtime-dist/c-2ag31260.js +2 -0
  47. package/runtime-dist/c-2c88ebgp.js +1 -0
  48. package/runtime-dist/c-30chvm5x.js +1 -0
  49. package/runtime-dist/c-37zx0wkd.js +1 -0
  50. package/runtime-dist/c-4agg4qbw.js +1 -0
  51. package/runtime-dist/c-4g3757ck.js +2 -0
  52. package/runtime-dist/c-4vjd8na5.js +1 -0
  53. package/runtime-dist/c-523qwqen.js +2 -0
  54. package/runtime-dist/c-56tgqzdn.js +2 -0
  55. package/runtime-dist/c-57mnqma1.js +1 -0
  56. package/runtime-dist/c-5gfe19fa.js +1 -0
  57. package/runtime-dist/c-5ma45m2j.js +1 -0
  58. package/runtime-dist/c-74emmp4y.js +1 -0
  59. package/runtime-dist/c-7dryrrsk.js +2 -0
  60. package/runtime-dist/c-82sqd7as.js +1 -0
  61. package/runtime-dist/c-8ahb2ywd.js +1 -0
  62. package/runtime-dist/c-8cc3yqpn.js +1 -0
  63. package/runtime-dist/c-8h2rwbd8.js +1 -0
  64. package/runtime-dist/c-8nyvd0h0.js +1 -0
  65. package/runtime-dist/c-8r1pgc8w.js +1 -0
  66. package/runtime-dist/c-8x8fdn2b.js +1 -0
  67. package/runtime-dist/c-8xxzrkpg.js +2 -0
  68. package/runtime-dist/c-98tbntdq.js +2 -0
  69. package/runtime-dist/c-9rx4pqjs.js +2 -0
  70. package/runtime-dist/c-b5wfx90n.js +1 -0
  71. package/runtime-dist/c-bhgqqt5x.js +2 -0
  72. package/runtime-dist/c-c60s3ncm.js +2 -0
  73. package/runtime-dist/c-cfrv87cv.js +1 -0
  74. package/runtime-dist/c-d3hafdna.js +1 -0
  75. package/runtime-dist/c-d8hfdner.js +2 -0
  76. package/runtime-dist/c-d9rzqgda.js +1 -0
  77. package/runtime-dist/c-dx8zkcbf.js +1 -0
  78. package/runtime-dist/c-dzx0rg0g.js +2 -0
  79. package/runtime-dist/c-e3rddwjq.js +1 -0
  80. package/runtime-dist/c-e45fhawr.js +1 -0
  81. package/runtime-dist/c-eh9ryhw7.js +2 -0
  82. package/runtime-dist/{c-fg782zf4.js → c-er7e0yqs.js} +1 -1
  83. package/runtime-dist/c-fbtxac36.js +1 -0
  84. package/runtime-dist/c-g4dt7z6r.js +2 -0
  85. package/runtime-dist/c-g6vc4fyb.js +1 -0
  86. package/runtime-dist/c-g9jhyx8j.js +1 -0
  87. package/runtime-dist/c-gf4wzfng.js +1 -0
  88. package/runtime-dist/c-gfzghvh2.js +1 -0
  89. package/runtime-dist/c-grqtxpm9.js +1 -0
  90. package/runtime-dist/c-h8ny4vpa.js +1 -0
  91. package/runtime-dist/c-hgdk0vqh.js +1 -0
  92. package/runtime-dist/c-hrbpqm8q.js +2 -0
  93. package/runtime-dist/c-j63hz554.js +2 -0
  94. package/runtime-dist/c-jxqht9an.js +2 -0
  95. package/runtime-dist/c-jy6yg5r5.js +3 -0
  96. package/runtime-dist/c-k3yb5e72.js +2 -0
  97. package/runtime-dist/c-k624qrhh.js +2 -0
  98. package/runtime-dist/c-kaqzctfm.js +15 -0
  99. package/runtime-dist/c-kbg0cafy.js +2 -0
  100. package/runtime-dist/c-kmx0mv0c.js +2 -0
  101. package/runtime-dist/c-kqsnm92z.js +1 -0
  102. package/runtime-dist/c-mcy4rvac.js +2 -0
  103. package/runtime-dist/c-mdj990nz.js +2 -0
  104. package/runtime-dist/c-mhzk96e8.js +1 -0
  105. package/runtime-dist/c-mv93h1f5.js +1 -0
  106. package/runtime-dist/c-mvdn43tv.js +2 -0
  107. package/runtime-dist/c-n27dcy6d.js +2 -0
  108. package/runtime-dist/c-n8sg12jt.js +1 -0
  109. package/runtime-dist/c-n9cyhrcb.js +2 -0
  110. package/runtime-dist/c-ny0mdx7k.js +2 -0
  111. package/runtime-dist/c-p3z8t4n5.js +1 -0
  112. package/runtime-dist/c-p8wyhrwm.js +2 -0
  113. package/runtime-dist/c-pfc9b97d.js +1 -0
  114. package/runtime-dist/c-pj08sk6j.js +2 -0
  115. package/runtime-dist/{c-pgxy0etb.js → c-pk2cv8zh.js} +1 -1
  116. package/runtime-dist/c-py0rvzyv.js +1 -0
  117. package/runtime-dist/c-pyj696ce.js +1 -0
  118. package/runtime-dist/c-qzar8xvm.js +2 -0
  119. package/runtime-dist/c-rf1xevya.js +1 -0
  120. package/runtime-dist/{c-ns42txax.js → c-rj7c7mwf.js} +2 -2
  121. package/runtime-dist/c-rktc0ksd.js +2 -0
  122. package/runtime-dist/c-rm0av36n.js +1 -0
  123. package/runtime-dist/c-rv7cxh2k.js +2 -0
  124. package/runtime-dist/c-s3vrabx6.js +1 -0
  125. package/runtime-dist/c-sd570jk7.js +2 -0
  126. package/runtime-dist/c-sjajadt4.js +2 -0
  127. package/runtime-dist/c-t83mbx7z.js +1 -0
  128. package/runtime-dist/c-tsyjqc1h.js +2 -0
  129. package/runtime-dist/c-vmp3ee81.js +1 -0
  130. package/runtime-dist/c-vztkfwfq.js +1 -0
  131. package/runtime-dist/c-xw7vce7r.js +2 -0
  132. package/runtime-dist/c-y7abh583.js +1 -0
  133. package/runtime-dist/c-ynwn0vws.js +1 -0
  134. package/runtime-dist/c-za724ed4.js +1 -0
  135. package/runtime-dist/c-zt8jhyxz.js +1 -0
  136. package/runtime-dist/c-zv49taf7.js +1 -0
  137. package/runtime-dist/ui-accordion.css +29 -0
  138. package/runtime-dist/ui-app-shell.css +36 -0
  139. package/runtime-dist/ui-avatar.css +28 -0
  140. package/runtime-dist/ui-badge.css +14 -0
  141. package/runtime-dist/ui-block-editor.css +85 -0
  142. package/runtime-dist/ui-block-view.css +50 -0
  143. package/runtime-dist/ui-block.css +20 -0
  144. package/runtime-dist/ui-bottom-nav.css +54 -0
  145. package/runtime-dist/ui-breadcrumb.css +25 -0
  146. package/runtime-dist/ui-button-group.css +39 -0
  147. package/runtime-dist/ui-calendar.css +168 -0
  148. package/runtime-dist/ui-card.css +26 -0
  149. package/runtime-dist/ui-carousel.css +35 -0
  150. package/runtime-dist/ui-chart.css +26 -0
  151. package/runtime-dist/ui-checkbox.css +25 -0
  152. package/runtime-dist/ui-chip.css +30 -0
  153. package/runtime-dist/ui-code-editor.css +25 -0
  154. package/runtime-dist/ui-colorpicker.css +46 -0
  155. package/runtime-dist/ui-combo.css +43 -0
  156. package/runtime-dist/ui-dataview.css +50 -0
  157. package/runtime-dist/ui-datepicker.css +80 -0
  158. package/runtime-dist/ui-dialog.css +119 -0
  159. package/runtime-dist/ui-divider.css +18 -0
  160. package/runtime-dist/ui-fieldset.css +25 -0
  161. package/runtime-dist/ui-filter-chip.css +24 -0
  162. package/runtime-dist/ui-floating.css +9 -0
  163. package/runtime-dist/ui-gantt.css +105 -0
  164. package/runtime-dist/ui-image.css +34 -0
  165. package/runtime-dist/ui-inplace.css +19 -0
  166. package/runtime-dist/ui-json-editor.css +40 -0
  167. package/runtime-dist/ui-layout.css +39 -0
  168. package/runtime-dist/ui-listbox.css +52 -0
  169. package/runtime-dist/ui-map.css +469 -0
  170. package/runtime-dist/ui-menu.css +38 -0
  171. package/runtime-dist/ui-menubar.css +55 -0
  172. package/runtime-dist/ui-meter.css +26 -0
  173. package/runtime-dist/ui-multiselect.css +62 -0
  174. package/runtime-dist/ui-nav-drawer.css +118 -0
  175. package/runtime-dist/ui-number.css +26 -0
  176. package/runtime-dist/ui-option-list.css +28 -0
  177. package/runtime-dist/ui-orderlist.css +54 -0
  178. package/runtime-dist/ui-orgchart.css +71 -0
  179. package/runtime-dist/ui-paginator.css +25 -0
  180. package/runtime-dist/ui-panel.css +28 -0
  181. package/runtime-dist/ui-password.css +26 -0
  182. package/runtime-dist/ui-picklist.css +58 -0
  183. package/runtime-dist/ui-popover.css +20 -0
  184. package/runtime-dist/ui-progress.css +31 -0
  185. package/runtime-dist/ui-radio.css +29 -0
  186. package/runtime-dist/ui-rating.css +19 -0
  187. package/runtime-dist/ui-richtext.css +48 -0
  188. package/runtime-dist/ui-scheduler.css +132 -0
  189. package/runtime-dist/ui-scroll-top.css +17 -0
  190. package/runtime-dist/ui-segmented.css +25 -0
  191. package/runtime-dist/ui-select.css +47 -0
  192. package/runtime-dist/ui-sheet.css +56 -0
  193. package/runtime-dist/ui-skeleton.css +18 -0
  194. package/runtime-dist/ui-slider.css +59 -0
  195. package/runtime-dist/ui-speed-dial.css +26 -0
  196. package/runtime-dist/ui-splitter.css +23 -0
  197. package/runtime-dist/ui-stepper.css +47 -0
  198. package/runtime-dist/ui-switch.css +31 -0
  199. package/runtime-dist/ui-table-panel.css +114 -0
  200. package/runtime-dist/ui-table.css +430 -0
  201. package/runtime-dist/ui-tabs.css +45 -0
  202. package/runtime-dist/ui-taskboard.css +104 -0
  203. package/runtime-dist/ui-timeline.css +44 -0
  204. package/runtime-dist/ui-toast.css +43 -0
  205. package/runtime-dist/ui-toggle-button.css +6 -0
  206. package/runtime-dist/ui-tooltip.css +21 -0
  207. package/runtime-dist/ui-tree.css +44 -0
  208. package/runtime-dist/ui-upload.css +46 -0
  209. package/runtime-dist/version.json +1 -1
  210. package/src/browser.ts +21 -2
  211. package/src/draft-toolbar.ts +67 -0
  212. package/src/front-view.ts +105 -51
  213. package/src/index.ts +2 -1
  214. package/src/items.ts +436 -0
  215. package/src/lazy.ts +38 -1
  216. package/src/messages.ts +38 -4
  217. package/src/sections/grid.ts +40 -4
  218. package/runtime-dist/c-7dddcgt2.js +0 -2
  219. package/runtime-dist/c-9a0nzf53.js +0 -2
  220. package/runtime-dist/c-c1e1x3y1.js +0 -1
  221. package/runtime-dist/c-fnkq09db.js +0 -1
  222. package/runtime-dist/c-j29w8z15.js +0 -1
  223. package/runtime-dist/c-mmxqs2mz.js +0 -1
  224. package/runtime-dist/c-xsq12y6b.js +0 -1
@@ -1 +0,0 @@
1
- function Tt(p){let g=Object.create(null);for(let N of p.split(","))g[N]=1;return(N)=>(N in g)}var fe={},mt=[],$e=()=>{},Kn=()=>!1,m=(p)=>p.charCodeAt(0)===111&&p.charCodeAt(1)===110&&(p.charCodeAt(2)>122||p.charCodeAt(2)<97),y=(p)=>p.startsWith("onUpdate:"),s=Object.assign,$t=(p,g)=>{let N=p.indexOf(g);if(N>-1)p.splice(N,1)},uo=Object.prototype.hasOwnProperty,ae=(p,g)=>uo.call(p,g),t=Array.isArray,dt=(p)=>xt(p)==="[object Map]",mn=(p)=>xt(p)==="[object Set]",Fr=(p)=>xt(p)==="[object Date]";var r=(p)=>typeof p==="function",i=(p)=>typeof p==="string",c=(p)=>typeof p==="symbol",Ee=(p)=>p!==null&&typeof p==="object",Yn=(p)=>(Ee(p)||r(p))&&r(p.then)&&r(p.catch),fo=Object.prototype.toString,xt=(p)=>fo.call(p),Gn=(p)=>xt(p).slice(8,-1),Br=(p)=>xt(p)==="[object Object]",En=(p)=>i(p)&&p!=="NaN"&&p[0]!=="-"&&""+parseInt(p,10)===p,Vt=Tt(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted");var po=1e4,yn=(p)=>{let g=Object.create(null),N=0;return(T)=>{let C=g[T];if(C!==void 0)return C;if(++N>po)g=Object.create(null),N=1;return g[T]=p(T)}},ho=/-\w/g,o=yn((p)=>p.replace(ho,(g)=>g.slice(1).toUpperCase())),go=/\B([A-Z])/g,u=yn((p)=>p.replace(go,"-$1").toLowerCase()),v=yn((p)=>p.charAt(0).toUpperCase()+p.slice(1)),Ft=yn((p)=>p?`on${v(p)}`:""),De=(p,g)=>!Object.is(p,g),vn=(p,...g)=>{for(let N=0;N<p.length;N++)p[N](...g)},Nn=(p,g,N,T=!1)=>{Object.defineProperty(p,g,{configurable:!0,enumerable:!1,writable:T,value:N})},Wr=(p)=>{let g=parseFloat(p);return isNaN(g)?p:g};var Lr,Lt=()=>Lr||(Lr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Ut(p){if(t(p)){let g={};for(let N=0;N<p.length;N++){let T=p[N],C=i(T)?yo(T):Ut(T);if(C)for(let A in C)g[A]=C[A]}return g}else if(i(p)||Ee(p))return p}var _o=/;(?![^(]*\))/g,mo=/:([^]+)/,Eo=/"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;function yo(p){let g={};return p.replace(Eo,(N)=>N.startsWith("/*")?"":N).split(_o).forEach((N)=>{if(N){let T=N.split(mo);T.length>1&&(g[T[0].trim()]=T[1].trim())}}),g}function Ht(p){let g="";if(i(p))g=p;else if(t(p))for(let N=0;N<p.length;N++){let T=Ht(p[N]);if(T)g+=T+" "}else if(Ee(p)){for(let N in p)if(p[N])g+=N+" "}return g.trim()}var Kr="itemscope,allowfullscreen,disablepictureinpicture,disableremoteplayback,formnovalidate,ismap,nomodule,novalidate,playsinline,readonly",R=Tt(Kr),vo=Tt(Kr+",async,autofocus,autoplay,controls,default,defer,disabled,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected");function x(p){return!!p||p===""}function No(p,g,N){if(p.length!==g.length)return!1;let T=!0;for(let C=0;T&&C<p.length;C++)T=jt(p[C],g[C],N);return T}function Ur(p,g,N){if(p.size!==g.size)return!1;let T=Array.from(g),C=new Uint8Array(T.length);for(let A of p){let k=-1;for(let F=0;F<T.length;F++)if(!C[F]&&jt(A,T[F],N)){k=F;break}if(k<0)return!1;C[k]=1}return!0}function Oo(p,g,N){let T=dt(p),C=dt(g);if(T||C)return T&&C?Ur(p,g,N):!1;if(T=mn(p),C=mn(g),T||C)return T&&C?Ur(p,g,N):!1;let A=Object.keys(p).length,k=Object.keys(g).length;if(A!==k)return!1;for(let F in p){let U=ae(p,F),j=ae(g,F);if(U&&!j||!U&&j||!jt(p[F],g[F],N))return!1}return jr(p)===jr(g)}function Hr(p,g,N,T){if(!N)N=[new Map,new Map];let[C,A]=N;if(C.has(p)||A.has(g))return C.get(p)===g&&A.get(g)===p;C.set(p,g),A.set(g,p);let k=T(p,g,N);return C.delete(p),A.delete(g),k}function jt(p,g,N){if(p===g)return!0;let T=Fr(p),C=Fr(g);if(T||C)return T&&C?p.getTime()===g.getTime():!1;if(T=c(p),C=c(g),T||C)return p===g;if(T=t(p),C=t(g),T||C)return T&&C?Hr(p,g,N,No):!1;if(T=Ee(p),C=Ee(g),T||C){if(!T||!C)return!1;return Hr(p,g,N,Oo)}return String(p)===String(g)}function jr(p){return Object.getPrototypeOf(p)===null&&p[Symbol.toPrimitive]==null&&typeof p.toString!=="function"&&typeof p.valueOf!=="function"?xt(p):String(p)}function bo(p,...g){console.warn(`[Vue warn] ${p}`,...g)}var be;class Tn{constructor(p=!1){if(this.detached=p,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!p&&be)if(be.active)this.parent=be,this.index=(be.scopes||(be.scopes=[])).push(this)-1;else this._active=!1,this._warnOnRun=!1}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let p,g;if(this.scopes){let N=this.scopes.slice();for(p=0,g=N.length;p<g;p++)N[p].pause()}for(p=0,g=this.effects.length;p<g;p++)this.effects[p].pause()}}resume(){if(this._active){if(this._isPaused){this._isPaused=!1;let p,g;if(this.scopes){let T=this.scopes.slice();for(p=0,g=T.length;p<g;p++)T[p].resume()}let N=this.effects.slice();for(p=0,g=N.length;p<g;p++)N[p].resume()}}}run(p){if(this._active){let g=be;try{return be=this,p()}finally{be=g}}}on(){if(++this._on===1)this.prevScope=be,be=this}off(){if(this._on>0&&--this._on===0){if(be===this)be=this.prevScope;else{let p=be;while(p){if(p.prevScope===this){p.prevScope=this.prevScope;break}p=p.prevScope}}this.prevScope=void 0}}stop(p){if(this._active){this._active=!1;let g,N;for(g=0,N=this.effects.length;g<N;g++)this.effects[g].stop();this.effects.length=0;for(g=0,N=this.cleanups.length;g<N;g++)this.cleanups[g]();if(this.cleanups.length=0,this.scopes){let T=this.scopes.slice();for(g=0,N=T.length;g<N;g++)T[g].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!p){let T=this.parent.scopes.pop();if(T&&T!==this)this.parent.scopes[this.index]=T,T.index=this.index}this.parent=void 0}}}function zr(){return be}function tr(p,g=!1){if(be)if(be.active)be.cleanups.push(p);else p()}var ye;var qn=new WeakSet;class zt{constructor(p){if(this.fn=p,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,be)if(be.active)be.effects.push(this);else this.flags&=-2}pause(){this.flags|=64}resume(){if(this.flags&64){if(this.flags&=-65,qn.has(this))qn.delete(this),this.trigger()}}notify(){if(this.flags&2&&!(this.flags&32))return;if(!(this.flags&8))Xr(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,Yr(this),Zr(this);let p=ye,g=He;ye=this,He=!0;try{return this.fn()}finally{Qr(this),ye=p,He=g,this.flags&=-3}}stop(){if(this.flags&1){for(let p=this.deps;p;p=p.nextDep)sr(p);this.deps=this.depsTail=void 0,Yr(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){if(this.flags&64)qn.add(this);else if(this.scheduler)this.scheduler();else this.runIfDirty()}runIfDirty(){if(Xn(this))this.run()}get dirty(){return Xn(this)}}var Jr=0,Wt,Kt;function Xr(p,g=!1){if(p.flags|=8,g){p.next=Kt,Kt=p;return}p.next=Wt,Wt=p}function nr(){Jr++}function rr(){if(--Jr>0)return;if(Kt){let g=Kt;Kt=void 0;while(g){let N=g.next;g.next=void 0,g.flags&=-9,g=N}}let p;while(Wt){let g=Wt;Wt=void 0;while(g){let N=g.next;if(g.next=void 0,g.flags&=-9,g.flags&1)try{g.trigger()}catch(T){if(!p)p=T}g=N}}if(p)throw p}function Zr(p){for(let g=p.deps;g;g=g.nextDep)g.version=-1,g.prevActiveLink=g.dep.activeLink,g.dep.activeLink=g}function Qr(p){let g,N=p.depsTail,T=N;while(T){let C=T.prevDep;if(T.version===-1){if(T===N)N=C;sr(T),wo(T)}else g=T;T.dep.activeLink=T.prevActiveLink,T.prevActiveLink=void 0,T=C}p.deps=g,p.depsTail=N}function Xn(p){for(let g=p.deps;g;g=g.nextDep)if(g.dep.version!==g.version||g.dep.computed&&(es(g.dep.computed)||g.dep.version!==g.version))return!0;if(p._dirty)return!0;return!1}function es(p){if(p.flags&4&&!(p.flags&16))return;if(p.flags&=-17,p.globalVersion===Yt)return;if(p.globalVersion=Yt,!p.isSSR&&p.flags&128&&(!p.deps&&!p._dirty||!Xn(p)))return;p.flags|=2;let g=p.dep,N=ye,T=He;ye=p,He=!0;try{Zr(p);let C=p.fn(p._value);if(g.version===0||De(C,p._value))p.flags|=128,p._value=C,g.version++}catch(C){throw g.version++,C}finally{ye=N,He=T,Qr(p),p.flags&=-3}}function sr(p,g=!1){let{dep:N,prevSub:T,nextSub:C}=p;if(T)T.nextSub=C,p.prevSub=void 0;if(C)C.prevSub=T,p.nextSub=void 0;if(N.subs===p){if(N.subs=T,!T&&N.computed){N.computed.flags&=-5;for(let A=N.computed.deps;A;A=A.nextDep)sr(A,!0)}}if(!g&&!--N.sc&&N.map)N.map.delete(N.key)}function wo(p){let{prevDep:g,nextDep:N}=p;if(g)g.nextDep=N,p.prevDep=void 0;if(N)N.prevDep=g,p.nextDep=void 0}var He=!0,ts=[];function je(){ts.push(He),He=!1}function Be(){let p=ts.pop();He=p===void 0?!0:p}function Yr(p){let{cleanup:g}=p;if(p.cleanup=void 0,g){let N=ye;ye=void 0;try{g()}finally{ye=N}}}var Yt=0;class ns{constructor(p,g){this.sub=p,this.dep=g,this.version=g.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class Jt{constructor(p){this.computed=p,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(p){if(!ye||!He||ye===this.computed)return;let g=this.activeLink;if(g===void 0||g.sub!==ye){if(g=this.activeLink=new ns(ye,this),!ye.deps)ye.deps=ye.depsTail=g;else g.prevDep=ye.depsTail,ye.depsTail.nextDep=g,ye.depsTail=g;rs(g)}else if(g.version===-1){if(g.version=this.version,g.nextDep){let N=g.nextDep;if(N.prevDep=g.prevDep,g.prevDep)g.prevDep.nextDep=N;if(g.prevDep=ye.depsTail,g.nextDep=void 0,ye.depsTail.nextDep=g,ye.depsTail=g,ye.deps===g)ye.deps=N}}return g}trigger(p){this.version++,Yt++,this.notify(p)}notify(p){nr();try{for(let g=this.subs;g;g=g.prevSub)if(g.sub.notify())g.sub.dep.notify()}finally{rr()}}}function rs(p){if(p.dep.sc++,p.sub.flags&4){let g=p.dep.computed;if(g&&!p.dep.subs){g.flags|=20;for(let T=g.deps;T;T=T.nextDep)rs(T)}let N=p.dep.subs;if(N!==p){if(p.prevSub=N,N)N.nextSub=p}p.dep.subs=p}}var Zn=new WeakMap,yt=Symbol(""),Qn=Symbol(""),Gt=Symbol("");function Ve(p,g,N){if(He&&ye){let T=Zn.get(p);if(!T)Zn.set(p,T=new Map);let C=T.get(N);if(!C)T.set(N,C=new Jt),C.map=T,C.key=N;C.track()}}function Xe(p,g,N,T,C,A){let k=Zn.get(p);if(!k){Yt++;return}let F=(U)=>{if(U)U.trigger()};if(nr(),g==="clear")k.forEach(F);else{let U=t(p),j=U&&En(N);if(U&&N==="length"){let H=Number(T);k.forEach((W,Z)=>{if(Z==="length"||Z===Gt||!c(Z)&&Z>=H)F(W)})}else{if(N!==void 0||k.has(void 0))F(k.get(N));if(j)F(k.get(Gt));switch(g){case"add":if(!U){if(F(k.get(yt)),dt(p))F(k.get(Qn))}else if(j)F(k.get("length"));break;case"delete":if(!U){if(F(k.get(yt)),dt(p))F(k.get(Qn))}break;case"set":if(dt(p))F(k.get(yt));break}}}rr()}function Ct(p){let g=de(p);if(g===p)return g;if(Ve(g,"iterate",Gt),Fe(p))return g;if(!We(p))return g.map(Ke);return ct(p)?g.map((N)=>ht(Ke(N))):g.map(ht)}function xn(p){return Ve(p=de(p),"iterate",Gt),p}function Je(p,g){if(We(p))return ct(p)?ht(Ke(g)):ht(g);return Ke(g)}var Do={__proto__:null,[Symbol.iterator](){return zn(this,Symbol.iterator,(p)=>Je(this,p))},concat(...p){return Ct(this).concat(...p.map((g)=>t(g)?Ct(g):g))},entries(){return zn(this,"entries",(p)=>(p[1]=Je(this,p[1]),p))},every(p,g){return it(this,"every",p,g,void 0,arguments)},filter(p,g){return it(this,"filter",p,g,(N)=>N.map((T)=>Je(this,T)),arguments)},find(p,g){return it(this,"find",p,g,(N)=>Je(this,N),arguments)},findIndex(p,g){return it(this,"findIndex",p,g,void 0,arguments)},findLast(p,g){return it(this,"findLast",p,g,(N)=>Je(this,N),arguments)},findLastIndex(p,g){return it(this,"findLastIndex",p,g,void 0,arguments)},forEach(p,g){return it(this,"forEach",p,g,void 0,arguments)},includes(...p){return Jn(this,"includes",p)},indexOf(...p){return Jn(this,"indexOf",p)},join(p){return Ct(this).join(p)},lastIndexOf(...p){return Jn(this,"lastIndexOf",p)},map(p,g){return it(this,"map",p,g,void 0,arguments)},pop(){return Bt(this,"pop")},push(...p){return Bt(this,"push",p)},reduce(p,...g){return qr(this,"reduce",p,g)},reduceRight(p,...g){return qr(this,"reduceRight",p,g)},shift(){return Bt(this,"shift")},some(p,g){return it(this,"some",p,g,void 0,arguments)},splice(...p){return Bt(this,"splice",p)},toReversed(){return Ct(this).toReversed()},toSorted(p){return Ct(this).toSorted(p)},toSpliced(...p){return Ct(this).toSpliced(...p)},unshift(...p){return Bt(this,"unshift",p)},values(){return zn(this,"values",(p)=>Je(this,p))}};function zn(p,g,N){let T=xn(p),C=T[g],A=C.call(T);if(T!==p&&!Fe(p)){if(A[Symbol.toStringTag]==="Array Iterator"){let k=Object.create(Object.getPrototypeOf(A));if(k.next=()=>Gr(A.next(),N),C!==ss[g])Object.defineProperties(k,{return:{get(){let F=A.return;return typeof F==="function"?F.bind(A):F}},throw:{get(){let F=A.throw;return typeof F==="function"?F.bind(A):F}}});return k}A._next=A.next,A.next=()=>Gr(A._next(),N)}return A}function Gr(p,g){if(!p.done)p.value=g(p.value);return p}var ss=Array.prototype;function it(p,g,N,T,C,A){let k=xn(p),F=k!==p&&!Fe(p),U=k[g];if(U!==ss[g]){let W=U.apply(p,A);return F?Ke(W):W}let j=N;if(k!==p){if(F)j=function(W,Z){return N.call(this,Je(p,W),Z,p)};else if(N.length>2)j=function(W,Z){return N.call(this,W,Z,p)}}let H=U.call(k,j,T);return F&&C?C(H):H}function qr(p,g,N,T){let C=xn(p),A=C!==p&&!Fe(p),k=N,F=!1;if(C!==p){if(A)F=T.length===0,k=function(j,H,W){if(F)F=!1,j=Je(p,j);return N.call(this,j,Je(p,H),W,p)};else if(N.length>3)k=function(j,H,W){return N.call(this,j,H,W,p)}}let U=C[g](k,...T);return F?Je(p,U):U}function Jn(p,g,N){let T=de(p);Ve(T,"iterate",Gt);let C=T[g](...N);if((C===-1||C===!1)&&Zt(N[0]))return N[0]=de(N[0]),T[g](...N);return C}function Bt(p,g,N=[]){je(),nr();let T=de(p)[g].apply(p,N);return rr(),Be(),T}var To=Tt("__proto__,__v_isRef,__isVue"),os=new Set(Object.getOwnPropertyNames(Symbol).filter((p)=>p!=="arguments"&&p!=="caller").map((p)=>Symbol[p]).filter(c));function xo(p){if(!c(p))p=String(p);let g=de(this);return Ve(g,"has",p),g.hasOwnProperty(p)}class or{constructor(p=!1,g=!1){this._isReadonly=p,this._isShallow=g}get(p,g,N){if(g==="__v_skip")return p.__v_skip;let T=this._isReadonly,C=this._isShallow;if(g==="__v_isReactive")return!T;else if(g==="__v_isReadonly")return T;else if(g==="__v_isShallow")return C;else if(g==="__v_raw"){if(N===(T?C?Mo:as:C?cs:ls).get(p)||Object.getPrototypeOf(p)===Object.getPrototypeOf(N))return p;return}let A=t(p);if(!T){let F;if(A&&(F=Do[g]))return F;if(g==="hasOwnProperty")return xo}let k=Reflect.get(p,g,Te(p)?p:N);if(c(g)?os.has(g):To(g))return k;if(!T)Ve(p,"get",g);if(C)return k;if(Te(k)){let F=A&&En(g)?k:k.value;return T&&Ee(F)?qt(F):F}if(Ee(k))return T?qt(k):Xt(k);return k}}class ir extends or{constructor(p=!1){super(!1,p)}set(p,g,N,T){let C=p[g],A=t(p)&&En(g);if(!this._isShallow){let U=We(C);if(!Fe(N)&&!We(N))C=de(C),N=de(N);if(!A&&Te(C)&&!Te(N))if(U)return!0;else return C.value=N,!0}let k=A?Number(g)<p.length:ae(p,g),F=Reflect.set(p,g,N,Te(p)?p:T);if(p===de(T)&&F){if(!k)Xe(p,"add",g,N);else if(De(N,C))Xe(p,"set",g,N,C)}return F}deleteProperty(p,g){let N=ae(p,g),T=p[g],C=Reflect.deleteProperty(p,g);if(C&&N)Xe(p,"delete",g,void 0,T);return C}has(p,g){let N=Reflect.has(p,g);if(!c(g)||!os.has(g))Ve(p,"has",g);return N}ownKeys(p){return Ve(p,"iterate",t(p)?"length":yt),Reflect.ownKeys(p)}}class is extends or{constructor(p=!1){super(!0,p)}set(p,g){return!0}deleteProperty(p,g){return!0}}var Vo=new ir,Co=new is,So=new ir(!0);var er=(p)=>p,On=(p)=>Reflect.getPrototypeOf(p);function Ao(p,g,N){return function(...T){let C=this.__v_raw,A=de(C),k=dt(A),F=p==="entries"||p===Symbol.iterator&&k,U=p==="keys"&&k,j=C[p](...T),H=N?er:g?ht:Ke;return!g&&Ve(A,"iterate",U?Qn:yt),s(Object.create(j),{next(){let{value:W,done:Z}=j.next();return Z?{value:W,done:Z}:{value:F?[H(W[0]),H(W[1])]:H(W),done:Z}}})}}function bn(p){return function(...g){return p==="delete"?!1:p==="clear"?void 0:this}}function Ro(p,g){let N={get(C){let A=this.__v_raw,k=de(A),F=de(C);if(!p){if(De(C,F))Ve(k,"get",C);Ve(k,"get",F)}let{has:U}=On(k),j=g?er:p?ht:Ke;if(U.call(k,C))return j(A.get(C));else if(U.call(k,F))return j(A.get(F));else if(A!==k)A.get(C)},get size(){let C=this.__v_raw;return!p&&Ve(de(C),"iterate",yt),C.size},has(C){let A=this.__v_raw,k=de(A),F=de(C);if(!p){if(De(C,F))Ve(k,"has",C);Ve(k,"has",F)}return C===F?A.has(C):A.has(C)||A.has(F)},forEach(C,A){let k=this,F=k.__v_raw,U=de(F),j=g?er:p?ht:Ke;return!p&&Ve(U,"iterate",yt),F.forEach((H,W)=>C.call(A,j(H),j(W),k))}};return s(N,p?{add:bn("add"),set:bn("set"),delete:bn("delete"),clear:bn("clear")}:{add(C){let A=de(this),k=On(A),F=de(C),U=!g&&!Fe(C)&&!We(C)?F:C;if(!(k.has.call(A,U)||De(C,U)&&k.has.call(A,C)||De(F,U)&&k.has.call(A,F)))A.add(U),Xe(A,"add",U,U);return this},set(C,A){if(!g&&!Fe(A)&&!We(A))A=de(A);let k=de(this),{has:F,get:U}=On(k),j=F.call(k,C);if(!j)C=de(C),j=F.call(k,C);let H=U.call(k,C);if(k.set(C,A),!j)Xe(k,"add",C,A);else if(De(A,H))Xe(k,"set",C,A,H);return this},delete(C){let A=de(this),{has:k,get:F}=On(A),U=k.call(A,C);if(!U)C=de(C),U=k.call(A,C);let j=F?F.call(A,C):void 0,H=A.delete(C);if(U)Xe(A,"delete",C,void 0,j);return H},clear(){let C=de(this),A=C.size!==0,k=void 0,F=C.clear();if(A)Xe(C,"clear",void 0,void 0,void 0);return F}}),["keys","values","entries",Symbol.iterator].forEach((C)=>{N[C]=Ao(C,p,g)}),N}function lr(p,g){let N=Ro(p,g);return(T,C,A)=>{if(C==="__v_isReactive")return!p;else if(C==="__v_isReadonly")return p;else if(C==="__v_isShallow")return g;else if(C==="__v_raw")return T;return Reflect.get(ae(N,C)&&C in T?N:T,C,A)}}var ko={get:lr(!1,!1)},Po={get:lr(!1,!0)},Io={get:lr(!0,!1)};var ls=new WeakMap,cs=new WeakMap,as=new WeakMap,Mo=new WeakMap;function $o(p){switch(p){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function Xt(p){if(We(p))return p;return ar(p,!1,Vo,ko,ls)}function cr(p){return ar(p,!1,So,Po,cs)}function qt(p){return ar(p,!0,Co,Io,as)}function ar(p,g,N,T,C){if(!Ee(p))return p;if(p.__v_raw&&!(g&&p.__v_isReactive))return p;if(p.__v_skip||!Object.isExtensible(p))return p;let A=C.get(p);if(A)return A;let k=$o(Gn(p));if(k===0)return p;let F=new Proxy(p,k===2?T:N);return C.set(p,F),F}function ct(p){if(We(p))return ct(p.__v_raw);return!!(p&&p.__v_isReactive)}function We(p){return!!(p&&p.__v_isReadonly)}function Fe(p){return!!(p&&p.__v_isShallow)}function Zt(p){return p?!!p.__v_raw:!1}function de(p){let g=p&&p.__v_raw;return g?de(g):p}function ur(p){if(!ae(p,"__v_skip")&&Object.isExtensible(p))Nn(p,"__v_skip",!0);return p}var Ke=(p)=>Ee(p)?Xt(p):p,ht=(p)=>Ee(p)?qt(p):p;function Te(p){return p?p.__v_isRef===!0:!1}function d(p){return us(p,!1)}function f(p){return us(p,!0)}function us(p,g){if(Te(p))return p;return new fs(p,g)}class fs{constructor(p,g){this.dep=new Jt,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=g?p:de(p),this._value=g?p:Ke(p),this.__v_isShallow=g}get value(){return this.dep.track(),this._value}set value(p){let g=this._rawValue,N=this.__v_isShallow||Fe(p)||We(p);if(p=N?p:de(p),De(p,g))this._rawValue=p,this._value=N?p:Ke(p),this.dep.trigger()}}function ps(p){return Te(p)?p.value:p}var Fo={get:(p,g,N)=>g==="__v_raw"?p:ps(Reflect.get(p,g,N)),set:(p,g,N,T)=>{let C=p[g];if(Te(C)&&!Te(N))return C.value=N,!0;else return Reflect.set(p,g,N,T)}};function Vn(p){return ct(p)?p:new Proxy(p,Fo)}class ds{constructor(p){this.__v_isRef=!0,this._value=void 0;let g=this.dep=new Jt,{get:N,set:T}=p(g.track.bind(g),g.trigger.bind(g));this._get=N,this._set=T}get value(){return this._value=this._get()}set value(p){this._set(p)}}function fr(p){return new ds(p)}class hs{constructor(p,g,N){this.fn=p,this.setter=g,this._value=void 0,this.dep=new Jt(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=Yt-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!g,this.isSSR=N}notify(){if(this.flags|=16,!(this.flags&8)&&ye!==this)return Xr(this,!0),!0}get value(){let p=this.dep.track();if(es(this),p)p.version=this.dep.version;return this._value}set value(p){if(this.setter)this.setter(p)}}function gs(p,g,N=!1){let T,C;if(r(p))T=p;else T=p.get,C=p.set;return new hs(T,C,N)}var wn={},Dn=new WeakMap,Et=void 0;function _s(p,g=!1,N=Et){if(N){let T=Dn.get(N);if(!T)Dn.set(N,T=[]);T.push(p)}}function ms(p,g,N=fe){let{immediate:T,deep:C,once:A,scheduler:k,augmentJob:F,call:U}=N,j=(ne)=>{(N.onWarn||bo)("Invalid watch source: ",ne,"A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.")},H=(ne)=>{if(C)return ne;if(Fe(ne)||C===!1||C===0)return lt(ne,1);return lt(ne)},W,Z,te,re,Q=!1,pe=!1;if(Te(p))Z=()=>p.value,Q=Fe(p);else if(ct(p))Z=()=>H(p),Q=!0;else if(t(p))pe=!0,Q=p.some((ne)=>ct(ne)||Fe(ne)),Z=()=>p.map((ne)=>{if(Te(ne))return ne.value;else if(ct(ne))return H(ne);else if(r(ne))return U?U(ne,2):ne()});else if(r(p))if(g)Z=U?()=>U(p,2):p;else Z=()=>{if(te){je();try{te()}finally{Be()}}let ne=Et;Et=W;try{return U?U(p,3,[re]):p(re)}finally{Et=ne}};else Z=$e;if(g&&C){let ne=Z,Ne=C===!0?1/0:C;Z=()=>lt(ne(),Ne)}let he=zr(),le=()=>{if(W.stop(),he&&he.active)$t(he.effects,W)};if(A&&g){let ne=g;g=(...Ne)=>{try{return ne(...Ne)}finally{le()}}}let ce=pe?Array(p.length).fill(wn):wn,xe=(ne)=>{if(!(W.flags&1)||!W.dirty&&!ne)return;if(g){let Ne=W.run();if(ne||C||Q||(pe?Ne.some((nt,Ue)=>De(nt,ce[Ue])):De(Ne,ce))){let nt=Et;je();try{if(te)te();Et=W;let Ue=[Ne,ce===wn?void 0:pe&&ce[0]===wn?[]:ce,re];ce=Ne,U?U(g,3,Ue):g(...Ue)}finally{Et=nt,Be()}}}else W.run()};if(F)F(xe);if(W=new zt(Z),W.scheduler=k?()=>k(xe,!1):xe,re=(ne)=>_s(ne,!1,W),te=W.onStop=()=>{let ne=Dn.get(W);if(ne){if(U)U(ne,4);else for(let Ne of ne)Ne();Dn.delete(W)}},g)if(T)xe(!0);else ce=W.run();else if(k)k(xe.bind(null,!0),!0);else W.run();return le.pause=W.pause.bind(W),le.resume=W.resume.bind(W),le.stop=le,le}function lt(p,g=1/0,N){if(g<=0||!Ee(p)||p.__v_skip)return p;if(N=N||new Map,(N.get(p)||0)>=g)return p;if(N.set(p,g),g--,Te(p))lt(p.value,g,N);else if(t(p))for(let T=0;T<p.length;T++)lt(p[T],g,N);else if(mn(p)||dt(p))p.forEach((T)=>{lt(T,g,N)});else if(Br(p)){for(let T in p)lt(p[T],g,N);for(let T of Object.getOwnPropertySymbols(p))if(Object.prototype.propertyIsEnumerable.call(p,T))lt(p[T],g,N)}return p}function fn(p,g,N,T){try{return T?p(...T):p()}catch(C){pn(C,g,N)}}function l(p,g,N,T){if(r(p)){let C=fn(p,g,N,T);if(C&&Yn(C))C.catch((A)=>{pn(A,g,N,void 0,!0)});return C}if(t(p)){let C=[];for(let A=0;A<p.length;A++)C.push(l(p[A],g,N,T));return C}}function pn(p,g,N,T=!0,C=!1){let A=g?g.vnode:null,{errorHandler:k,throwUnhandledErrorInProduction:F}=g&&g.appContext.config||fe;if(g){let{parent:U,proxy:j}=g,H=`https://vuejs.org/error-reference/#runtime-${N}`;while(U){let W=U.ec;if(W&&!U.isUnmounted&&(!C||U.scope.active)){for(let Z=0;Z<W.length;Z++)if(W[Z](p,j,H)===!1)return}U=U.parent}if(k){je(),fn(k,null,10,[p,j,H]),Be();return}}Uo(p,N,A,T,F)}function Uo(p,g,N,T=!0,C=!1){if(C)throw p;else console.error(p)}var Re=[],Ye=-1,Qe=[],gt=null,St=0,Rs=Promise.resolve(),An=null;function Ho(p){let g=An||Rs;return p?g.then(this?p.bind(this):p):g}function jo(p){let g=Ye+1,N=Re.length;while(g<N){let T=g+N>>>1,C=Re[T],A=ln(C);if(A<p||A===p&&C.flags&2)g=T+1;else N=T}return g}function br(p){if(!(p.flags&1)){let g=ln(p),N=Re[Re.length-1];if(!N||!(p.flags&2)&&g>=ln(N))Re.push(p);else Re.splice(jo(g),0,p);p.flags|=1,ks()}}function ks(){if(!An)An=Rs.then(Ms)}function Bo(p){if(!t(p)){if(gt&&p.id===-1)gt.splice(St+1,0,p);else if(!(p.flags&1))Qe.push(p),p.flags|=1}else for(let g=0;g<p.length;g++)Qe.push(p[g]);ks()}function Ps(p,g,N,T=Ye+1){for(;T<Re.length;T++){let C=Re[T];if(C&&C.flags&2){if(p&&C.id!==p.uid||g!==void 0&&!(C.id>=g))continue;if(Re.splice(T,1),T=p?T-1:Ye,C.flags&4)C.flags&=-2;if(C(),!(C.flags&4))C.flags&=-2}}}function Is(p,g,N=0){if(Qe.length){let T=Qe,C=0;if(g){T=[];for(let k=0;k<Qe.length;k++){let F=Qe[k];if(F.i!==void 0?!F.i||F.i.uid<N:g.has(F))Qe[C++]=F;else T.push(F)}}let A=[...new Set(T)].sort((k,F)=>ln(k)-ln(F));if(Qe.length=C,gt){for(let k=0;k<A.length;k++)gt.push(A[k]);return}gt=A;for(St=0;St<gt.length;St++){let k=gt[St];if(k.flags&4)k.flags&=-2;if(!(k.flags&8))k();k.flags&=-2}gt=null,St=0}}var pr=!1;function Wo(p,g){if(pr){p();return}let N=g===void 0?void 0:new Set(Qe);p(),pr=!0;try{Ps(void 0,g),Is(void 0,N,g)}finally{pr=!1}}var ln=(p)=>p.id==null?p.flags&2?-1:1/0:p.id;function Ms(p){let g=$e;try{for(Ye=0;Ye<Re.length;Ye++){let N=Re[Ye];if(N&&!(N.flags&8)){if(N.flags&4)N.flags&=-2;if(fn(N,N.i,N.i?15:14),!(N.flags&4))N.flags&=-2}}}finally{for(;Ye<Re.length;Ye++){let N=Re[Ye];if(N)N.flags&=-2}if(Ye=-1,Re.length=0,Is(p),An=null,Re.length||Qe.length)Ms(p)}}var tt=null,$s=null;function Rn(p){let g=tt;return tt=p,$s=p&&p.type.__scopeId||null,g}function Ko(p,g=tt,N){if(!g)return p;if(p._n)return p;let T=(...C)=>{if(T._d)In(-1);let A=Rn(g),k=Rt.length,F;try{F=p(...C)}finally{for(let U=Rt.length;U>k;U--)$i();if(Rn(A),T._d)In(1)}return F};return T._n=!0,T._c=!0,T._d=!0,T}function vt(p,g,N,T){let C=p;if(T==="beforeMount")p._mount=p;else if(T==="beforeUpdate"){let F=g&&g._mount;if(F)F._latest=p,p._mount=F}else if(T==="mounted"){let F=p._latest;if(p._mount=p._latest=void 0,F)C=F,F._mount=void 0}let A=C.dirs,k=g&&g.dirs;for(let F=0;F<A.length;F++){let U=A[F];if(k)U.oldValue=k[F].value;else if(T==="mounted"&&U.oldValue!==void 0)U=s({},U,{oldValue:void 0});let j=U.dir[T];if(j)je(),l(j,N,8,[p.el,U,C,g]),Be()}}function b(p,g){if(Ce){let N=Ce.provides,T=Ce.parent&&Ce.parent.provides;if(T===N)N=Ce.provides=Object.create(T);N[p]=g}}function a(p,g,N=!1){let T=_();if(T||At){let C=At?At._context.provides:T?T.parent==null||T.ce?T.vnode.appContext&&T.vnode.appContext.provides:T.parent.provides:void 0;if(C&&p in C)return C[p];else if(arguments.length>1)return N&&r(g)?g.call(T&&T.proxy):g}}var Yo=Symbol.for("v-scx"),Go=()=>{{let p=a(Yo);return p}};function qo(p,g){return wr(p,null,{flush:"sync"})}function E(p,g,N){return wr(p,g,N)}function wr(p,g,N=fe){let{immediate:T,deep:C,flush:A,once:k}=N,F=s({},N),U=g&&T||!g&&A!=="post",j;if(Pt){if(A==="sync"){let te=Go();j=te.__watcherHandles||(te.__watcherHandles=[])}else if(!U){let te=()=>{};return te.stop=$e,te.resume=$e,te.pause=$e,te}}let H=Ce;F.call=(te,re,Q)=>l(te,H,re,Q);let W=!1;if(A==="post")F.scheduler=(te)=>{te.i=H,Ae(te,H&&H.suspense)};else if(A!=="sync")W=!0,F.scheduler=(te,re)=>{if(re)te();else br(te)};F.augmentJob=(te)=>{if(g)te.flags|=4;if(W){if(te.flags|=2,H)te.id=H.uid,te.i=H}};let Z=ms(p,g,F);if(Pt){if(j)j.push(Z);else if(U)Z()}return Z}function zo(p,g,N){let T=this.proxy,C=i(p)?p.includes(".")?Fs(T,p):()=>T[p]:p.bind(T,T),A;if(r(g))A=g;else A=g.handler,N=g;let k=dn(this),F=wr(C,A.bind(T),N);return k(),F}function Fs(p,g){let N=g.split(".");return()=>{let T=p;for(let C=0;C<N.length&&T;C++)T=T[N[C]];return T}}var Jo=Symbol("_vte"),Fn=(p)=>p.__isTeleport;var dr=Symbol("_leaveCb");function Xo(p){let g=p[0];if(p.length>1){let N=!1;for(let T of p)if(T.type!==ft){g=T,N=!0;break}}return g}function Ls(p){if(!Ln(p)){if(Fn(p.type)&&p.children)return Xo(p.children);return p}if(p.component)return p.component.subTree;let{shapeFlag:g,children:N}=p;if(N){if(g&16)return N[0];if(g&32&&r(N.default))return N.default()}}function tn(p,g){if(p.shapeFlag&6&&p.component){p.transition=g;let N=p.component.subTree;tn(Fn(N.type)?Ls(N)||N:N,g)}else if(p.shapeFlag&128){let N=p.suspense;if(N){let T=N.isHydrating?N.pendingBranch:N.activeBranch;if(T)tn(T,g.clone(T))}else p.ssContent.transition=g.clone(p.ssContent),p.ssFallback.transition=g.clone(p.ssFallback)}else if(p.transition=g,p.type===Ge&&t(p.children)){let N=Ks(p.children,!1);if(N)tn(N,g)}}function Er(p){if(p.component)return Er(p.component.subTree);if(p.type===Ge){let g=t(p.children)&&Ks(p.children,!1);return g?Er(g):void 0}if(p.type!==ft)return p}function n(p,g){return r(p)?(()=>s({name:p.name},g,{setup:p}))():p}function D(){let p=_();if(p)return(p.appContext.config.idPrefix||"v")+"-"+p.ids[0]+p.ids[1]++;return""}function Dr(p){p.ids=[p.ids[0]+p.ids[2]+++"-",0,0]}function Es(p,g){let N;return!!((N=Object.getOwnPropertyDescriptor(p,g))&&!N.configurable)}var kn=new WeakMap;function nn(p,g,N,T,C=!1){if(t(p)){p.forEach((Q,pe)=>nn(Q,g&&(t(g)?g[pe]:g),N,T,C));return}if(rn(T)&&!C){if(T.shapeFlag&512&&T.type.__asyncResolved&&T.component.subTree.component)nn(p,g,N,T.component.subTree);return}let A=T.shapeFlag&4?Sr(T.component):T.el,k=C?null:A,{i:F,r:U}=p,j=g&&g.r,H=F.refs===fe?F.refs={}:F.refs,W=F.setupState,Z=de(W),te=W===fe?Kn:(Q)=>{if(Es(H,Q))return!1;return ae(Z,Q)},re=(Q,pe)=>{if(pe&&Es(H,pe))return!1;return!0};if(j!=null&&j!==U){if(ys(g),i(j)){if(H[j]=null,te(j))W[j]=null}else if(Te(j)){let Q=g;if(re(j,Q.k))j.value=null;if(Q.k)H[Q.k]=null}}if(r(U))fn(U,F,12,[k,H]);else{let Q=i(U),pe=Te(U);if(Q||pe){let he=()=>{if(p.f){let le=Q?te(U)?W[U]:H[U]:re(U)||!p.k?U.value:H[p.k];if(C)t(le)&&$t(le,A);else if(!t(le))if(Q){if(H[U]=[A],te(U))W[U]=H[U]}else{let ce=[A];if(re(U,p.k))U.value=ce;if(p.k)H[p.k]=ce}else if(!le.includes(A))le.push(A)}else if(Q){if(H[U]=k,te(U))W[U]=k}else if(pe){if(re(U,p.k))U.value=k;if(p.k)H[p.k]=k}};if(k){let le=()=>{he(),kn.delete(p)};le.id=-1,kn.set(p,le),Ae(le,N)}else ys(p),he()}}}function ys(p){let g=kn.get(p);if(g)g.flags|=8,kn.delete(p)}var vs=(p)=>p.nodeType===8;var wl=Lt().requestIdleCallback||((p)=>setTimeout(p,1)),Dl=Lt().cancelIdleCallback||((p)=>clearTimeout(p));function Zo(p,g){if(vs(p)&&p.data==="["){let N=1,T=p.nextSibling;while(T){if(T.nodeType===1){if(g(T)===!1)break}else if(vs(T)){if(T.data==="]"){if(--N===0)break}else if(T.data==="[")N++}T=T.nextSibling}}else g(p)}var rn=(p)=>!!p.type.__asyncLoader;function P(p){if(r(p))p={loader:p};let{loader:g,loadingComponent:N,errorComponent:T,delay:C=200,hydrate:A,timeout:k,suspensible:F=!0,onError:U}=p,j=null,H,W=0,Z=()=>(W++,j=null,te()),te=()=>{let re;return j||(re=j=g().catch((Q)=>{if(Q=Q instanceof Error?Q:Error(String(Q)),U)return new Promise((pe,he)=>{U(Q,()=>pe(Z()),()=>he(Q),W+1)});else throw Q}).then((Q)=>{if(re!==j&&j)return j;if(Q&&(Q.__esModule||Q[Symbol.toStringTag]==="Module"))Q=Q.default;return H=Q,Q}))};return n({name:"AsyncComponentWrapper",__asyncLoader:te,__asyncHydrate(re,Q,pe){let he=re.isConnected,le=!1;(Q.bu||(Q.bu=[])).push(()=>le=!0);let ce=()=>{if(le)return;if(!re.parentNode||he&&!re.isConnected)return;pe()},xe=A?()=>{let ne=A(ce,(Ne)=>Zo(re,Ne));if(ne)(Q.bum||(Q.bum=[])).push(ne)}:ce;if(H)xe();else te().then(()=>!Q.isUnmounted&&xe())},get __asyncResolved(){return H},setup(){let re=Ce;if(Dr(re),H)return()=>Cn(H,re);let Q=(ne)=>{j=null,pn(ne,re,13,!T,!0)};if(F&&re.suspense||Pt)return te().then((ne)=>()=>Cn(ne,re)).catch((ne)=>(Q(ne),()=>T?Pe(T,{error:ne}):null));let pe=d(!1),he=d(),le=d(!!C),ce,xe;if(tr(()=>{if(ce!=null)clearTimeout(ce);if(xe!=null)clearTimeout(xe)}),C)xe=setTimeout(()=>{if(re.isUnmounted)return;le.value=!1},C);if(k!=null)ce=setTimeout(()=>{if(re.isUnmounted)return;if(!pe.value&&!he.value){let ne=Error(`Async component timed out after ${k}ms.`);Q(ne),he.value=ne}},k);return te().then(()=>{if(re.isUnmounted)return;if(pe.value=!0,re.parent&&Ln(re.parent.vnode))re.parent.update()}).catch((ne)=>{if(re.isUnmounted){j=null;return}Q(ne),he.value=ne}),()=>{if(pe.value&&H)return Cn(H,re);else if(he.value&&T)return Pe(T,{error:he.value});else if(N&&!le.value)return Cn(N,re)}}})}function Cn(p,g){let{ref:N,props:T,children:C,ce:A}=g.vnode,k=Pe(p,T,C);return k.ref=N,k.ce=A,delete g.vnode.ce,k}var Ln=(p)=>p.type.__isKeepAlive;function Qo(p,g){Us(p,"a",g)}function ei(p,g){Us(p,"da",g)}function Us(p,g,N=Ce){let T=p.__wdc||(p.__wdc=()=>{let C=N;while(C){if(C.isDeactivated)return;C=C.parent}return p()});if(cn(g,T,N),N){let C=N.parent;while(C&&C.parent){if(Ln(C.parent.vnode))ti(T,g,N,C);C=C.parent}}}function ti(p,g,N,T){let C=cn(g,p,T,!0),A=cn("um",()=>$t(T[g],C),N);A.flags=16}function cn(p,g,N=Ce,T=!1){if(N){let C=N[p]||(N[p]=[]),A=g.__weh||(g.__weh=(...k)=>{je();let F=dn(N),U=l(g,N,p,k);return F(),Be(),U});if(T)C.unshift(A);else C.push(A);return A}}var pt=(p)=>(g,N=Ce)=>{if(!Pt||p==="sp")cn(p,(...T)=>g(...T),N)},ni=pt("bm"),S=pt("m"),ri=pt("bu"),si=pt("u"),w=pt("bum"),oi=pt("um"),ii=pt("sp"),li=pt("rtg"),ci=pt("rtc");function ai(p,g=Ce){cn("ec",p,g)}var ui=Symbol.for("v-ndc");var yr=(p)=>{if(!p)return null;if(io(p))return Sr(p);return yr(p.parent)};var sn=s(Object.create(null),{$:(p)=>p,$el:(p)=>p.vnode.el,$data:(p)=>p.data,$props:(p)=>p.props,$attrs:(p)=>p.attrs,$slots:(p)=>p.slots,$refs:(p)=>p.refs,$parent:(p)=>yr(p.parent),$root:(p)=>yr(p.root),$host:(p)=>p.ce,$emit:(p)=>p.emit,$options:(p)=>Tr(p),$forceUpdate:(p)=>p.f||(p.f=()=>{br(p.update)}),$nextTick:(p)=>p.n||(p.n=Ho.bind(p.proxy)),$watch:(p)=>zo.bind(p)});var hr=(p,g)=>p!==fe&&!p.__isScriptSetup&&ae(p,g),fi={get({_:p},g){if(g==="__v_skip")return!0;let{ctx:N,setupState:T,data:C,props:A,accessCache:k,type:F,appContext:U}=p;if(g[0]!=="$"){let Z=k[g];if(Z!==void 0)switch(Z){case 1:return T[g];case 2:return C[g];case 4:return N[g];case 3:return A[g]}else if(hr(T,g))return k[g]=1,T[g];else if(C!==fe&&ae(C,g))return k[g]=2,C[g];else if(ae(A,g))return k[g]=3,A[g];else if(N!==fe&&ae(N,g))return k[g]=4,N[g];else if(vr)k[g]=0}let j=sn[g],H,W;if(j){if(g==="$attrs")Ve(p.attrs,"get","");return j(p)}else if((H=F.__cssModules)&&(H=H[g]))return H;else if(N!==fe&&ae(N,g))return k[g]=4,N[g];else if(W=U.config.globalProperties,ae(W,g))return W[g]},set({_:p},g,N){let{data:T,setupState:C,ctx:A}=p;if(hr(C,g))return C[g]=N,!0;else if(T!==fe&&ae(T,g))return T[g]=N,!0;else if(ae(p.props,g))return!1;if(g[0]==="$"&&g.slice(1)in p)return!1;else A[g]=N;return!0},has({_:{data:p,setupState:g,accessCache:N,ctx:T,appContext:C,props:A,type:k}},F){let U;return!!(N[F]||p!==fe&&F[0]!=="$"&&ae(p,F)||hr(g,F)||ae(A,F)||ae(T,F)||ae(sn,F)||ae(C.config.globalProperties,F)||(U=k.__cssModules)&&U[F])},defineProperty(p,g,N){if(N.get!=null)p._.accessCache[g]=0;else if(ae(N,"value"))this.set(p,g,N.value,null);return Reflect.defineProperty(p,g,N)}};function Ns(p){return t(p)?p.reduce((g,N)=>(g[N]=null,g),{}):p}var vr=!0;function pi(p){let g=Tr(p),{proxy:N,ctx:T}=p;if(vr=!1,g.beforeCreate)Os(g.beforeCreate,p,"bc");let{data:C,computed:A,methods:k,watch:F,provide:U,inject:j,created:H,beforeMount:W,mounted:Z,beforeUpdate:te,updated:re,activated:Q,deactivated:pe,beforeDestroy:he,beforeUnmount:le,destroyed:ce,unmounted:xe,render:ne,renderTracked:Ne,renderTriggered:nt,errorCaptured:Ue,serverPrefetch:qe,expose:Ot,inheritAttrs:_t,components:bt,directives:hn,filters:Ar}=g,gn=null;if(j)di(j,T,gn);if(k)for(let ve in k){let _e=k[ve];if(r(_e))T[ve]=_e.bind(N)}if(C){let ve=C.call(N,N);if(!Ee(ve));else p.data=Xt(ve)}if(vr=!0,A)for(let ve in A){let _e=A[ve],rt=r(_e)?_e.bind(N,N):r(_e.get)?_e.get.bind(N,N):$e,jn=!r(_e)&&r(_e.set)?_e.set.bind(N):$e,It=h({get:rt,set:jn});Object.defineProperty(T,ve,{enumerable:!0,configurable:!0,get:()=>It.value,set:(wt)=>It.value=wt})}if(F)for(let ve in F)Hs(F[ve],T,N,ve);if(U){let ve=r(U)?U.call(N):U;Reflect.ownKeys(ve).forEach((_e)=>{b(_e,ve[_e])})}if(H)Os(H,p,"c");function ke(ve,_e){if(t(_e))_e.forEach((rt)=>ve(rt.bind(N)));else if(_e)ve(_e.bind(N))}if(ke(ni,W),ke(S,Z),ke(ri,te),ke(si,re),ke(Qo,Q),ke(ei,pe),ke(ai,Ue),ke(ci,Ne),ke(li,nt),ke(w,le),ke(oi,xe),ke(ii,qe),t(Ot)){if(Ot.length){let ve=p.exposed||(p.exposed={});Ot.forEach((_e)=>{Object.defineProperty(ve,_e,{get:()=>N[_e],set:(rt)=>N[_e]=rt,enumerable:!0})})}else if(!p.exposed)p.exposed={}}if(ne&&p.render===$e)p.render=ne;if(_t!=null)p.inheritAttrs=_t;if(bt)p.components=bt;if(hn)p.directives=hn;if(qe)Dr(p)}function di(p,g,N=$e){if(t(p))p=Nr(p);for(let T in p){let C=p[T],A;if(Ee(C))if("default"in C)A=a(C.from||T,C.default,!0);else A=a(C.from||T);else A=a(C);if(Te(A))Object.defineProperty(g,T,{enumerable:!0,configurable:!0,get:()=>A.value,set:(k)=>A.value=k});else g[T]=A}}function Os(p,g,N){l(t(p)?p.map((T)=>T.bind(g.proxy)):p.bind(g.proxy),g,N)}function Hs(p,g,N,T){let C=T.includes(".")?Fs(N,T):()=>N[T];if(i(p)){let A=g[p];if(r(A))E(C,A)}else if(r(p))E(C,p.bind(N));else if(Ee(p))if(t(p))p.forEach((A)=>Hs(A,g,N,T));else{let A=r(p.handler)?p.handler.bind(N):g[p.handler];if(r(A))E(C,A,p)}}function Tr(p){let g=p.type,{mixins:N,extends:T}=g,{mixins:C,optionsCache:A,config:{optionMergeStrategies:k}}=p.appContext,F=A.get(g),U;if(F)U=F;else if(!C.length&&!N&&!T)U=g;else{if(U={},C.length)C.forEach((j)=>Pn(U,j,k,!0));Pn(U,g,k)}if(Ee(g))A.set(g,U);return U}function Pn(p,g,N,T=!1){let{mixins:C,extends:A}=g;if(A)Pn(p,A,N,!0);if(C)C.forEach((k)=>Pn(p,k,N,!0));for(let k in g)if(T&&k==="expose");else{let F=hi[k]||N&&N[k];p[k]=F?F(p[k],g[k]):g[k]}return p}var hi={data:bs,props:ws,emits:ws,methods:en,computed:en,beforeCreate:Se,created:Se,beforeMount:Se,mounted:Se,beforeUpdate:Se,updated:Se,beforeDestroy:Se,beforeUnmount:Se,destroyed:Se,unmounted:Se,activated:Se,deactivated:Se,errorCaptured:Se,serverPrefetch:Se,components:en,directives:en,watch:_i,provide:bs,inject:gi};function bs(p,g){if(!g)return p;if(!p)return g;return function(){return s(r(p)?p.call(this,this):p,r(g)?g.call(this,this):g)}}function gi(p,g){return en(Nr(p),Nr(g))}function Nr(p){if(t(p)){let g={};for(let N=0;N<p.length;N++)g[p[N]]=p[N];return g}return p}function Se(p,g){return p?[...new Set([].concat(p,g))]:g}function en(p,g){return p?s(Object.create(null),p,g):g}function ws(p,g){if(p){if(t(p)&&t(g))return[...new Set([...p,...g])];return s(Object.create(null),Ns(p),Ns(g!=null?g:{}))}else return g}function _i(p,g){if(!p)return g;if(!g)return p;let N=s(Object.create(null),p);for(let T in g)N[T]=Se(p[T],g[T]);return N}function js(){return{app:null,config:{isNativeTag:Kn,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}var mi=0;function Ei(p,g){return function(T,C=null){if(!r(T))T=s({},T);if(C!=null&&!Ee(C))C=null;let A=js(),k=new WeakSet,F=[],U=!1,j=A.app={_uid:mi++,_component:T,_props:C,_container:null,_context:A,_instance:null,version:Ji,get config(){return A.config},set config(H){},use(H,...W){if(k.has(H));else if(H&&r(H.install))k.add(H),H.install(j,...W);else if(r(H))k.add(H),H(j,...W);return j},mixin(H){if(!A.mixins.includes(H))A.mixins.push(H);return j},component(H,W){if(!W)return A.components[H];return A.components[H]=W,j},directive(H,W){if(!W)return A.directives[H];return A.directives[H]=W,j},mount(H,W,Z){if(!U){let te=j._ceVNode||Pe(T,C);if(te.appContext=A,Z===!0)Z="svg";else if(Z===!1)Z=void 0;if(W&&g)g(te,H);else p(te,H,Z);return U=!0,j._container=H,H.__vue_app__=j,Sr(te.component)}},onUnmount(H){F.push(H)},unmount(){if(U)l(F,j._instance,16),p(null,j._container),delete j._container.__vue_app__},provide(H,W){return A.provides[H]=W,j},runWithContext(H){let W=At;At=j;try{return H()}finally{At=W}}};return j}}var At=null;function V(p,g,N=fe){let T=_(),C=o(g),A=u(g),k=Bs(p,C),F=fr((U,j)=>{let H,W=fe,Z;return qo(()=>{let te=p[C];if(De(H,te))H=te,j()}),{get(){return U(),N.get?N.get(H):H},set(te){let re=N.set?N.set(te):te;if(!De(re,H)&&!(W!==fe&&De(te,W)))return;let Q=T.vnode.props,pe=!!(Q&&((g in Q)||(C in Q)||(A in Q))&&((`onUpdate:${g}`in Q)||(`onUpdate:${C}`in Q)||(`onUpdate:${A}`in Q)));if(!pe)H=te,j();if(T.emit(`update:${g}`,re),De(te,W)&&(De(te,re)&&!De(re,Z)||pe&&W!==fe&&!De(re,H)))j();W=te,Z=re}}});return F[Symbol.iterator]=()=>{let U=0;return{next(){if(U<2)return{value:U++?k||fe:F,done:!1};else return{done:!0}}}},F}var Bs=(p,g)=>g==="modelValue"||g==="model-value"?p.modelModifiers:p[`${g}Modifiers`]||p[`${o(g)}Modifiers`]||p[`${u(g)}Modifiers`];function yi(p,g,...N){if(p.isUnmounted)return;let T=p.vnode.props||fe,C=N,A=g.startsWith("update:"),k=A&&Bs(T,g.slice(7));if(k){if(k.trim)C=N.map((H)=>i(H)?H.trim():H);if(k.number)C=C.map(Wr)}let F,U=T[F=Ft(g)]||T[F=Ft(o(g))];if(!U&&A)U=T[F=Ft(u(g))];if(U)l(U,p,6,C);let j=T[F+"Once"];if(j){if(!p.emitted)p.emitted={};else if(p.emitted[F])return;p.emitted[F]=!0,l(j,p,6,C)}}var vi=new WeakMap;function Ws(p,g,N=!1){let T=N?vi:g.emitsCache,C=T.get(p);if(C!==void 0)return C;let A=p.emits,k={},F=!1;if(!r(p)){let U=(j)=>{let H=Ws(j,g,!0);if(H)F=!0,s(k,H)};if(!N&&g.mixins.length)g.mixins.forEach(U);if(p.extends)U(p.extends);if(p.mixins)p.mixins.forEach(U)}if(!A&&!F){if(Ee(p))T.set(p,null);return null}if(t(A))A.forEach((U)=>k[U]=null);else s(k,A);if(Ee(p))T.set(p,k);return k}function Un(p,g){if(!p||!m(g))return!1;return g=g.slice(2),g=g==="Once"?g:g.replace(/Once$/,""),ae(p,g[0].toLowerCase()+g.slice(1))||ae(p,u(g))||ae(p,g)}function gr(p){let{type:g,vnode:N,proxy:T,withProxy:C,propsOptions:[A],slots:k,attrs:F,emit:U,render:j,renderCache:H,props:W,data:Z,setupState:te,ctx:re,inheritAttrs:Q}=p,pe=Rn(p),he,le;try{if(N.shapeFlag&4){let ne=C||T,Ne=ne;he=et(j.call(Ne,ne,H,W,te,Z,re)),le=F}else{let ne=g;he=et(ne.length>1?ne(W,{attrs:F,slots:k,emit:U}):ne(W,null)),le=g.props?F:Ni(F)}}catch(ne){Rt.length=0,pn(ne,p,1),he=Pe(ft)}let ce=he,xe=void 0;if(le&&Q!==!1){let ne=Object.keys(le),{shapeFlag:Ne}=ce;if(ne.length){if(Ne&7){if(A&&ne.some(y))le=Oi(le,A);ce=kt(ce,le,!1,!0)}}}if(N.dirs)ce=kt(ce,null,!1,!0),ce.dirs=ce.dirs?ce.dirs.concat(N.dirs):N.dirs;if(N.transition){let ne=Fn(ce.type)?Ls(ce)||ce:ce;tn(ne,N.transition)}return he=ce,Rn(pe),he}function Ks(p,g=!0){let N;for(let T=0;T<p.length;T++){let C=p[T];if(an(C)){if(C.type!==ft||C.children==="v-if")if(N)return;else N=C}else return}return N}var Ni=(p)=>{let g;for(let N in p)if(N==="class"||N==="style"||m(N))(g||(g={}))[N]=p[N];return g},Oi=(p,g)=>{let N={};for(let T in p)if(!y(T)||!(T.slice(9)in g))N[T]=p[T];return N};function bi(p,g,N){let{props:T,children:C,component:A}=p,{props:k,children:F,patchFlag:U}=g,j=A.emitsOptions;if(g.dirs||g.transition)return!0;if(N&&U>=0){if(U&1024)return!0;if(U&16){if(!T)return!!k;return Ds(T,k,j)}else if(U&8){let H=g.dynamicProps;for(let W=0;W<H.length;W++){let Z=H[W];if(Ys(k,T,Z)&&!Un(j,Z))return!0}}}else{if(C||F){if(!F||!F.$stable)return!0}if(T===k)return!1;if(!T)return!!k;if(!k)return!0;return Ds(T,k,j)}return!1}function Ds(p,g,N){let T=Object.keys(g);if(T.length!==Object.keys(p).length)return!0;for(let C=0;C<T.length;C++){let A=T[C];if(!ae(p,A)||Ys(g,p,A)&&!Un(N,A))return!0}return!1}function Ys(p,g,N){let T=p[N],C=g[N];if(N==="style"&&Ee(T)&&Ee(C))return!jt(T,C);return T!==C}function wi({vnode:p,parent:g,suspense:N},T){while(g){let C=g.subTree;if(C.suspense&&C.suspense.activeBranch===p)C.suspense.vnode.el=C.el=T,p=C;if(C===p)(p=g.vnode).el=T,g=g.parent;else break}if(N&&N.activeBranch===p)N.vnode.el=T}var Gs={},qs=()=>Object.create(Gs),zs=(p)=>Object.getPrototypeOf(p)===Gs;function Di(p,g,N,T=!1){let C={},A=qs();p.propsDefaults=Object.create(null),Js(p,g,C,A);for(let k in p.propsOptions[0])if(!(k in C))C[k]=void 0;if(N)p.props=T?C:cr(C);else if(!p.type.props)p.props=A;else p.props=C;p.attrs=A}function Ti(p,g,N,T){let{props:C,attrs:A,vnode:{patchFlag:k}}=p,F=de(C),[U]=p.propsOptions,j=!1;if((T||k>0)&&!(k&16)){if(k&8){let H=p.vnode.dynamicProps;for(let W=0;W<H.length;W++){let Z=H[W];if(Un(p.emitsOptions,Z))continue;let te=g[Z];if(U)if(ae(A,Z)){if(te!==A[Z])A[Z]=te,j=!0}else{let re=o(Z);C[re]=Or(U,F,re,te,p,!1)}else if(te!==A[Z])A[Z]=te,j=!0}}}else{if(Js(p,g,C,A))j=!0;let H;for(let W in F)if(!g||!ae(g,W)&&((H=u(W))===W||!ae(g,H)))if(U){if(N&&(N[W]!==void 0||N[H]!==void 0))C[W]=Or(U,F,W,void 0,p,!0)}else delete C[W];if(A!==F){for(let W in A)if(!g||!ae(g,W)&&!0)delete A[W],j=!0}}if(j)Xe(p.attrs,"set","")}function Js(p,g,N,T){let[C,A]=p.propsOptions,k=!1,F;if(g)for(let U in g){if(Vt(U))continue;let j=g[U],H;if(C&&ae(C,H=o(U)))if(!A||!A.includes(H))N[H]=j;else(F||(F={}))[H]=j;else if(!Un(p.emitsOptions,U)){if(!(U in T)||j!==T[U])T[U]=j,k=!0}}if(A){let U=de(N),j=F||fe;for(let H=0;H<A.length;H++){let W=A[H];N[W]=Or(C,U,W,j[W],p,!ae(j,W))}}return k}function Or(p,g,N,T,C,A){let k=p[N];if(k!=null){let F=ae(k,"default");if(F&&T===void 0){let U=k.default;if(k.type!==Function&&!k.skipFactory&&r(U)){let{propsDefaults:j}=C;if(N in j)T=j[N];else{let H=dn(C);T=j[N]=U.call(null,g),H()}}else T=U;if(C.ce)C.ce._setProp(N,T)}if(k[0]){if(A&&!F)T=!1;else if(k[1]&&(T===""||T===u(N)))T=!0}}return T}var xi=new WeakMap;function Xs(p,g,N=!1){let T=N?xi:g.propsCache,C=T.get(p);if(C)return C;let A=p.props,k={},F=[],U=!1;if(!r(p)){let H=(W)=>{U=!0;let[Z,te]=Xs(W,g,!0);if(s(k,Z),te)F.push(...te)};if(!N&&g.mixins.length)g.mixins.forEach(H);if(p.extends)H(p.extends);if(p.mixins)p.mixins.forEach(H)}if(!A&&!U){if(Ee(p))T.set(p,mt);return mt}if(t(A))for(let H=0;H<A.length;H++){let W=o(A[H]);if(Ts(W))k[W]=fe}else if(A)for(let H in A){let W=o(H);if(Ts(W)){let Z=A[H],te=k[W]=t(Z)||r(Z)?{type:Z}:s({},Z),re=te.type,Q=!1,pe=!0;if(t(re))for(let he=0;he<re.length;++he){let le=re[he],ce=r(le)&&le.name;if(ce==="Boolean"){Q=!0;break}else if(ce==="String")pe=!1}else Q=r(re)&&re.name==="Boolean";if(te[0]=Q,te[1]=pe,Q||ae(te,"default"))F.push(W)}}let j=[k,F];if(Ee(p))T.set(p,j);return j}function Ts(p){if(p[0]!=="$"&&!Vt(p))return!0;return!1}var xr=(p)=>p==="_"||p==="_ctx"||p==="$stable",Vr=(p)=>t(p)?p.map(et):[et(p)],Vi=(p,g,N)=>{if(g._n)return g;let T=Ko((...C)=>Vr(g(...C)),N);return T._c=!1,T},Zs=(p,g,N)=>{let T=p._ctx;for(let C in p){if(xr(C))continue;let A=p[C];if(r(A))g[C]=Vi(C,A,T);else if(A!=null){let k=Vr(A);g[C]=()=>k}}},Qs=(p,g)=>{let N=Vr(g);p.slots.default=()=>N},eo=(p,g,N)=>{for(let T in g)if(N||!xr(T))p[T]=g[T]},Ci=(p,g,N)=>{let T=p.slots=qs();if(p.vnode.shapeFlag&32){let C=g._;if(C){if(eo(T,g,N),N)Nn(T,"_",C,!0)}else Zs(g,T)}else if(g)Qs(p,g)},Si=(p,g,N)=>{let{vnode:T,slots:C}=p,A=!0,k=fe;if(T.shapeFlag&32){let F=g._;if(F)if(N&&F===1)A=!1;else eo(C,g,N);else A=!g.$stable,Zs(g,C);k=g}else if(g)Qs(p,g),k={default:1};if(A){for(let F in C)if(!xr(F)&&k[F]==null)delete C[F]}};function Ai(){let p=[]}var Ae=Mi;function I(p){return Ri(p)}function Ri(p,g){Ai();let N=Lt();N.__VUE__=!0;let{insert:T,remove:C,patchProp:A,createElement:k,createText:F,createComment:U,setText:j,setElementText:H,parentNode:W,nextSibling:Z,setScopeId:te=$e,insertStaticContent:re}=p,Q=(M,L,B,q=null,K=null,G=null,X=void 0,J=null,z=!!L.dynamicChildren)=>{if(M===L)return;if(M&&!Qt(M,L))q=_n(M),st(M,K,G,!0),M=null;if(L.patchFlag===-2)z=!1,L.dynamicChildren=null;if(L.dynamicChildren&&M&&M.dynamicChildren&&M.dynamicChildren.hasOnce){if(L.dynamicChildren===mt)L.dynamicChildren=[];L.dynamicChildren.hasOnce=!0}let{type:Y,ref:oe,shapeFlag:ee}=L;switch(Y){case Hn:pe(M,L,B,q);break;case ft:he(M,L,B,q);break;case mr:if(M==null)le(L,B,q,X);break;case Ge:hn(M,L,B,q,K,G,X,J,z);break;default:if(ee&1)Ne(M,L,B,q,K,G,X,J,z);else if(ee&6)Ar(M,L,B,q,K,G,X,J,z);else if(ee&64)Y.process(M,L,B,q,K,G,X,J,z,Dt);else if(ee&128)Y.process(M,L,B,q,K,G,X,J,z,Dt)}if(oe!=null&&K)nn(oe,M&&M.ref,G,L||M,!L);else if(oe==null&&M&&M.ref!=null)nn(M.ref,null,G,M,!0)},pe=(M,L,B,q)=>{if(M==null)T(L.el=F(L.children),B,q);else{let K=L.el=M.el;if(L.children!==M.children)j(K,L.children)}},he=(M,L,B,q)=>{if(M==null)T(L.el=U(L.children||""),B,q);else L.el=M.el},le=(M,L,B,q)=>{[M.el,M.anchor]=re(M.children,L,B,q,M.el,M.anchor)},ce=(M,L,B,q)=>{if(L.children!==M.children){let K=Z(M.anchor);ne(M),[L.el,L.anchor]=re(L.children,B,K,q)}else L.el=M.el,L.anchor=M.anchor},xe=({el:M,anchor:L},B,q)=>{let K;while(M&&M!==L)K=Z(M),T(M,B,q),M=K;T(L,B,q)},ne=({el:M,anchor:L})=>{let B;while(M&&M!==L)B=Z(M),C(M),M=B;C(L)},Ne=(M,L,B,q,K,G,X,J,z)=>{if(L.type==="svg")X="svg";else if(L.type==="math")X="mathml";if(M==null)nt(L,B,q,K,G,X,J,z);else{let Y=M.el&&M.el._isVueCE?M.el:null;try{if(Y)Y._beginPatch();Ot(M,L,K,G,X,J,z)}finally{if(Y)Y._endPatch()}}},nt=(M,L,B,q,K,G,X,J)=>{let z,Y,{props:oe,shapeFlag:ee,transition:se,dirs:ie}=M;if(z=M.el=k(M.type,G,oe&&oe.is,oe),ee&8)H(z,M.children);else if(ee&16)qe(M.children,z,null,q,K,_r(M,G),X,J);if(ie)vt(M,null,q,"created");if(Ue(z,M,M.scopeId,X,q),oe){for(let me in oe)if(me!=="value"&&!Vt(me))A(z,me,null,oe[me],G,q);if("value"in oe)A(z,"value",null,oe.value,G);if(Y=oe.onVnodeBeforeMount)Ze(Y,q,M)}if(ie)vt(M,null,q,"beforeMount");let ue=ki(K,se);if(ue)se.beforeEnter(z);else if(se&&!se.persisted)z[Ii]=!0;if(T(z,L,B),(Y=oe&&oe.onVnodeMounted)||ue||ie)Ae(()=>{let ge;try{Y&&Ze(Y,q,M),ue&&se.enter(z),ie&&vt(M,null,q,"mounted")}finally{}},K)},Ue=(M,L,B,q,K)=>{if(B)te(M,B);if(q)for(let G=0;G<q.length;G++)te(M,q[G]);if(K){let G=K.subTree;if(L===G||ro(G.type)&&(G.ssContent===L||G.ssFallback===L)){let X=K.vnode;Ue(M,X,X.scopeId,X.slotScopeIds,K.parent)}}},qe=(M,L,B,q,K,G,X,J,z=0)=>{for(let Y=z;Y<M.length;Y++){let oe=M[Y]=J?at(M[Y]):et(M[Y]);Q(null,oe,L,B,q,K,G,X,J)}},Ot=(M,L,B,q,K,G,X)=>{let J=L.el=M.el,{patchFlag:z,dynamicChildren:Y,dirs:oe}=L;z|=M.patchFlag&16;let ee=M.props||fe,se=L.props||fe,ie;if(B&&Nt(B,!1),ie=se.onVnodeBeforeUpdate)Ze(ie,B,L,M);if(oe)vt(L,M,B,"beforeUpdate");if(B&&Nt(B,!0),Y&&(!M.dynamicChildren||M.dynamicChildren.length!==Y.length))z=0,X=!1,Y=null;if(ee.innerHTML&&se.innerHTML==null||ee.textContent&&se.textContent==null)H(J,"");if(Y)_t(M.dynamicChildren,Y,J,B,q,_r(L,K),G);else if(!X)rt(M,L,J,null,B,q,_r(L,K),G,!1);if(z>0){if(z&16)bt(J,ee,se,B,K);else{if(z&2){if(ee.class!==se.class)A(J,"class",null,se.class,K)}if(z&4)A(J,"style",ee.style,se.style,K);if(z&8){let ue=L.dynamicProps;for(let me=0;me<ue.length;me++){let ge=ue[me],Oe=ee[ge],we=se[ge];if(we!==Oe||ge==="value")A(J,ge,Oe,we,K,B)}}}if(z&1){if(M.children!==L.children)H(J,L.children)}}else if(!X&&Y==null)bt(J,ee,se,B,K);if((ie=se.onVnodeUpdated)||oe)Ae(()=>{ie&&Ze(ie,B,L,M),oe&&vt(L,M,B,"updated")},q)},_t=(M,L,B,q,K,G,X)=>{for(let J=0;J<L.length;J++){let z=M[J],Y=L[J],oe=z.el||on(z),ee=oe&&(z.type===Ge||!Qt(z,Y)||z.shapeFlag&198)?W(oe):B;Q(z,Y,ee,null,q,K,G,X,!0)}},bt=(M,L,B,q,K)=>{if(L!==B){if(L!==fe){for(let G in L)if(!Vt(G)&&!(G in B))A(M,G,L[G],null,K,q)}for(let G in B){if(Vt(G))continue;let X=B[G],J=L[G];if(X!==J&&G!=="value")A(M,G,J,X,K,q)}if("value"in B)A(M,"value",L.value,B.value,K)}},hn=(M,L,B,q,K,G,X,J,z)=>{let Y=L.el=M?M.el:F(""),oe=L.anchor=M?M.anchor:F(""),{patchFlag:ee,dynamicChildren:se,slotScopeIds:ie}=L;if(ie)J=J?J.concat(ie):ie;if(M==null)T(Y,B,q),T(oe,B,q),qe(L.children||[],B,oe,K,G,X,J,z);else if(ee>0&&ee&64&&se&&M.dynamicChildren&&M.dynamicChildren.length===se.length){if(_t(M.dynamicChildren,se,B,K,G,X,J),L.key!=null||K&&L===K.subTree)to(M,L,!0)}else rt(M,L,B,oe,K,G,X,J,z)},Ar=(M,L,B,q,K,G,X,J,z)=>{if(L.slotScopeIds=J,M==null)if(L.shapeFlag&512)K.ctx.activate(L,B,q,X,z);else gn(L,B,q,K,G,X,z);else ke(M,L,z)},gn=(M,L,B,q,K,G,X)=>{let J=M.component=Wi(M,q,K);if(Ln(M))J.ctx.renderer=Dt;if(Ki(J,!1,X),J.asyncDep){if(K&&K.registerDep(J,ve,X,G),!M.el){let z=J.subTree=Pe(ft);he(null,z,L,B),M.placeholder=z.el}}else ve(J,M,L,B,K,G,X)},ke=(M,L,B)=>{let q=L.component=M.component;if(bi(M,L,B))if(q.asyncDep&&!q.asyncResolved){L.el=M.el,L.placeholder=M.placeholder,_e(q,L,B);return}else q.next=L,q.update();else L.el=M.el,L.placeholder=M.placeholder,q.vnode=L},ve=(M,L,B,q,K,G,X)=>{let J=()=>{if(!M.isMounted){let ee,{el:se,props:ie}=L,{bm:ue,m:me,parent:ge,root:Oe,type:we}=M,Le=rn(L);if(Nt(M,!1),ue)vn(ue);if(!Le&&(ee=ie&&ie.onVnodeBeforeMount))Ze(ee,ge,L);if(Nt(M,!0),se&&Wn){let Ie=()=>{M.subTree=gr(M),Wn(se,M.subTree,M,K,null)};if(Le&&we.__asyncHydrate)we.__asyncHydrate(se,M,Ie);else Ie()}else{if(Oe.ce&&Oe.ce._hasShadowRoot())Oe.ce._injectChildStyle(we,M.parent?M.parent.type:void 0);let Ie=M.subTree=gr(M);Q(null,Ie,B,q,M,K,G),L.el=Ie.el}if(me)Ae(me,K);if(!Le&&(ee=ie&&ie.onVnodeMounted)){let Ie=L;Ae(()=>Ze(ee,ge,Ie),K)}if(L.shapeFlag&256||ge&&rn(ge.vnode)&&ge.vnode.shapeFlag&256)M.a&&Ae(M.a,K);M.isMounted=!0,L=B=q=null}else{let{next:ee,bu:se,u:ie,parent:ue,vnode:me}=M;{let Ie=no(M);if(Ie){if(ee)ee.el=me.el,_e(M,ee,X);Ie.asyncDep.then(()=>{let ot=()=>{if(M.job.flags&8)return;if(K&&K.pendingBranch)Ae(ot,K);else Y()};ot.flags=48,Ae(ot,K)});return}}let ge=ee,Oe;if(Nt(M,!1),ee)ee.el=me.el,_e(M,ee,X);else ee=me;if(se)vn(se);if(Oe=ee.props&&ee.props.onVnodeBeforeUpdate)Ze(Oe,ue,ee,me);Nt(M,!0);let we=gr(M),Le=M.subTree;if(M.subTree=we,Q(Le,we,W(Le.el||on(Le)),_n(Le),M,K,G),ee.el=we.el,ge===null)wi(M,we.el);if(ie)Ae(ie,K);if(Oe=ee.props&&ee.props.onVnodeUpdated)Ae(()=>Ze(Oe,ue,ee,me),K)}};M.scope.on();let z=M.effect=new zt(J);M.scope.off();let Y=M.update=z.run.bind(z),oe=M.job=z.runIfDirty.bind(z);oe.i=M,oe.id=M.uid,z.scheduler=()=>br(oe),Nt(M,!0),Y()},_e=(M,L,B)=>{L.component=M;let q=M.vnode.props;M.vnode=L,M.next=null,Ti(M,L.props,q,B),Si(M,L.children,B),je(),Ps(M),Be()},rt=(M,L,B,q,K,G,X,J,z=!1)=>{let Y=M&&M.children,oe=M?M.shapeFlag:0,ee=L.children,{patchFlag:se,shapeFlag:ie}=L;if(se>0){if(se&128){It(Y,ee,B,q,K,G,X,J,z);return}else if(se&256){jn(Y,ee,B,q,K,G,X,J,z);return}}if(ie&8){if(oe&16)Mt(Y,K,G);if(ee!==Y)H(B,ee)}else if(oe&16)if(ie&16)It(Y,ee,B,q,K,G,X,J,z);else Mt(Y,K,G,!0);else{if(oe&8)H(B,"");if(ie&16)qe(ee,B,q,K,G,X,J,z)}},jn=(M,L,B,q,K,G,X,J,z)=>{M=M||mt,L=L||mt;let Y=M.length,oe=L.length,ee=Math.min(Y,oe),se;for(se=0;se<ee;se++){let ie=L[se]=z?at(L[se]):et(L[se]);Q(M[se],ie,B,null,K,G,X,J,z)}if(Y>oe)Mt(M,K,G,!0,!1,ee);else qe(L,B,q,K,G,X,J,z,ee)},It=(M,L,B,q,K,G,X,J,z)=>{let Y=0,oe=L.length,ee=M.length-1,se=oe-1;while(Y<=ee&&Y<=se){let ie=M[Y],ue=L[Y]=z?at(L[Y]):et(L[Y]);if(Qt(ie,ue))Q(ie,ue,B,null,K,G,X,J,z);else break;Y++}while(Y<=ee&&Y<=se){let ie=M[ee],ue=L[se]=z?at(L[se]):et(L[se]);if(Qt(ie,ue))Q(ie,ue,B,null,K,G,X,J,z);else break;ee--,se--}if(Y>ee){if(Y<=se){let ie=se+1,ue=ie<oe?L[ie].el:q;while(Y<=se)Q(null,L[Y]=z?at(L[Y]):et(L[Y]),B,ue,K,G,X,J,z),Y++}}else if(Y>se)while(Y<=ee)st(M[Y],K,G,!0),Y++;else{let ie=Y,ue=Y,me=new Map;for(Y=ue;Y<=se;Y++){let Me=L[Y]=z?at(L[Y]):et(L[Y]);if(Me.key!=null)me.set(Me.key,Y)}let ge,Oe=0,we=se-ue+1,Le=!1,Ie=0,ot=Array(we);for(Y=0;Y<we;Y++)ot[Y]=0;for(Y=ie;Y<=ee;Y++){let Me=M[Y];if(Oe>=we){st(Me,K,G,!0);continue}let ze;if(Me.key!=null)ze=me.get(Me.key);else for(ge=ue;ge<=se;ge++)if(ot[ge-ue]===0&&Qt(Me,L[ge])){ze=ge;break}if(ze===void 0)st(Me,K,G,!0);else{if(ot[ze-ue]=Y+1,ze>=Ie)Ie=ze;else Le=!0;Q(Me,L[ze],B,null,K,G,X,J,z),Oe++}}let Ir=Le?Pi(ot):mt;ge=Ir.length-1;for(Y=we-1;Y>=0;Y--){let Me=ue+Y,ze=L[Me],Mr=L[Me+1],$r=Me+1<oe?Mr.el||on(Mr):q;if(ot[Y]===0)Q(null,ze,B,$r,K,G,X,J,z);else if(Le)if(ge<0||Y!==Ir[ge])wt(ze,B,$r,2);else ge--}}},wt=(M,L,B,q,K=null)=>{let{el:G,type:X,transition:J,children:z,shapeFlag:Y}=M;if(Y&6){wt(M.component.subTree,L,B,q);return}if(Y&128){M.suspense.move(L,B,q);return}if(Y&64){X.move(M,L,B,Dt);return}if(X===Ge){T(G,L,B);for(let ee=0;ee<z.length;ee++)wt(z[ee],L,B,q);T(M.anchor,L,B);return}if(X===mr){xe(M,L,B);return}if(q!==2&&Y&1&&J)if(q===0)if(J.persisted&&!G[dr])T(G,L,B);else J.beforeEnter(G),T(G,L,B),Ae(()=>J.enter(G),K);else{let{leave:ee,delayLeave:se,afterLeave:ie}=J,ue=()=>{if(M.ctx.isUnmounted)C(G);else T(G,L,B)},me=()=>{let ge=G._isLeaving||!!G[dr];if(G._isLeaving)G[dr](!0);if(J.persisted&&!ge)ue();else ee(G,()=>{ue(),ie&&ie()})};if(se)se(G,ue,me);else me()}else T(G,L,B)},st=(M,L,B,q=!1,K=!1)=>{let{type:G,props:X,ref:J,children:z,dynamicChildren:Y,shapeFlag:oe,patchFlag:ee,dirs:se,cacheIndex:ie,memo:ue}=M;if(ee===-2||Y&&Y.hasOnce)K=!1;if(J!=null)je(),nn(J,null,B,M,!0),Be();if(ie!=null&&(!M.ctx||M.ctx===L))L.renderCache[ie]=void 0;if(oe&256&&L.ctx.deactivate(M))return;let me=oe&1&&se,ge=!rn(M),Oe;if(ge&&(Oe=X&&X.onVnodeBeforeUnmount))Ze(Oe,L,M);if(oe&6)ao(M.component,B,q);else{if(oe&128){M.suspense.unmount(B,q);return}if(me)vt(M,null,L,"beforeUnmount");if(oe&64)M.type.remove(M,L,B,Dt,q);else if(Y&&!Y.hasOnce&&(G!==Ge||ee>0&&ee&64))Mt(Y,L,B,!1,!0);else if(G===Ge&&ee&384||!K&&oe&16)Mt(z,L,B);if(q)Rr(M)}let we=ue!=null&&ie==null;if(ge&&(Oe=X&&X.onVnodeUnmounted)||me||we)Ae(()=>{if(Oe&&Ze(Oe,L,M),me&&vt(M,null,L,"unmounted"),we)M.el=null},B)},Rr=(M)=>{let{type:L,el:B,anchor:q,transition:K}=M,G=L===Ge;if(G&&!K){kr(B,q);return}if(L===mr){if(ne(M),K&&!K.persisted&&K.afterLeave)K.afterLeave();return}let X=G?Er(M):M,J=()=>{if(G){if(W(B))kr(B,q)}else C(B);if(K&&!K.persisted&&K.afterLeave)K.afterLeave()};if(X&&X.shapeFlag&1&&K&&!K.persisted){let{leave:z,delayLeave:Y}=K,oe=X.el,ee=()=>z(oe,J);if(Y)Y(oe,J,ee);else ee()}else J()},kr=(M,L)=>{let B;while(M!==L)B=Z(M),C(M),M=B;C(L)},ao=(M,L,B)=>{let{bum:q,scope:K,job:G,subTree:X,um:J,m:z,a:Y}=M;if(xs(z),xs(Y),q)vn(q);if(K.stop(),G)G.flags|=8,st(X,M,L,B);else if(X)X.transition=M.vnode.transition,st(X,M,L,B);if(J)Ae(J,L);let oe=()=>{M.isUnmounted=!0};oe.flags=16,Ae(oe,L)},Mt=(M,L,B,q=!1,K=!1,G=0)=>{for(let X=G;X<M.length;X++)st(M[X],L,B,q,K)},_n=(M)=>{if(M.shapeFlag&6)return _n(M.component.subTree);if(M.shapeFlag&128)return M.suspense.next();let L=Z(M.anchor||M.el),B=L&&L[Jo];return B?Z(B):L},Pr=(M,L,B)=>{let q=M&&L._vnode?void 0:M&&M.component?M.component.uid:Bi();Wo(()=>{if(M==null){if(L._vnode)st(L._vnode,null,null,!0)}else Q(L._vnode||null,M,L,null,null,null,B);L._vnode=M},q)},Dt={p:Q,um:st,m:wt,r:Rr,mt:gn,mc:qe,pc:rt,pbc:_t,n:_n,o:p},Bn,Wn;if(g)[Bn,Wn]=g(Dt);return{render:Pr,hydrate:Bn,createApp:Ei(Pr,Bn)}}function _r({type:p,props:g},N){return N==="svg"&&p==="foreignObject"||N==="mathml"&&p==="annotation-xml"&&g&&g.encoding&&g.encoding.includes("html")?void 0:N}function Nt({effect:p,job:g},N){if(N)p.flags|=32,g.flags|=4;else p.flags&=-33,g.flags&=-5}function ki(p,g){return(!p||p&&!p.pendingBranch)&&g&&!g.persisted}function to(p,g,N=!1){let T=p.children,C=g.children;if(t(T)&&t(C))for(let A=0;A<T.length;A++){let k=T[A],F=C[A];if(F.shapeFlag&1&&!F.dynamicChildren){if(F.patchFlag<=0||F.patchFlag===32)F=C[A]=at(C[A]),F.el=k.el;if(!N&&F.patchFlag!==-2)to(k,F)}if(F.type===Hn){if(F.patchFlag===-1)F=C[A]=at(F);F.el=k.el}if(F.type===ft&&!F.el)F.el=k.el}}function Pi(p){let g=p.slice(),N=[0],T,C,A,k,F,U=p.length;for(T=0;T<U;T++){let j=p[T];if(j!==0){if(C=N[N.length-1],p[C]<j){g[T]=C,N.push(T);continue}A=0,k=N.length-1;while(A<k)if(F=A+k>>1,p[N[F]]<j)A=F+1;else k=F;if(j<p[N[A]]){if(A>0)g[T]=N[A-1];N[A]=T}}}A=N.length,k=N[A-1];while(A-- >0)N[A]=k,k=g[k];return N}function no(p){let g=p.subTree.component;if(g)if(g.asyncDep&&!g.asyncResolved)return g;else return no(g)}function xs(p){if(p)for(let g=0;g<p.length;g++)p[g].flags|=8}function on(p){if(p.placeholder)return p.placeholder;let g=p.component;if(g)return on(g.subTree);let N=p.suspense;if(N&&N.activeBranch)return on(N.activeBranch);return null}var ro=(p)=>p.__isSuspense;var Ii=Symbol("_deferredEnter");function Mi(p,g){if(g&&g.pendingBranch)if(t(p))g.effects.push(...p);else g.effects.push(p);else Bo(p)}var Ge=Symbol.for("v-fgt"),Hn=Symbol.for("v-txt"),ft=Symbol.for("v-cmt"),mr=Symbol.for("v-stc"),Rt=[],ut=null;function $i(){Rt.pop(),ut=Rt[Rt.length-1]||null}var Cr=1;function In(p,g=!1){if(Cr+=p,p<0&&ut&&g)ut.hasOnce=!0}function an(p){return p?p.__v_isVNode===!0:!1}function Qt(p,g){return p.type===g.type&&p.key===g.key}var so=({key:p})=>p!=null?p:null,Sn=({ref:p,ref_key:g,ref_for:N})=>{if(typeof p==="number")p=""+p;return p!=null?i(p)||Te(p)||r(p)?{i:tt,r:p,k:g,f:!!N}:p:null};function Fi(p,g=null,N=null,T=0,C=null,A=p===Ge?0:1,k=!1,F=!1){let U={__v_isVNode:!0,__v_skip:!0,type:p,props:g,key:g&&so(g),ref:g&&Sn(g),scopeId:$s,slotScopeIds:null,children:N,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:A,patchFlag:T,dynamicProps:C,dynamicChildren:null,appContext:null,ctx:tt};if(F){if(Mn(U,N),A&128)p.normalize(U)}else if(N)U.shapeFlag|=i(N)?8:16;if(Cr>0&&!k&&ut&&(U.patchFlag>0||A&6)&&U.patchFlag!==32)ut.push(U);return U}var Pe=Li;function Li(p,g=null,N=null,T=0,C=null,A=!1){if(!p||p===ui)p=ft;if(an(p)){let F=kt(p,g,!0);if(N)Mn(F,N);if(Cr>0&&!A&&ut)if(F.shapeFlag&6)ut[ut.indexOf(p)]=F;else ut.push(F);return F.patchFlag=-2,F}if(zi(p))p=p.__vccOpts;if(g){g=Ui(g);let{class:F,style:U}=g;if(F&&!i(F))g.class=Ht(F);if(Ee(U)){if(Zt(U)&&!t(U))U=s({},U);g.style=Ut(U)}}let k=i(p)?1:ro(p)?128:Fn(p)?64:Ee(p)?4:r(p)?2:0;return Fi(p,g,N,T,C,k,A,!0)}function Ui(p){if(!p)return null;if(Zt(p))return s({},p);return zs(p)?s({},p[co]||p):p}function kt(p,g,N=!1,T=!1){let{props:C,ref:A,patchFlag:k,children:F,transition:U}=p,j=g?O(C||{},g):C,H={__v_isVNode:!0,__v_skip:!0,type:p.type,props:j,key:j&&so(j),ref:g&&g.ref?N&&A?t(A)?A.concat(Sn(g)):[A,Sn(g)]:Sn(g):A,scopeId:p.scopeId,slotScopeIds:p.slotScopeIds,children:F,target:p.target,targetStart:p.targetStart,targetAnchor:p.targetAnchor,staticCount:p.staticCount,shapeFlag:p.shapeFlag,patchFlag:g&&p.type!==Ge?k===-1?16:k|16:k,dynamicProps:p.dynamicProps,dynamicChildren:p.dynamicChildren,appContext:p.appContext,dirs:p.dirs,transition:U,component:p.component,suspense:p.suspense,ssContent:p.ssContent&&kt(p.ssContent),ssFallback:p.ssFallback&&kt(p.ssFallback),placeholder:p.placeholder,el:p.el,anchor:p.anchor,ctx:p.ctx,ce:p.ce,cacheIndex:p.cacheIndex};if(U&&T)tn(H,U.clone(H));return H}function Hi(p=" ",g=0){return Pe(Hn,null,p,g)}function et(p){if(p==null||typeof p==="boolean")return Pe(ft);else if(t(p))return Pe(Ge,null,p.slice());else if(an(p))return at(p);else return Pe(Hn,null,String(p))}function at(p){return p.el===null&&p.patchFlag!==-1||p.memo?p:kt(p)}function Mn(p,g){let N=0,{shapeFlag:T}=p;if(g==null)g=null;else if(t(g))N=16;else if(typeof g==="object")if(T&65){let C=g.default;if(C)C._c&&(C._d=!1),Mn(p,C()),C._c&&(C._d=!0);return}else{N=32;let C=g._;if(!C&&!zs(g))g._ctx=tt;else if(C===3&&tt)if(tt.slots._===1)g._=1;else g._=2,p.patchFlag|=1024}else if(r(g)){if(T&65){Mn(p,{default:g});return}g={default:g,_ctx:tt},N=32}else if(g=String(g),T&64)N=16,g=[Hi(g)];else N=8;p.children=g,p.shapeFlag|=N}function O(...p){let g={};for(let N=0;N<p.length;N++){let T=p[N];for(let C in T)if(C==="class"){if(g.class!==T.class)g.class=Ht([g.class,T.class])}else if(C==="style")g.style=Ut([g.style,T.style]);else if(m(C)){let A=g[C],k=T[C];if(k&&A!==k&&!(t(A)&&A.includes(k)))g[C]=A?[].concat(A,k):k;else if(k==null&&A==null&&!y(C))g[C]=k}else if(C!=="")g[C]=T[C]}return g}function Ze(p,g,N,T=null){l(p,g,7,[N,T])}var ji=js(),oo=0;function Bi(){return oo}function Wi(p,g,N){let T=p.type,C=(g?g.appContext:p.appContext)||ji,A={uid:oo++,vnode:p,type:T,parent:g,appContext:C,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new Tn(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:g?g.provides:Object.create(C.provides),ids:g?g.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:Xs(T,C),emitsOptions:Ws(T,C),emit:null,emitted:null,propsDefaults:fe,inheritAttrs:T.inheritAttrs,ctx:fe,data:fe,props:fe,attrs:fe,slots:fe,refs:fe,setupState:fe,setupContext:null,suspense:N,suspenseId:N?N.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};if(A.ctx={_:A},A.root=g?g.root:A,A.emit=yi.bind(null,A),p.ce)p.ce(A);return A}var Ce=null,_=()=>Ce||tt,$n,un;{let p=Lt(),g=(N,T)=>{let C;if(!(C=p[N]))C=p[N]=[];return C.push(T),(A)=>{if(C.length>1)C.forEach((k)=>k(A));else C[0](A)}};$n=g("__VUE_INSTANCE_SETTERS__",(N)=>Ce=N),un=g("__VUE_SSR_SETTERS__",(N)=>Pt=N)}var dn=(p)=>{let g=Ce;return $n(p),p.scope.on(),()=>{p.scope.off(),$n(g)}},Vs=()=>{Ce&&Ce.scope.off(),$n(null)};function io(p){return p.vnode.shapeFlag&4}var Pt=!1;function Ki(p,g=!1,N=!1){g&&un(g);let{props:T,children:C}=p.vnode,A=io(p);Di(p,T,A,g),Ci(p,C,N||g);let k=A?Yi(p,g):void 0;return g&&un(!1),k}function Yi(p,g){let N=p.type;p.accessCache=Object.create(null),p.proxy=new Proxy(p.ctx,fi);let{setup:T}=N;if(T){je();let C=p.setupContext=T.length>1?qi(p):null,A=dn(p),k=fn(T,p,0,[p.props,C]),F=Yn(k);if(Be(),A(),(F||p.sp)&&!rn(p))Dr(p);if(F)if(k.then(Vs,Vs),g)return k.then((U)=>{un(!0);try{Cs(p,U,g)}finally{un(!1)}}).catch((U)=>{pn(U,p,0,void 0,!0),p.ssrRender=(j,H)=>H("<!---->")});else p.asyncDep=k;else Cs(p,k,g)}else lo(p,g)}function Cs(p,g,N){if(r(g))if(p.type.__ssrInlineRender)p.ssrRender=g;else p.render=g;else if(Ee(g))p.setupState=Vn(g);lo(p,N)}var Ss,As;function lo(p,g,N){let T=p.type;if(!p.render){if(!g&&Ss&&!T.render){let C=T.template||Tr(p).template;if(C){let{isCustomElement:A,compilerOptions:k}=p.appContext.config,{delimiters:F,compilerOptions:U}=T,j=s(s({isCustomElement:A,delimiters:F},k),U);T.render=Ss(C,j)}}if(p.render=T.render||$e,As)As(p)}{let C=dn(p);je();try{pi(p)}finally{Be(),C()}}}var co=Symbol(),Gi={get(p,g){return Ve(p,"get",""),g===co?p:p[g]}};function qi(p){let g=(N)=>{p.exposed=N||{}};return{attrs:new Proxy(p.attrs,Gi),slots:p.slots,emit:p.emit,expose:g}}function Sr(p){if(p.exposed)return p.exposeProxy||(p.exposeProxy=new Proxy(Vn(ur(p.exposed)),{get(g,N){if(N in g)return g[N];else if(N in sn)return sn[N](p)},has(g,N){return N in g||N in sn}}));else return p.proxy}function zi(p){return r(p)&&"__vccOpts"in p}var h=(p,g)=>gs(p,g,Pt);function e(p,g,N){try{In(-1);let T=arguments.length;if(T===2)if(Ee(g)&&!t(g)){if(an(g))return Pe(p,null,[g]);return Pe(p,g)}else return Pe(p,null,g);else{if(T>3)N=Array.prototype.slice.call(arguments,2);else if(T===3&&an(N))N=[N];return Pe(p,g,N)}}finally{In(1)}}var Ji="3.5.46";export{m,y,s,t,r,i,c,o,u,v,R,x,d,f,l,b,a,E,n,D,P,S,w,V,I,O,_,h,e};
@@ -1 +0,0 @@
1
- import{M}from"./c-ns42txax.js";export{M as PoadButton};
@@ -1 +0,0 @@
1
- import{g}from"./c-9a0nzf53.js";import{p}from"./c-7dddcgt2.js";import{n,V,e}from"./c-fnkq09db.js";var u={info:"info",success:"check-circle",warning:"alert-triangle",danger:"alert-circle",secondary:"info"};function i(s){return["poad-message",`sev-${s.severity??"info"}`,`var-${s.variant??"soft"}`,s.size==="sm"&&"size-sm",s.hidden&&"is-hidden"].filter(Boolean).join(" ")}function r(s){if(s.icon==="")return null;return s.icon||u[s.severity??"info"]}var c=(s)=>s.size==="sm"?13:15;var z=n({name:"PoadMessage",props:{severity:String,text:String,icon:{type:String,default:void 0},closable:Boolean,variant:String,size:String,open:{type:Boolean,default:!0}},emits:{"update:open":(s)=>!0,close:()=>!0},setup(s,{emit:l,slots:m}){let{t:d}=p(),t=V(s,"open");return()=>{let o={...s,hidden:!t.value},a=r(o);return e("div",{class:i(o),role:"status"},[a&&e(g,{class:"poad-message__icon",name:a,size:c(o)}),e("div",{class:"poad-message__body"},[s.text,m.default?.()]),s.closable&&e("button",{type:"button",class:"poad-message__close","aria-label":d("common.close"),onClick:()=>{t.value=!1,l("close")}},[e(g,{name:"x",size:13})])])}}});export{z as PoadMessage};
@@ -1 +0,0 @@
1
- import{M}from"./c-ns42txax.js";import{p}from"./c-7dddcgt2.js";import{f,b,a,E,n,D,S,w,O,_,h,e}from"./c-fnkq09db.js";class v extends Error{code;messageKey;status;sourceCode;path;params;field;rule;cause;constructor(t,r,s={}){super(r);if(this.name="DataStoreError",this.code=t,this.messageKey=s.messageKey??(t==="validation"&&s.rule?`data.${s.rule}`:`data.${t}`),s.status!==void 0)this.status=s.status;if(s.sourceCode!==void 0)this.sourceCode=s.sourceCode;if(s.path!==void 0)this.path=s.path;if(s.params!==void 0)this.params=s.params;if(s.field!==void 0)this.field=s.field;if(s.rule!==void 0)this.rule=s.rule;if(s.cause!==void 0)this.cause=s.cause}}function L(t){if(t instanceof v)return t;let r=typeof t==="object"&&t!==null?t:{},s=typeof r.status==="number"?r.status:void 0,i=typeof r.code==="string"?r.code:void 0,o=typeof r.message==="string"&&r.message?r.message:String(t),l=i==="55000"||i==="0A000"?"read_only":Sn(r.kind)??vn(s,i),c=typeof r.column==="string"?r.column:l==="constraint"?On(o):void 0;return new v(l,o,{...s!==void 0?{status:s}:{},...i!==void 0?{sourceCode:i}:{},...c?{field:c}:{},cause:t})}function Sn(t){switch(t){case"network":case"aborted":return"network";case"unauthorized":case"forbidden":case"not_found":case"conflict":case"constraint":case"server":return t;case"invalid":return"invalid_query";case"timeout":return"server";default:return}}function vn(t,r){if(r==="network_error"||r==="aborted"||t===0)return"network";if(r==="42501"||r==="forbidden"||t===403)return"forbidden";if(r==="unauthorized"||r==="PGRST301"||t===401)return"unauthorized";if(r==="not_found"||t===404)return"not_found";if(r&&/^23/.test(r))return"constraint";if(r==="40001"||t===409||t===412)return"conflict";if(r&&/^(22|42)/.test(r))return"invalid_query";if(r==="invalid_request"||t===400)return"invalid_query";if(t!==void 0&&t>=500)return"server";if(kn(r))return"network";return"unknown"}var kn=(t)=>t==="ECONNREFUSED"||t==="ECONNRESET"||t==="ETIMEDOUT";function On(t){return(/column "([A-Za-z_][A-Za-z0-9_]*)"/.exec(t)??/Key \(([A-Za-z_][A-Za-z0-9_]*)\)=/.exec(t))?.[1]}var Mt=/^[A-Za-z_][A-Za-z0-9_]{0,62}$/,xn=/^(0|[1-9][0-9]{0,8})$/,Kt=16,ct=new Set(["__proto__","prototype","constructor"]);function K(t,r="field"){if(t===void 0||t==="")return[];if(Array.isArray(t)){if(t.length>Kt)throw ve(r,"path too deep");return t.map((i,o)=>{if(typeof i==="number"?Number.isInteger(i)&&i>=0:typeof i==="string"&&Mt.test(i)&&!ct.has(i))return i;throw ve(`${r}[${o}]`,"expected a field name or an array index")})}if(typeof t!=="string")throw ve(r,'expected a path such as "adresse.ville" or "lignes.0.qte"');let s=t.split(".");if(s.length>Kt)throw ve(r,"path too deep");return s.map((i)=>{if(xn.test(i))return Number(i);if(Mt.test(i)&&!ct.has(i))return i;throw ve(r,`invalid segment "${i}" (expected a field name or an array index)`)})}var ue=(t)=>t.join(".");function W(t,r){let s=t;for(let i of r){if(s===null||typeof s!=="object")return;if(typeof i==="number"){if(!Array.isArray(s))return;s=s[i]}else{if(Array.isArray(s)||!Object.prototype.hasOwnProperty.call(s,i))return;s=s[i]}}return s}function ce(t,r,s){if(r.length===0)return s;let[i,...o]=r;if(typeof i==="number"){let c=Array.isArray(t)?[...t]:[];return c[i]=ce(c[i],o,s),c}if(ct.has(i))throw ve("field",`invalid segment "${i}"`);let l=t!==null&&typeof t==="object"&&!Array.isArray(t)?{...t}:{};return l[i]=ce(Object.prototype.hasOwnProperty.call(l,i)?l[i]:void 0,o,s),l}function P(t,r,s=0){if(Object.is(t,r))return!0;if(s>64||typeof t!=="object"||typeof r!=="object"||t===null||r===null)return!1;if(Array.isArray(t)!==Array.isArray(r))return!1;if(Array.isArray(t)){let l=r;return t.length===l.length&&t.every((c,u)=>P(c,l[u],s+1))}let i=Object.keys(t),o=Object.keys(r);if(i.length!==o.length)return!1;return i.every((l)=>Object.prototype.hasOwnProperty.call(r,l)&&P(t[l],r[l],s+1))}var ve=(t,r)=>new v("invalid_binding",`invalid field path at ${t}: ${r}`,{path:t});class Y{hooks;value;listeners=new Set;constructor(t,r={}){this.hooks=r,this.value=t}get(){return this.value}get observed(){return this.listeners.size>0}set(t){if(Object.is(t,this.value))return;this.value=t;for(let r of[...this.listeners])if(this.listeners.has(r))r(t)}replace(t){this.value=t}subscribe(t){let r=(i)=>t(i);if(this.listeners.add(r),this.listeners.size===1)this.hooks.start?.();let s=!0;return()=>{if(!s)return;if(s=!1,this.listeners.delete(r),this.listeners.size===0)this.hooks.stop?.()}}}var Bt=["add","sub","mul","div","round","min","max","concat","coalesce","if","eq","ne","gt","gte","lt","lte","and","or","not"],_n=new Set(Bt),An={sub:[2,2],div:[2,2],round:[1,2],if:[3,3],eq:[2,2],ne:[2,2],gt:[2,2],gte:[2,2],lt:[2,2],lte:[2,2],not:[1,1]},fe=(t,r)=>{throw new v("invalid_description",`invalid compute at ${t}: ${r}`,{path:t})};function dt(t,r="compute",s=0){if(s>16)fe(r,"expression nested too deeply");if(t===null||typeof t==="boolean")return t;if(typeof t==="number")return Number.isFinite(t)?t:fe(r,"expected a finite number");if(typeof t==="string")return K(t),t;if(typeof t!=="object"||Array.isArray(t))return fe(r,'expected a field name, a number, { "text": … } or { "<op>": [ … ] }');let i=Object.keys(t);if(i.length!==1)return fe(r,"expected exactly one operator");let o=i[0],l=t[o];if(o==="text")return typeof l==="string"?t:fe(`${r}.text`,"expected a string");if(!_n.has(o))throw new v("unknown_operator",`unknown compute operator "${o}" at ${r}: expected one of ${Bt.join(", ")}`,{path:r,params:{operator:o}});if(!Array.isArray(l)||l.length===0)return fe(`${r}.${o}`,"expected a non-empty array of operands");let[c,u]=An[o]??[1,64];if(l.length<c||l.length>u)fe(`${r}.${o}`,c===u?`expected ${c} operands`:`expected ${c} to ${u} operands`);return l.forEach((g,d)=>dt(g,`${r}.${o}[${d}]`,s+1)),t}var ut=(t)=>{if(typeof t==="number"&&Number.isFinite(t))return t;if(typeof t==="string"&&t.trim()!==""&&Number.isFinite(Number(t)))return Number(t);return null};function ft(t,r){if(t===null||typeof t==="boolean"||typeof t==="number")return t;if(typeof t==="string")return W(r,K(t));let s=Object.keys(t)[0];if(s==="text")return t.text;let i=t[s],o=(g)=>ft(i[g],r),l=()=>i.map((g)=>ft(g,r)),c=()=>{let g=[];for(let d of l()){let m=ut(d);if(m===null)return null;g.push(m)}return g},u=(g)=>{let d=o(0),m=o(1);if(d===null||d===void 0||m===null||m===void 0)return null;let y=ut(d),k=ut(m);return y!==null&&k!==null?g(y,k):g(String(d),String(m))};switch(s){case"add":{let g=c();return g&&g.reduce((d,m)=>d+m,0)}case"mul":{let g=c();return g&&g.reduce((d,m)=>d*m,1)}case"sub":{let g=c();return g&&g[0]-g[1]}case"div":{let g=c();return g&&g[1]!==0?g[0]/g[1]:null}case"round":{let g=c();if(!g)return null;let d=10**Math.max(0,Math.min(10,Math.trunc(g[1]??0)));return Math.round(g[0]*d)/d}case"min":{let g=c();return g&&Math.min(...g)}case"max":{let g=c();return g&&Math.max(...g)}case"concat":return l().map((g)=>g===null||g===void 0?"":String(g)).join("");case"coalesce":return l().find((g)=>g!==null&&g!==void 0)??null;case"if":return o(0)?o(1):o(2);case"eq":return JSON.stringify(o(0)??null)===JSON.stringify(o(1)??null);case"ne":return JSON.stringify(o(0)??null)!==JSON.stringify(o(1)??null);case"gt":return u((g,d)=>g>d);case"gte":return u((g,d)=>g>=d);case"lt":return u((g,d)=>g<d);case"lte":return u((g,d)=>g<=d);case"and":return l().every(Boolean);case"or":return l().some(Boolean);case"not":return!o(0);default:return null}}function Wt(t,r){if(typeof t==="function")try{let s=t(r);return typeof s==="number"&&!Number.isFinite(s)?null:s}catch{return null}return ft(t,r)}var Vt=["key","label","description","search","start","end","duration","resource","geometry","latitude","longitude","parent","order","group","status","progress","color","image","value","version"],Ut=new Set(Vt),$n=["required","min","max","minLength","maxLength","pattern"],Rn=new Set(["field","key","header","type","roles","width","minWidth","align","sortable","filterable","editable","hidden","format","options","compute",...$n]),jn=/^\d{4}-\d{2}-\d{2}([T ][0-9:.]+(Z|[+-]\d{2}:?\d{2})?)?$/,Cn=new Set(["decimals","currency","percent","date"]),ht=new Set(["text","number","date","datetime","boolean","enum","json","geometry"]),En=new Set(["left","right","center"]),Nn=/^[A-Za-z_][A-Za-z0-9_.-]{0,127}$/,Tn=/^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$/,Dn=/^(\d+(\.\d+)?)(px|rem|em|ch|%|vw)$/,Pn=/^[A-Z]{3}$/,Zt=200,Ve=200,N=(t,r)=>{throw new v("invalid_binding",`invalid field at ${t}: ${r}`,{path:t})},Ce=(t)=>typeof t==="object"&&t!==null&&!Array.isArray(t)&&(Object.getPrototypeOf(t)===Object.prototype||Object.getPrototypeOf(t)===null);function Yt(t,r){if(typeof t==="string"){if(t.length===0||t.length>Ve)N(r,`expected 1 to ${Ve} characters`);return t}if(!Ce(t)||Object.keys(t).length===0)return N(r,'expected a text or an object of texts by language ({ "fr": "…", "en": "…" })');for(let[s,i]of Object.entries(t)){if(!Tn.test(s))N(`${r}.${s}`,"expected a language tag (fr, en, fr-CA)");if(typeof i!=="string"||i.length===0||i.length>Ve)N(`${r}.${s}`,`expected 1 to ${Ve} characters`)}return t}function Jt(t,r){if(typeof t==="number"){if(!Number.isInteger(t)||t<1||t>4000)N(r,"expected a width in px between 1 and 4000");return`${t}px`}if(typeof t!=="string"||!Dn.test(t))return N(r,"expected a number (px) or a CSS length (12rem, 20%)");return t}function ke(t,r){if(typeof t!=="boolean")N(r,"expected true or false");return t}function zn(t,r){if(!Ce(t))return N(r,"expected an object");for(let[s,i]of Object.entries(t)){let o=`${r}.${s}`;if(!Cn.has(s))N(o,"unknown key");if(s==="decimals"&&(typeof i!=="number"||!Number.isInteger(i)||i<0||i>20))N(o,"expected an integer between 0 and 20");if(s==="currency"&&(typeof i!=="string"||!Pn.test(i)))N(o,"expected an ISO 4217 code (EUR)");if(s==="percent")ke(i,o);if(s==="date"&&i!=="short"&&i!=="medium"&&i!=="long")N(o,'expected "short", "medium" or "long"')}return t}var Ln=/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/;function Fn(t,r,s){for(let i of Object.keys(t))if(i!=="store"&&i!=="fields")N(`${r}.${i}`,'unknown key (a reference has "store" and "fields")');if(typeof t.store!=="string"||!Ln.test(t.store))N(`${r}.store`,"expected a store name");if(s>0&&t.fields!==void 0)N(`${r}.fields`,"a reference inside a reference cannot declare fields");return{store:t.store,...t.fields!==void 0?{fields:te(t.fields,{at:`${r}.fields`,depth:s+1})}:{}}}function In(t,r){if(!Array.isArray(t)||t.length===0||t.length>1000)return N(r,"expected a non-empty array of { value, label }");return t.map((s,i)=>{let o=`${r}[${i}]`;if(!Ce(s))return N(o,"expected { value, label }");for(let c of Object.keys(s))if(c!=="value"&&c!=="label")N(`${o}.${c}`,"unknown key");let l=s.value;if(!(l===null||typeof l==="string"||typeof l==="boolean"||typeof l==="number"&&Number.isFinite(l)))N(`${o}.value`,"expected a scalar");return{value:l,label:Yt(s.label,`${o}.label`)}})}function Mn(t,r,s){let i={};if(t.required!==void 0)i.required=ke(t.required,`${r}.required`);for(let o of["min","max"]){let l=t[o];if(l===void 0)continue;if(s==="date"||s==="datetime"){if(typeof l!=="string"||!jn.test(l))N(`${r}.${o}`,"expected an ISO date (2026-01-01)")}else if(typeof l!=="number"||!Number.isFinite(l))N(`${r}.${o}`,"expected a number");i[o]=l}for(let o of["minLength","maxLength"]){let l=t[o];if(l===void 0)continue;if(typeof l!=="number"||!Number.isInteger(l)||l<0||l>1e6)N(`${r}.${o}`,"expected a non-negative integer");i[o]=l}if(t.pattern!==void 0){let o=t.pattern;if(typeof o!=="string"||o.length===0||o.length>500)N(`${r}.pattern`,"expected a regular expression (1 to 500 characters)");try{new RegExp(o,"u")}catch{N(`${r}.pattern`,"not a valid regular expression")}i.pattern=o}if(i.min!==void 0&&i.max!==void 0&&Kn(i.min,i.max)>0)N(`${r}.min`,"min is greater than max");if(i.minLength!==void 0&&i.maxLength!==void 0&&i.minLength>i.maxLength)N(`${r}.minLength`,"minLength is greater than maxLength");return Object.keys(i).length?i:void 0}var Kn=(t,r)=>typeof t==="number"&&typeof r==="number"?t-r:Date.parse(String(t))-Date.parse(String(r));function Bn(t){let r=t.toLowerCase().replace(/^pg_catalog\./,"");if(ht.has(r))return r;if(/^(int[248]?|smallint|integer|bigint|numeric|decimal|real|float[48]?|double precision|money|serial|bigserial)(\(.*\))?$/.test(r))return"number";if(r==="date")return"date";if(/^timestamp/.test(r))return"datetime";if(r==="bool"||r==="boolean")return"boolean";if(/^(geometry|geography)(\(.*\))?$/.test(r))return"geometry";if(r==="json"||r==="jsonb"||r.endsWith("[]"))return"json";if(/^(text|varchar|character varying|char|character|bpchar|uuid|citext|name|time|timetz|interval|inet)/.test(r))return"text";return}function Wn(t,r){if(!Array.isArray(t))return N(r,"expected an array of roles");let s=new Set;return t.map((i,o)=>{if(typeof i!=="string"||!Ut.has(i))N(`${r}[${o}]`,`unknown role (known: ${Vt.join(", ")})`);if(s.has(i))N(`${r}[${o}]`,"duplicate role");return s.add(i),i})}function te(t,r={}){let s=r.at??"fields";if(!Array.isArray(t)||t.length===0||t.length>Zt)return N(s,`expected 1 to ${Zt} fields`);let i=new Set;return t.map((o,l)=>{let c=`${s}[${l}]`,u=typeof o==="string"?{field:o}:Ce(o)?o:N(c,"expected a field path or a field object");for(let C of Object.keys(u))if(!Rn.has(C))N(`${c}.${C}`,"unknown key");if(typeof u.field!=="string"||u.field==="")N(`${c}.field`,"expected a field path");let g=ue(K(u.field,`${c}.field`)),d=u.key===void 0?g:typeof u.key==="string"&&Nn.test(u.key)?u.key:N(`${c}.key`,"expected an identifier");if(i.has(d))N(`${c}.key`,`duplicate field "${d}" (give a distinct "key")`);i.add(d);let m=Ce(u.options)?Fn(u.options,`${c}.options`,r.depth??0):void 0,y,k;if(m&&u.type===void 0)y="enum",k="declared";else if(u.type!==void 0){if(!ht.has(u.type))N(`${c}.type`,`expected one of ${[...ht].join(", ")}`);y=u.type,k="declared"}else{let C=!g.includes(".")?r.meta?.columns[g]:void 0,T=C?Bn(C):void 0;y=T??"text",k=T?"meta":"default"}let x=u.options!==void 0&&!m?In(u.options,`${c}.options`):void 0;if(y==="enum"&&!x&&!m)N(`${c}.options`,'an enum field needs its options (a list, or a reference store { "store": "…" })');if((x||m)&&y!=="enum")N(`${c}.options`,"options are only for an enum field");if(u.align!==void 0&&!En.has(u.align))N(`${c}.align`,'expected "left", "right" or "center"');let R=Mn(u,c,y),j;if(u.compute!==void 0){if(typeof u.compute==="function")j=u.compute;else try{j=dt(u.compute,`${c}.compute`)}catch(C){if(C.code==="unknown_operator")throw C;N(C.path??`${c}.compute`,C.message.replace(/^invalid compute at [^:]+: /,""))}if(u.editable===!0)N(`${c}.editable`,"a computed field cannot be edited")}return{key:d,field:g,header:u.header!==void 0?Yt(u.header,`${c}.header`):g,type:y,typeSource:k,roles:u.roles!==void 0?Wn(u.roles,`${c}.roles`):[],...u.width!==void 0?{width:Jt(u.width,`${c}.width`)}:{},...u.minWidth!==void 0?{minWidth:Jt(u.minWidth,`${c}.minWidth`)}:{},align:u.align??(y==="number"?"right":y==="boolean"?"center":"left"),sortable:u.sortable!==void 0?ke(u.sortable,`${c}.sortable`):y!=="json"&&y!=="geometry"&&!g.includes("."),filterable:u.filterable!==void 0?ke(u.filterable,`${c}.filterable`):!1,editable:u.editable!==void 0?ke(u.editable,`${c}.editable`):!1,hidden:u.hidden!==void 0?ke(u.hidden,`${c}.hidden`):!1,...u.format!==void 0?{format:zn(u.format,`${c}.format`)}:{},...x?{options:x}:{},...m?{reference:m}:{},...R?{rules:R}:{},...j!==void 0?{compute:j}:{}}})}function Ue(t,r){if(typeof t==="string")return t;let s=r.split("-")[0]??r;return t[r]??t[s]??t.en??Object.values(t)[0]??""}function Ye(t,r){let s=(l,c)=>new v("validation",`invalid value for "${t.field}": ${l}`,{rule:l,field:t.field,...c?{params:c}:{}}),i=t.rules??{};if(r===null||r===void 0||r===""||Array.isArray(r)&&r.length===0)return i.required?s("required"):null;switch(t.type){case"number":if(typeof r!=="number"||!Number.isFinite(r))return s("type");if(i.min!==void 0&&typeof i.min==="number"&&r<i.min)return s("min",{min:i.min});if(i.max!==void 0&&typeof i.max==="number"&&r>i.max)return s("max",{max:i.max});break;case"date":case"datetime":{let l=r instanceof Date?r.getTime():typeof r==="string"?Date.parse(r):NaN;if(Number.isNaN(l))return s("type");if(i.min!==void 0&&l<Date.parse(String(i.min)))return s("min",{min:String(i.min)});if(i.max!==void 0&&l>Date.parse(String(i.max)))return s("max",{max:String(i.max)});break}case"boolean":if(typeof r!=="boolean")return s("type");break;case"enum":if(t.options&&!(Array.isArray(r)?r:[r]).every((l)=>t.options.some((c)=>c.value===l)))return s("enum");break;default:break}if(typeof r==="string"){if(i.minLength!==void 0&&r.length<i.minLength)return s("minLength",{min:i.minLength});if(i.maxLength!==void 0&&r.length>i.maxLength)return s("maxLength",{max:i.maxLength});if(i.pattern!==void 0&&!new RegExp(`^(?:${i.pattern})$`,"u").test(r))return s("pattern")}return null}function Ee(t,r){if(!Ut.has(r))N("role",`unknown role "${String(r)}"`);return(Array.isArray(t)?t:t.fields??[]).filter((i)=>i.roles.includes(r))}var Z=globalThis;var Ge="*",de=Object.freeze({kind:"update",dirty:!1,saving:!1,changes:{},errors:{},conflicts:{},error:null});function Ne(t,r,s){if(!r)return!0;if(s){let i=Number(t[s]),o=Number(r[s]);if(Number.isFinite(i)&&Number.isFinite(o))return i>o}return!P(t,r)}var Te=(t)=>JSON.stringify(t??null),Zn=3,Xe=()=>({signal:new Z.AbortController().signal});class De{host;entries=new Map;seq=0;constructor(t){this.host=t}state(t){return this.entries.get(t)?.view??de}allView=Object.freeze({});all(){return this.allView}inserted(){return[...this.entries.entries()].filter(([,t])=>t.kind==="insert"&&t.keyValue===null).map(([t,r])=>({id:t,row:{...r.changes}}))}get dirty(){for(let t of this.entries.values())if(t.view.dirty)return!0;return!1}get saving(){for(let t of this.entries.values())if(t.saving)return!0;return!1}merge(t,r){let s=this.entries.get(t);if(!s||Object.keys(s.changes).length===0)return r;return{...r,...s.changes}}isDeleted(t){return this.entries.get(t)?.kind==="delete"}get versionColumn(){return this.host.version}base(t){return this.entries.get(t)?.base??null}incoming(t,r){let s=this.entries.get(t);if(!s||s.kind==="insert"&&s.keyValue===null)return"none";if(s.saving)return this.held.set(t,r),"deferred";if(r===null){if(s.kind==="delete")return this.entries.delete(t),this.publishAll(),"none";return s.conflicts={},s.error=new v("not_found","the row was deleted meanwhile",{messageKey:"data.save_not_found"}),this.publish(t,s),"handled"}if(!Ne(r,s.base,this.host.version))return"stale";if(s.kind==="delete")return s.conflicts={[Ge]:{mine:null,theirs:r,base:s.base}},s.base={...r},s.error=new v("conflict","the row was changed before its deletion",{messageKey:"data.conflict"}),this.publish(t,s),"handled";if(this.compare(s,r),Object.keys(s.conflicts).length>0)s.error=Gt(s);return this.publish(t,s),"handled"}held=new Map;compare(t,r){let s=t.base??{};for(let i of Object.keys(t.changes)){let o=r[i],l=s[i],c=t.changes[i];if(P(o,l))continue;if(P(o,c)){delete t.changes[i],delete t.conflicts[i];continue}t.conflicts[i]={mine:c,theirs:o,base:t.conflicts[i]?.base??l}}t.base={...r}}set(t,r,s,i){let o=this.entry(t,r);if(o.kind==="delete")throw new v("read_only","this row is being deleted",{field:s});let l=o.base?o.base[s]:void 0;if(o.kind==="update"&&P(i,l))delete o.changes[s];else o.changes[s]=i;delete o.conflicts[s];let c=this.host.rule(s),u=c?Ye(c,i):null;if(u)o.errors[s]=u;else delete o.errors[s];if(Object.keys(o.conflicts).length===0)o.error=null;if(this.publish(t,o),this.host.mode()==="immediate")this.schedule(t)}insert(t){return this.insertAs(`new:${++this.seq}`,t)}insertAs(t,r){let s=this.fresh(null,null);s.kind="insert",s.changes={...r};for(let[i,o]of Object.entries(r)){let l=this.host.rule(i),c=l?Ye(l,o):null;if(c)s.errors[i]=c}if(this.entries.set(t,s),this.publish(t,s),this.host.mode()==="immediate")this.schedule(t);return t}remove(t,r){let s=this.entries.get(t);if(s?.kind==="insert"&&s.keyValue===null){this.entries.delete(t),this.publishAll();return}let i=this.entry(t,r);if(i.kind="delete",i.changes={},i.errors={},i.conflicts={},i.error=null,this.publish(t,i),this.host.mode()==="immediate")this.schedule(t)}revert(t,r){let s=t===void 0?[...this.entries.keys()]:[t];for(let i of s){let o=this.entries.get(i);if(!o)continue;if(r!==void 0){if(delete o.changes[r],delete o.errors[r],delete o.conflicts[r],Object.keys(o.conflicts).length===0)o.error=null;this.publish(i,o);continue}if(o.saving){o.again=!1;continue}if(o.kind==="insert"&&o.keyValue===null)this.entries.delete(i);else this.entries.delete(i)}this.publishAll()}dismiss(t){let r=this.entries.get(t);if(!r||r.saving)return;r.error=null,this.publish(t,r)}resolve(t,r,s){let i=this.entries.get(t);if(!i)return;let o=r===null?Object.keys(i.conflicts):[r];for(let l of o){if(!(l in i.conflicts))continue;if(l===Ge){if(s==="theirs"){this.entries.delete(t),this.publishAll();return}}else if(s==="theirs")delete i.changes[l],delete i.errors[l];delete i.conflicts[l]}if(Object.keys(i.conflicts).length===0)i.error=null;if(i.kind==="update"&&Object.keys(i.changes).length===0&&!i.error&&Object.keys(i.errors).length===0){this.entries.delete(t),this.publishAll();return}if(this.publish(t,i),this.host.mode()==="immediate"&&Object.keys(i.conflicts).length===0)this.schedule(t)}validate(t,r,s){let i=this.entries.get(t);if(!i||i.kind==="delete")return!0;let o={...r??i.base??{},...i.changes},l=s||i.kind==="insert"?new Set([...this.host.ruled(),...Object.keys(i.changes)]):new Set(Object.keys(i.changes));for(let c of l){let u=this.host.rule(c),g=u?Ye(u,o[c]):null;if(g)i.errors[c]=g;else delete i.errors[c]}return this.publish(t,i),Object.keys(i.errors).length===0}validateAll(t){let r=!0;for(let s of[...this.entries.keys()])if(!this.validate(s,t?.(s)??null,!1))r=!1;return r}async save(t,r,s=!1){let i=t===void 0?[...this.entries.keys()]:[t];return(await Promise.all(i.map((l)=>this.saveOne(l,r?.(l)??null,s,0)))).every(Boolean)}fresh(t,r){return{keyValue:t,base:r,kind:"update",changes:{},errors:{},conflicts:{},error:null,saving:!1,again:!1,view:de}}entry(t,r){let s=this.entries.get(t);if(!s)s=this.fresh(r?r[this.host.keyColumn]:null,r?{...r}:null),this.entries.set(t,s);return s}publish(t,r){let s=r.kind!=="update"||Object.keys(r.changes).length>0;if(r.kind==="update"&&!s&&!r.saving&&!r.error&&Object.keys(r.errors).length===0&&Object.keys(r.conflicts).length===0&&this.entries.get(t)===r)this.entries.delete(t);else r.view=Object.freeze({kind:r.kind,dirty:s,saving:r.saving,changes:Object.freeze({...r.changes}),errors:Object.freeze({...r.errors}),conflicts:Object.freeze({...r.conflicts}),error:r.error});this.publishAll()}publishAll(){let t={};for(let[r,s]of this.entries)t[r]=s.view;this.allView=Object.freeze(t),this.host.changed()}scheduled=new Set;schedule(t){if(this.scheduled.has(t))return;this.scheduled.add(t),Promise.resolve().then(()=>{this.scheduled.delete(t);let r=this.entries.get(t);if(!r)return;if(r.saving){r.again=!0;return}this.saveOne(t,null,!1,0)})}where(t){let{keyColumn:r,version:s}=this.host,i={[r]:t.keyValue};if(s&&t.base&&t.base[s]!==void 0&&t.base[s]!==null)i[s]=t.base[s];return i}async saveOne(t,r,s,i){let o=this.entries.get(t);if(!o)return!0;if(o.saving)return o.again=!0,!1;let l=this.host.mode()==="immediate";if(Object.keys(o.conflicts).length>0)return!1;if(!this.validate(t,r,s)){if(l&&o.kind==="update")this.rollback(t,o,o.errors[Object.keys(o.errors)[0]]??null);return!1}if(o.kind==="update"&&Object.keys(o.changes).length===0)return this.publish(t,o),!0;let{transport:c,table:u}=this.host;if(!c||!u){if(o.kind==="update"){let d={...o.base??{},...o.changes};this.entries.delete(t),this.host.commitLocal?.(t,d),this.publishAll()}return!0}let g={...o.changes};o.saving=!0,o.error=null,o.again=!1,this.publish(t,o);try{if(o.kind==="insert")return await this.sendInsert(t,o,g,c,u);if(o.kind==="delete")return await this.sendDelete(t,o,c,u,i);return await this.sendUpdate(t,o,g,c,u,i)}finally{let d=this.entries.get(t);if(d&&d.saving)d.saving=!1,this.publish(t,d);if(d&&d.again&&!d.saving&&this.entries.get(t)===d){if(d.again=!1,Object.keys(d.conflicts).length===0)this.saveOne(t,null,!1,0)}if(this.held.has(t)&&!this.entries.get(t)?.saving){let m=this.held.get(t)??null;this.held.delete(t),this.host.incoming?.(t,m)}}}fail(t,r,s,i){let o=L(s);if(r.saving=!1,o.code==="constraint"&&!o.field&&this.host.table){let l=Jn(o.message,this.host.table,Object.keys(i));if(l)o=new v("constraint",o.message,{...gt(o),field:l})}if(o.field&&o.field in i)r.errors[o.field]=o;else r.error=o.code==="forbidden"?new v("forbidden",o.message,{...gt(o),messageKey:"data.save_forbidden"}):o;if(this.host.mode()==="immediate"&&r.kind==="update")this.rollback(t,r,r.error??o);else this.publish(t,r);return!1}rollback(t,r,s){r.changes={},r.errors={},r.error=s,r.again=!1,this.publish(t,r)}async sendInsert(t,r,s,i,o){if(typeof i.insert!=="function")return this.fail(t,r,pt(i,"insert"),s);let l;try{l=await i.insert({table:o,values:s},Xe())}catch(c){return this.fail(t,r,c,s)}return this.inserted_(t,r,s,l)}inserted_(t,r,s,i){r.saving=!1;let o=i?.[this.host.keyColumn],l=this.host.insertedId?.(t)??Te(o);this.entries.delete(t);let c={};for(let[u,g]of Object.entries(r.changes))if(!P(g,s[u]))c[u]=g;if(Object.keys(c).length){let u=this.fresh(o,i);u.changes=c,this.entries.set(l,u)}return this.host.stored(l,i,t),this.publishAll(),!0}async sendDelete(t,r,s,i,o){if(typeof s.remove!=="function")return this.fail(t,r,pt(s,"remove"),{});let l;try{l=await s.remove({table:i,where:this.where(r)},Xe())}catch(g){return this.fail(t,r,g,{})}if(l.length>0)return this.entries.delete(t),this.host.removed(t),this.publishAll(),!0;let c=await this.readBack(r);if(c===void 0)return this.fail(t,r,new v("unknown","cannot read the row back"),{});if(c===null)return this.entries.delete(t),this.host.removed(t),this.publishAll(),!0;let u=this.host.version;if(u&&!P(c[u],r.base?.[u]))return r.conflicts={[Ge]:{mine:null,theirs:c,base:r.base}},r.base=c,r.saving=!1,r.error=new v("conflict","the row was changed before its deletion",{messageKey:"data.conflict"}),this.host.stored(t,c,t),this.publish(t,r),!1;return this.fail(t,r,new v("forbidden","nothing deleted: refused by the row security",{messageKey:"data.save_forbidden"}),{})}async sendUpdate(t,r,s,i,o,l){if(typeof i.update!=="function")return this.fail(t,r,pt(i,"update"),s);let c;try{c=await i.update({table:o,where:this.where(r),set:s},Xe())}catch(u){return this.fail(t,r,u,s)}if(c.length>0)return this.updated_(t,r,s,c[0]);if(!await this.explainUnmatched(t,r,s))return!1;if(Object.keys(r.changes).length===0)return!0;if(l+1>=Zn)return this.fail(t,r,new v("conflict","the row keeps changing"),s);return this.saveOne(t,null,!1,l+1)}updated_(t,r,s,i){for(let[o,l]of Object.entries(s))if(P(r.changes[o],l))delete r.changes[o];return r.base={...i},r.saving=!1,r.error=null,this.host.stored(t,i,t),this.publish(t,r),!0}async explainUnmatched(t,r,s){let i=await this.readBack(r);if(i===void 0)return this.fail(t,r,new v("unknown","nothing written and the row cannot be read back"),s);if(i===null)return this.fail(t,r,new v("not_found","nothing written: the row no longer exists or is not visible",{messageKey:"data.save_not_found"}),{});let o=this.host.version;if(!o||P(i[o],r.base?.[o]))return this.fail(t,r,new v("forbidden","nothing written: refused by the row security",{messageKey:"data.save_forbidden"}),{});if(this.compare(r,i),r.saving=!1,this.host.stored(t,i,t),Object.keys(r.conflicts).length>0)return r.error=Gt(r),this.publish(t,r),!1;return this.publish(t,r),!0}batchSent=new Map;batchPrepare(t){let r=this.host.table,s=[],i=[],o=!0;for(let[l,c]of[...this.entries]){if(!c.view.dirty||c.saving)continue;if(Object.keys(c.conflicts).length>0||!this.validate(l,t(l),!1)){o=!1;continue}if(!r)continue;if(c.kind==="insert")s.push({op:"create",table:r,values:{...c.changes}});else if(c.kind==="delete")s.push({op:"destroy",table:r,where:this.where(c),expect:"one"});else if(Object.keys(c.changes).length>0)s.push({op:"update",table:r,where:this.where(c),set:{...c.changes},expect:"one"});else continue;i.push(l)}return o?{operations:s,ids:i}:null}batchStart(t){for(let r of t){let s=this.entries.get(r);if(!s)continue;this.batchSent.set(r,{...s.changes}),s.saving=!0,s.error=null,s.again=!1,this.publish(r,s)}}batchDone(t,r){let s=this.entries.get(t),i=this.batchSent.get(t)??{};if(this.batchSent.delete(t),!s)return;if(s.kind==="insert"){if(r[0])this.inserted_(t,s,i,r[0]);return}if(s.kind==="delete"){s.saving=!1,this.entries.delete(t),this.host.removed(t),this.publishAll();return}if(r[0])this.updated_(t,s,i,r[0])}async batchFailed(t,r,s){let i=this.entries.get(t),o=this.batchSent.get(t)??{};if(this.batchSent.delete(t),!i)return;if(i.saving=!1,!s){this.publish(t,i);return}if(r.code==="conflict"&&i.kind!=="insert")if(i.kind==="delete"){let l=await this.readBack(i);if(l&&this.host.version&&!P(l[this.host.version],i.base?.[this.host.version])){i.conflicts={[Ge]:{mine:null,theirs:l,base:i.base}},i.base=l,i.error=new v("conflict","the row was changed before its deletion",{messageKey:"data.conflict"}),this.host.stored(t,l,t),this.publish(t,i);return}}else if(await this.explainUnmatched(t,i,o)){i.error=new v("conflict","the row was changed meanwhile: send again",{messageKey:"data.conflict"}),this.publish(t,i);return}else return;if(i.error=r.code==="forbidden"?new v("forbidden",r.message,{...gt(r),messageKey:"data.save_forbidden"}):r,r.field&&r.field in o)i.errors[r.field]=r,i.error=null;this.publish(t,i)}async readBack(t){let{transport:r,table:s,keyColumn:i}=this.host;if(!r?.findOne||!s)return;try{return await r.findOne({table:s,where:{[i]:t.keyValue}},Xe())??null}catch{return}}}var Gt=(t)=>new v("conflict","the row was changed meanwhile",{params:{count:Object.keys(t.conflicts).length}});function Jn(t,r,s){let i=/constraint "([^"]+)"/.exec(t)?.[1];if(!i)return;let o=r.split(".").pop();return s.find((l)=>i===`${o}_${l}_check`||i===`${o}_${l}_key`||i===`${o}_${l}_fkey`)}var pt=(t,r)=>new v("read_only",`transport "${t.name}" cannot ${r}`),gt=(t)=>({...t.status!==void 0?{status:t.status}:{},...t.sourceCode!==void 0?{sourceCode:t.sourceCode}:{},cause:t.cause??t});var Vn=(t)=>t.type==="list"?t.get().rows:t.get().value,Pe=(t,r)=>t.type==="list"&&r.length>0&&typeof r[0]==="string",Un=Object.freeze({writable:!1,dirty:!1,saving:!1,error:null,conflict:null});class Xt{store;path;cell;statusCell;stopStore=null;stopStatus=null;status;constructor(t,r){this.store=t,this.path=r,this.cell=new Y(this.compute(),{start:()=>{if(Pe(t,r)&&t.type==="list")t.useCursor();this.sync(),this.stopStore=t.subscribe(()=>this.sync())},stop:()=>{this.stopStore?.(),this.stopStore=null}}),this.statusCell=new Y(this.computeStatus(),{start:()=>{this.syncStatus(),this.stopStatus=t.subscribe(()=>this.syncStatus())},stop:()=>{this.stopStatus?.(),this.stopStatus=null}});let s=this.statusCell;this.status={get:()=>{if(!s.observed)this.syncStatus();return s.get()},subscribe:(i)=>s.subscribe(i)}}get writable(){let t=this.path;if(this.store.type==="record")return t.length>=1;if(Pe(this.store,t))return!0;return t.length>=2&&typeof t[0]==="number"&&typeof t[1]==="string"}compute(){if(Pe(this.store,this.path)&&this.store.type==="list"){let t=this.store.get().current.row;return t===null?void 0:W(t,this.path)}return W(Vn(this.store),this.path)}sync(){let t=this.compute();if(!P(t,this.cell.get()))this.cell.set(t)}target(){let t=this.path;if(this.store.type==="record"){if(t.length===0)return null;let o=this.store.get();return{edit:o.edit,column:String(t[0]),id:null,original:W(o.original,t)}}if(Pe(this.store,t)){let o=this.store.get(),l=o.current.row;if(l===null)return null;let c=this.store.keyOf(l);return{edit:o.edits[c]??de,column:String(t[0]),id:c,original:void 0}}if(t.length<2||typeof t[0]!=="number")return null;let r=this.store.get(),s=r.rows[t[0]];if(s===void 0)return null;let i=this.store.keyOf(s);return{edit:r.edits[i]??de,column:String(t[1]),id:i,original:void 0}}computeStatus(){let t=this.target();if(!t)return Un;let{edit:r,column:s}=t,i=s in r.changes||r.kind==="insert";if(i&&this.store.type==="record"&&this.path.length>1)i=!P(this.compute(),t.original);return{writable:this.writable,dirty:i,saving:r.saving,error:r.errors[s]??(i?r.error:null),conflict:r.conflicts[s]??null}}syncStatus(){let t=this.computeStatus(),r=this.statusCell.get();if(r.writable===t.writable&&r.dirty===t.dirty&&r.saving===t.saving&&r.error===t.error&&r.conflict===t.conflict)return;this.statusCell.set(t)}get(){if(!this.cell.observed)this.sync();return this.cell.get()}subscribe(t){return this.cell.subscribe(t)}set(t){if(!this.writable)throw new v("read_only",`field "${ue(this.path)||"*"}" cannot be changed (give a field of a record, or "rows.<index>.<column>")`,{path:"field"});if(this.store.type==="record"){this.store.set(this.path,t);return}let r=this.target();if(Pe(this.store,this.path)){if(!r?.id)throw new v("read_only","no current record: move the cursor first (first(), next()…)",{path:"field"});this.store.set(r.id,this.path,t);return}if(!r?.id)throw new v("read_only",`no row at index ${String(this.path[0])}`,{path:"field"});this.store.set(r.id,this.path.slice(1),t)}resolve(t){let r=this.target();if(!r)return;if(this.store.type==="record")this.store.resolve([this.path[0]],t);else if(r.id)this.store.resolve(r.id,r.column,t)}revert(){let t=this.target();if(!t)return;if(this.store.type==="record")this.store.revert([this.path[0]]);else if(t.id)this.store.revert(t.id,t.column)}toString(){return`field(${ue(this.path)||"*"})`}}function Oe(t,r){return new Xt(t,K(r))}var Ht=["eq","ne","gt","gte","lt","lte","in","notIn","like","ilike","notLike","notIlike","is","not","between","notBetween","contains","containedBy","overlap","match"],Yn=new Set(Ht),Gn=/^:([A-Za-z_][A-Za-z0-9_]{0,62})$/,Xn=/^[A-Za-z_][A-Za-z0-9_]{0,62}$/,mt=(t)=>typeof t==="string"?Gn.exec(t)?.[1]??null:null;function Hn(t,r){if(typeof t!=="string"||!Yn.has(t))throw new v("unknown_operator",`unknown operator "${String(t)}" at ${r}: expected one of ${Ht.join(", ")}`,{path:r,params:{operator:String(t)}});return t}function yt(t,r,s){let i=Hn(r,t),o={[t]:{[i]:s}};return re(o,"where"),o}function Qt(t,r){if(!t)return t;let s=(i)=>{if(Array.isArray(i))return i.map(s);if(i&&typeof i==="object")return Object.fromEntries(Object.entries(i).map(([o,l])=>[o,s(l)]));if(typeof i==="string"){let o=mt(i);if(o){if(!(o in r)||r[o]===void 0)throw new v("missing_param",`the parameter ":${o}" has no value: load({ ${o}: … })`,{path:o,params:{name:o}});return r[o]}if(i.startsWith("::"))return i.slice(1)}return i};return s(t)}function xe(t,r){if(!t||Object.keys(t).length===0)return r;let s=(u,g)=>JSON.stringify(u)===JSON.stringify(g),i=(u)=>("and"in u)||("or"in u)||("not"in u),o=r,l=t.and&&Object.keys(t).length===1?[...t.and]:[t],c=(u)=>s(u,r)||!i(u)&&!i(o)&&Object.keys(o).every((g)=>(g in u)&&s(u[g],o[g]));if(l.some(c))return t;if(!i(o)){if(l.findIndex((g)=>!i(g)&&Object.keys(o).every((d)=>!(d in g)))===0){let g={...l[0],...o};return l.length===1?g:{and:[g,...l.slice(1)]}}}return{and:[...l,r]}}function he(t){let r=[],s={where(i,o,l){return r.push(yt(i,o,l)),s},and(i){return r.push(pe("and",he(i))),s},or(i){return r.push(pe("or",he(i))),s},not(i){return r.push({not:pe("and",he(i))}),s}};if(t(s),r.length===0)throw new v("invalid_description","an empty group: write at least one .where(…) inside",{path:"where"});return r}function pe(t,r){if(r.length===1)return r[0];return t==="and"?{and:r}:{or:r}}function qt(t){if(typeof t!=="string")throw new v("invalid_description",'select expects a text: "a, b, relation(c, d)"',{path:"select"});let r=0,s=(u)=>{throw new v("invalid_description",`invalid select at ${r}: ${u}`,{path:"select"})},i=()=>{while(r<t.length&&/\s/.test(t[r]))r++},o=()=>{if(i(),t[r]==="*")return r++,"*";let u=/^[A-Za-z_][A-Za-z0-9_]{0,62}/.exec(t.slice(r));if(!u)return s("expected a column name");return r+=u[0].length,u[0]},l=(u)=>{if(u>8)s("relations nested too deeply");let g=[],d=!1,m={};for(;;){let y=o();if(i(),t[r]==="("){if(y==="*")s('"*" has no columns');r++;let k=l(u+1);if(i(),t[r]!==")")s('expected ")"');r++,m[y]={select:k.select,...Object.keys(k.include).length?{include:k.include}:{}}}else if(y==="*")d=!0;else if(!g.includes(y))g.push(y);if(i(),t[r]===","){r++;continue}break}return{select:d?"*":g,include:m}},c=l(0);if(i(),r<t.length)s(`unexpected "${t[r]}"`);if(c.select!=="*"&&c.select.length===0)return{select:"*",include:c.include};return{select:c.select,...Object.keys(c.include).length?{include:c.include}:{}}}function er(t,r="asc"){if(typeof t!=="string"||!Xn.test(t))throw new v("invalid_description",`invalid order column "${String(t)}"`,{path:"order"});if(r!=="asc"&&r!=="desc")throw new v("invalid_description",'order direction: "asc" or "desc"',{path:"order"});return r==="asc"?t:[t,r]}function tr(t,r){let s=typeof r==="string"?r:r[0];return[...(t??[]).filter((o)=>(typeof o==="string"?o:o[0])!==s),r]}var lr=20,ne=1000,cr=["save","version","fields","realtime"],Qn=new Set(["type","table","select","where","order","pageSize","include","search","keyColumn","reference","parent","cursor","params","dependsOn","autoLoad","aggregate",...cr]),qn=new Set(["group","count","sum","avg","min","max"]),ur=/^[A-Za-z_][A-Za-z0-9_]{0,62}$/,fr=/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/,es=new Set(["select","where","order","limit","required","count","include"]),rr=new Set(["eq","ne","gt","gte","lt","lte"]),nr=new Set(["in","notIn"]),sr=new Set(["like","ilike","notLike","notIlike","match"]),ir=new Set(["between","notBetween"]),or=new Set(["is","not"]),ar=new Set(["contains","containedBy","overlap"]),dr=/^[A-Za-z_][A-Za-z0-9_]{0,62}$/,ts=/^([A-Za-z_][A-Za-z0-9_]{0,62}\.)?[A-Za-z_][A-Za-z0-9_]{0,62}$/,rs=/^[A-Za-z_][A-Za-z0-9_]{0,62}(\.[A-Za-z0-9_]{1,63})+$/,A=(t,r)=>{throw new v("invalid_description",`invalid list description at ${t}: ${r}`,{path:t})},J=(t)=>typeof t==="object"&&t!==null&&!Array.isArray(t)&&(Object.getPrototypeOf(t)===Object.prototype||Object.getPrototypeOf(t)===null),ge=(t)=>t===null||typeof t==="string"||typeof t==="boolean"||typeof t==="number"&&Number.isFinite(t);function He(t,r,s=0){if(s>32)A(r,"value nested too deeply");if(ge(t))return;if(Array.isArray(t))return t.forEach((i,o)=>He(i,`${r}[${o}]`,s+1));if(J(t))return Object.entries(t).forEach(([i,o])=>He(o,`${r}.${i}`,s+1));A(r,"not a JSON value")}function X(t,r){if(typeof t!=="string"||!dr.test(t))A(r,"expected a column name");return t}function wt(t,r){if(t==="*")return"*";if(!Array.isArray(t)||t.length===0)return A(r,'expected "*" or a non-empty array of column names');return t.map((s,i)=>X(s,`${r}[${i}]`))}function hr(t,r){if(!Array.isArray(t))return A(r,'expected an array of "column" or ["column", "asc" | "desc"]');return t.map((s,i)=>{let o=`${r}[${i}]`;if(typeof s==="string")return X(s,o);if(!Array.isArray(s)||s.length!==2)return A(o,'expected "column" or ["column", "asc" | "desc"]');let[l,c]=s;if(c!=="asc"&&c!=="desc")A(`${o}[1]`,'expected "asc" or "desc"');return[X(l,`${o}[0]`),c]})}function ns(t,r){if(ge(t))return;if(Array.isArray(t))return t.forEach((i,o)=>ge(i)?void 0:A(`${r}[${o}]`,"expected a scalar"));if(!J(t))return A(r,"expected a value, an array or an object of operators");let s=Object.entries(t);if(s.length===0)A(r,"empty condition");for(let[i,o]of s){let l=`${r}.${i}`;if(mt(o)&&(rr.has(i)||nr.has(i)||sr.has(i)||ir.has(i)||or.has(i)||ar.has(i)))continue;if(rr.has(i)){if(!ge(o))A(l,"expected a scalar")}else if(nr.has(i)){if(!Array.isArray(o)||!o.every(ge))A(l,"expected an array of scalars")}else if(sr.has(i)){if(typeof o!=="string")A(l,"expected a string")}else if(ir.has(i)){if(!Array.isArray(o)||o.length!==2||!o.every(ge))A(l,"expected [low, high]")}else if(or.has(i)){if(o!==null&&typeof o!=="boolean")A(l,"expected null, true or false")}else if(ar.has(i)){if(i==="overlap"&&!Array.isArray(o))A(l,"expected an array");He(o,l)}else throw new v("unknown_operator",`invalid list description at ${l}: unknown operator`,{path:l,params:{operator:i}})}}function re(t,r="where",s=0){if(s>16)A(r,"filter nested too deeply");if(!J(t))return A(r,"expected an object");for(let[i,o]of Object.entries(t)){let l=`${r}.${i}`;if(i==="and"||i==="or"){if(!Array.isArray(o)||o.length===0)A(l,"expected a non-empty array of filters");o.forEach((c,u)=>re(c,`${l}[${u}]`,s+1))}else if(i==="not")re(o,l,s+1);else if(dr.test(i)||rs.test(i))ns(o,l);else A(l,"expected a column name, a JSON path or and / or / not")}return t}function St(t,r,s=0){if(s>8)A(r,"relations nested too deeply");if(Array.isArray(t)){if(t.length===0)A(r,"empty array");return t.map((i,o)=>X(i,`${r}[${o}]`))}if(!J(t))return A(r,"expected an array of relations or an object");for(let[i,o]of Object.entries(t)){let l=`${r}.${i}`;if(X(i,l),typeof o==="boolean")continue;if(!J(o))A(l,"expected true, false or an object");for(let[c,u]of Object.entries(o)){let g=`${l}.${c}`;if(!es.has(c))A(g,"unknown key");if(c==="select")wt(u,g);else if(c==="where")re(u,g);else if(c==="order")hr(u,g);else if(c==="limit")pr(u,g,ne);else if(c==="required"||c==="count"){if(typeof u!=="boolean")A(g,"expected true or false")}else St(u,g,s+1)}}return t}function pr(t,r,s){if(typeof t!=="number"||!Number.isInteger(t)||t<1||t>s)A(r,`expected an integer between 1 and ${s}`);return t}function se(t){if(!J(t))return A("$","expected an object");if("kind"in t)A("kind",'a description has no "kind" (a store object has kind "store")');for(let i of Object.keys(t))if(!Qn.has(i))A(i,"unknown key");if(t.type!==void 0&&t.type!=="list")A("type",'expected "list"');let r=mr(t.table),s=t.type==="list"?{type:"list",table:r}:{table:r};if(t.select!==void 0)s.select=wt(t.select,"select");if(t.where!==void 0)s.where=re(t.where);if(t.order!==void 0)s.order=hr(t.order,"order");if(t.pageSize!==void 0)s.pageSize=pr(t.pageSize,"pageSize",ne);if(t.include!==void 0)s.include=St(t.include,"include");if(t.search!==void 0){let i=t.search;if(!Array.isArray(i)||i.length===0)A("search","expected a non-empty array of column names");s.search=i.map((o,l)=>X(o,`search[${l}]`))}if(t.keyColumn!==void 0)s.keyColumn=X(t.keyColumn,"keyColumn");if(t.reference!==void 0){if(typeof t.reference!=="boolean")A("reference","expected true or false");s.reference=t.reference}if(t.parent!==void 0){let i=t.parent;if(!J(i))A("parent",'expected { "store": "…", "column": "…" }');let o=i;for(let l of Object.keys(o))if(l!=="store"&&l!=="column")A(`parent.${l}`,"unknown key");if(typeof o.store!=="string"||!fr.test(o.store))A("parent.store","expected a store name");if(s.parent={store:o.store,column:X(o.column,"parent.column")},s.reference)A("parent","a reference store has no parent")}if(t.cursor!==void 0){if(t.cursor!=="first"&&t.cursor!=="last"&&t.cursor!=="none")A("cursor",'expected "first", "last" or "none"');s.cursor=t.cursor}if(t.params!==void 0)s.params=ss(t.params);if(t.dependsOn!==void 0)s.dependsOn=gr(t.dependsOn);if(t.autoLoad!==void 0){if(typeof t.autoLoad!=="boolean")A("autoLoad","expected true or false");s.autoLoad=t.autoLoad}if(t.aggregate!==void 0)s.aggregate=is(t.aggregate);return bt(t,s),s}function ss(t){if(!J(t))return A("params",'expected { "name": value }');for(let[r,s]of Object.entries(t)){if(!ur.test(r))A(`params.${r}`,"expected a parameter name");if(!ge(s))A(`params.${r}`,"expected a scalar")}return t}function gr(t,r="dependsOn"){let s=(i,o)=>{if(!J(i))return A(o,'expected { "store": "…", "field": "…", "param": "…" }');for(let l of Object.keys(i))if(l!=="store"&&l!=="field"&&l!=="param")A(`${o}.${l}`,"unknown key");if(typeof i.store!=="string"||!fr.test(i.store))A(`${o}.store`,"expected a store name");if(typeof i.field!=="string"||!/^[A-Za-z_][A-Za-z0-9_]{0,62}(\.[A-Za-z0-9_]{1,63})*$/.test(i.field))A(`${o}.field`,"expected a field path");if(typeof i.param!=="string"||!ur.test(i.param))A(`${o}.param`,"expected a parameter name");return i};if(Array.isArray(t)){if(t.length===0)A(r,"expected a non-empty array");return t.map((i,o)=>s(i,`${r}[${o}]`))}return s(t,r)}function is(t){if(!J(t))return A("aggregate",'expected { "group"?: [...], "count"?: true, "sum"?: [...], … }');for(let[s,i]of Object.entries(t)){let o=`aggregate.${s}`;if(!qn.has(s))throw new v("unknown_operator",`invalid list description at ${o}: unknown aggregate`,{path:o,params:{operator:s}});if(s==="count"){if(typeof i!=="boolean")A(o,"expected true or false")}else if(!Array.isArray(i)||i.length===0)A(o,"expected a non-empty array of column names");else i.forEach((l,c)=>X(l,`${o}[${c}]`))}let r=t;if(!r.count&&!r.sum&&!r.avg&&!r.min&&!r.max)A("aggregate","expected at least one of count, sum, avg, min, max");return r}function bt(t,r){if(t.save!==void 0){if(t.save!=="batch"&&t.save!=="immediate")A("save",'expected "batch" or "immediate"');r.save=t.save}if(t.version!==void 0)r.version=X(t.version,"version");if(t.realtime!==void 0){if(typeof t.realtime!=="boolean")A("realtime","expected true or false");r.realtime=t.realtime}if(t.fields!==void 0){try{te(t.fields,{at:"fields"})}catch(s){let i=s.path??"fields";A(i,s.message.replace(/^invalid field at [^:]+: /,""))}r.fields=t.fields}}function mr(t){if(typeof t!=="string"||!ts.test(t))A("table",'expected a table name ("clients" or "schema.clients")');return t}var os=new Set(["type","table","key","keyColumn","select","include","dependsOn","autoLoad",...cr]);function ze(t){if(!J(t))return A("$","expected an object");if("kind"in t)A("kind",'a description has no "kind" (a store object has kind "store")');if(t.type!=="record")A("type",'expected "record"');if("value"in t){for(let l of Object.keys(t))if(l!=="type"&&l!=="value"&&l!=="fields"&&l!=="save")A(l,'unknown key (a local record has only "value", "fields" and "save")');let i=t.value;if(!J(i)&&!Array.isArray(i))A("value","expected a JSON object or array");He(i,"value");let o={type:"record",value:i};return bt(t,o),o}for(let i of Object.keys(t))if(!os.has(i))A(i,"unknown key");let r={type:"record",table:mr(t.table)},s=t.key;if(s!==void 0){if(!(typeof s==="string"&&s.length>0)&&!(typeof s==="number"&&Number.isFinite(s)))A("key","expected a non-empty string or a number");r.key=s}if(t.keyColumn!==void 0)r.keyColumn=X(t.keyColumn,"keyColumn");if(t.select!==void 0)r.select=wt(t.select,"select");if(t.include!==void 0)r.include=St(t.include,"include");if(t.dependsOn!==void 0){r.dependsOn=gr(t.dependsOn);for(let i of[r.dependsOn].flat())if(i.param!=="key")A("dependsOn.param",'a record follows its key: "param": "key"')}if(t.autoLoad!==void 0){if(typeof t.autoLoad!=="boolean")A("autoLoad","expected true or false");r.autoLoad=t.autoLoad}return bt(t,r),r}function vt(t){if(J(t)&&t.type==="record")return ze(t);return se(t)}var Qe=(t)=>(t??[]).map((r)=>typeof r==="string"?{column:r,direction:"asc"}:{column:r[0],direction:r[1]});var yr=(t)=>!!t.rules||t.type==="enum";class Le{own;sources=[];constructor(t){this.own=t?te(t):[]}all(){return[...this.own,...this.sources.flat()].filter((t)=>!t.field.includes("."))}rule(t){let r=this.all().filter((s)=>s.field===t);return r.find(yr)??r[0]}ruled(){return[...new Set(this.all().filter(yr).map((t)=>t.field))]}use(t){this.sources.push(t);let r=!1;return()=>{if(r)return;r=!0;let s=this.sources.indexOf(t);if(s>=0)this.sources.splice(s,1)}}versionColumn(){return this.all().find((t)=>t.roles.includes("version"))?.field}path(t){return K(t)}declared(){return this.own}}var et=(t,r)=>!r||r==="*"?t:Object.fromEntries(r.map((s)=>[s,t[s]])),wr=(t,r)=>{if(t===r)return 0;if(t===null||t===void 0)return 1;if(r===null||r===void 0)return-1;return t<r?-1:1};function as(t,r){if(r.length===0)return t;return[...t].sort((s,i)=>{for(let o of r){let l=wr(s[o.column],i[o.column]);if(l!==0)return o.direction==="asc"?l:-l}return 0})}function qe(t,r){let s="";for(let i=0;i<t.length;i++){let o=t[i];if(o==="\\"&&i+1<t.length)s+=t[++i].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(o==="%")s+=".*";else if(o==="_")s+=".";else s+=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}return new RegExp("^"+s+"$",r+"s")}function ls(t,r){let s=r.term.toLowerCase();return r.columns.some((i)=>String(t[i]??"").toLowerCase().includes(s))}function ie(t,r){return Object.entries(r).every(([s,i])=>{if(i===void 0)return!0;if(s==="and")return i.every((o)=>ie(t,o));if(s==="or")return i.some((o)=>ie(t,o));if(s==="not")return!ie(t,i);return cs(t[s],i)})}var br=/^\d{4}-\d{2}-\d{2}T/,_e=(t,r)=>{if(typeof t==="string"&&typeof r==="string"&&br.test(t)&&br.test(r))return Date.parse(t)-Date.parse(r);return wr(t,r)},I=(t)=>t===null||t===void 0;function cs(t,r){if(r===null)return I(t);if(Array.isArray(r))return r.includes(t);if(typeof r!=="object")return t===r;return Object.entries(r).every(([s,i])=>{switch(s){case"eq":return i===null?I(t):!I(t)&&t===i;case"ne":return!I(t)&&t!==i;case"gt":return!I(t)&&_e(t,i)>0;case"gte":return!I(t)&&_e(t,i)>=0;case"lt":return!I(t)&&_e(t,i)<0;case"lte":return!I(t)&&_e(t,i)<=0;case"between":return!I(t)&&_e(t,i[0])>=0&&_e(t,i[1])<=0;case"in":return!I(t)&&i.includes(t);case"notIn":return!I(t)&&!i.includes(t);case"like":return!I(t)&&qe(i,"").test(String(t));case"ilike":return!I(t)&&qe(i,"i").test(String(t));case"notLike":return!I(t)&&!qe(i,"").test(String(t));case"notIlike":return!I(t)&&!qe(i,"i").test(String(t));case"is":return i===null?I(t):t===i;case"not":return i===null?!I(t):t!==i;default:throw Error(`fake transport: operator "${s}" is not supported`)}})}function us(t,r){let s=new Map;for(let l of t){let c=JSON.stringify((r.group??[]).map((u)=>l[u]??null));s.set(c,[...s.get(c)??[],l])}if(!r.group&&s.size===0)s.set("[]",[]);let i=(l,c)=>l.map((u)=>u[c]).filter((u)=>typeof u==="number"),o=[...s.entries()].map(([l,c])=>{let u={};if((r.group??[]).forEach((d,m)=>u[d]=JSON.parse(l)[m]),r.count)u.count=c.length;let g=(d,m,y)=>{if(m)u[d]=Object.fromEntries(m.map((k)=>[k,y(i(c,k))]))};return g("sum",r.sum,(d)=>d.length?d.reduce((m,y)=>m+y,0):null),g("avg",r.avg,(d)=>d.length?d.reduce((m,y)=>m+y,0)/d.length:null),g("min",r.min,(d)=>d.length?Math.min(...d):null),g("max",r.max,(d)=>d.length?Math.max(...d):null),u});if(r.order?.length){let l=(c,u)=>u.includes(".")?c[u.split(".")[0]]?.[u.split(".")[1]]:c[u];o=[...o].sort((c,u)=>{for(let g of r.order){let d=l(c,g.column),m=l(u,g.column);if(d===m)continue;let y=d<m?-1:1;return g.direction==="asc"?y:-y}return 0})}return r.limit?o.slice(0,r.limit):o}function Fe(t,r){return t.filter((s)=>(!r.where||ie(s,r.where))&&(!r.search||ls(s,r.search)))}function kt(t,r){return as([...Fe(t,r)],r.order).slice(r.offset,r.offset+r.limit).map((s)=>et(s,r.select))}function Sr(t,r={}){let s=t.map((l)=>({...l})),i=r.keyColumn??"id",o=()=>s.reduce((l,c)=>Math.max(l,typeof c[i]==="number"?c[i]:0),0)+1;return{name:r.name??"memory",rows:()=>s,async find(l,c){return kt(s,l)},async count(l,c){return Fe(s,l).length},async findOne(l,c){let u=s.find((g)=>ie(g,l.where));return u?et(u,l.select):null},async insert(l,c){let u={[i]:o(),...l.values};return s=[...s,u],u},async update(l,c){let u=[];return s=s.map((g)=>{if(!ie(g,l.where))return g;let d={...g,...l.set};return u.push(d),d}),u},async remove(l,c){let u=s.filter((g)=>ie(g,l.where));return s=s.filter((g)=>!u.includes(g)),u},async aggregate(l,c){return us(Fe(s,l),l)}}}var H=(t)=>typeof t==="object"&&t!==null&&typeof t.setArgs==="function"&&typeof t.fn==="string",tt=(t)=>Array.isArray(t)?t:t&&typeof t==="object"&&Array.isArray(t.rows)?t.rows:t&&typeof t==="object"?[t]:[];function vr(t,r,s,i={}){let o=i.args,l=null,c=null,u=(d,m)=>{if(typeof t.call!=="function")return Promise.reject(new v("read_only",`transport "${t.name}" cannot call functions (no call())`));let y=d?{...o??{},...d}:o,k=JSON.stringify(y??null);if(l&&l.key===k)return l.promise;let x=t.call({kind:r,name:s,...y!==void 0?{args:y}:{}},m),R={key:k,promise:x};l=R;let j=()=>{if(l===R)l=null};return x.then(j,j),x},g=(d)=>({...d.limit!==void 0?{limit:d.limit,offset:d.offset??0}:{},...d.order&&d.order.length?{order:d.order.map((m)=>[m.column,m.direction])}:{},...d.where?{where:d.where}:{},...d.search?{search:d.search}:{}});return{name:`${t.name}:${r}`,kind:r,fn:s,args:()=>o,setArgs(d){o=d,l=null},async find(d,m){if(i.server)return c=g(d),tt(await u(c,m)).map((y)=>et(y,d.select));return kt(tt(await u(null,m)),d)},async count(d,m){if(i.server){let y=await u(c??g(d),m),k=y&&typeof y==="object"&&!Array.isArray(y)?y.total:void 0;return typeof k==="number"?k:tt(y).length}return Fe(tt(await u(null,m)),d).length},async findOne(d,m){let y=await u(null,m);if(y===null||y===void 0)return null;if(!Array.isArray(y))return y;return(Object.keys(d.where).length?y.find((x)=>ie(x,d.where)):void 0)??y[0]??null}}}var kr=["beforeload","load","beforesave","saved","change","error","current"],Or=(t,r)=>globalThis.console?.error(`@poadio/data: a "${t}" listener failed`,r);class Ie{listeners=new Map;on(t,r){if(!kr.includes(t))throw TypeError(`unknown store event "${String(t)}": ${kr.join(", ")}`);if(typeof r!=="function")throw TypeError("a store event listener is a function");let s=this.listeners.get(t);if(!s)this.listeners.set(t,s=new Set);let i=r;return s.add(i),()=>void s.delete(i)}has(t){return(this.listeners.get(t)?.size??0)>0}emit(t,r){let s=this.listeners.get(t);if(!s)return;for(let i of[...s])try{i(r)}catch(o){Or(t,o)}}before(t,r){let s=this.listeners.get(t),i={};if(!s)return i;for(let o of[...s]){let l;try{l=o(r)}catch(c){Or(t,c);continue}if(l===!1)return!1;if(l&&typeof l==="object"&&!Array.isArray(l))Object.assign(i,l)}return i}}var fs={setTimeout:(t,r)=>Z.setTimeout(t,r),clearTimeout:(t)=>Z.clearTimeout(t)},Me=(t,r)=>t===null?1:Math.max(1,Math.ceil(t/r)),Ae=(t,r)=>JSON.stringify(t)===JSON.stringify(r);class _r{transport;kind="store";type="list";description;state;events=new Ie;debounceMs;scheduler;seq=0;controller=null;timer=null;stale=!0;countKey=null;waiters=[];mode;keyColumn;fields;baseRows=[];writer;constructor(t,r){this.transport=t;let{debounceMs:s,scheduler:i,realtimeDebounceMs:o,parentStore:l,...c}=r;if(this.realtimeDebounceMs=o??250,this.description=se(c),s!==void 0&&(!Number.isFinite(s)||s<0))throw new v("invalid_description","debounceMs must be a non-negative number",{path:"debounceMs"});if(this.debounceMs=s??300,this.scheduler=i??fs,this.mode=this.description.save??(this.description.parent?"batch":"immediate"),l)this.linkParent(()=>l);this.keyColumn=this.description.keyColumn??"id",this.fields=new Le(this.description.fields);let u=this;this.writer=new De({table:this.description.table,keyColumn:this.keyColumn,get version(){return u.description.version??u.fields.versionColumn()??null},transport:t,mode:()=>this.mode,rule:(d)=>this.fields.rule(d),ruled:()=>this.fields.ruled(),changed:()=>this.publishRows(),stored:(d,m,y)=>{this.stored(d,m,y),this.emitWrite({event:y!==d?"insert":"update",table:this.description.table,record:m})},removed:(d)=>{let m=this.baseRows.find((y)=>this.keyOf(y)===d)?.[this.keyColumn];this.removed(d),this.emitWrite({event:"delete",table:this.description.table,old:{[this.keyColumn]:m??JSON.parse(d)}})},incoming:(d,m)=>this.receiveRow(d,m)});let g=this.description.pageSize??(this.description.reference?ne:lr);if(this.state=new Y({rows:[],total:null,page:1,pageSize:g,pageCount:1,order:Qe(this.description.order),filters:{},search:"",searchColumns:this.description.search??[],status:"idle",error:null,edits:this.writer.all(),dirty:!1,saving:!1,realtime:"off",current:ds,filtered:!1,params:{...this.description.params??{}},totals:null},{start:()=>this.start(),stop:()=>this.stop()}),this.cursorActive=this.description.cursor!==void 0,this.description.autoLoad)Promise.resolve().then(()=>this.keepAlive())}get(){return this.state.get()}subscribe(t){return this.state.subscribe(t)}toJSON(){throw new v("not_serializable","a data store cannot be serialised: pass its JSON description instead")}setPage(t){let r=Math.max(1,Math.floor(Number.isFinite(t)?t:1));if(r===this.get().page)return;this.change({page:r})}setPageSize(t){if(!Number.isInteger(t)||t<1||t>ne)throw new v("invalid_description",`pageSize must be an integer between 1 and ${ne}`,{path:"pageSize"});if(t===this.get().pageSize)return;this.change({pageSize:t,page:1})}setOrder(t){let r=this.toSorts(t);if(Ae(r,this.get().order))return;this.change({order:r,page:1})}toSorts(t){let r=t.map((s)=>typeof s==="string"||Array.isArray(s)?Qe([s])[0]:s);return se({table:this.description.table,order:r.map((s)=>[s.column,s.direction])}),r}checkColumns(t){return se({table:this.description.table,search:[...t]}),[...t]}setSearchColumns(t){let r=t===null?this.description.search??[]:t.length?this.checkColumns(t):[];if(Ae(r,this.get().searchColumns))return;if(!this.get().search.trim()){this.put({...this.get(),searchColumns:r});return}this.change({searchColumns:r,page:1})}update(t){let r=this.get(),s={},i=!1;if(t.pageSize!==void 0&&t.pageSize!==r.pageSize){if(!Number.isInteger(t.pageSize)||t.pageSize<1||t.pageSize>ne)throw new v("invalid_description",`pageSize must be an integer between 1 and ${ne}`,{path:"pageSize"});s.pageSize=t.pageSize,i=!0}if(t.order!==void 0){let l=this.toSorts(t.order);if(!Ae(l,r.order))s.order=l,i=!0}if(t.filters!==void 0){if(re(t.filters,"filters"),!Ae(t.filters,r.filters))s.filters={...t.filters},i=!0}if(t.searchColumns!==void 0){let l=t.searchColumns===null?this.description.search??[]:t.searchColumns.length?this.checkColumns(t.searchColumns):[];if(!Ae(l,r.searchColumns)){if(s.searchColumns=l,r.search.trim()||(t.search??"").trim())i=!0}}if(t.search!==void 0&&t.search!==r.search){if(s.search=t.search,t.search.trim()!==r.search.trim())i=!0}if(t.page!==void 0){let l=Math.max(1,Math.floor(Number.isFinite(t.page)?t.page:1));if(l!==r.page)s.page=l}else if(i&&r.page!==1)s.page=1;if(Object.keys(s).length===0)return;if(!(Object.keys(s).some((l)=>l!=="search")||(s.search??r.search).trim()!==r.search.trim())){this.put({...r,...s});return}this.change(s)}toggleSort(t){let r=this.get().order[0];if(r?.column!==t)this.setOrder([{column:t,direction:"asc"}]);else if(r.direction==="asc")this.setOrder([{column:t,direction:"desc"}]);else this.setOrder([])}setFilter(t,r){let{[t]:s,...i}=this.get().filters;this.setFilters(r===void 0?i:{...i,[t]:r})}setFilters(t){if(re(t,"filters"),Ae(t,this.get().filters))return;this.change({filters:{...t},page:1})}setSearch(t){if(t===this.get().search)return;if(this.put({...this.get(),search:t,page:1}),this.stale=!0,!this.state.observed)return;this.clearTimer(),this.timer=this.scheduler.setTimeout(()=>{this.timer=null,this.read()},this.debounceMs)}refresh(){if(!this.state.observed)return this.stale=!0,Promise.resolve();return this.countKey=null,this.read()}load(t){if(t!==void 0)this.applyParams(t);return this.loadReady()}sync(t){return this.load(t)}applyParams(t){if(H(this.transport)){if(this.transport.setArgs(t),this.countKey=null,this.stale=!0,this.state.observed)this.read();return}let r=t??{},s={...r.params&&typeof r.params==="object"?r.params:{}};for(let[i,o]of Object.entries(r))if(!hs.has(i))s[i]=o;if(Object.keys(s).length>0)this.setParams(s);this.update({...r.where!==void 0?{filters:r.where}:{},...r.order!==void 0?{order:r.order}:{},...r.search!==void 0?{search:r.search}:{},...r.page!==void 0?{page:r.page}:{},...r.pageSize!==void 0?{pageSize:r.pageSize}:{}})}described=null;describeAs(t){this.described=t}toDescription(){if(this.described)return xr(this.described);let{table:t,...r}=this.description;return xr({name:"",source:"table",table:t,...r})}async loadReady(){let t=!1;for(let s=0;s<8;s++){let i=this.get();if(this.controller)await new Promise((o)=>this.waiters.push(o));else if(!t&&(this.stale||i.status==="idle"||i.status==="error"))t=!0,await this.read();else break}let r=this.get();if(r.status==="error"&&r.error)throw r.error;return r}writeListeners=new Set;onWrite(t){return this.writeListeners.add(t),()=>void this.writeListeners.delete(t)}emitWrite(t){for(let r of[...this.writeListeners])r(t)}realtimeDebounceMs;stopRealtime=null;realtimeTimer=null;loadedOnce=!1;lastRead=0;gone=new Set;receive(t){if(!_t(t.table,this.description.table))return;let s=(t.event==="delete"?t.old:t.record)?.[this.keyColumn];if(s===void 0){this.scheduleRefetch();return}let i=this.description.parent;if(i&&t.record&&!me(t.record[i.column],this.lastParentKey)&&!this.baseRows.some((o)=>this.keyOf(o)===Te(s)))return;this.receiveRow(Te(s),t.event==="delete"?null:t.record,t.event)}receiveRow(t,r,s){let i=this.baseRows.findIndex((d)=>this.keyOf(d)===t),o=i>=0?this.baseRows[i]:null,l=this.writer.versionColumn,c=this.writer.incoming(t,r);if(c==="deferred"||c==="stale")return;if(r===null){if(c==="handled"){this.gone.add(t),this.adjustTotal(-1);return}if(o)this.baseRows=this.baseRows.filter((d,m)=>m!==i),this.adjustTotal(-1),this.put({...this.get(),rows:this.mergedRows()});this.scheduleRefetch();return}if(!o){this.scheduleRefetch();return}if(c==="none"&&!Ne(r,o,l))return;let u=Ke(r,o,this.description.include),g=Object.keys({...o,...u}).filter((d)=>!me(o[d],u[d]));if(this.baseRows=this.baseRows.map((d,m)=>m===i?u:d),this.put({...this.get(),rows:this.mergedRows()}),s==="insert"||g.some((d)=>this.movingColumns().has(d))||this.description.include&&g.length>0)this.scheduleRefetch()}movingColumns(){let t=this.get(),r=new Set(t.order.map((s)=>s.column));if(t.search.trim())for(let s of t.searchColumns)r.add(s);for(let s of[this.description.where,t.filters])if(s)xt(s,r);if(this.description.parent)r.add(this.description.parent.column);return r}adjustTotal(t){let r=this.get();if(r.total===null)return;let s=Math.max(0,r.total+t);this.put({...r,total:s,pageCount:Me(s,r.pageSize)})}scheduleRefetch(){if(!this.state.observed){this.stale=!0;return}if(this.realtimeTimer!==null)this.scheduler.clearTimeout(this.realtimeTimer);this.realtimeTimer=this.scheduler.setTimeout(()=>{if(this.realtimeTimer=null,this.writer.saving)return this.scheduleRefetch();this.countKey=null,this.read(!0)},this.realtimeDebounceMs)}startRealtime(t){if(this.stopRealtime||this.description.realtime===!1||typeof this.transport.subscribe!=="function")return;let r=t;this.setRealtime("connecting",r),this.stopRealtime=this.transport.subscribe({table:this.description.table},{change:(s)=>this.receive(s),status:(s)=>{let i=this.get().realtime;if(this.setRealtime(s,r),s==="live"&&i!=="live"&&this.loadedOnce&&!(this.description.reference&&Date.now()-this.lastRead<2000))this.scheduleRefetch()}}),r=!1}setRealtime(t,r=!1){if(this.get().realtime===t)return;if(r)this.put({...this.get(),realtime:t},!0);else this.put({...this.get(),realtime:t})}draftIds=new WeakMap;keyOf(t){let r=t!==null&&typeof t==="object"?this.draftIds.get(t):void 0;if(r)return r;return Te(t!==null&&typeof t==="object"?t[this.keyColumn]:void 0)}shown(t){let r=this.baseRows.find((s)=>this.keyOf(s)===t);if(r)return r;return this.writer.inserted().find((s)=>s.id===t)?.row??null}set(t,r,s){let i=K(r);if(i.length===0||typeof i[0]!=="string")throw new v("read_only","a row is changed column by column: give a column",{path:"field"});let o=i[0];if(this.computed().has(o))throw new v("read_only",`"${o}" is a computed field: it is never written`,{field:o});if(o===this.keyColumn&&!t.startsWith("new:"))throw new v("read_only",`the key column "${o}" cannot be changed`,{field:o});let l=this.baseRows.find((g)=>this.keyOf(g)===t),c=this.writer.merge(t,l??this.shown(t)??{}),u=i.length===1?s:W(ce(c,i,s),[o]);this.writer.set(t,l??null,o,u)}insert(t){let r=this.description.parent,s=r?this.parentKey():null;return this.writer.insert(r&&s!==null&&t[r.column]===void 0?{...t,[r.column]:s}:{...t})}remove(t){let r=this.baseRows.find((s)=>this.keyOf(s)===t);this.writer.remove(t,r??null)}async save(t){if(this.events.has("beforesave")){let i=this.pendingChanges(t);if(i.length>0){let o=this.events.before("beforesave",{changes:i});if(o===!1)return!1;for(let l of i)if(l.kind!=="delete")for(let[c,u]of Object.entries(o))this.set(l.id,c,u)}}let r=this.pendingChanges(t).map((i)=>i.id),s=await this.saveRows(t);if(s&&r.length)this.events.emit("saved",{ids:r});if(!s){let i=Object.values(this.writer.all()).map((o)=>o.error??Object.values(o.errors)[0]??null).find(Boolean);if(i)this.events.emit("error",{error:i,during:"save"})}return s}pendingChanges(t){let r=this.writer.all();return Object.entries(r).filter(([s,i])=>i.dirty&&(t===void 0||s===t)).map(([s,i])=>({id:s,kind:i.kind,values:i.changes}))}saveRows(t){let r=this.description.parent;if(r){let s=this.parentKey();if(s===null&&this.writer.inserted().length>0)return Promise.resolve(!1);for(let i of this.writer.inserted())if(i.row[r.column]===void 0||i.row[r.column]===null)this.writer.set(i.id,null,r.column,s)}return this.writer.save(t,(s)=>this.baseRows.find((i)=>this.keyOf(i)===s)??null)}revert(t,r){this.writer.revert(t,r)}resolveParent=null;parentStore=null;stopParent=null;unlinkParent=null;lastParentKey=void 0;linkParent(t){this.resolveParent=t}parent(){if(this.parentStore||!this.description.parent||!this.resolveParent)return this.parentStore;let t=null;try{t=this.resolveParent()}catch{t=null}if(!t)return null;if(t.type!=="record")throw new v("invalid_description",`the parent of a child store must be a record store ("${this.description.parent.store}")`,{path:"parent.store"});return this.parentStore=t,this.unlinkParent=t.linkChild({dirty:()=>this.writer.dirty,saving:()=>this.writer.saving,save:()=>this.save(),revert:()=>this.writer.revert(),valid:()=>this.writer.validateAll((r)=>this.baseRows.find((s)=>this.keyOf(s)===r)??null),adopt:(r)=>{this.lastParentKey=r;let s=this.description.parent;for(let i of this.writer.inserted())if(i.row[s.column]===void 0||i.row[s.column]===null)this.writer.set(i.id,null,s.column,r)}}),t}parentKey(){let t=this.parent();return t?t.key():null}parentChanged(){let t=this.parentKey();if(t===this.lastParentKey)return;let r=this.lastParentKey===void 0;if(this.lastParentKey=t,r)return;this.writer.revert(),this.change({page:1})}notifyParent(){this.parentStore?.childChanged()}resolve(t,r,s){this.writer.resolve(t,r,s)}dismiss(t){this.writer.dismiss(t)}mergedRows(){return this.pipeline(this.rawRows())}rawRows(){let t=this.writer.all();if(this.gone.size)for(let i of[...this.gone]){if(t[i])continue;this.gone.delete(i),this.baseRows=this.baseRows.filter((o)=>this.keyOf(o)!==i)}if(Object.keys(t).length===0)return this.baseRows;let r=this.writer.inserted().map((i)=>(this.draftIds.set(i.row,i.id),i.row)),s=this.baseRows.filter((i)=>!this.writer.isDeleted(this.keyOf(i))).map((i)=>this.writer.merge(this.keyOf(i),i));return[...r,...s]}publishRows(){let t=this.get(),r=this.writer.all();if(t.edits===r)return;this.put({...t,rows:this.mergedRows(),edits:r,dirty:this.writer.dirty,saving:this.writer.saving}),this.notifyParent()}stored(t,r,s){let i=this.get(),o=this.baseRows.findIndex((c)=>this.keyOf(c)===t||this.keyOf(c)===s),l=o>=0?Ke(r,this.baseRows[o],this.description.include):r;if(this.description.include)this.scheduleRefetch();if(o>=0)this.baseRows=this.baseRows.map((c,u)=>u===o?l:c);else if(this.baseRows=[l,...this.baseRows],i.total!==null&&s!==t)this.put({...i,total:i.total+1,pageCount:Me(i.total+1,i.pageSize)});this.publishRows(),this.put({...this.get(),rows:this.mergedRows()})}removed(t){let r=this.get(),s=this.baseRows.length;if(this.baseRows=this.baseRows.filter((i)=>this.keyOf(i)!==t),this.baseRows.length!==s&&r.total!==null)this.put({...r,total:Math.max(0,r.total-1),pageCount:Me(Math.max(0,r.total-1),r.pageSize)});this.put({...this.get(),rows:this.mergedRows()})}change(t){if(["filters","search","searchColumns","order","params","pageSize"].some((s)=>(s in t))&&!this.cursorTarget)this.cursorKey=null,this.cursorMoved=!1;let r={...this.get(),...t};if(this.put({...r,pageCount:Me(r.total,r.pageSize)}),this.stale=!0,this.state.observed)this.read()}start(){if(this.startDepends(),this.description.parent){let s=this.parent();if(s){this.lastParentKey=s.key();let i=!0;this.stopParent=s.subscribe(()=>{if(i)return;this.parentChanged()}),i=!1}}let t=this.description.reference&&this.get().status==="ready"&&this.loadedOnce,r=!t&&(this.stale||this.get().status==="idle");if(this.startRealtime(r),r)this.read();else if(t&&this.stale)this.read(!0)}stop(){this.stopDepending(),this.stopParent?.(),this.stopParent=null,this.clearTimer(),this.cancel();let t=this.description.reference&&this.get().status==="ready"&&this.loadedOnce;if(this.stale=!t,this.realtimeTimer!==null)this.scheduler.clearTimeout(this.realtimeTimer);if(this.realtimeTimer=null,this.stopRealtime?.(),this.stopRealtime=null,!t)this.loadedOnce=!1;if(this.setRealtime("off"),this.get().status==="loading")this.put({...this.get(),status:this.get().total===null?"idle":"ready"})}clearTimer(){if(this.timer!==null)this.scheduler.clearTimeout(this.timer);this.timer=null}cancel(){this.seq++,this.controller?.abort(),this.controller=null,this.settleWaiters()}settleWaiters(){let t=this.waiters;this.waiters=[];for(let r of t)r()}combinedWhere(t){let r=[this.description.where,t,this.get().filters].filter((s)=>!!s&&Object.keys(s).length>0);if(r.length===0)return;return r.length===1?r[0]:{and:r}}read(t=!1){this.clearTimer(),this.cancel();let r=this.seq,s=new Z.AbortController;this.controller=s,this.stale=!1;let i=this.get(),o=this.description.parent,l=o?this.parentKey():null,c=()=>(this.baseRows=[],this.countKey=null,this.controller=null,this.put({...this.get(),rows:this.mergedRows(),total:0,pageCount:1,status:"ready",error:null,totals:null}),this.settleWaiters(),Promise.resolve());if(o&&l===null)return c();if(this.dependsList().some((z)=>i.params[z.param]===null||i.params[z.param]===void 0))return c();let u=i.params;if(this.events.has("beforeload")){let z=this.events.before("beforeload",{params:u});if(z===!1)return this.controller=null,this.settleWaiters(),Promise.resolve();u={...u,...z}}this.lastParentKey=o?l:this.lastParentKey;let g;try{g=Qt(this.combinedWhere(o?{[o.column]:l}:void 0),u)}catch(z){this.controller=null;let U=L(z);return this.put({...this.get(),status:"error",error:U}),this.events.emit("error",{error:U,during:"load"}),this.settleWaiters(),Promise.resolve()}let d=bs(g,this.description.include),m=d.where,y=i.search.trim(),k=i.searchColumns,x=y&&k.length?{term:y,columns:k}:void 0,R={table:this.description.table,...m?{where:m}:{},...x?{search:x}:{},...d.include?{include:d.include}:{}};this.lastBase=R;let j=this.computed(),C=i.order.filter((z)=>!j.has(z.column)),T=this.description.aggregate,B={signal:s.signal};if(!t)this.put({...i,status:"loading",error:null});let Q=new Promise((z)=>this.waiters.push(z)),ee;if(T?.group)ee=this.aggregateRows(T,R,C,B).then((z)=>[z,z.length,null]);else{let z={...R,...this.description.select?{select:ps(this.description.select,this.keyColumn,this.writer.versionColumn)}:{},order:C,limit:i.pageSize,offset:(i.page-1)*i.pageSize},U=JSON.stringify(R),Ze=U!==this.countKey||i.total===null,Je=T&&Ze?d.include&&d.include!==this.description.include?Promise.resolve(null):this.aggregateRows(T,R,[],B).then((le)=>le[0]??null):Promise.resolve(i.totals);ee=Promise.all([this.transport.find(z,B),Ze?this.transport.count(R,B):Promise.resolve(i.total??0),Je]).then(([le,Se,wn])=>{if(r===this.seq)this.countKey=U;return[le,Se,wn]})}return ee.then(([z,U,Ze])=>{if(r!==this.seq)return;this.controller=null;let Je=this.get();this.baseRows=z,this.loadedOnce=!0,this.lastRead=Date.now();for(let le of this.gone)if(!this.baseRows.some((Se)=>this.keyOf(Se)===le)){let Se=this.writer.base(le);if(Se&&this.writer.all()[le])this.baseRows=[Se,...this.baseRows]}if(this.freshRead=!0,this.put({...Je,rows:this.mergedRows(),total:U,pageCount:Me(U,Je.pageSize),status:"ready",error:null,totals:Ze}),this.freshRead=!1,this.events.emit("load",{rows:this.get().rows,total:U}),this.settleWaiters(),this.description.cursor==="last"&&!this.cursorMoved)this.cursorMoved=!0,this.last()},(z)=>{if(r!==this.seq)return;this.controller=null,this.countKey=null;let U=L(z);this.put({...this.get(),status:"error",error:U}),this.events.emit("error",{error:U,during:"load"}),this.settleWaiters()}),Q}aggregateRows(t,r,s,i){if(typeof this.transport.aggregate!=="function")return Promise.reject(new v("unsupported",`transport "${this.transport.name}" cannot aggregate`,{params:{feature:"aggregate"}}));let o={table:r.table,...r.where?{where:r.where}:{},...r.search?{search:r.search}:{},...t.group?{group:t.group,limit:ne}:{},...t.count?{count:!0}:{},...t.sum?{sum:t.sum}:{},...t.avg?{avg:t.avg}:{},...t.min?{min:t.min}:{},...t.max?{max:t.max}:{},...s.length?{order:s}:{}};return this.transport.aggregate(o,i)}lastBase=null;freshRead=!1;put(t,r=!1){let s=this.state.get(),i=this.cursorOf(t,s),o=i===t.current?t:{...t,current:i};if(r)this.state.replace(o);else this.state.set(o);if(o.rows!==s.rows)this.events.emit("change",{rows:o.rows});let l=(c)=>c.row===null?null:this.keyOf(c.row);if(o.current.index!==s.current.index||l(o.current)!==l(s.current))this.events.emit("current",{index:o.current.index,row:o.current.row})}cursorKey=null;cursorLocal=-1;cursorPage=1;cursorTarget=null;cursorActive=!1;cursorMoved=!1;cursorOf(t,r){let s=t.rows,i=-1;if(s.length>0){let k=this.cursorTarget;if(k&&this.freshRead&&t.page===k.page)i=k.local==="last"?s.length-1:Math.min(k.local,s.length-1),this.cursorTarget=null;else if(this.cursorKey!==null){let x=s.findIndex((R)=>this.keyOf(R)===this.cursorKey);if(x>=0)i=x;else if(t.page===this.cursorPage&&(t.status!=="loading"||s===r.rows)&&t.page===r.page)if(t.status==="loading")i=Math.min(this.cursorLocal,s.length-1);else{let R=(t.page-1)*t.pageSize,j=t.total!==null&&R+this.cursorLocal<t.total;if(this.cursorLocal>=s.length&&j&&!this.freshRead)this.cursorTarget={page:t.page,local:this.cursorLocal};i=Math.min(this.cursorLocal,s.length-1)}else i=0}else if(this.cursorTarget)i=-1;else i=this.description.cursor==="none"&&!this.cursorMoved?-1:0}if(t.status==="loading"&&s===r.rows&&r.current.row!==null&&this.cursorKey!==null&&i<0)return r.current;this.cursorLocal=i,this.cursorPage=t.page;let o=i>=0?s[i]:null;this.cursorKey=o===null?s.length===0?this.cursorKey:null:this.keyOf(o);let l=(t.page-1)*t.pageSize,c=i>=0?l+i:-1,u=t.page>=t.pageCount,g=i<=0&&(t.page<=1||i<0),d=s.length===0||i>=s.length-1&&(t.filtered||t.total===null?u:c>=t.total-1),m=this.cursorActive,y=r.current;if(y.index===c&&y.row===o&&y.bof===g&&y.eof===d&&y.active===m)return y;return{index:c,row:o,bof:g,eof:d,active:m}}setCursor(t){let r=this.get(),s=r.rows[t];if(s===void 0)return;this.cursorActive=!0,this.cursorMoved=!0,this.cursorTarget=null,this.cursorKey=this.keyOf(s),this.cursorLocal=t,this.cursorPage=r.page,this.put({...r})}async leaveCurrent(){let t=this.get().current.row;if(t===null)return!0;let r=this.keyOf(t),s=this.get().edits[r];if(!s?.dirty||s.saving||this.mode!=="batch")return!0;let i=await this.save(r);if(!i){let o=this.get().edits[r],l=o?.error??Object.values(o?.errors??{})[0]??null;if(l)this.events.emit("error",{error:l,during:"move"})}return i}async goTo(t,r){let s=this.get();if(this.cursorActive=!0,this.cursorMoved=!0,t===s.page&&s.status==="ready"&&!this.stale){let o=r==="last"?s.rows.length-1:r;if(o<0||o>=s.rows.length)return!1;return this.setCursor(o),!0}if(this.cursorTarget={page:t,local:r},t!==s.page)this.change({page:t});else this.stale=!0;await this.loadReady().catch(()=>{return});let i=this.get();if(this.cursorTarget&&i.page===t&&i.status==="ready"){let o=r==="last"?i.rows.length-1:Math.min(r,i.rows.length-1);if(this.cursorTarget=null,o>=0)this.setCursor(o)}return i.page===t&&i.current.row!==null}useCursor(){if(this.cursorActive)return;this.cursorActive=!0,this.put({...this.get()})}async first(){if(!await this.leaveCurrent())return!1;return this.goTo(1,0)}async last(){if(!await this.leaveCurrent())return!1;let t=this.get();if(t.total===null)t=await this.loadReady().catch(()=>this.get());if(t.total===null||t.total===0)return!1;return this.goTo(this.get().pageCount,"last")}async next(){if(!await this.leaveCurrent())return!1;for(let t=0;t<1000;t++){let r=this.get(),s=r.current.row===null?-1:this.cursorLocal;if(s+1<r.rows.length)return this.setCursor(s+1),!0;if(r.page>=r.pageCount)return!1;let i=await this.goTo(r.page+1,0);if(i||!this.get().filtered)return i}return!1}async prior(){if(!await this.leaveCurrent())return!1;for(let t=0;t<1000;t++){let r=this.get();if(r.current.row!==null&&this.cursorLocal>0)return this.setCursor(this.cursorLocal-1),!0;if(r.page<=1)return!1;let s=await this.goTo(r.page-1,"last");if(s||!this.get().filtered)return s}return!1}async moveTo(t){if(!Number.isInteger(t)||t<0)return!1;let r=this.get();if(r.total!==null&&t>=r.total)return!1;if(!await this.leaveCurrent())return!1;return this.goTo(Math.floor(t/r.pageSize)+1,t%r.pageSize)}async makeCurrent(t){let r=this.get(),s=this.keyOf(t);if(r.rows.findIndex((l)=>l===t||this.keyOf(l)===s)<0)return!1;if(r.current.row!==null&&this.keyOf(r.current.row)===s){if(this.cursorActive=!0,!r.current.active)this.put({...r});return!0}if(!await this.leaveCurrent())return!1;let o=this.get().rows.findIndex((l)=>this.keyOf(l)===s);if(o<0)return!1;return this.setCursor(o),!0}async locate(t){let r=Object.keys(t??{});if(r.length===0)return!1;let s=(C)=>r.every((T)=>me(W(C,K(T)),t[T])),i=this.get();if(i.rows.findIndex(s)>=0){if(i.current.row!==null&&s(i.current.row))return!0;if(!await this.leaveCurrent())return!1;let C=this.get().rows.findIndex(s);if(C<0)return!1;return this.setCursor(C),!0}if(H(this.transport)||this.description.aggregate?.group)return!1;if(this.stale||i.status!=="ready")await this.loadReady().catch(()=>{return});let l=this.lastBase;if(!l)return!1;let c={signal:new Z.AbortController().signal},u=this.get().order.filter((C)=>!this.computed().has(C.column)),g=r.reduce((C,T)=>xe(C,{[T]:t[T]}),void 0),m=(await this.transport.find({...l,where:l.where?{and:[l.where,g]}:g,order:u,limit:1,offset:0},c).catch(()=>[]))[0];if(!m)return!1;let y=ms(m,u,this.keyColumn),k=y===null?0:await this.transport.count({...l,where:l.where?{and:[l.where,y]}:y},c).catch(()=>-1);if(k<0)return!1;if(!await this.leaveCurrent())return!1;let x=this.get().pageSize;await this.goTo(Math.floor(k/x)+1,k%x);let R=this.get();if(R.current.row!==null&&s(R.current.row))return!0;let j=R.rows.findIndex(s);if(j>=0)return this.setCursor(j),!0;return!1}filterFn=null;computedCache=new WeakMap;computedRows=new WeakSet;computedFields=null;computed(){if(!this.computedFields){this.computedFields=new Map;for(let t of this.fields.declared())if(t.compute!==void 0)this.computedFields.set(t.field,t.compute)}return this.computedFields}pipeline(t){let r=this.computed(),s=t;if(r.size>0)s=t.map((o)=>{if(o===null||typeof o!=="object"||this.computedRows.has(o))return o;let l=this.computedCache.get(o);if(l)return l;let c={...o};for(let[g,d]of r)c[g]=Wt(d,o);let u=this.draftIds.get(o);if(u)this.draftIds.set(c,u);return this.computedRows.add(c),this.computedCache.set(o,c),c});if(this.filterFn){let o=this.filterFn;s=s.filter((l)=>{try{return o(l)}catch{return!1}})}let i=this.get()?.order??[];if(r.size>0&&i.some((o)=>r.has(o.column)))s=gs(s,i);return s===t&&t.length===0?t:s}filterBy(t){if(typeof t!=="function")throw new v("invalid_description","filterBy takes a function of the row",{path:"filterBy"});this.filterFn=t,this.put({...this.get(),rows:this.mergedRows(),filtered:!0})}clearFilterBy(){if(!this.filterFn)return;this.filterFn=null,this.put({...this.get(),rows:this.mergedRows(),filtered:!1})}on(t,r){return this.events.on(t,r)}setParams(t){let r=this.get(),s={...r.params,...t};if(me(s,r.params))return;if(H(this.transport))this.transport.setArgs({...this.transport.args()??{},...t});this.countKey=null,this.change({params:s,page:1})}resolveStore=null;stopDepends=[];linkStores(t){this.resolveStore=t}startDepends(){if(this.stopDepends.length>0||!this.resolveStore)return;for(let t of this.dependsList()){let r=this.resolveStore(t.store);if(!r)continue;let s=K(t.field),i=()=>{let u=r.type==="list"?r.get().current.row:r.get().value,g=u===null||u===void 0?null:W(u,s);return g===void 0?null:g},o=()=>{let u=i();if(me(u,this.get().params[t.param]??null)&&t.param in this.get().params)return;this.cursorKey=null,this.cursorTarget=null,this.cursorMoved=!1,this.writer.revert(),this.setParams({[t.param]:u})},l=i(),c=this.get();if(!me(l,c.params[t.param]??null)||!(t.param in c.params)){if(H(this.transport))this.transport.setArgs({...this.transport.args()??{},[t.param]:l});this.put({...c,params:{...c.params,[t.param]:l}},!0),this.stale=!0,this.countKey=null}this.stopDepends.push(r.subscribe(o))}}stopDepending(){for(let t of this.stopDepends)t();this.stopDepends=[]}alive=null;keepAlive(){this.alive??=this.subscribe(()=>{})}redescribe(t){let r=H(this.transport),s=new Set(["order","pageSize","search","cursor","dependsOn","autoLoad"]);if(r){for(let c of Object.keys(t))if(!s.has(c))throw new v("invalid_description",`"${c}" is not an option of a function store`,{path:c})}let i={...this.description,...t};for(let[c,u]of Object.entries(t))if(u===void 0)delete i[c];if(this.description=se(i),this.described){let c={...this.described,...t};for(let[u,g]of Object.entries(t))if(g===void 0)delete c[u];this.described=c}let o=this.get(),l={};if("order"in t)l.order=Qe(this.description.order);if("pageSize"in t&&this.description.pageSize)l.pageSize=this.description.pageSize;if("search"in t)l.searchColumns=this.description.search??[];if("params"in t)l.params={...this.description.params??{},...o.params,...t.params};if("cursor"in t)this.cursorActive=!0;if(this.countKey=null,this.change({...l,page:1}),"dependsOn"in t&&this.state.observed)this.stopDepending(),this.startDepends();if("autoLoad"in t&&this.description.autoLoad)Promise.resolve().then(()=>this.keepAlive());return this}select(t){let{select:r,include:s}=qt(t);return this.redescribe({select:r,include:s})}where(t,r,s){return this.redescribe({where:xe(this.description.where,yt(t,r,s))})}or(t){return this.redescribe({where:xe(this.description.where,pe("or",he(t)))})}and(t){return this.redescribe({where:xe(this.description.where,pe("and",he(t)))})}not(t){return this.redescribe({where:xe(this.description.where,{not:pe("and",he(t))})})}order(t,r="asc"){return this.redescribe({order:tr(this.description.order,er(t,r))})}pageSize(t){return this.redescribe({pageSize:t})}search(...t){return this.redescribe({search:t})}param(t,r){return this.redescribe({params:{...this.description.params??{},[t]:r}})}cursor(t){return this.redescribe({cursor:t})}dependsOn(t,r,s){let i=[...this.dependsList().filter((o)=>o.param!==s),{store:t,field:r,param:s}];return this.redescribe({dependsOn:i.length===1?i[0]:i})}dependsList(){let t=this.description.dependsOn;return t===void 0?[]:Array.isArray(t)?t:[t]}aggregatePatch(t,r){let s={...this.description.aggregate??{}};if(r===!0)s[t]=!0;else s[t]=[...new Set([...s[t]??[],...r])];if(!s.count&&!s.sum&&!s.avg&&!s.min&&!s.max)return this.pendingAggregate=s,this;return this.pendingAggregate=null,this.redescribe({aggregate:s})}pendingAggregate=null;groupBy(...t){let r=this.pendingAggregate??this.description.aggregate??{},s={...r,group:[...new Set([...r.group??[],...t])]};for(let[i,o]of t.entries())if(typeof o!=="string"||!/^[A-Za-z_][A-Za-z0-9_]{0,62}$/.test(o))throw new v("invalid_description",`invalid group column at ${i}`,{path:"aggregate.group"});if(!s.count&&!s.sum&&!s.avg&&!s.min&&!s.max)return this.pendingAggregate=s,this;return this.redescribe({aggregate:s})}count(){if(this.pendingAggregate)this.description={...this.description,aggregate:this.pendingAggregate};return this.aggregatePatch("count",!0)}sum(...t){if(this.pendingAggregate)this.description={...this.description,aggregate:this.pendingAggregate};return this.aggregatePatch("sum",t)}avg(...t){if(this.pendingAggregate)this.description={...this.description,aggregate:this.pendingAggregate};return this.aggregatePatch("avg",t)}min(...t){if(this.pendingAggregate)this.description={...this.description,aggregate:this.pendingAggregate};return this.aggregatePatch("min",t)}max(...t){if(this.pendingAggregate)this.description={...this.description,aggregate:this.pendingAggregate};return this.aggregatePatch("max",t)}pendingBatch(){let t=this.description.parent;if(t){let r=this.parentKey();for(let s of this.writer.inserted())if(s.row[t.column]===void 0||s.row[t.column]===null){if(r===null)return null;this.writer.set(s.id,null,t.column,r)}}return this.writer.batchPrepare((r)=>this.baseRows.find((s)=>this.keyOf(s)===r)??null)}batchStart(t){this.writer.batchStart(t)}batchDone(t,r){if(t.forEach((s,i)=>this.writer.batchDone(s,r[i]??[])),t.length)this.events.emit("saved",{ids:t})}async batchFailed(t,r,s){await Promise.all(t.map((i)=>this.writer.batchFailed(i,r,s===null||s===i))),this.events.emit("error",{error:r,during:"save"})}}var ds=Object.freeze({index:-1,row:null,bof:!0,eof:!0,active:!1}),hs=new Set(["where","order","search","page","pageSize","params"]);function ps(t,r,s){if(t==="*")return t;let i=[...t];if(!i.includes(r))i.unshift(r);if(s&&!i.includes(s))i.push(s);return i}function xr(t){let r=t.fields;if(!r||!r.some((l)=>typeof l==="object"&&l!==null&&typeof l.compute==="function"))return t;let s=r.filter((l)=>!(typeof l==="object"&&l!==null&&typeof l.compute==="function")),{fields:i,...o}=t;return s.length?{...o,fields:s}:o}function gs(t,r){return[...t].sort((s,i)=>{for(let o of r){let l=s[o.column],c=i[o.column];if(me(l,c))continue;if(l===null||l===void 0)return 1;if(c===null||c===void 0)return-1;let u=typeof l==="number"&&typeof c==="number"?l-c:String(l).localeCompare(String(c));if(u!==0)return o.direction==="asc"?u:-u}return 0})}function ms(t,r,s){let i=r.some((c)=>c.column===s)?[...r]:[...r,{column:s,direction:"asc"}],o=(c,u)=>u===null||u===void 0?{[c]:{is:null}}:{[c]:{eq:u}},l=[];return i.forEach((c,u)=>{let g=t[c.column],d;if(g===null||g===void 0)d=c.direction==="asc"?{[c.column]:{not:null}}:null;else d=c.direction==="asc"?{[c.column]:{lt:g}}:{or:[{[c.column]:{gt:g}},{[c.column]:{is:null}}]};if(!d)return;let m=i.slice(0,u).map((y)=>o(y.column,t[y.column]));l.push(m.length?{and:[...m,d]}:d)}),l.length===0?null:l.length===1?l[0]:{or:l}}var me=(t,r)=>JSON.stringify(t)===JSON.stringify(r),_t=(t,r)=>t===r||t.replace(/^public\./,"")===r.replace(/^public\./,""),Ar=(t)=>new Set(t===void 0?[]:Array.isArray(t)?t:Object.entries(t).filter(([,r])=>r!==!1).map(([r])=>r));function Ke(t,r,s){if(!s||!r)return t;let i=null;for(let o of Ar(s))if(!(o in t)&&o in r)(i??={...t})[o]=r[o];return i??t}function ys(t,r){let s=null,i=(o)=>Object.entries(o).every(([l,c])=>{if(l==="and"||l==="or")return c.every(i);if(l==="not")return i(c);let u=l.split(".")[0];if(!l.includes(".")||!r.has(u)||s!==null&&s!==u)return!1;return s=u,!0});return i(t)?s:null}function Ot(t,r){let s={};for(let[i,o]of Object.entries(t))if(i==="and"||i==="or")s[i]=o.map((l)=>Ot(l,r));else if(i==="not")s[i]=Ot(o,r);else s[i.slice(r.length+1)]=o;return s}function bs(t,r){let s=Ar(r);if(!t||s.size===0)return{where:t,include:r};let i=t.and&&Object.keys(t).length===1?[...t.and]:[t],o=[],l=new Map;for(let u of i){let g=ys(u,s);if(g)l.set(g,[...l.get(g)??[],Ot(u,g)]);else o.push(u)}if(l.size===0)return{where:t,include:r};let c=Array.isArray(r)?Object.fromEntries(r.map((u)=>[u,!0])):{...r};for(let[u,g]of l){let d=c[u],m=typeof d==="object"?d:{},y=[...m.where?[m.where]:[],...g];c[u]={...m,where:y.length===1?y[0]:{and:y},required:!0}}return{where:o.length===0?void 0:o.length===1?o[0]:{and:o},include:c}}function xt(t,r){for(let[s,i]of Object.entries(t))if(s==="and"||s==="or")for(let o of i)xt(o,r);else if(s==="not")xt(i,r);else r.add(s)}function ae(t,r){return new _r(t,r)}var V=(t)=>typeof t==="object"&&t!==null&&t.kind==="store"&&t.type==="list"&&typeof t.subscribe==="function";var F="record";class $r{description;transport;kind="store";type="record";mode;fields;state;key_;seq=0;controller=null;stale=!0;waiters=[];original;loadStatus;loadError=null;writer;events=new Ie;creating=!1;constructor(t,r){this.description=t,this.transport=r;let s="value"in t;if(!s&&!r)throw new v("invalid_description","a remote record needs a transport",{path:"transport"});if(!s&&r&&typeof r.findOne!=="function")throw new v("invalid_description",`transport "${r.name}" cannot read a single record (no findOne)`,{path:"transport"});this.mode=t.save??"batch",this.fields=new Le(t.fields),this.key_=s?null:t.key??null,this.original=s?t.value:null,this.loadStatus=s?"ready":"idle";let i=t,o=this.fields;if(this.writer=new De({table:s?null:i.table,keyColumn:s?"id":i.keyColumn??"id",get version(){return s?null:i.version??o.versionColumn()??null},transport:s?null:r,mode:()=>this.mode,rule:(l)=>this.fields.rule(l),ruled:()=>this.fields.ruled(),changed:()=>this.publish(),insertedId:()=>F,stored:(l,c)=>{if(this.creating){let g=c[this.keyColumn];if(this.creating=!1,this.key_=typeof g==="number"||typeof g==="string"?g:null,this.original=c,this.loadStatus="ready",this.loadError=null,this.stale=!1,this.key_!==null)for(let d of this.children)d.adopt?.(this.key_);if(this.publish(),!s)this.emitWrite({event:"insert",table:i.table,record:c});return}let u=s?void 0:i.include;if(this.original=Ke(c,this.original,u),u&&this.state?.observed)this.read(!0);if(this.publish(),!s)this.emitWrite({event:"update",table:i.table,record:c})},removed:()=>{let l=this.key_;if(this.original=null,this.publish(),!s)this.emitWrite({event:"delete",table:i.table,old:{[i.keyColumn??"id"]:l}})},incoming:(l,c)=>this.receiveRow(c),commitLocal:(l,c)=>{this.original=c}}),this.state=new Y(this.compute(),{start:()=>this.start(),stop:()=>this.stop()}),!s&&i.autoLoad)Promise.resolve().then(()=>this.alive??=this.subscribe(()=>{}))}alive=null;on(t,r){return this.events.on(t,r)}resolveStore=null;stopDepends=[];linkStores(t){this.resolveStore=t}deps(){let t=this.local?void 0:this.description.dependsOn;return t===void 0?[]:Array.isArray(t)?t:[t]}startDepends(){if(this.stopDepends.length>0||!this.resolveStore)return;for(let t of this.deps()){let r=this.resolveStore(t.store);if(!r)continue;let s=t.field.split("."),i=()=>{let l=r.type==="list"?r.get().current.row:r.get().value,c=l===null||l===void 0?null:W(l,s);return typeof c==="string"&&c.length>0?c:typeof c==="number"&&Number.isFinite(c)?c:null},o=i();if(o!==this.key_)this.key_=o,this.writer.revert(),this.stale=!0;this.stopDepends.push(r.subscribe(()=>{let l=i();if(l!==this.key_)this.setKey(l)}))}}pendingBatch(){return this.writer.batchPrepare(()=>this.original)}batchStart(t){this.writer.batchStart(t)}batchDone(t,r){if(t.forEach((s,i)=>this.writer.batchDone(s,r[i]??[])),t.length)this.events.emit("saved",{ids:t})}async batchFailed(t,r,s){await Promise.all(t.map((i)=>this.writer.batchFailed(i,r,s===null||s===i))),this.events.emit("error",{error:r,during:"save"})}get keyColumn(){return this.local?"id":this.description.keyColumn??"id"}key(){return this.key_}children=new Set;linkChild(t){return this.children.add(t),this.publish(),()=>{this.children.delete(t),this.publish()}}childChanged(){this.publish()}get local(){return"value"in this.description}get(){return this.state.get()}subscribe(t){return this.state.subscribe(t)}toJSON(){throw new v("not_serializable","a data store cannot be serialised: pass its JSON description instead")}compute(){let t=this.writer.state(F),r=this.original===null?null:this.writer.merge(F,this.original),{dirty:s,saving:i}=t;for(let o of this.children??[])s||=o.dirty(),i||=o.saving();return{value:r,original:this.original,status:this.loadStatus,error:this.loadError,edit:t,dirty:s,saving:i,realtime:this.realtimeStatus}}publish(){let t=this.compute(),r=this.state.get();if(r.value===t.value&&r.original===t.original&&r.status===t.status&&r.error===t.error&&r.edit===t.edit&&r.realtime===t.realtime&&r.dirty===t.dirty&&r.saving===t.saving)return;if(this.state.set(t),t.value!==r.value)this.events.emit("change",{rows:t.value===null?[]:[t.value]})}writeListeners=new Set;onWrite(t){return this.writeListeners.add(t),()=>void this.writeListeners.delete(t)}emitWrite(t){for(let r of[...this.writeListeners])r(t)}realtimeStatus="off";stopRealtime=null;loadedOnce=!1;receive(t){if(this.local||this.key_===null)return;let r=this.description;if(!_t(t.table,r.table))return;let i=(t.event==="delete"?t.old:t.record)?.[r.keyColumn??"id"];if(i===void 0||String(i)!==String(this.key_))return;this.receiveRow(t.event==="delete"?null:t.record)}receiveRow(t){let r=this.writer.incoming(F,t);if(r==="deferred"||r==="stale")return;if(t===null){if(r==="handled")return;this.original=null,this.loadStatus="error",this.loadError=new v("not_found","the record was deleted",{status:404}),this.publish();return}if(r==="none"&&!Ne(t,this.original,this.writer.versionColumn))return;let s=this.local?void 0:this.description.include;if(this.original=Ke(t,this.original,s),s&&this.state.observed)this.read(!0);this.loadStatus="ready",this.loadError=null,this.publish()}startRealtime(t){let r=this.transport;if(this.local||this.stopRealtime||this.description.realtime===!1||!r||typeof r.subscribe!=="function")return;let s=t;this.setRealtime("connecting",s),this.stopRealtime=r.subscribe({table:this.description.table},{change:(i)=>this.receive(i),status:(i)=>{let o=this.realtimeStatus;if(this.setRealtime(i,s),i==="live"&&o!=="live"&&this.loadedOnce&&this.state.observed)this.read(!0)}}),s=!1}setRealtime(t,r=!1){if(this.realtimeStatus===t)return;if(this.realtimeStatus=t,!this.state)return;if(r)this.state.replace(this.compute());else this.publish()}isNew(){return this.creating}create(t={}){if(this.local)throw new v("invalid_description","a local record is changed with set(), not created",{path:"value"});if(this.transport&&H(this.transport))throw new v("read_only","a function result cannot be created");this.cancel(),this.writer.revert();for(let r of this.children)r.revert();this.key_=null,this.creating=!0,this.original={},this.loadStatus="ready",this.loadError=null,this.stale=!1,this.writer.insertAs(F,{...t}),this.publish()}setKey(t){if(this.local)throw new v("invalid_description","a local record has no key",{path:"key"});if(t!==null&&!(typeof t==="string"&&t.length>0)&&!(typeof t==="number"&&Number.isFinite(t)))throw new v("invalid_description","key must be a non-empty string or a number",{path:"key"});if(t===this.key_&&!this.creating)return;this.creating=!1,this.key_=t,this.writer.revert();for(let r of this.children)r.revert();if(this.stale=!0,this.state.observed)this.read()}load(t){if(t!==void 0&&this.transport){if(H(this.transport)){if(this.transport.setArgs(t),this.stale=!0,this.state.observed)this.read()}else if(t&&typeof t==="object"&&"key"in t)this.setKey(t.key)}return this.loadReady()}sync(t){return this.load(t)}described=null;describeAs(t){this.described=t}toDescription(){if(this.described)return this.described;let t=this.description;if("value"in t)return{name:"",source:"data",data:t.value};let{table:r,type:s,...i}=t;return{name:"",source:"table",table:r,...i}}async loadReady(){let t=!1;for(let s=0;!this.local&&this.key_!==null&&s<8;s++)if(this.controller)await new Promise((i)=>this.waiters.push(i));else if(!t&&(this.stale||this.loadStatus==="idle"||this.loadStatus==="error"))t=!0,await this.read();else break;let r=this.get();if(r.status==="error"&&r.error)throw r.error;return r}refresh(){if(this.local||!this.state.observed)return this.stale=!0,Promise.resolve();return this.read()}set(t,r){let s=this.fields.path(t);if(s.length===0)throw new v("read_only","a record is changed field by field: give a path",{path:"field"});let i=this.get().value;if(i===null||typeof i!=="object")throw new v("read_only","nothing to change: the record is not loaded",{path:"field"});if(Array.isArray(i)){this.original=ce(i,s,r),this.publish();return}let o=String(s[0]),l=s.length===1?r:W(ce(i,s,r),[s[0]]);this.writer.set(F,this.original,o,l)}async save(){let t=this.writer.state(F);if(t.dirty&&this.events.has("beforesave")){let s=this.events.before("beforesave",{changes:[{id:F,kind:t.kind,values:t.changes}]});if(s===!1)return!1;for(let[i,o]of Object.entries(s))this.set(i,o)}let r=await this.saveAll();if(r&&t.dirty)this.events.emit("saved",{ids:[F]});if(!r){let s=this.writer.state(F),i=s.error??Object.values(s.errors)[0]??null;if(i)this.events.emit("error",{error:i,during:"save"})}return r}async saveAll(){if(this.creating){let s=this.writer.validate(F,null,!0),i=[...this.children].map((o)=>o.valid?.()??!0);if(!s||i.includes(!1))return!1}if(!await this.writer.save(F,()=>this.original,!0))return!1;return(await Promise.all([...this.children].filter((s)=>s.dirty()).map((s)=>s.save()))).every(Boolean)}revert(t){if(t===void 0){this.writer.revert(F);for(let r of this.children)r.revert();if(this.creating)this.writer.insertAs(F,{})}else this.writer.revert(F,String(this.fields.path(t)[0]))}resolve(t,r){this.writer.resolve(F,t===null?null:String(this.fields.path(t)[0]),r)}dismiss(){this.writer.dismiss(F)}start(){this.startDepends();let t=!this.local&&(this.stale||this.loadStatus==="idle");if(this.startRealtime(t&&this.key_!==null),t)this.read()}stop(){for(let t of this.stopDepends)t();if(this.stopDepends=[],this.cancel(),this.stale=!0,this.stopRealtime?.(),this.stopRealtime=null,this.loadedOnce=!1,this.setRealtime("off"),this.loadStatus==="loading")this.loadStatus=this.original===null?"idle":"ready",this.publish()}cancel(){this.seq++,this.controller?.abort(),this.controller=null;let t=this.waiters;this.waiters=[];for(let r of t)r()}read(t=!1){this.cancel(),this.stale=!1;let r=this.description;if(this.key_===null){if(this.creating)return Promise.resolve();return this.original=null,this.loadStatus="idle",this.loadError=null,this.publish(),Promise.resolve()}let s=this.seq,i=new Z.AbortController;this.controller=i;let o={table:r.table,where:{[r.keyColumn??"id"]:this.key_},...r.select?{select:r.select}:{},...r.include?{include:r.include}:{}};if(!t)this.loadStatus="loading",this.loadError=null,this.publish();let l=new Promise((u)=>this.waiters.push(u)),c=(u,g)=>{if(s!==this.seq)return;if(this.controller=null,g)this.loadStatus="error",this.loadError=g,this.events.emit("error",{error:g,during:"load"});else{if(!P(u,this.original))this.original=u;if(this.loadedOnce=!0,u&&this.writer.state(F)!==de)this.writer.incoming(F,u);this.loadStatus=u===null?"error":"ready",this.loadError=u===null?new v("not_found",`no visible row in "${r.table}" for this key`,{status:404}):null}if(this.publish(),!g&&u!==null)this.events.emit("load",{rows:[u],total:1});let d=this.waiters;this.waiters=[];for(let m of d)m()};if(this.events.has("beforeload")&&this.events.before("beforeload",{params:{key:this.key_}})===!1){if(this.controller=null,!t)this.loadStatus=this.original===null?"idle":"ready",this.publish();let u=this.waiters;this.waiters=[];for(let g of u)g();return l}return this.transport.findOne(o,{signal:i.signal}).then((u)=>c(u??null,null),(u)=>c(null,L(u))),l}}function $e(t,r){return new $r(ze(t),r??null)}var q=(t)=>typeof t==="object"&&t!==null&&t.kind==="store"&&t.type==="record";var Rr=(t)=>t.replace(/[\\%_]/g,(r)=>`\\${r}`);function At(t){let r=[];if(t.where&&Object.keys(t.where).length>0)r.push(t.where);if(t.search&&t.search.term&&t.search.columns.length>0){let s=`%${Rr(t.search.term)}%`,i=t.search.columns.map((o)=>({[o]:{ilike:s}}));r.push(i.length===1?i[0]:{or:i})}if(r.length===0)return;return r.length===1?r[0]:{and:r}}function ws(t){let r=At(t);return{...t.select?{select:t.select}:{},...r?{where:r}:{},...t.include?{include:t.include}:{},...t.order.length>0?{order:t.order.map((s)=>[s.column,s.direction])}:{},limit:t.limit,offset:t.offset}}function Ss(t){return{where:t.where,...t.select?{select:t.select}:{},...t.include?{include:t.include}:{}}}function vs(t){let r=At(t);return{...r?{where:r}:{},...t.group?{group:t.group}:{},...t.count?{count:!0}:{},...t.sum?{sum:t.sum}:{},...t.avg?{avg:t.avg}:{},...t.min?{min:t.min}:{},...t.max?{max:t.max}:{},...t.order&&t.order.length>0?{order:t.order.map((s)=>[s.column,s.direction])}:{},...t.limit!==void 0?{limit:t.limit}:{}}}var rt=(t,r)=>new v("unsupported",`the poad data service does not know ${t}: update poad`,{params:{feature:t},status:404,cause:r});function ks(t){let r=At(t);return{...r?{where:r}:{},...t.include?{include:t.include}:{}}}async function oe(t){let{data:r,error:s}=await t;if(s)throw L(s);return r}var ye=(t,r,s)=>t.abortable===!0&&s?.signal?{...r,signal:s.signal}:r;function jr(t,r={}){if(!t||typeof t.from!=="function")throw TypeError("poadTransport: expected a data-js or client-js client (with from())");let s=Os(t,r);if(s.subscribe&&r.followAuth!==!1)xs(t,s.reconnect);return{subscribe:s.subscribe,reconnectRealtime:s.reconnect,name:"poad",async find(i,o){let l=t.from(i.table);return await oe(l.find(ye(l,ws(i),o)))??[]},async count(i,o){let l=t.from(i.table);return await oe(l.count(ye(l,ks(i),o)))??0},async findOne(i,o){let l=t.from(i.table);return await oe(l.findOne(ye(l,Ss(i),o)))??null},async insert(i,o){let l=t.from(i.table);if(!l.create)throw Be("create");let u=(await oe(l.create({...i.values},ye(l,{returning:!0},o))))?.[0];if(!u)throw L({status:403,code:"forbidden",message:"the created row is not visible (returning)"});return u},async update(i,o){let l=t.from(i.table);if(!l.update)throw Be("update");return await oe(l.update(ye(l,{where:i.where,set:{...i.set},returning:!0},o)))??[]},async call(i,o){if(i.kind==="pgfn"){if(typeof t.rpc!=="function")throw Be("rpc");return await oe(t.rpc(i.name,i.args))}if(r.invoke)return await oe(r.invoke(i.name,i.args,o?.signal));if(typeof t.fn!=="function")throw Be("fn");return await oe(t.fn(i.name,i.args,o?.signal?{signal:o.signal}:{}))},async remove(i,o){let l=t.from(i.table);if(!l.destroy)throw Be("destroy");return await oe(l.destroy(ye(l,{where:i.where,returning:!0},o)))??[]},async aggregate(i,o){let l=t.from(i.table);if(typeof l.aggregate!=="function")throw rt("aggregate",null);let{data:c,error:u}=await l.aggregate(ye(l,vs(i),o));if(u){let g=L(u);if(g.status===404&&/opération inconnue|unknown operation|aucune ligne/i.test(g.message))throw rt("aggregate",u);throw g}return c??[]},async batch(i,o){let l=typeof t.call==="function"?t.call.bind(t):typeof t.data?.call==="function"?t.data.call.bind(t.data):void 0;if(!l)throw rt("batch",null);let c={operations:i.map((m)=>({...m,returning:!0}))},{data:u,error:g}=await l("POST","/_batch",c,o?.signal?{signal:o.signal}:{});if(g){let m=L(g);if(/table inconnue : _batch|unknown table:? _batch/i.test(m.message)||m.status===404&&!/_batch :/.test(m.message))throw rt("batch",g);let y=String(g.hint??""),k=/index=(\d+)/.exec(`${y} ${m.message}`)?.[1];throw Object.assign(m,k!==void 0?{batchIndex:Number(k)}:{})}let d=u?.results;if(!Array.isArray(d))throw new v("server","the batch answer has no results");return d.map((m)=>Array.isArray(m)?m:[])}}}function Os(t,r){let s=r.realtime,i=null,o=()=>{if(s===!1)return null;if(!i)i=typeof s==="function"?s():s??t.realtime??null;return i},l=new Map,c=0,u=(m,y,k)=>{if(m.status=y,k!==void 0)m.error=k;for(let x of[...m.subs])x.status(y,k)},g=(m,y)=>{let k=o();if(!k)return;let[x,R]=m.includes(".")?m.split(".",2):[void 0,m];y.closed=!1;let j=k.channel(`poad-data:${m}:${++c}`);j.on("change",{table:R,...x?{schema:x}:{}},(C)=>{if(y.closed)return;let T={event:C.event,table:m,...C.record!==void 0?{record:C.record}:{},...C.old_record!==void 0?{old:C.old_record}:{}};for(let B of[...y.subs])B.change(T)}),y.channel=j,j.subscribe((C,T)=>{if(y.closed||y.channel!==j)return;u(y,C==="SUBSCRIBED"?"live":C==="ERROR"?"error":"reconnecting",T)})},d=(m)=>{m.closed=!0;let y=m.channel;m.channel=null,y?.unsubscribe()};return{subscribe:o()===null?void 0:(m,y)=>{let k=l.get(m.table);if(!k)k={channel:null,subs:new Set,status:"connecting",closed:!1},l.set(m.table,k),k.subs.add(y),y.status("connecting"),g(m.table,k);else k.subs.add(y),y.status(k.status,k.error);let x=k,R=!0;return()=>{if(!R)return;if(R=!1,x.subs.delete(y),x.subs.size===0&&l.get(m.table)===x)l.delete(m.table),d(x)}},reconnect(){if(l.size===0)return;for(let m of l.values())d(m);if(i?.disconnect?.(),typeof s==="function")i=null;for(let[m,y]of l)u(y,"reconnecting"),g(m,y)}}}function xs(t,r){let s=t.auth;if(!s||typeof s.onChange!=="function")return;let i=void 0;s.onChange((o,l)=>{let c=l?.user?.id??null,u=i===void 0,g=i;if(i=c,u?o==="INITIAL_SESSION":c===g)return;r()})}var Be=(t)=>L({status:400,code:"invalid_request",message:`this client has no ${t}() (data-js >= 0.3.0)`});var $t=(t)=>(typeof t==="object"||typeof t==="function")&&t!==null;function nt(t){return $t(t)&&typeof t.find==="function"&&typeof t.count==="function"}function _s(t){return $t(t)&&typeof t.from==="function"&&!nt(t)}var As=(t)=>t===null?"null":Array.isArray(t)?"an array":$t(t)?`an object without from() nor find()/count() (keys: ${Object.keys(t).slice(0,6).join(", ")||"none"})`:typeof t;function Re(t,r="store.connect"){if(nt(t))return t;if(_s(t))return jr(t);throw new v("invalid_transport",`${r}: expected a poad client (createClient from @poadio/client-js, or a DataClient from @poadio/data-js) or a DataTransport, got ${As(t)}`,{path:"transport"})}function st(t,r){let s=t.client!==void 0&&t.client!==null,i=t.transport!==void 0&&t.transport!==null;if(s&&i)throw new v("invalid_transport",`${r}: pass either { client } or { transport }, not both`,{path:"transport"});if(s)return Re(t.client,`${r}({ client })`);if(i)return Re(t.transport,`${r}({ transport })`);return}async function it(t){let r=[...new Set(t)],s=[],i=[],o=[],l=!0,c=null;for(let g of r){if(!g.transport||g.transport.name==="memory"||H(g.transport)){if(g.transport===null||g.transport.name==="memory")o.push(g);continue}let d=g.pendingBatch();if(d===null){l=!1;continue}if(d.operations.length===0)continue;if(c&&c!==g.transport)throw new v("invalid_transport","sync: all the stores of a batch use the same poad project (one transport)");c??=g.transport,s.push({store:g,ids:d.ids,from:i.length,to:i.length+d.operations.length}),i.push(...d.operations)}if(!l)return!1;if(i.length>0){let g=c;if(typeof g.batch!=="function")throw new v("unsupported",`transport "${g.name}" cannot write a batch in one transaction`,{params:{feature:"batch"}});for(let m of s)m.store.batchStart(m.ids);let d;try{d=await g.batch(i,{signal:new Z.AbortController().signal})}catch(m){let y=L(m),k=typeof m?.batchIndex==="number"?m.batchIndex:null;if(await Promise.all(s.map((x)=>{let R=k!==null&&k>=x.from&&k<x.to?x.ids[k-x.from]:k===null?null:"\x00";return x.store.batchFailed(x.ids,y,R)})),y.code==="unsupported")throw y;return!1}for(let m of s)m.store.batchDone(m.ids,d.slice(m.from,m.to))}return(await Promise.all(o.map((g)=>g.type==="list"?g.save():g.save()))).every(Boolean)}var Rt=1,$s=new Set(["version","store","field","fields","fieldsOnly"]),Rs=/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/,js=(t)=>typeof t==="object"&&t!==null&&!Array.isArray(t)&&(Object.getPrototypeOf(t)===Object.prototype||Object.getPrototypeOf(t)===null);function je(t,r="store"){if(typeof t!=="string"||!Rs.test(t))throw new v("invalid_binding",`invalid store name at ${r}: expected a letter then letters, digits, "_" or "-" (64 at most)`,{path:r});return t}function be(t,r={}){if(!js(t))throw new v("invalid_binding",'invalid binding: expected { "store": "…", "field"?: "…" }',{path:"$"});for(let c of Object.keys(t))if(!$s.has(c))throw new v("invalid_binding",`invalid binding at ${c}: unknown key`,{path:c});if(t.version!==void 0&&t.version!==Rt)throw new v("invalid_binding",`invalid binding at version: this engine reads version ${Rt}`,{path:"version"});let s=je(t.store);if(t.field!==void 0&&typeof t.field!=="string")throw new v("invalid_binding","invalid binding at field: expected a path",{path:"field"});let i=ue(K(t.field)),o={version:Rt,store:s,field:i,...t.fields!==void 0?{fields:te(t.fields,r.meta?{meta:r.meta}:{})}:{},fieldsOnly:!1},l=o.fields?.findIndex((c)=>c.compute!==void 0)??-1;if(l>=0)throw new v("invalid_binding",`invalid binding at fields[${l}].compute: a computed field is declared in the store's fields`,{path:`fields[${l}].compute`});if(t.fieldsOnly!==void 0){if(typeof t.fieldsOnly!=="boolean")throw new v("invalid_binding","invalid binding at fieldsOnly: expected true or false",{path:"fieldsOnly"});if(t.fieldsOnly&&o.fields===void 0)throw new v("invalid_binding",'invalid binding at fieldsOnly: needs "fields"',{path:"fieldsOnly"});o.fieldsOnly=t.fieldsOnly}return jt.add(o),o}var jt=new WeakSet,Er=(t)=>typeof t==="object"&&t!==null&&jt.has(t)?t:be(t),Cr=(t)=>("table"in t.description)?t.description.table:null;function Nr(t={}){let r=new Map,s=t.client!==void 0&&t.client!==null?st(t,"createStoreRegistry"):void 0,i=null,o=()=>{if(s)return s;let d=t.transport;if(d===void 0||d===null)return;if(nt(d))return d;if(i?.from!==d)i={from:d,to:Re(d,"createStoreRegistry({ transport })")};return i.to},l=(d)=>r.get(d)?.store??null,c=(d)=>{let m=u(d);if(typeof m.store.linkStores==="function")m.store.linkStores(l);return m},u=(d)=>{if(V(d)||q(d)){let j=V(d)?d.description.parent:void 0;if(j&&V(d)&&d.parentKey()===null)d.linkParent(()=>{let C=r.get(j.store)?.store??null;return C&&q(C)?C:null});return{store:d,key:d}}let m=vt(d),y=JSON.stringify(m);if(m.type==="record"){let j="value"in m,C=o();if(!j&&!C)throw new v("invalid_description","a remote record needs a transport: createStoreRegistry({ client })",{path:"transport"});return{store:$e(m,C??null),key:y}}let k=o();if(!k)throw new v("invalid_description","a list description needs a transport: createStoreRegistry({ client })",{path:"transport"});let x=ae(k,m),R=m.parent;if(R)x.linkParent(()=>{let j=r.get(R.store)?.store??null;return j&&q(j)?j:null});return{store:x,key:y}},g={define(d,m){je(d,"name");let y=r.get(d),k;if(y){if(!(y.source===m||typeof y.source==="string"&&!V(m)&&!q(m)&&y.source===JSON.stringify(vt(m))))throw new v("duplicate_store",`a different store is already named "${d}"`,{params:{name:d},path:d});y.refs++,k=y}else{let{store:R,key:j}=c(m);k={store:R,source:j,refs:1},r.set(d,k);let C=k;C.stopWrite=typeof R.onWrite==="function"?R.onWrite((T)=>{let B=Cr(R);if(!B)return;for(let Q of new Set([...r.values()].map((ee)=>ee.store))){if(Q===R||Cr(Q)!==B)continue;if(typeof Q.receive==="function")Q.receive(T);else Q.refresh()}}):void 0}let x=!1;return{name:d,store:k.store,release(){if(x)return;if(x=!0,--k.refs===0&&r.get(d)===k)r.delete(d),k.stopWrite?.()}}},get(d){let m=r.get(d);if(!m)throw new v("unknown_store",`no store named "${d}"`,{params:{name:d},path:d});return m.store},has:(d)=>r.has(d),names:()=>[...r.keys()],saveAll:()=>it([...new Set([...r.values()].map((d)=>d.store))]),field(d){let m=typeof d==="object"&&d!==null&&jt.has(d)?d:be(d);return Oe(g.get(m.store),m.field)}};return g}var Cs=new v("invalid_binding","invalid binding: give either data (JSON) or store (and field), not both",{path:"store"}),Es=new v("invalid_binding",'invalid binding at field: a field needs a store (store="…" or [store]="…")',{path:"field"}),Ns=new v("invalid_binding",'invalid binding at fields: fields need a store (store="…" or [store]="…")',{path:"fields"}),Ts=new v("invalid_binding","invalid binding at fields: expected an array of fields",{path:"fields"}),Tr=new v("invalid_binding","invalid binding at store: expected a store object or the name of a store of the registry",{path:"store"}),Dr=new WeakMap,Pr=new Map,zr=new WeakMap,ot=(t)=>typeof t==="object"&&t!==null&&t.kind==="store-binding";function Lr(t,r){if(ot(t))return{binding:be({store:"_",...t.field?{field:t.field}:{},fields:t.fields}),store:t.store};let s=Er(t);if(!r)throw new v("invalid_binding","a JSON binding needs a store registry (provide one with your framework adapter)",{path:"store"});return{binding:s,store:r.get(s.store)}}function at(t,r,s,i){let o=r!==null&&r!==void 0&&r!=="",l=s!==null&&s!==void 0&&s!=="",c=i!==null&&i!==void 0;if(!o&&!l&&!c)return t??null;if(t!==null&&t!==void 0)return Cs;if(!o)return l?Es:Ns;if(c){if(typeof i!=="object")return Ts;if(typeof r!=="string"&&!V(r)&&!q(r))return Tr;let u=zr.get(i);if(!u)zr.set(i,u=new Map);let g=u.get(r);if(!g)u.set(r,g=new Map);let d=l?s:"",m=g.get(d);if(m===void 0)m=typeof r==="string"?{store:r,...l?{field:s}:{},fields:i}:Object.freeze({kind:"store-binding",store:r,field:d,fields:i}),g.set(d,m);return m}if(typeof r==="string"){let u=`${r}\x00${l?s:""}`,g=Pr.get(u);if(!g)Pr.set(u,g=l?{store:r,field:s}:{store:r});return g}if(V(r)&&!l)return r;if(V(r)||q(r)){let u=Dr.get(r);if(!u)Dr.set(r,u=new Map);let g=l?s:"",d=u.get(g);if(!d)u.set(g,d=Oe(r,g));return d}return Tr}var Fr=["select","where","order","pageSize","include","search","keyColumn","version","fields","save","realtime","reference","parent","key","cursor","params","dependsOn","autoLoad","aggregate"],Ds=new Set(["key","keyColumn","select","include","version","fields","save","realtime","dependsOn","autoLoad"]),Ir=["args","result","server","order","pageSize","search","fields","keyColumn","cursor","dependsOn","autoLoad"],Ps=/^[A-Za-z0-9_-]{1,63}$/,zs=/^[A-Za-z_][A-Za-z0-9_]{0,62}$/,Mr={data:[],table:Fr,view:[...Fr,"readOnly"],pgfn:Ir,fn:Ir},Kr=(t)=>typeof t==="object"&&t!==null&&!Array.isArray(t),G=(t,r)=>{throw new v("invalid_description",`invalid store at ${t}: ${r}`,{path:t})};function Br(t){if(!Kr(t))return G("$",'expected { "name": …, "source": "data" | "table" | "view" | "pgfn" | "fn", … }');let{name:r,source:s,...i}=t;if(je(r,"name"),typeof s!=="string"||!(s in Mr))return G("source",'expected "data", "table", "view", "pgfn" or "fn"');let o=s;if(!(o in i))G(o,`expected the ${o==="data"?"data (an object or an array)":`${o} name`}`);let{[o]:l,...c}=i,u=new Set(Mr[o]);for(let x of Object.keys(c))if(!u.has(x))G(x,`unknown key for a "${o}" store`);if(o==="data"){if(!Kr(l)&&!Array.isArray(l))G("data","expected an object (a record) or an array (rows)");return t}if(o==="table"||o==="view"){if(typeof l!=="string")return G(o,`expected the ${o} name`);let x=c;if(x.readOnly!==void 0&&typeof x.readOnly!=="boolean")G("readOnly","expected true or false");let{readOnly:R,key:j,...C}=x;if(j!==void 0){for(let T of Object.keys(x))if(T!=="readOnly"&&!Ds.has(T))G(T,"not an option of a single record (key)");ze({type:"record",table:l,...j!==null?{key:j}:{},...C})}else se({table:l,...C});return t}if(typeof l!=="string"||!(o==="pgfn"?zs:Ps).test(l))return G(o,"expected a function name");let g=c;if(g.result!==void 0&&g.result!=="rows"&&g.result!=="record")G("result",'expected "rows" or "record"');if(g.server!==void 0&&typeof g.server!=="boolean")G("server","expected true or false");if(g.args!==void 0)try{JSON.stringify(g.args)}catch{G("args","expected JSON")}let{args:d,result:m,server:y,...k}=g;return se({table:"__fn",...k}),t}var Ls=new Set(["data","table","view","pgfn","fn"]),Fs=(t)=>typeof t==="object"&&t!==null&&!Array.isArray(t),We=(t,r)=>{throw new v("invalid_description",`invalid store at ${t}: ${r}`,{path:t})},Is=(t,r)=>`__${t}_${r.replace(/[^A-Za-z0-9_]/g,"_")}`.slice(0,63),Ms=["keyColumn","select","include","version","fields","save","realtime","dependsOn","autoLoad"];function Ks(t){return{name:`${t.name}:read-only`,find:(r,s)=>t.find(r,s),count:(r,s)=>t.count(r,s),...t.findOne?{findOne:(r,s)=>t.findOne(r,s)}:{},...t.aggregate?{aggregate:(r,s)=>t.aggregate(r,s)}:{},...t.subscribe?{subscribe:(r,s)=>t.subscribe(r,s)}:{}}}function Bs(t={}){let r=st(t,"createStore")??null,s=Nr({get transport(){return r??void 0}}),i=(d)=>r??We("transport",`${d} needs a transport: store.connect(client) first`),o=new WeakMap,l=(d,m,y)=>{if(je(d,"name"),s.has(d)){let x=s.get(d);if(o.get(x)===JSON.stringify(m)||typeof x.toDescription==="function"&&JSON.stringify(x.toDescription())===JSON.stringify(m))return x}let k=y();return o.set(k,JSON.stringify(m)),k.describeAs(m),s.define(d,k),k},c=(d,m,y,k={})=>{let x={name:d,source:m,[m]:y,...k};return l(d,x,()=>{let R=i(m),j=m==="view"&&k.readOnly?Ks(R):R,{key:C,readOnly:T,...B}=k;if(C!==void 0){let Q={type:"record",table:y,...C!==null?{key:C}:{}};for(let ee of Ms)if(B[ee]!==void 0)Q[ee]=B[ee];return $e(Q,j)}return ae(j,{table:y,...B})})},u=(d,m,y,k={})=>{let x={name:d,source:m,[m]:y,...k};return l(d,x,()=>{let R=vr(i(m),m,y,k),j=Is(m,y);if(k.result==="record")return $e({type:"record",table:j,key:"*",keyColumn:k.keyColumn??"__fn",realtime:!1,...k.fields?{fields:k.fields}:{}},R);return ae(R,{table:j,realtime:!1,...k.order?{order:k.order}:{},...k.pageSize?{pageSize:k.pageSize}:{},...k.search?{search:k.search}:{},...k.fields?{fields:k.fields}:{},...k.keyColumn?{keyColumn:k.keyColumn}:{},...k.cursor?{cursor:k.cursor}:{},...k.dependsOn?{dependsOn:k.dependsOn}:{},...k.autoLoad?{autoLoad:k.autoLoad}:{}})})},g={registry:s,get transport(){return r},connect(d){return r=Re(d,"store.connect"),g},define(d,m){if(Array.isArray(m))return l(d,{name:d,source:"data",data:m},()=>ae(Sr(m),{table:`__data_${d.replace(/[^A-Za-z0-9_]/g,"_")}`.slice(0,63),pageSize:Math.min(Math.max(m.length,20),1000)}));if(!Fs(m))return We("data","define takes local data: an object (a record) or an array (rows)");return l(d,{name:d,source:"data",data:m},()=>$e({type:"record",value:m}))},table:(d,m,y)=>c(d,"table",m,y),view:(d,m,y)=>c(d,"view",m,y),pgfn:(d,m,y)=>u(d,"pgfn",m,y),fn:(d,m,y)=>u(d,"fn",m,y),fromJSON(d){Br(d);let{name:m,source:y,...k}=d;if(typeof m!=="string")return We("name","expected a store name");if(typeof y!=="string"||!Ls.has(y))return We("source",'expected "data", "table", "view", "pgfn" or "fn"');let x=k[y],{[y]:R,...j}=k;if(y==="data")return g.define(m,x);if(typeof x!=="string")return We(y,`expected the ${y} name`);if(y==="table"||y==="view")return c(m,y,x,j);return u(m,y,x,j)},get:(d)=>s.get(d),has:(d)=>s.has(d),names:()=>s.names(),field:(d)=>s.field(d),sync:(d)=>it(d.map((m)=>typeof m==="string"?s.get(m):m)),saveAll:()=>s.saveAll()};return g}var Ws=Bs();function Wr(){return typeof globalThis.document<"u"?Ws.registry:null}var Zr=new Map;function Jr(t,r){let s=Zr.get(t);if(!s)s=r(),Zr.set(t,s);return s}var Vr=/^(\d{4})-(\d{2})-(\d{2})$/;function Zs(t){if(t instanceof Date)return Number.isNaN(t.getTime())?null:t;if(typeof t==="number")return Number.isFinite(t)?new Date(t):null;if(typeof t!=="string"||!t)return null;let r=Vr.exec(t),s=r?new Date(Number(r[1]),Number(r[2])-1,Number(r[3])):/^\d{4}-\d{2}-\d{2}[T ]/.test(t)?new Date(t):null;return s&&!Number.isNaN(s.getTime())?s:null}function Ct(t,r,s){if(t===null||t===void 0||t==="")return"";let i=r.fieldType??r.type??"text",o=r.format??{},l=s.locale;switch(i){case"number":{let c=typeof t==="number"?t:typeof t==="string"&&t.trim()!==""?Number(t):NaN;if(!Number.isFinite(c))return String(t);let u=`n|${l}|${o.currency??""}|${o.percent?1:0}|${o.decimals??""}`;return Jr(u,()=>new Intl.NumberFormat(l,{...o.currency?{style:"currency",currency:o.currency}:o.percent?{style:"percent"}:{},...o.decimals!==void 0?{minimumFractionDigits:o.decimals,maximumFractionDigits:o.decimals}:o.currency?{}:{maximumFractionDigits:2}})).format(c)}case"date":case"datetime":{let c=Zs(t);if(!c)return String(t);let u=o.date??"short",g=i==="datetime"&&!(typeof t==="string"&&Vr.test(t)),d=`d|${l}|${u}|${g?1:0}`;return Jr(d,()=>new Intl.DateTimeFormat(l,{...u==="short"?{year:"numeric",month:"2-digit",day:"2-digit"}:{dateStyle:u},...g?u==="short"?{hour:"2-digit",minute:"2-digit"}:{timeStyle:"short"}:{}})).format(c)}case"boolean":return typeof t==="boolean"?s.booleanText?s.booleanText(t):String(t):String(t);case"enum":{let c=(r.filterOptions??r.options)?.find((u)=>u.value===t);return c?String(typeof c.label==="string"?c.label:t):String(t)}default:if(typeof t==="object")try{return JSON.stringify(t)}catch{return String(t)}return String(t)}}var Ur=/^[A-Za-z_][A-Za-z0-9_]{0,62}$/,lt=Object.freeze([]),Yr=20,Et=(t,r)=>{let s=t;for(let i of r.split(".")){if(s===null||typeof s!=="object")return;s=s[i]}return s},Gr=(t)=>t===null||t===void 0?"":typeof t==="object"?JSON.stringify(t):String(t);function Js(t,r){let s=r.fields??(t.description.fields?te(t.description.fields):[]),i=Ee(s,"key")[0]?.field??t.keyColumn,o=Ee(s,"label")[0]?.field??s.find((g)=>g.type==="text"&&g.field!==i)?.field??i,l=Ee(s,"description")[0]?.field,c=Ee(s,"search").map((g)=>g.field).filter((g)=>Ur.test(g)),u=c.length?c:t.description.search?.length?t.description.search:Ur.test(o)?[o]:[];return{key:i,label:o,...l?{description:l}:{},search:u}}var Xr=(t,r)=>{let s=r.description?Gr(Et(t,r.description)):"";return{value:Et(t,r.key),label:Gr(Et(t,r.label)),...s?{description:s}:{},row:t}},Hr=(t,r)=>t.map((s)=>({value:s.value,label:Ue(s.label,r)})),we=(t,r)=>t===r||t!==null&&r!==null&&t!==void 0&&r!==void 0&&typeof t!=="object"&&String(t)===String(r)||P(t,r),Nt=(t)=>t.normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase();function Tt(t,r){let s=Nt(r.trim());if(!s)return[...t];return t.filter((i)=>Nt(i.label).includes(s)||(i.description?Nt(i.description).includes(s):!1))}function Qr(t,r){return new qr(t,r)}class qr{ref;roles;store;error;cell;stops=[];searchStore=null;stopSearch=null;term="";looked=new Map;asked=new Set;wanted=[];lookupSeq=0;lastRows=null;lastSearchRows=null;baseOptions=lt;searchOptions=lt;constructor(t,r){this.ref=t;let s=null,i=null;try{if(!r)throw new v("invalid_binding","a reference store needs a store registry (provide one with your framework adapter)",{path:"options.store"});let o=r.get(t.store);if(!V(o))throw new v("invalid_binding",`the reference "${t.store}" must be a list store`,{path:"options.store"});s=o}catch(o){i=L(o)}this.store=s,this.error=i,this.roles=s?Js(s,t):null,this.cell=new Y(this.compute(),{start:()=>this.start(),stop:()=>this.stop()})}get(){if(!this.cell.observed)this.sync();return this.cell.get()}subscribe(t){return this.cell.subscribe(t)}keyOf=(t)=>t!==null&&typeof t==="object"?JSON.stringify(t):String(t);find(t){if(t===null||t===void 0)return;return this.get().options.find((s)=>we(s.value,t))??this.baseOptions.find((s)=>we(s.value,t))??this.looked.get(this.keyOf(t))}search(t){let r=t.trim();if(r===this.term)return;if(this.term=r,!this.store)return;let s=this.store.get();if(!r||this.complete(s)){this.closeSearch(),this.sync();return}let i=this.roles;if(!this.searchStore){let o=this.store.description;this.searchStore=ae(this.store.transport,{table:o.table,...o.select?{select:o.select}:{},...o.where?{where:o.where}:{},...o.order?{order:o.order}:{},...o.include?{include:o.include}:{},...o.keyColumn?{keyColumn:o.keyColumn}:{},...i.search.length?{search:i.search}:{},pageSize:o.reference?Yr:o.pageSize??Yr,realtime:!1,debounceMs:0})}if(this.searchStore.update({search:r}),this.cell.observed&&!this.stopSearch)this.stopSearch=this.searchStore.subscribe(()=>this.sync());this.sync()}suggest(t){if(!this.store)return Promise.resolve(lt);let r=this.store.get();if(this.complete(r)||!t.trim())return this.search(""),this.whenLoaded(this.store).then(()=>Tt(this.baseOptionsNow(),t));this.search(t);let s=this.searchStore;return this.whenLoaded(s).then(()=>this.optionsOf(s.get().rows))}whenLoaded(t){let r=()=>t.get().status==="ready"||t.get().status==="error";if(r()&&!(t===this.searchStore&&t.get().search.trim()!==this.term))return Promise.resolve();return new Promise((s)=>{let i=t.subscribe(()=>{if(!r())return;i(),s()})})}baseOptionsNow(){return this.sync(),this.baseOptions}want(t){this.wanted=t.filter((r)=>r!==null&&r!==void 0),this.lookup(),this.sync()}async retry(){await this.store?.refresh()}complete(t){return t.status==="ready"&&t.total!==null&&t.total<=t.rows.length}optionsOf(t){let r=this.roles;return t.map((s)=>Xr(s,r))}lookup(){let t=this.store;if(!t||!this.cell.observed||t.get().status!=="ready")return;let r=(u)=>this.baseOptions.some((g)=>we(g.value,u))||this.looked.has(this.keyOf(u)),s=this.wanted.filter((u)=>!r(u)&&!this.asked.has(this.keyOf(u))&&typeof u!=="object");if(s.length===0)return;for(let u of s)this.asked.add(this.keyOf(u));let i=this.roles,o=t.description,l=++this.lookupSeq,c=new Z.AbortController;t.transport.find({table:o.table,...o.select?{select:o.select}:{},...o.include?{include:o.include}:{},where:{[i.key]:{in:s}},order:[],limit:s.length,offset:0},{signal:c.signal}).then((u)=>{for(let g of u){let d=Xr(g,i);this.looked.set(this.keyOf(d.value),d)}this.sync()},()=>{})}start(){if(!this.store)return;if(this.stops.push(this.store.subscribe(()=>{this.sync(),this.lookup()})),this.searchStore&&this.term)this.stopSearch=this.searchStore.subscribe(()=>this.sync());this.sync(),this.lookup()}stop(){let t=this.stops;this.stops=[];for(let r of t)r();this.stopSearch?.(),this.stopSearch=null}closeSearch(){this.stopSearch?.(),this.stopSearch=null}sync(){let t=this.compute(),r=this.cell?.get();if(r&&r.options===t.options&&r.loading===t.loading&&r.error===t.error&&r.complete===t.complete&&r.search===t.search)return;if(this.cell)this.cell.set(t)}compute(){if(!this.store)return{options:lt,loading:!1,error:this.error,complete:!0,search:""};let t=this.store.get();if(t.rows!==this.lastRows)this.lastRows=t.rows,this.baseOptions=this.optionsOf(t.rows);let r=!!this.term&&!!this.searchStore&&this.stopSearch!==null,s=r?this.searchStore.get():null;if(s&&s.rows!==this.lastSearchRows)this.lastSearchRows=s.rows,this.searchOptions=this.optionsOf(s.rows);let i=s?this.searchOptions:this.baseOptions,o=[];for(let g of this.wanted){if(i.some((m)=>we(m.value,g)))continue;let d=this.baseOptions.find((m)=>we(m.value,g))??this.looked.get(this.keyOf(g));if(d)o.push(d)}let l=o.length?[...i,...o]:i,c=this.cell?.get();return{options:c&&c.options.length===l.length&&c.options.every((g,d)=>g===l[d])?c.options:l,loading:t.status==="loading"||s?.status==="loading",error:t.error??s?.error??null,complete:this.complete(t),search:r?this.term:""}}}var en=(t)=>typeof t==="object"&&t!==null&&Array.isArray(t.path)&&typeof t.subscribe==="function"&&("store"in t);var Pt=(t)=>en(t)||ot(t)||t instanceof v?t:JSON.stringify(t),Dt=(t,r=2)=>String(t).padStart(r,"0"),tn=(t)=>`${Dt(t.getFullYear(),4)}-${Dt(t.getMonth()+1)}-${Dt(t.getDate())}`;function rn(t,r){if((r==="date"||r==="datetime")&&typeof t==="string"&&t){let s=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(s)return new Date(Number(s[1]),Number(s[2])-1,Number(s[3]));let i=new Date(t);return Number.isNaN(i.getTime())?t:i}return t}function nn(t,r){if(r==="date")return t instanceof Date?tn(t):t===""?null:t;if(r==="datetime")return t instanceof Date?t.toISOString():t===""?null:t;if(r==="number"){if(t===""||t===null||t===void 0)return null;if(typeof t==="string"){let s=Number(t.replace(",","."));return Number.isFinite(s)?s:t}return t}return t}function Vs(t,r){try{let s=(typeof r==="function"?r():r)??Wr();if(t instanceof v)throw t;if(en(t))return{target:t,binding:null,field:null,error:null,registry:s};let{binding:i,store:o}=Lr(ot(t)?t:be(t),s);if(!V(o)&&!q(o))throw new v("unknown_store",`no store named "${i.store}"`,{params:{name:i.store},path:"store"});let l=Oe(o,i.field),c=i.fields?.find((u)=>u.field===i.field||u.key===i.field)??(i.fields?.length===1?i.fields[0]:void 0);return{target:l,binding:i,field:c??null,error:null,registry:s}}catch(s){return{target:null,binding:null,field:null,error:L(s),registry:null}}}var Us=(t)=>{let r=t.path;if(t.store.type==="record")return typeof r[0]==="string"?r[0]:null;return typeof r[1]==="string"?r[1]:null};class sn{r;cell;stops=[];constructor(t,r){this.r=Vs(t,r),this.cell=new Y(this.compute(),{start:()=>this.start(),stop:()=>this.stop()})}get target(){return this.r.target}get binding(){return this.r.binding}get(){if(!this.cell.observed)this.sync();return this.cell.get()}subscribe(t){return this.cell.subscribe(t)}toJSON(){throw new v("not_serializable","a field binding cannot be serialised: pass its JSON description instead")}descriptor(){if(this.r.field)return this.r.field;let t=this.r.target;if(!t)return null;let r=Us(t);return r?t.store.fields.rule(r)??null:null}feed=null;feedFor=null;stopFeed=null;localized=null;optionsFeed(){let t=this.descriptor()?.reference;if(!t)return null;let r=JSON.stringify(t);if(this.feed&&this.feedFor===r)return this.feed;if(this.stopFeed?.(),this.stopFeed=null,this.feed=Qr(t,this.r.registry),this.feedFor=r,this.cell?.observed)this.listenFeed();return this.feed}listenFeed(){if(!this.feed||this.stopFeed)return;this.stopFeed=this.feed.subscribe(()=>this.sync()),this.wantValue()}wantValue(){let t=this.r.target?.get();this.feed?.want(Array.isArray(t)?t:t===null||t===void 0?[]:[t])}options(t){let r=this.descriptor();if(!r)return null;if(r.reference)return this.optionsFeed()?.get().options??null;if(!r.options)return null;let s=this.localized;if(s&&s.locale===t&&s.source===r.options)return s.out;let i=Hr(r.options,t);return this.localized={locale:t,source:r.options,out:i},i}searchOptions(t){this.optionsFeed()?.search(t)}suggest(t,r){let s=this.optionsFeed();if(s)return s.suggest(t);return Promise.resolve(Tt(this.options(r)??[],t))}optionOf(t,r){let s=this.optionsFeed();if(s)return s.find(t);return(this.options(r)??[]).find((i)=>we(i.value,t))}set(t){let r=this.r.target;if(!r||!r.writable)return;if(P(t,r.get()))return;r.set(t)}setFromControl(t){this.set(nn(t,this.descriptor()?.type))}controlValue(){return rn(this.get().value,this.descriptor()?.type)}resolve(t){this.r.target?.resolve(t)}revert(){this.r.target?.revert()}format(t,r){let s=this.descriptor();if(!s)return Ct(t,{},r);let i=s.options?.map((o)=>({value:o.value,label:Ue(o.label,r.locale)}));return Ct(t,{fieldType:s.type,...s.format?{format:s.format}:{},...i?{options:i}:{}},r)}start(){let t=this.r.target;if(!t)return;if(this.r.field)this.stops.push(t.store.fields.use([this.r.field]));if(this.stops.push(t.subscribe(()=>{this.wantValue(),this.sync()})),this.stops.push(t.status.subscribe(()=>this.sync())),this.stops.push(t.store.subscribe(()=>this.sync())),this.optionsFeed())this.listenFeed();this.sync()}stop(){let t=this.stops;this.stops=[];for(let r of t)r();this.stopFeed?.(),this.stopFeed=null}sync(){let t=this.compute(),r=this.cell.get();if(r.value===t.value&&r.writable===t.writable&&r.dirty===t.dirty&&r.saving===t.saving&&r.error===t.error&&r.conflict===t.conflict&&r.loading===t.loading&&r.field===t.field&&Gs(r.choice,t.choice))return;this.cell.set(t)}compute(){let t=this.r.target,r=this.descriptor();if(!t){let l=this.r.error;return{value:void 0,writable:!1,dirty:!1,saving:!1,error:l,conflict:null,loading:!1,field:null,required:!1,errorKey:l?.messageKey??null,...l?.params?{errorParams:l.params}:{},choice:null}}let s=t.status.get(),i=t.store.get(),o=s.error??(i.status==="error"?i.error:null);return{value:t.get(),writable:s.writable,dirty:s.dirty,saving:s.saving,error:o,conflict:s.conflict,loading:i.status==="loading",field:r,required:!!r?.rules?.required,errorKey:o?.messageKey??null,...o?.params?{errorParams:o.params}:{},choice:this.choiceState(r)}}choiceState(t){if(t?.reference){let r=this.feed&&this.feedFor===JSON.stringify(t.reference)?this.feed:null,s=r?r.get():null;return{source:"reference",loading:s?.loading??!1,complete:s?.complete??!1,error:s?.error??null,options:s?.options??null}}if(t?.options)return Ys;return null}}var Ys=Object.freeze({source:"static",loading:!1,complete:!0,error:null,options:null}),Gs=(t,r)=>t===r||!!t&&!!r&&t.source===r.source&&t.loading===r.loading&&t.complete===r.complete&&t.error===r.error&&t.options===r.options;function zt(t,r={}){return new sn(t,r.registry)}function Lt(t,r,s,i){let o=!!r.conflict,l=o?s("data.conflict_field",{theirs:t.format(r.conflict.theirs,i)||"—"}):r.errorKey?s(r.errorKey,r.errorParams):null,c=[r.dirty?"is-dirty":"",r.saving?"is-saving":"",o?"is-conflict":""].filter(Boolean).join(" ");return{invalid:!!r.error||o,classes:c,message:l,conflict:o,required:r.required}}var on=(t)=>`${t}-msg`,an=(t)=>!!t.error;function Ft(t){if(t.error)return{id:on(t.id),text:t.error,error:!0,role:"alert",className:"poad-field__msg is-error"};if(t.hint)return{id:on(t.id),text:t.hint,error:!1,role:null,className:"poad-field__msg"};return null}function ln(t){return{"aria-describedby":Ft(t)?.id??null,"aria-invalid":an(t)?"true":null}}function cn(t){return{"is-invalid":an(t),"is-disabled":!!t.disabled,"is-inline":!!t.inline,"size-sm":t.size==="sm","size-lg":t.size==="lg","is-plain":!!t.plain}}function un(t){return{"size-sm":t.size==="sm","size-lg":t.size==="lg","is-invalid":!!t.invalid,"is-mono":!!t.mono}}function fn(t,r){return{"aria-invalid":t.invalid||r?.["aria-invalid"]==="true"?"true":null,"aria-describedby":r?.["aria-describedby"]??null}}var dn=(t)=>`${t+2}px`;function hn(t,r={},s){let i=[t];for(let[o,l]of Object.entries(r))if(l)i.push(o);if(s)i.push(s);return i.join(" ")}var pn=Symbol("poad.storeRegistry");var It=Symbol("poad-bound-field-source");function gn(t,r=!0){let s=a(pn,null),i=r?a(It,null):null,o=p(),l=f(null),c=f(null),u=null,g=!1,d=void 0,m=()=>t()??i?.()??null,y=()=>{u?.(),u=null;let R=l.value;if(!R||!g)return;u=R.subscribe((j)=>c.value=j),c.value=R.get()},k=(R)=>{let j=R==null?null:Pt(R);if(l.value&&j===d)return;d=j,u?.(),u=null,l.value=R==null?null:zt(R,{registry:s}),c.value=l.value?l.value.get():null,y()};if(k(m()),E(m,(R)=>k(R)),_())S(()=>{g=!0,y()}),w(()=>{g=!1,u?.(),u=null});let x=h(()=>{let R=l.value,j=c.value;if(!R||!j)return null;return Lt(R,j,(C,T)=>o.t(C,T),{locale:o.locale})});return{binding:l,state:c,view:x,value:()=>(c.value,l.value?.controlValue()),input:(R)=>l.value?.setFromControl(R)}}var mn=Symbol("poad-field-binding"),yn=Symbol("poad-field"),mu=n({name:"PoadField",props:{label:String,hint:String,error:String,required:Boolean,disabled:Boolean,inline:Boolean,size:{type:String,default:"md"},plain:Boolean,optionalText:String,optional:Boolean,id:String,data:{type:Object,default:null},store:{type:[Object,String],default:null},field:{type:String,default:null}},setup(t,{slots:r}){let{text:s,t:i}=p(),o=D(),l=gn(()=>at(t.data,t.store,t.field),!1);b(It,()=>at(t.data,t.store,t.field)),b(mn,l);let c=h(()=>{let u=l.view.value;return{...t,id:o,error:u?.message??t.error,required:t.required||!!u?.required}});return b(yn,h(()=>({controlId:t.id??o,control:ln(c.value)}))),()=>{let u=Ft(c.value),g=t.optionalText??(t.optional?s(null,"field.optional"):""),d=l.state.value,m=!!d?.conflict;return e("div",{class:hn("poad-field",{...cn(c.value),"is-dirty":!!d?.dirty,"is-saving":!!d?.saving,"is-conflict":m})},[t.label&&e("label",{class:"poad-field__label",for:t.id??o},[t.label,c.value.required&&e("span",{class:"poad-field__req","aria-hidden":"true"},"*"),g&&e("span",{class:"poad-field__opt"},g),d?.dirty&&e("span",{class:"poad-field__mod"},i("data.modified"))]),e("div",{class:"poad-field__box"},r.default?.()),u&&e("div",{class:u.className+(m?" is-conflict":""),id:u.id,role:u.role??void 0},u.text),m&&e("div",{class:"poad-field__actions"},[e(M,{size:"sm",variant:"outline",severity:"secondary",type:"button","data-choice":"mine",onClick:()=>l.binding.value?.resolve("mine")},()=>i("data.keep_mine")),e(M,{size:"sm",variant:"outline",severity:"secondary",type:"button","data-choice":"theirs",onClick:()=>l.binding.value?.resolve("theirs")},()=>i("data.take_theirs"))])])}}}),bn=(t)=>n({name:t==="input"?"PoadInput":"PoadTextarea",inheritAttrs:!1,props:{modelValue:{type:[String,Number],default:void 0},size:String,invalid:Boolean,mono:Boolean,autosize:Boolean},emits:{"update:modelValue":(r)=>!0},setup(r,{attrs:s,emit:i}){let o=a(yn,null),l=a(mn,null);return()=>{let c=!!l?.binding.value,u=c?l.value():void 0,g=fn({invalid:r.invalid},o?.value.control),d=[s["aria-describedby"],g["aria-describedby"]].filter(Boolean).join(" ")||void 0;return e(t,O(s,{id:s.id??o?.value.controlId,class:["poad-input",un(r)],"aria-invalid":g["aria-invalid"]??s["aria-invalid"],"aria-describedby":d,...c?{value:u==null?"":String(u)}:r.modelValue!==void 0?{value:r.modelValue}:{},onInput:(m)=>{if(c)l.input(m.target.value);let y=m.target;if(r.autosize&&t==="textarea")y.style.height="auto",y.style.height=dn(y.scrollHeight);i("update:modelValue",y.value)}}))}}}),yu=bn("input"),bu=bn("textarea");export{mu as PoadField,yu as PoadInput,bu as PoadTextarea};