@theobourgeois/ytdb 0.2.8 → 0.2.10

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 (166) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +1 -0
  3. package/.next/build-manifest.json +6 -6
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/routes-manifest.json +9 -0
  6. package/.next/server/app/[connectionId]/[schema]/[table]/page.js +1 -1
  7. package/.next/server/app/[connectionId]/[schema]/[table]/page_client-reference-manifest.js +1 -1
  8. package/.next/server/app/[connectionId]/diff/page.js +2 -2
  9. package/.next/server/app/[connectionId]/diff/page_client-reference-manifest.js +1 -1
  10. package/.next/server/app/[connectionId]/migrations/[setId]/page.js +1 -0
  11. package/.next/server/app/[connectionId]/migrations/[setId]/page.js.nft.json +1 -0
  12. package/.next/server/app/[connectionId]/migrations/[setId]/page_client-reference-manifest.js +1 -0
  13. package/.next/server/app/[connectionId]/migrations/page.js +1 -1
  14. package/.next/server/app/[connectionId]/migrations/page.js.nft.json +1 -1
  15. package/.next/server/app/[connectionId]/migrations/page_client-reference-manifest.js +1 -1
  16. package/.next/server/app/[connectionId]/page.js +1 -1
  17. package/.next/server/app/[connectionId]/page_client-reference-manifest.js +1 -1
  18. package/.next/server/app/[connectionId]/query/page.js +1 -1
  19. package/.next/server/app/[connectionId]/query/page_client-reference-manifest.js +1 -1
  20. package/.next/server/app/_global-error/page.js +2 -2
  21. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  22. package/.next/server/app/_global-error.html +1 -1
  23. package/.next/server/app/_global-error.rsc +1 -1
  24. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  25. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  26. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  27. package/.next/server/app/_not-found/page.js +1 -1
  28. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  29. package/.next/server/app/_not-found.html +1 -1
  30. package/.next/server/app/_not-found.rsc +5 -5
  31. package/.next/server/app/_not-found.segments/_full.segment.rsc +5 -5
  32. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +5 -5
  33. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  34. package/.next/server/app/api/activity/route.js +2 -2
  35. package/.next/server/app/api/cell/route.js +1 -1
  36. package/.next/server/app/api/definition/route.js +2 -2
  37. package/.next/server/app/api/delete-rows/route.js +3 -3
  38. package/.next/server/app/api/health/route.js +1 -1
  39. package/.next/server/app/api/insert-row/route.js +1 -1
  40. package/.next/server/app/api/ledger/route.js +1 -1
  41. package/.next/server/app/api/lookup/route.js +2 -2
  42. package/.next/server/app/api/migrate/route.js +1 -1
  43. package/.next/server/app/api/query/route.js +2 -2
  44. package/.next/server/app/api/related/route.js +2 -2
  45. package/.next/server/app/api/rows/route.js +1 -1
  46. package/.next/server/app/api/schema/route.js +2 -2
  47. package/.next/server/app/api/tables/route.js +3 -3
  48. package/.next/server/app/api/update-row/route.js +1 -1
  49. package/.next/server/app/favicon.ico/route.js +1 -1
  50. package/.next/server/app/icon.svg/route.js +1 -1
  51. package/.next/server/app/index.html +1 -1
  52. package/.next/server/app/index.rsc +6 -6
  53. package/.next/server/app/index.segments/__PAGE__.segment.rsc +6 -6
  54. package/.next/server/app/index.segments/_full.segment.rsc +6 -6
  55. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  56. package/.next/server/app/page.js +2 -2
  57. package/.next/server/app/page_client-reference-manifest.js +1 -1
  58. package/.next/server/app-paths-manifest.json +1 -0
  59. package/.next/server/chunks/25.js +1 -1
  60. package/.next/server/chunks/702.js +1 -0
  61. package/.next/server/chunks/729.js +1 -1
  62. package/.next/server/chunks/792.js +1 -1
  63. package/.next/server/middleware-build-manifest.js +1 -1
  64. package/.next/server/pages/404.html +1 -1
  65. package/.next/server/pages/500.html +1 -1
  66. package/.next/static/{FSwOIUlobain5tMrHGgSI → NEAfmHhp-9__5VYm1xePl}/_buildManifest.js +1 -1
  67. package/.next/static/chunks/1528-3257b0cb7a73dd8b.js +1 -0
  68. package/.next/static/chunks/3123-9d121152b53da311.js +1 -0
  69. package/.next/static/chunks/363642f4-681bfd753af22ae9.js +1 -0
  70. package/.next/static/chunks/3794-d7cddff008311ab3.js +52 -0
  71. package/.next/static/chunks/4100-7151c91ac47f0e66.js +1 -0
  72. package/.next/static/chunks/4bd1b696-8a4ab4fdf0ae305a.js +1 -0
  73. package/.next/static/chunks/5541-28b0ead901dee457.js +1 -0
  74. package/.next/static/chunks/{39-3411368bf75bda4b.js → 6039-02dbcff4d4ccf559.js} +1 -1
  75. package/.next/static/chunks/6091-de8d2e51b0196435.js +1 -0
  76. package/.next/static/chunks/6842-c2831fd548ae657c.js +1 -0
  77. package/.next/static/chunks/7449-de75a89ab8afe5c1.js +1 -0
  78. package/.next/static/chunks/8322-b1154a96547c860d.js +1 -0
  79. package/.next/static/chunks/8360-5a3ba00eb4ee0720.js +1 -0
  80. package/.next/static/chunks/8500-01a63dafd809e317.js +1 -0
  81. package/.next/static/chunks/8651-f7ba864bc5a5b128.js +1 -0
  82. package/.next/static/chunks/9680-3eeb0b7b44c6cab3.js +1 -0
  83. package/.next/static/chunks/app/[connectionId]/[schema]/[table]/page-f2f42daf21a075f2.js +1 -0
  84. package/.next/static/chunks/app/[connectionId]/diff/page-f3262f6929e005e0.js +10 -0
  85. package/.next/static/chunks/app/[connectionId]/layout-18239a50b43285f6.js +1 -0
  86. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/page-20581d3ca2f1c5b3.js +1 -0
  87. package/.next/static/chunks/app/[connectionId]/migrations/page-ebee230da73b5481.js +1 -0
  88. package/.next/static/chunks/app/[connectionId]/page-6dcee1a99ffdd27c.js +1 -0
  89. package/.next/static/chunks/app/[connectionId]/query/page-46af4cc6f90448f5.js +1 -0
  90. package/.next/static/chunks/app/_global-error/page-6dcee1a99ffdd27c.js +1 -0
  91. package/.next/static/chunks/app/_not-found/page-57d82169a5493d9f.js +1 -0
  92. package/.next/static/chunks/app/api/activity/route-6dcee1a99ffdd27c.js +1 -0
  93. package/.next/static/chunks/app/api/cell/route-6dcee1a99ffdd27c.js +1 -0
  94. package/.next/static/chunks/app/api/definition/route-6dcee1a99ffdd27c.js +1 -0
  95. package/.next/static/chunks/app/api/delete-rows/route-6dcee1a99ffdd27c.js +1 -0
  96. package/.next/static/chunks/app/api/health/route-6dcee1a99ffdd27c.js +1 -0
  97. package/.next/static/chunks/app/api/insert-row/route-6dcee1a99ffdd27c.js +1 -0
  98. package/.next/static/chunks/app/api/ledger/route-6dcee1a99ffdd27c.js +1 -0
  99. package/.next/static/chunks/app/api/lookup/route-6dcee1a99ffdd27c.js +1 -0
  100. package/.next/static/chunks/app/api/migrate/route-6dcee1a99ffdd27c.js +1 -0
  101. package/.next/static/chunks/app/api/query/route-6dcee1a99ffdd27c.js +1 -0
  102. package/.next/static/chunks/app/api/related/route-6dcee1a99ffdd27c.js +1 -0
  103. package/.next/static/chunks/app/api/rows/route-6dcee1a99ffdd27c.js +1 -0
  104. package/.next/static/chunks/app/api/schema/route-6dcee1a99ffdd27c.js +1 -0
  105. package/.next/static/chunks/app/api/tables/route-6dcee1a99ffdd27c.js +1 -0
  106. package/.next/static/chunks/app/api/update-row/route-6dcee1a99ffdd27c.js +1 -0
  107. package/.next/static/chunks/app/layout-dd332a9583f47cd6.js +1 -0
  108. package/.next/static/chunks/app/{page-b2d6b39a184ee5c7.js → page-b582d36c1b014a02.js} +2 -2
  109. package/.next/static/chunks/framework-666c53740fc261c8.js +1 -0
  110. package/.next/static/chunks/{main-9bf13cd161e78f68.js → main-3446eb75b8e429cb.js} +2 -2
  111. package/.next/static/chunks/main-app-f73ec34e89cb8fdd.js +1 -0
  112. package/.next/static/chunks/next/dist/client/components/builtin/app-error-6dcee1a99ffdd27c.js +1 -0
  113. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-6dcee1a99ffdd27c.js +1 -0
  114. package/.next/static/chunks/next/dist/client/components/builtin/global-error-cbba959419f86022.js +1 -0
  115. package/.next/static/chunks/next/dist/client/components/builtin/not-found-6dcee1a99ffdd27c.js +1 -0
  116. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-6dcee1a99ffdd27c.js +1 -0
  117. package/.next/static/chunks/{webpack-51196f53e7d6229d.js → webpack-34eb118f56295776.js} +1 -1
  118. package/.next/static/css/19402b14d1698bdd.css +1 -0
  119. package/README.md +16 -7
  120. package/package.json +1 -1
  121. package/.next/static/chunks/100-867b197be5f4ee51.js +0 -1
  122. package/.next/static/chunks/363642f4-4ee279341b3325ec.js +0 -1
  123. package/.next/static/chunks/444-1a5198873808abcb.js +0 -1
  124. package/.next/static/chunks/469-5223a74e4a332e16.js +0 -1
  125. package/.next/static/chunks/4bd1b696-c9cc1fe3b38e59bb.js +0 -1
  126. package/.next/static/chunks/500-2d1136a2b6ea2d76.js +0 -1
  127. package/.next/static/chunks/541-7100f33afc3f8243.js +0 -1
  128. package/.next/static/chunks/603-4d453706a69687ab.js +0 -1
  129. package/.next/static/chunks/680-15c080c77c182ea3.js +0 -1
  130. package/.next/static/chunks/794-5400405c4012cb77.js +0 -52
  131. package/.next/static/chunks/842-7d4f33472de28bfd.js +0 -1
  132. package/.next/static/chunks/9-34415c4a38da9de1.js +0 -1
  133. package/.next/static/chunks/938-3d7a8b7b2f336e91.js +0 -1
  134. package/.next/static/chunks/app/[connectionId]/[schema]/[table]/page-ef736a4ea9a8fb54.js +0 -1
  135. package/.next/static/chunks/app/[connectionId]/diff/page-1b02df901ab4745d.js +0 -10
  136. package/.next/static/chunks/app/[connectionId]/layout-5ceae464cef50cb0.js +0 -1
  137. package/.next/static/chunks/app/[connectionId]/migrations/page-a5b61ff9ef6a087b.js +0 -1
  138. package/.next/static/chunks/app/[connectionId]/page-8b8a8b371736af96.js +0 -1
  139. package/.next/static/chunks/app/[connectionId]/query/page-13dafbced1a1f739.js +0 -1
  140. package/.next/static/chunks/app/_global-error/page-8b8a8b371736af96.js +0 -1
  141. package/.next/static/chunks/app/_not-found/page-dd605227cfa5bf04.js +0 -1
  142. package/.next/static/chunks/app/api/activity/route-8b8a8b371736af96.js +0 -1
  143. package/.next/static/chunks/app/api/cell/route-8b8a8b371736af96.js +0 -1
  144. package/.next/static/chunks/app/api/definition/route-8b8a8b371736af96.js +0 -1
  145. package/.next/static/chunks/app/api/delete-rows/route-8b8a8b371736af96.js +0 -1
  146. package/.next/static/chunks/app/api/health/route-8b8a8b371736af96.js +0 -1
  147. package/.next/static/chunks/app/api/insert-row/route-8b8a8b371736af96.js +0 -1
  148. package/.next/static/chunks/app/api/ledger/route-8b8a8b371736af96.js +0 -1
  149. package/.next/static/chunks/app/api/lookup/route-8b8a8b371736af96.js +0 -1
  150. package/.next/static/chunks/app/api/migrate/route-8b8a8b371736af96.js +0 -1
  151. package/.next/static/chunks/app/api/query/route-8b8a8b371736af96.js +0 -1
  152. package/.next/static/chunks/app/api/related/route-8b8a8b371736af96.js +0 -1
  153. package/.next/static/chunks/app/api/rows/route-8b8a8b371736af96.js +0 -1
  154. package/.next/static/chunks/app/api/schema/route-8b8a8b371736af96.js +0 -1
  155. package/.next/static/chunks/app/api/tables/route-8b8a8b371736af96.js +0 -1
  156. package/.next/static/chunks/app/api/update-row/route-8b8a8b371736af96.js +0 -1
  157. package/.next/static/chunks/app/layout-6c0fa591484fc6df.js +0 -1
  158. package/.next/static/chunks/framework-b820d88d6bcfde5e.js +0 -1
  159. package/.next/static/chunks/main-app-f0a2b35cb4db2c5e.js +0 -1
  160. package/.next/static/chunks/next/dist/client/components/builtin/app-error-8b8a8b371736af96.js +0 -1
  161. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-8b8a8b371736af96.js +0 -1
  162. package/.next/static/chunks/next/dist/client/components/builtin/global-error-e3e280d85e32fd8d.js +0 -1
  163. package/.next/static/chunks/next/dist/client/components/builtin/not-found-8b8a8b371736af96.js +0 -1
  164. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-8b8a8b371736af96.js +0 -1
  165. package/.next/static/css/c36a068647b766f7.css +0 -1
  166. /package/.next/static/{FSwOIUlobain5tMrHGgSI → NEAfmHhp-9__5VYm1xePl}/_ssgManifest.js +0 -0
@@ -1,2 +1,2 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[39],{1934:(e,t,s)=>{"use strict";s.d(t,{v:()=>o});var i=s(12115);let n=e=>{let t,s=new Set,i=(e,i)=>{let n="function"==typeof e?e(t):e;if(!Object.is(n,t)){let e=t;t=(null!=i?i:"object"!=typeof n||null===n)?n:Object.assign({},t,n),s.forEach(s=>s(t,e))}},n=()=>t,r={setState:i,getState:n,getInitialState:()=>o,subscribe:e=>(s.add(e),()=>s.delete(e))},o=t=e(i,n,r);return r},r=e=>{let t=e?n(e):n,s=e=>(function(e,t=e=>e){let s=i.useSyncExternalStore(e.subscribe,i.useCallback(()=>t(e.getState()),[e,t]),i.useCallback(()=>t(e.getInitialState()),[e,t]));return i.useDebugValue(s),s})(t,e);return Object.assign(s,t),s},o=e=>e?r(e):r},31692:(e,t,s)=>{"use strict";s.d(t,{Zr:()=>n});let i=e=>t=>{try{let s=e(t);if(s instanceof Promise)return s;return{then:e=>i(e)(s),catch(e){return this}}}catch(e){return{then(e){return this},catch:t=>i(t)(e)}}},n=(e,t)=>(s,n,r)=>{let o,a={storage:function(e){let t;try{t=e()}catch(e){return}return{getItem:e=>{var s;let i=e=>null===e?null:JSON.parse(e,void 0),n=null!=(s=t.getItem(e))?s:null;return n instanceof Promise?n.then(i):i(n)},setItem:(e,s)=>t.setItem(e,JSON.stringify(s,void 0)),removeItem:e=>t.removeItem(e)}}(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},u=!1,h=0,l=new Set,c=new Set,d=a.storage;if(!d)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),s(...e)},n,r);let g=()=>{let e=a.partialize({...n()});return d.setItem(a.name,{state:e,version:a.version})},f=r.setState;r.setState=(e,t)=>(f(e,t),g());let y=e((...e)=>(s(...e),g()),n,r);r.getInitialState=()=>y;let p=()=>{var e,t;if(!d)return;let r=++h;u=!1,l.forEach(e=>{var t;return e(null!=(t=n())?t:y)});let f=(null==(t=a.onRehydrateStorage)?void 0:t.call(a,null!=(e=n())?e:y))||void 0;return i(d.getItem.bind(d))(a.name).then(e=>{if(e)if("number"!=typeof e.version||e.version===a.version)return[!1,e.state];else{if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(e=>{var t;if(r!==h)return;let[i,u]=e;if(s(o=a.merge(u,null!=(t=n())?t:y),!0),i)return g()}).then(()=>{r===h&&(null==f||f(n(),void 0),o=n(),u=!0,c.forEach(e=>e(o)))}).catch(e=>{r===h&&(null==f||f(void 0,e))})};return r.persist={setOptions:e=>{a={...a,...e},e.storage&&(d=e.storage)},clearStorage:()=>{++h,null==d||d.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>p(),hasHydrated:()=>u,onHydrate:e=>(l.add(e),()=>{l.delete(e)}),onFinishHydration:e=>(c.add(e),()=>{c.delete(e)})},a.skipHydration||p(),o||y}},34244:e=>{e.exports={style:{fontFamily:"'Geist', 'Geist Fallback'",fontStyle:"normal"},className:"__className_246ccd",variable:"__variable_246ccd"}},64939:e=>{e.exports={style:{fontFamily:"'Geist Mono', 'Geist Mono Fallback'",fontStyle:"normal"},className:"__className_c29908",variable:"__variable_c29908"}},92328:(e,t,s)=>{"use strict";let i;s.d(t,{hD:()=>eW,eH:()=>eD});for(var n,r,o=s(12115),a=[],u=[],h=Uint8Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,d=l.length;c<d;++c)a[c]=l[c],u[l.charCodeAt(c)]=c;function g(e){var t,s,i=function(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var s=e.indexOf("=");-1===s&&(s=t);var i=s===t?0:4-s%4;return[s,i]}(e),n=i[0],r=i[1],o=new h((n+r)*3/4-r),a=0,l=r>0?n-4:n;for(s=0;s<l;s+=4)t=u[e.charCodeAt(s)]<<18|u[e.charCodeAt(s+1)]<<12|u[e.charCodeAt(s+2)]<<6|u[e.charCodeAt(s+3)],o[a++]=t>>16&255,o[a++]=t>>8&255,o[a++]=255&t;return 2===r&&(t=u[e.charCodeAt(s)]<<2|u[e.charCodeAt(s+1)]>>4,o[a++]=255&t),1===r&&(t=u[e.charCodeAt(s)]<<10|u[e.charCodeAt(s+1)]<<4|u[e.charCodeAt(s+2)]>>2,o[a++]=t>>8&255,o[a++]=255&t),o}function f(e){for(var t,s=e.length,i=s%3,n=[],r=0,o=s-i;r<o;r+=16383)n.push(function(e,t,s){for(var i,n=[],r=t;r<s;r+=3)i=(e[r]<<16&0xff0000)+(e[r+1]<<8&65280)+(255&e[r+2]),n.push(a[i>>18&63]+a[i>>12&63]+a[i>>6&63]+a[63&i]);return n.join("")}(e,r,r+16383>o?o:r+16383));return 1===i?n.push(a[(t=e[s-1])>>2]+a[t<<4&63]+"=="):2===i&&n.push(a[(t=(e[s-2]<<8)+e[s-1])>>10]+a[t>>4&63]+a[t<<2&63]+"="),n.join("")}function y(e){if(void 0===e)return{};if(!p(e))throw Error(`The arguments to a Convex function must be an object. Received: ${e}`);return e}function p(e){let t="object"==typeof e,s=Object.getPrototypeOf(e),i=null===s||s===Object.prototype||s?.constructor?.name==="Object";return t&&i}u[45]=62,u[95]=63;let m=BigInt("-9223372036854775808"),v=BigInt("9223372036854775807"),b=BigInt("0"),S=BigInt("8"),k=BigInt("256"),w="This commit timestamp is unresolved: its value is assigned when the mutation commits. Read the document after the mutation completes to get its value.";class R{[Symbol.toPrimitive](e){if("string"===e)return this.toString();throw Error(w)}valueOf(){throw Error(w)}toJSON(){throw Error(w)}toString(){return"[unresolved commit timestamp]"}}let C=new R;function T(e){return Number.isNaN(e)||!Number.isFinite(e)||Object.is(e,-0)}let A=DataView.prototype.setBigInt64?function(e){if(e<m||v<e)throw Error(`BigInt ${e} does not fit into a 64-bit signed integer.`);let t=new ArrayBuffer(8);return new DataView(t).setBigInt64(0,e,!0),f(new Uint8Array(t))}:function(e){e<b&&(e-=m+m);let t=e.toString(16);t.length%2==1&&(t="0"+t);let s=new Uint8Array(new ArrayBuffer(8)),i=0;for(let n of t.match(/.{2}/g).reverse())s.set([parseInt(n,16)],i++),e>>=S;return f(s)},q=DataView.prototype.getBigInt64?function(e){let t=g(e);if(8!==t.byteLength)throw Error(`Received ${t.byteLength} bytes, expected 8 for $integer`);return new DataView(t.buffer).getBigInt64(0,!0)}:function(e){let t=g(e);if(8!==t.byteLength)throw Error(`Received ${t.byteLength} bytes, expected 8 for $integer`);let s=b,i=b;for(let e of t)s+=BigInt(e)*k**i,i++;return s>v&&(s+=m+m),s};function M(e){if(e.length>1024)throw Error(`Field name ${e} exceeds maximum field name length 1024.`);if(e.startsWith("$"))throw Error(`Field name ${e} starts with a '$', which is reserved.`);for(let t=0;t<e.length;t+=1){let s=e.charCodeAt(t);if(s<32||s>=127)throw Error(`Field name ${e} has invalid character '${e[t]}': Field names can only contain non-control ASCII characters`)}}function I(e){if(null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e)return e;if(Array.isArray(e))return e.map(e=>I(e));if("object"!=typeof e)throw Error(`Unexpected type of ${e}`);let t=Object.entries(e);if(1===t.length){let s=t[0][0];if("$bytes"===s){if("string"!=typeof e.$bytes)throw Error(`Malformed $bytes field on ${e}`);return g(e.$bytes).buffer}if("$integer"===s){if("string"!=typeof e.$integer)throw Error(`Malformed $integer field on ${e}`);return q(e.$integer)}if("$float"===s){if("string"!=typeof e.$float)throw Error(`Malformed $float field on ${e}`);let t=g(e.$float);if(8!==t.byteLength)throw Error(`Received ${t.byteLength} bytes, expected 8 for $float`);let s=new DataView(t.buffer).getFloat64(0,!0);if(!T(s))throw Error(`Float ${s} should be encoded as a number`);return s}if("$commitTs"===s){if(null!==e.$commitTs)throw Error(`Malformed $commitTs field on ${e}`);return C}if("$set"===s)throw Error("Received a Set which is no longer supported as a Convex type.");if("$map"===s)throw Error("Received a Map which is no longer supported as a Convex type.")}let s={};for(let[t,i]of Object.entries(e))M(t),s[t]=I(i);return s}function $(e){let t=JSON.stringify(e,(e,t)=>void 0===t?"undefined":"bigint"==typeof t?`${t.toString()}n`:t);if(t.length>16384){let e="[...truncated]",s=16384-e.length,i=t.codePointAt(s-1);return void 0!==i&&i>65535&&(s-=1),t.substring(0,s)+e}return t}function Q(e,t,s,i){return e?`${t}${$(s)} is not a supported Convex type (present at path ${e} in original object ${$(i)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.`:`${t}${$(s)} is not a supported Convex type.`}function O(e){return function e(t,s,i,n){if(void 0===t){let e=i&&` (present at path ${i} in original object ${$(s)})`;throw Error(`undefined is not a valid Convex value${e}. To learn about Convex's supported types, see https://docs.convex.dev/using/types.`)}if(null===t)return t;if("bigint"==typeof t){if(t<m||v<t)throw Error(`BigInt ${t} does not fit into a 64-bit signed integer.`);return{$integer:A(t)}}if("number"==typeof t)if(!T(t))return t;else{let e=new ArrayBuffer(8);return new DataView(e).setFloat64(0,t,!0),{$float:f(new Uint8Array(e))}}if("boolean"==typeof t||"string"==typeof t)return t;if(t instanceof ArrayBuffer)return{$bytes:f(new Uint8Array(t))};if(t instanceof R)return{$commitTs:null};if(Array.isArray(t))return t.map((t,n)=>e(t,s,i+`[${n}]`,!1));if(t instanceof Set)throw Error(Q(i,"Set",[...t],s));if(t instanceof Map)throw Error(Q(i,"Map",[...t],s));if(!p(t)){let e=t?.constructor?.name;throw Error(Q(i,e?`${e} `:"",t,s))}let r={},o=Object.entries(t);for(let[t,a]of(o.sort(([e,t],[s,i])=>e===s?0:e<s?-1:1),o))void 0!==a?(M(t),r[t]=e(a,s,i+`.${t}`,!1)):n&&(M(t),r[t]=function(t,s,i){if(void 0===t)return{$undefined:null};if(void 0===s)throw Error(`Programming error. Current value is ${$(t)} but original value is undefined`);return e(t,s,i,!1)}(a,s,i+`.${t}`));return r}(e,e,"",!1)}var x=Object.defineProperty,E=(e,t,s)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?x(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s};let P=Symbol.for("ConvexError");class V extends(r=Error,n=P,r){constructor(e){super("string"==typeof e?e:$(e)),E(this,"name","ConvexError"),E(this,"data"),E(this,n,!0),this.data=e}}let L=()=>Array.from({length:4},()=>0);L(),L();let _="1.45.0";var N=Object.defineProperty,F=(e,t,s)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?N(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s};function B(e){switch(e){case"query":return"Q";case"mutation":return"M";case"action":return"A";case"any":return"?"}}class U{constructor(e){F(this,"_onLogLineFuncs"),F(this,"_verbose"),this._onLogLineFuncs={},this._verbose=e.verbose}addLogLineListener(e){let t=Math.random().toString(36).substring(2,15);for(let e=0;e<10&&void 0!==this._onLogLineFuncs[t];e++)t=Math.random().toString(36).substring(2,15);return this._onLogLineFuncs[t]=e,()=>{delete this._onLogLineFuncs[t]}}logVerbose(...e){if(this._verbose)for(let t of Object.values(this._onLogLineFuncs))t("debug",`${new Date().toISOString()}`,...e)}log(...e){for(let t of Object.values(this._onLogLineFuncs))t("info",...e)}warn(...e){for(let t of Object.values(this._onLogLineFuncs))t("warn",...e)}error(...e){for(let t of Object.values(this._onLogLineFuncs))t("error",...e)}}function D(e){let t=new U(e);return t.addLogLineListener((e,...t)=>{switch(e){case"debug":console.debug(...t);break;case"info":default:console.log(...t);break;case"warn":console.warn(...t);break;case"error":console.error(...t)}}),t}function j(e,t,s,i,n){let r=B(s);if("object"==typeof n&&(n=`ConvexError ${JSON.stringify(n.errorData,null,2)}`),"info"===t){let t=n.match(/^\[.*?\] /);if(null===t)return void e.error(`[CONVEX ${r}(${i})] Could not parse console.log`);let s=n.slice(1,t[0].length-2),o=n.slice(t[0].length);e.log(`%c[CONVEX ${r}(${i})] [${s}]`,"color:rgb(0, 145, 255)",o)}else e.error(`[CONVEX ${r}(${i})] ${n}`)}function W(e,t,s){let i=B(e);return`[CONVEX ${i}(${t})] ${s.errorMessage}
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6039],{1934:(e,t,s)=>{"use strict";s.d(t,{v:()=>o});var i=s(12115);let n=e=>{let t,s=new Set,i=(e,i)=>{let n="function"==typeof e?e(t):e;if(!Object.is(n,t)){let e=t;t=(null!=i?i:"object"!=typeof n||null===n)?n:Object.assign({},t,n),s.forEach(s=>s(t,e))}},n=()=>t,r={setState:i,getState:n,getInitialState:()=>o,subscribe:e=>(s.add(e),()=>s.delete(e))},o=t=e(i,n,r);return r},r=e=>{let t=e?n(e):n,s=e=>(function(e,t=e=>e){let s=i.useSyncExternalStore(e.subscribe,i.useCallback(()=>t(e.getState()),[e,t]),i.useCallback(()=>t(e.getInitialState()),[e,t]));return i.useDebugValue(s),s})(t,e);return Object.assign(s,t),s},o=e=>e?r(e):r},31692:(e,t,s)=>{"use strict";s.d(t,{Zr:()=>n});let i=e=>t=>{try{let s=e(t);if(s instanceof Promise)return s;return{then:e=>i(e)(s),catch(e){return this}}}catch(e){return{then(e){return this},catch:t=>i(t)(e)}}},n=(e,t)=>(s,n,r)=>{let o,a={storage:function(e){let t;try{t=e()}catch(e){return}return{getItem:e=>{var s;let i=e=>null===e?null:JSON.parse(e,void 0),n=null!=(s=t.getItem(e))?s:null;return n instanceof Promise?n.then(i):i(n)},setItem:(e,s)=>t.setItem(e,JSON.stringify(s,void 0)),removeItem:e=>t.removeItem(e)}}(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},u=!1,h=0,l=new Set,c=new Set,d=a.storage;if(!d)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),s(...e)},n,r);let g=()=>{let e=a.partialize({...n()});return d.setItem(a.name,{state:e,version:a.version})},f=r.setState;r.setState=(e,t)=>(f(e,t),g());let y=e((...e)=>(s(...e),g()),n,r);r.getInitialState=()=>y;let p=()=>{var e,t;if(!d)return;let r=++h;u=!1,l.forEach(e=>{var t;return e(null!=(t=n())?t:y)});let f=(null==(t=a.onRehydrateStorage)?void 0:t.call(a,null!=(e=n())?e:y))||void 0;return i(d.getItem.bind(d))(a.name).then(e=>{if(e)if("number"!=typeof e.version||e.version===a.version)return[!1,e.state];else{if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(e=>{var t;if(r!==h)return;let[i,u]=e;if(s(o=a.merge(u,null!=(t=n())?t:y),!0),i)return g()}).then(()=>{r===h&&(null==f||f(n(),void 0),o=n(),u=!0,c.forEach(e=>e(o)))}).catch(e=>{r===h&&(null==f||f(void 0,e))})};return r.persist={setOptions:e=>{a={...a,...e},e.storage&&(d=e.storage)},clearStorage:()=>{++h,null==d||d.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>p(),hasHydrated:()=>u,onHydrate:e=>(l.add(e),()=>{l.delete(e)}),onFinishHydration:e=>(c.add(e),()=>{c.delete(e)})},a.skipHydration||p(),o||y}},34244:e=>{e.exports={style:{fontFamily:"'Geist', 'Geist Fallback'",fontStyle:"normal"},className:"__className_246ccd",variable:"__variable_246ccd"}},64939:e=>{e.exports={style:{fontFamily:"'Geist Mono', 'Geist Mono Fallback'",fontStyle:"normal"},className:"__className_c29908",variable:"__variable_c29908"}},92328:(e,t,s)=>{"use strict";let i;s.d(t,{hD:()=>eW,eH:()=>eD});for(var n,r,o=s(12115),a=[],u=[],h=Uint8Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,d=l.length;c<d;++c)a[c]=l[c],u[l.charCodeAt(c)]=c;function g(e){var t,s,i=function(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var s=e.indexOf("=");-1===s&&(s=t);var i=s===t?0:4-s%4;return[s,i]}(e),n=i[0],r=i[1],o=new h((n+r)*3/4-r),a=0,l=r>0?n-4:n;for(s=0;s<l;s+=4)t=u[e.charCodeAt(s)]<<18|u[e.charCodeAt(s+1)]<<12|u[e.charCodeAt(s+2)]<<6|u[e.charCodeAt(s+3)],o[a++]=t>>16&255,o[a++]=t>>8&255,o[a++]=255&t;return 2===r&&(t=u[e.charCodeAt(s)]<<2|u[e.charCodeAt(s+1)]>>4,o[a++]=255&t),1===r&&(t=u[e.charCodeAt(s)]<<10|u[e.charCodeAt(s+1)]<<4|u[e.charCodeAt(s+2)]>>2,o[a++]=t>>8&255,o[a++]=255&t),o}function f(e){for(var t,s=e.length,i=s%3,n=[],r=0,o=s-i;r<o;r+=16383)n.push(function(e,t,s){for(var i,n=[],r=t;r<s;r+=3)i=(e[r]<<16&0xff0000)+(e[r+1]<<8&65280)+(255&e[r+2]),n.push(a[i>>18&63]+a[i>>12&63]+a[i>>6&63]+a[63&i]);return n.join("")}(e,r,r+16383>o?o:r+16383));return 1===i?n.push(a[(t=e[s-1])>>2]+a[t<<4&63]+"=="):2===i&&n.push(a[(t=(e[s-2]<<8)+e[s-1])>>10]+a[t>>4&63]+a[t<<2&63]+"="),n.join("")}function y(e){if(void 0===e)return{};if(!p(e))throw Error(`The arguments to a Convex function must be an object. Received: ${e}`);return e}function p(e){let t="object"==typeof e,s=Object.getPrototypeOf(e),i=null===s||s===Object.prototype||s?.constructor?.name==="Object";return t&&i}u[45]=62,u[95]=63;let m=BigInt("-9223372036854775808"),v=BigInt("9223372036854775807"),b=BigInt("0"),S=BigInt("8"),k=BigInt("256"),w="This commit timestamp is unresolved: its value is assigned when the mutation commits. Read the document after the mutation completes to get its value.";class R{[Symbol.toPrimitive](e){if("string"===e)return this.toString();throw Error(w)}valueOf(){throw Error(w)}toJSON(){throw Error(w)}toString(){return"[unresolved commit timestamp]"}}let C=new R;function T(e){return Number.isNaN(e)||!Number.isFinite(e)||Object.is(e,-0)}let A=DataView.prototype.setBigInt64?function(e){if(e<m||v<e)throw Error(`BigInt ${e} does not fit into a 64-bit signed integer.`);let t=new ArrayBuffer(8);return new DataView(t).setBigInt64(0,e,!0),f(new Uint8Array(t))}:function(e){e<b&&(e-=m+m);let t=e.toString(16);t.length%2==1&&(t="0"+t);let s=new Uint8Array(new ArrayBuffer(8)),i=0;for(let n of t.match(/.{2}/g).reverse())s.set([parseInt(n,16)],i++),e>>=S;return f(s)},q=DataView.prototype.getBigInt64?function(e){let t=g(e);if(8!==t.byteLength)throw Error(`Received ${t.byteLength} bytes, expected 8 for $integer`);return new DataView(t.buffer).getBigInt64(0,!0)}:function(e){let t=g(e);if(8!==t.byteLength)throw Error(`Received ${t.byteLength} bytes, expected 8 for $integer`);let s=b,i=b;for(let e of t)s+=BigInt(e)*k**i,i++;return s>v&&(s+=m+m),s};function M(e){if(e.length>1024)throw Error(`Field name ${e} exceeds maximum field name length 1024.`);if(e.startsWith("$"))throw Error(`Field name ${e} starts with a '$', which is reserved.`);for(let t=0;t<e.length;t+=1){let s=e.charCodeAt(t);if(s<32||s>=127)throw Error(`Field name ${e} has invalid character '${e[t]}': Field names can only contain non-control ASCII characters`)}}function I(e){if(null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e)return e;if(Array.isArray(e))return e.map(e=>I(e));if("object"!=typeof e)throw Error(`Unexpected type of ${e}`);let t=Object.entries(e);if(1===t.length){let s=t[0][0];if("$bytes"===s){if("string"!=typeof e.$bytes)throw Error(`Malformed $bytes field on ${e}`);return g(e.$bytes).buffer}if("$integer"===s){if("string"!=typeof e.$integer)throw Error(`Malformed $integer field on ${e}`);return q(e.$integer)}if("$float"===s){if("string"!=typeof e.$float)throw Error(`Malformed $float field on ${e}`);let t=g(e.$float);if(8!==t.byteLength)throw Error(`Received ${t.byteLength} bytes, expected 8 for $float`);let s=new DataView(t.buffer).getFloat64(0,!0);if(!T(s))throw Error(`Float ${s} should be encoded as a number`);return s}if("$commitTs"===s){if(null!==e.$commitTs)throw Error(`Malformed $commitTs field on ${e}`);return C}if("$set"===s)throw Error("Received a Set which is no longer supported as a Convex type.");if("$map"===s)throw Error("Received a Map which is no longer supported as a Convex type.")}let s={};for(let[t,i]of Object.entries(e))M(t),s[t]=I(i);return s}function $(e){let t=JSON.stringify(e,(e,t)=>void 0===t?"undefined":"bigint"==typeof t?`${t.toString()}n`:t);if(t.length>16384){let e="[...truncated]",s=16384-e.length,i=t.codePointAt(s-1);return void 0!==i&&i>65535&&(s-=1),t.substring(0,s)+e}return t}function Q(e,t,s,i){return e?`${t}${$(s)} is not a supported Convex type (present at path ${e} in original object ${$(i)}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.`:`${t}${$(s)} is not a supported Convex type.`}function O(e){return function e(t,s,i,n){if(void 0===t){let e=i&&` (present at path ${i} in original object ${$(s)})`;throw Error(`undefined is not a valid Convex value${e}. To learn about Convex's supported types, see https://docs.convex.dev/using/types.`)}if(null===t)return t;if("bigint"==typeof t){if(t<m||v<t)throw Error(`BigInt ${t} does not fit into a 64-bit signed integer.`);return{$integer:A(t)}}if("number"==typeof t)if(!T(t))return t;else{let e=new ArrayBuffer(8);return new DataView(e).setFloat64(0,t,!0),{$float:f(new Uint8Array(e))}}if("boolean"==typeof t||"string"==typeof t)return t;if(t instanceof ArrayBuffer)return{$bytes:f(new Uint8Array(t))};if(t instanceof R)return{$commitTs:null};if(Array.isArray(t))return t.map((t,n)=>e(t,s,i+`[${n}]`,!1));if(t instanceof Set)throw Error(Q(i,"Set",[...t],s));if(t instanceof Map)throw Error(Q(i,"Map",[...t],s));if(!p(t)){let e=t?.constructor?.name;throw Error(Q(i,e?`${e} `:"",t,s))}let r={},o=Object.entries(t);for(let[t,a]of(o.sort(([e,t],[s,i])=>e===s?0:e<s?-1:1),o))void 0!==a?(M(t),r[t]=e(a,s,i+`.${t}`,!1)):n&&(M(t),r[t]=function(t,s,i){if(void 0===t)return{$undefined:null};if(void 0===s)throw Error(`Programming error. Current value is ${$(t)} but original value is undefined`);return e(t,s,i,!1)}(a,s,i+`.${t}`));return r}(e,e,"",!1)}var x=Object.defineProperty,E=(e,t,s)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?x(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s};let P=Symbol.for("ConvexError");class V extends(r=Error,n=P,r){constructor(e){super("string"==typeof e?e:$(e)),E(this,"name","ConvexError"),E(this,"data"),E(this,n,!0),this.data=e}}let L=()=>Array.from({length:4},()=>0);L(),L();let _="1.45.0";var N=Object.defineProperty,F=(e,t,s)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?N(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s};function B(e){switch(e){case"query":return"Q";case"mutation":return"M";case"action":return"A";case"any":return"?"}}class U{constructor(e){F(this,"_onLogLineFuncs"),F(this,"_verbose"),this._onLogLineFuncs={},this._verbose=e.verbose}addLogLineListener(e){let t=Math.random().toString(36).substring(2,15);for(let e=0;e<10&&void 0!==this._onLogLineFuncs[t];e++)t=Math.random().toString(36).substring(2,15);return this._onLogLineFuncs[t]=e,()=>{delete this._onLogLineFuncs[t]}}logVerbose(...e){if(this._verbose)for(let t of Object.values(this._onLogLineFuncs))t("debug",`${new Date().toISOString()}`,...e)}log(...e){for(let t of Object.values(this._onLogLineFuncs))t("info",...e)}warn(...e){for(let t of Object.values(this._onLogLineFuncs))t("warn",...e)}error(...e){for(let t of Object.values(this._onLogLineFuncs))t("error",...e)}}function D(e){let t=new U(e);return t.addLogLineListener((e,...t)=>{switch(e){case"debug":console.debug(...t);break;case"info":default:console.log(...t);break;case"warn":console.warn(...t);break;case"error":console.error(...t)}}),t}function j(e,t,s,i,n){let r=B(s);if("object"==typeof n&&(n=`ConvexError ${JSON.stringify(n.errorData,null,2)}`),"info"===t){let t=n.match(/^\[.*?\] /);if(null===t)return void e.error(`[CONVEX ${r}(${i})] Could not parse console.log`);let s=n.slice(1,t[0].length-2),o=n.slice(t[0].length);e.log(`%c[CONVEX ${r}(${i})] [${s}]`,"color:rgb(0, 145, 255)",o)}else e.error(`[CONVEX ${r}(${i})] ${n}`)}function W(e,t,s){let i=B(e);return`[CONVEX ${i}(${t})] ${s.errorMessage}
2
2
  Called by client`}function H(e,t){return t.data=e.errorData,t}function J(e){let t,s,i=e.split(":");return 1===i.length?(t=i[0],s="default"):(t=i.slice(0,i.length-1).join(":"),s=i[i.length-1]),t.endsWith(".js")&&(t=t.slice(0,-3)),`${t}:${s}`}function K(e,t){return JSON.stringify({udfPath:J(e),args:O(t)})}function z(e,t,s){let{initialNumItems:i,id:n}=s;return JSON.stringify({type:"paginated",udfPath:J(e),args:O(t),options:O({initialNumItems:i,id:n})})}var G=Object.defineProperty,X=(e,t,s)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?G(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s};class Y{constructor(){X(this,"nextQueryId"),X(this,"querySetVersion"),X(this,"querySet"),X(this,"queryIdToToken"),X(this,"identityVersion"),X(this,"auth"),X(this,"outstandingQueriesOlderThanRestart"),X(this,"outstandingAuthOlderThanRestart"),X(this,"paused"),X(this,"pendingQuerySetModifications"),this.nextQueryId=0,this.querySetVersion=0,this.identityVersion=0,this.querySet=new Map,this.queryIdToToken=new Map,this.outstandingQueriesOlderThanRestart=new Set,this.outstandingAuthOlderThanRestart=!1,this.paused=!1,this.pendingQuerySetModifications=new Map}hasSyncedPastLastReconnect(){return 0===this.outstandingQueriesOlderThanRestart.size&&!this.outstandingAuthOlderThanRestart}markAuthCompletion(){this.outstandingAuthOlderThanRestart=!1}subscribe(e,t,s,i){let n=J(e),r=K(n,t),o=this.querySet.get(r);if(void 0!==o)return o.numSubscribers+=1,{queryToken:r,modification:null,unsubscribe:()=>this.removeSubscriber(r)};{let e=this.nextQueryId++;this.querySet.set(r,{id:e,canonicalizedUdfPath:n,args:t,numSubscribers:1,journal:s,componentPath:i}),this.queryIdToToken.set(e,r);let o=this.querySetVersion,a=this.querySetVersion+1,u={type:"Add",queryId:e,udfPath:n,args:[O(t)],journal:s,componentPath:i};return this.paused?this.pendingQuerySetModifications.set(e,u):this.querySetVersion=a,{queryToken:r,modification:{type:"ModifyQuerySet",baseVersion:o,newVersion:a,modifications:[u]},unsubscribe:()=>this.removeSubscriber(r)}}}transition(e){for(let t of e.modifications)switch(t.type){case"QueryUpdated":case"QueryFailed":{this.outstandingQueriesOlderThanRestart.delete(t.queryId);let e=t.journal;if(void 0!==e){let s=this.queryIdToToken.get(t.queryId);void 0!==s&&(this.querySet.get(s).journal=e)}break}case"QueryRemoved":this.outstandingQueriesOlderThanRestart.delete(t.queryId);break;default:throw Error(`Invalid modification ${t.type}`)}}queryId(e,t){let s=K(J(e),t),i=this.querySet.get(s);return void 0!==i?i.id:null}isCurrentOrNewerAuthVersion(e){return e>=this.identityVersion}getAuth(){return this.auth}setAuth(e){this.auth={tokenType:"User",value:e};let t=this.identityVersion;return this.paused||(this.identityVersion=t+1),{type:"Authenticate",baseVersion:t,...this.auth}}setAdminAuth(e,t){let s={tokenType:"Admin",value:e,impersonating:t};this.auth=s;let i=this.identityVersion;return this.paused||(this.identityVersion=i+1),{type:"Authenticate",baseVersion:i,...s}}clearAuth(){this.auth=void 0,this.markAuthCompletion();let e=this.identityVersion;return this.paused||(this.identityVersion=e+1),{type:"Authenticate",tokenType:"None",baseVersion:e}}hasAuth(){return!!this.auth}isNewAuth(e){return this.auth?.value!==e}queryPath(e){let t=this.queryIdToToken.get(e);return t?this.querySet.get(t).canonicalizedUdfPath:null}queryArgs(e){let t=this.queryIdToToken.get(e);return t?this.querySet.get(t).args:null}queryToken(e){return this.queryIdToToken.get(e)??null}queryJournal(e){return this.querySet.get(e)?.journal}restart(){this.unpause(),this.outstandingQueriesOlderThanRestart.clear();let e=[];for(let t of this.querySet.values()){let s={type:"Add",queryId:t.id,udfPath:t.canonicalizedUdfPath,args:[O(t.args)],journal:t.journal,componentPath:t.componentPath};e.push(s),this.outstandingQueriesOlderThanRestart.add(t.id)}this.querySetVersion=1;let t={type:"ModifyQuerySet",baseVersion:0,newVersion:1,modifications:e};if(!this.auth)return this.identityVersion=0,[t,void 0];this.outstandingAuthOlderThanRestart=!0;let s={type:"Authenticate",baseVersion:0,...this.auth};return this.identityVersion=1,[t,s]}pause(){this.paused=!0}resume(){let e=this.pendingQuerySetModifications.size>0?{type:"ModifyQuerySet",baseVersion:this.querySetVersion,newVersion:++this.querySetVersion,modifications:Array.from(this.pendingQuerySetModifications.values())}:void 0,t=void 0!==this.auth?{type:"Authenticate",baseVersion:this.identityVersion++,...this.auth}:void 0;return this.unpause(),[e,t]}unpause(){this.paused=!1,this.pendingQuerySetModifications.clear()}removeSubscriber(e){let t=this.querySet.get(e);if(t.numSubscribers>1)return t.numSubscribers-=1,null;{this.querySet.delete(e),this.queryIdToToken.delete(t.id),this.outstandingQueriesOlderThanRestart.delete(t.id);let s=this.querySetVersion,i=this.querySetVersion+1,n={type:"Remove",queryId:t.id};return this.paused?this.pendingQuerySetModifications.has(t.id)?this.pendingQuerySetModifications.delete(t.id):this.pendingQuerySetModifications.set(t.id,n):this.querySetVersion=i,{type:"ModifyQuerySet",baseVersion:s,newVersion:i,modifications:[n]}}}}var Z=Object.defineProperty,ee=(e,t,s)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?Z(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s};class et{constructor(e,t){this.logger=e,this.markConnectionStateDirty=t,ee(this,"inflightRequests"),ee(this,"requestsOlderThanRestart"),ee(this,"inflightMutationsCount",0),ee(this,"inflightActionsCount",0),this.inflightRequests=new Map,this.requestsOlderThanRestart=new Set}request(e,t){let s=new Promise(s=>{this.inflightRequests.set(e.requestId,{message:e,status:{status:t?"Requested":"NotSent",requestedAt:new Date,onResult:s}}),"Mutation"===e.type?this.inflightMutationsCount++:"Action"===e.type&&this.inflightActionsCount++});return this.markConnectionStateDirty(),s}onResponse(e){let t,s,i=this.inflightRequests.get(e.requestId);if(void 0===i||"Completed"===i.status.status)return null;let n="Mutation"===i.message.type?"mutation":"action",r=i.message.udfPath;for(let t of e.logLines)j(this.logger,"info",n,r,t);let o=i.status;if(e.success)t={success:!0,logLines:e.logLines,value:I(e.result)},s=()=>o.onResult(t);else{let i=e.result,{errorData:a}=e;j(this.logger,"error",n,r,i),t={success:!1,errorMessage:i,errorData:void 0!==a?I(a):void 0,logLines:e.logLines},s=()=>o.onResult(t)}return"ActionResponse"!==e.type&&e.success?(i.status={status:"Completed",result:t,ts:e.ts,onResolve:s},null):(s(),this.inflightRequests.delete(e.requestId),this.requestsOlderThanRestart.delete(e.requestId),"Action"===i.message.type?this.inflightActionsCount--:"Mutation"===i.message.type&&this.inflightMutationsCount--,this.markConnectionStateDirty(),{requestId:e.requestId,result:t})}removeCompleted(e){let t=new Map;for(let[s,i]of this.inflightRequests.entries()){let n=i.status;"Completed"===n.status&&n.ts.lessThanOrEqual(e)&&(n.onResolve(),t.set(s,n.result),"Mutation"===i.message.type?this.inflightMutationsCount--:"Action"===i.message.type&&this.inflightActionsCount--,this.inflightRequests.delete(s),this.requestsOlderThanRestart.delete(s))}return t.size>0&&this.markConnectionStateDirty(),t}restart(){this.requestsOlderThanRestart=new Set(this.inflightRequests.keys());let e=[];for(let[t,s]of this.inflightRequests){if("NotSent"===s.status.status){s.status.status="Requested",e.push(s.message);continue}if("Mutation"===s.message.type)e.push(s.message);else if("Action"===s.message.type){if(this.inflightRequests.delete(t),this.requestsOlderThanRestart.delete(t),this.inflightActionsCount--,"Completed"===s.status.status)throw Error("Action should never be in 'Completed' state");s.status.onResult({success:!1,errorMessage:"Connection lost while action was in flight",logLines:[]})}}return this.markConnectionStateDirty(),e}resume(){let e=[];for(let[,t]of this.inflightRequests)if("NotSent"===t.status.status){t.status.status="Requested",e.push(t.message);continue}return e}hasIncompleteRequests(){for(let e of this.inflightRequests.values())if("Requested"===e.status.status)return!0;return!1}hasInflightRequests(){return this.inflightRequests.size>0}hasSyncedPastLastReconnect(){return 0===this.requestsOlderThanRestart.size}timeOfOldestInflightRequest(){if(0===this.inflightRequests.size)return null;let e=Date.now();for(let t of this.inflightRequests.values())"Completed"!==t.status.status&&t.status.requestedAt.getTime()<e&&(e=t.status.requestedAt.getTime());return new Date(e)}inflightMutations(){return this.inflightMutationsCount}inflightActions(){return this.inflightActionsCount}}let es=Symbol.for("functionName"),ei=Symbol.for("toReferencePath");function en(e){let t=function(e){let t;if("string"==typeof e)t=e.startsWith("function://")?{functionHandle:e}:{name:e};else if(e[es])t={name:e[es]};else{let s=e[ei]??null;if(!s)throw Error(`${e} is not a functionReference`);t={reference:s}}return t}(e);if(void 0===t.name){if(void 0!==t.functionHandle)throw Error(`Expected function reference like "api.file.func" or "internal.file.func", but received function handle ${t.functionHandle}`);if(void 0!==t.reference)throw Error(`Expected function reference in the current component like "api.file.func" or "internal.file.func", but received reference ${t.reference}`);throw Error(`Expected function reference like "api.file.func" or "internal.file.func", but received ${JSON.stringify(t)}`)}if("string"==typeof e)return e;let s=e[es];if(!s)throw Error(`${e} is not a functionReference`);return s}!function e(t=[]){return new Proxy({},{get(s,i){if("string"==typeof i)return e([...t,i]);if(i===es){if(t.length<2){let e=["api",...t].join(".");throw Error(`API path is expected to be of the form \`api.moduleName.functionName\`. Found: \`${e}\``)}let e=t.slice(0,-1).join("/"),s=t[t.length-1];return"default"===s?e:e+":"+s}return i===Symbol.toStringTag?"FunctionReference":void 0}})}();var er=Object.defineProperty,eo=(e,t,s)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?er(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s};class ea{constructor(e){eo(this,"queryResults"),eo(this,"modifiedQueries"),this.queryResults=e,this.modifiedQueries=[]}getQuery(e,...t){let s=y(t[0]),i=en(e),n=this.queryResults.get(K(i,s));if(void 0!==n)return ea.queryValue(n.result)}getAllQueries(e){let t=[],s=en(e);for(let e of this.queryResults.values())e.udfPath===J(s)&&t.push({args:e.args,value:ea.queryValue(e.result)});return t}setQuery(e,t,s){let i=y(t),n=en(e),r=K(n,i);this.queryResults.set(r,{udfPath:n,args:i,result:void 0===s?void 0:{success:!0,value:s,logLines:[]}}),this.modifiedQueries.push(r)}static queryValue(e){return void 0===e?void 0:e.success?e.value:void 0}}class eu{constructor(){eo(this,"queryResults"),eo(this,"optimisticUpdates"),this.queryResults=new Map,this.optimisticUpdates=[]}ingestQueryResultsFromServer(e,t){this.optimisticUpdates=this.optimisticUpdates.filter(e=>!t.has(e.mutationId));let s=this.queryResults;this.queryResults=new Map(e);let i=new ea(this.queryResults);for(let e of this.optimisticUpdates)e.update(i);let n=[];for(let[e,t]of this.queryResults){let i=s.get(e);(void 0===i||i.result!==t.result)&&n.push(e)}return n}applyOptimisticUpdate(e,t){this.optimisticUpdates.push({update:e,mutationId:t});let s=new ea(this.queryResults);return e(s),s.modifiedQueries}rawQueryResult(e){let t=this.queryResults.get(e);if(void 0!==t)return t.result}queryResult(e){let t=this.queryResults.get(e);if(void 0===t)return;let s=t.result;if(void 0!==s){if(s.success)return s.value;if(void 0!==s.errorData)throw H(s,new V(W("query",t.udfPath,s)));throw Error(W("query",t.udfPath,s))}}hasQueryResult(e){return void 0!==this.queryResults.get(e)}queryLogs(e){let t=this.queryResults.get(e);return t?.result?.logLines}}var eh=Object.defineProperty,el=(e,t,s)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?eh(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s};class ec{constructor(e,t){el(this,"low"),el(this,"high"),el(this,"__isUnsignedLong__"),this.low=0|e,this.high=0|t,this.__isUnsignedLong__=!0}static isLong(e){return!0===(e&&e.__isUnsignedLong__)}static fromBytesLE(e){return new ec(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24)}toBytesLE(){let e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]}static fromNumber(e){return isNaN(e)||e<0?ed:e>=ef?ey:new ec(e%eg|0,e/eg|0)}toString(){return(BigInt(this.high)*BigInt(eg)+BigInt(this.low)).toString()}equals(e){return ec.isLong(e)||(e=ec.fromValue(e)),(this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low}notEquals(e){return!this.equals(e)}comp(e){return(ec.isLong(e)||(e=ec.fromValue(e)),this.equals(e))?0:e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1}lessThanOrEqual(e){return 0>=this.comp(e)}static fromValue(e){return"number"==typeof e?ec.fromNumber(e):new ec(e.low,e.high)}}let ed=new ec(0,0),eg=0x100000000,ef=0xffffffffffffffff,ey=new ec(-1,-1);var ep=Object.defineProperty,em=(e,t,s)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?ep(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s};class ev{constructor(e,t){em(this,"version"),em(this,"remoteQuerySet"),em(this,"queryPath"),em(this,"logger"),this.version={querySet:0,ts:ec.fromNumber(0),identity:0},this.remoteQuerySet=new Map,this.queryPath=e,this.logger=t}transition(e){let t=e.startVersion;if(this.version.querySet!==t.querySet||this.version.ts.notEquals(t.ts)||this.version.identity!==t.identity)throw Error(`Invalid start version: ${t.ts.toString()}:${t.querySet}:${t.identity}, transitioning from ${this.version.ts.toString()}:${this.version.querySet}:${this.version.identity}`);for(let t of e.modifications)switch(t.type){case"QueryUpdated":{let e=this.queryPath(t.queryId);if(e)for(let s of t.logLines)j(this.logger,"info","query",e,s);let s=I(t.value??null);this.remoteQuerySet.set(t.queryId,{success:!0,value:s,logLines:t.logLines});break}case"QueryFailed":{let e=this.queryPath(t.queryId);if(e)for(let s of t.logLines)j(this.logger,"info","query",e,s);let{errorData:s}=t;this.remoteQuerySet.set(t.queryId,{success:!1,errorMessage:t.errorMessage,errorData:void 0!==s?I(s):void 0,logLines:t.logLines});break}case"QueryRemoved":this.remoteQuerySet.delete(t.queryId);break;default:throw Error(`Invalid modification ${t.type}`)}this.version=e.endVersion}remoteQueryResults(){return this.remoteQuerySet}timestamp(){return this.version.ts}}function eb(e){let t=g(e);return ec.fromBytesLE(Array.from(t))}function eS(e){switch(e.type){case"FatalError":case"AuthError":case"ActionResponse":case"TransitionChunk":case"Ping":return{...e};case"MutationResponse":if(e.success)return{...e,ts:eb(e.ts)};return{...e};case"Transition":return{...e,startVersion:{...e.startVersion,ts:eb(e.startVersion.ts)},endVersion:{...e.endVersion,ts:eb(e.endVersion.ts)}}}}var ek=Object.defineProperty,ew=(e,t,s)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?ek(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s};function eR(){return(void 0===i&&(i=Date.now()),"u"<typeof performance||!performance.now)?Date.now():Math.round(i+performance.now())}function eC(){return`t=${Math.round((eR()-i)/100)/10}s`}let eT={InternalServerError:{timeout:1e3},SubscriptionsWorkerFullError:{timeout:3e3},TooManyConcurrentRequests:{timeout:3e3},CommitterFullError:{timeout:3e3},AwsTooManyRequestsException:{timeout:3e3},ExecuteFullError:{timeout:3e3},SystemTimeoutError:{timeout:3e3},ExpiredInQueue:{timeout:3e3},VectorIndexesUnavailable:{timeout:1e3},SearchIndexesUnavailable:{timeout:1e3},TableSummariesUnavailable:{timeout:1e3},VectorIndexTooLarge:{timeout:3e3},SearchIndexTooLarge:{timeout:3e3},TooManyWritesInTimePeriod:{timeout:3e3}};class eA{constructor(e,t,s,i,n,r){this.markConnectionStateDirty=n,this.debug=r,ew(this,"socket"),ew(this,"connectionCount"),ew(this,"_hasEverConnected",!1),ew(this,"lastCloseReason"),ew(this,"transitionChunkBuffer",null),ew(this,"defaultInitialBackoff"),ew(this,"maxBackoff"),ew(this,"retries"),ew(this,"serverInactivityThreshold"),ew(this,"reconnectDueToServerInactivityTimeout"),ew(this,"scheduledReconnect",null),ew(this,"networkOnlineHandler",null),ew(this,"pendingNetworkRecoveryInfo",null),ew(this,"uri"),ew(this,"onOpen"),ew(this,"onResume"),ew(this,"onMessage"),ew(this,"webSocketConstructor"),ew(this,"logger"),ew(this,"onServerDisconnectError"),this.webSocketConstructor=s,this.socket={state:"disconnected"},this.connectionCount=0,this.lastCloseReason="InitialConnect",this.defaultInitialBackoff=1e3,this.maxBackoff=16e3,this.retries=0,this.serverInactivityThreshold=6e4,this.reconnectDueToServerInactivityTimeout=null,this.uri=e,this.onOpen=t.onOpen,this.onResume=t.onResume,this.onMessage=t.onMessage,this.onServerDisconnectError=t.onServerDisconnectError,this.logger=i,this.setupNetworkListener(),this.connect()}setSocketState(e){this.socket=e,this._logVerbose(`socket state changed: ${this.socket.state}, paused: ${"paused"in this.socket?this.socket.paused:void 0}`),this.markConnectionStateDirty()}setupNetworkListener(){"u"<typeof window||"function"!=typeof window.addEventListener||null===this.networkOnlineHandler&&(this.networkOnlineHandler=()=>{this._logVerbose("network online event detected"),this.tryReconnectImmediately()},window.addEventListener("online",this.networkOnlineHandler),this._logVerbose("network online event listener registered"))}cleanupNetworkListener(){this.networkOnlineHandler&&"u">typeof window&&"function"==typeof window.removeEventListener&&(window.removeEventListener("online",this.networkOnlineHandler),this.networkOnlineHandler=null,this._logVerbose("network online event listener removed"))}assembleTransition(e){if(e.partNumber<0||e.partNumber>=e.totalParts||0===e.totalParts||this.transitionChunkBuffer&&(this.transitionChunkBuffer.totalParts!==e.totalParts||this.transitionChunkBuffer.transitionId!==e.transitionId))throw this.transitionChunkBuffer=null,Error("Invalid TransitionChunk");if(null===this.transitionChunkBuffer&&(this.transitionChunkBuffer={chunks:[],totalParts:e.totalParts,transitionId:e.transitionId}),e.partNumber!==this.transitionChunkBuffer.chunks.length){let t=this.transitionChunkBuffer.chunks.length;throw this.transitionChunkBuffer=null,Error(`TransitionChunk received out of order: expected part ${t}, got ${e.partNumber}`)}if(this.transitionChunkBuffer.chunks.push(e.chunk),this.transitionChunkBuffer.chunks.length===e.totalParts){let e=this.transitionChunkBuffer.chunks.join("");this.transitionChunkBuffer=null;let t=eS(JSON.parse(e));if("Transition"!==t.type)throw Error(`Expected Transition, got ${t.type} after assembling chunks`);return t}return null}connect(){if("terminated"===this.socket.state)return;if("disconnected"!==this.socket.state&&"stopped"!==this.socket.state)throw Error("Didn't start connection from disconnected state: "+this.socket.state);let e=new this.webSocketConstructor(this.uri);this._logVerbose("constructed WebSocket"),this.setSocketState({state:"connecting",ws:e,paused:"no"}),this.resetServerInactivityTimeout(),e.onopen=()=>{if(this.logger.logVerbose("begin ws.onopen"),"connecting"!==this.socket.state)throw Error("onopen called with socket not in connecting state");if(this.setSocketState({state:"ready",ws:e,paused:"yes"===this.socket.paused?"uninitialized":"no"}),this.resetServerInactivityTimeout(),"no"===this.socket.paused&&(this._hasEverConnected=!0,this.onOpen({connectionCount:this.connectionCount,lastCloseReason:this.lastCloseReason,clientTs:eR()})),"InitialConnect"!==this.lastCloseReason&&(this.lastCloseReason?this.logger.log("WebSocket reconnected at",eC(),"after disconnect due to",this.lastCloseReason):this.logger.log("WebSocket reconnected at",eC())),this.connectionCount+=1,this.lastCloseReason=null,null!==this.pendingNetworkRecoveryInfo){let{timeSavedMs:e}=this.pendingNetworkRecoveryInfo;this.pendingNetworkRecoveryInfo=null,this.sendMessage({type:"Event",eventType:"NetworkRecoveryReconnect",event:{timeSavedMs:e}}),this.logger.log(`Network recovery reconnect saved ~${Math.round(e/1e3)}s of waiting`)}},e.onerror=e=>{this.transitionChunkBuffer=null;let t=e.message;t&&this.logger.log(`WebSocket error message: ${t}`)},e.onmessage=e=>{this.resetServerInactivityTimeout();let t=e.data.length,s=eS(JSON.parse(e.data));if(this._logVerbose(`received ws message with type ${s.type}`),"Ping"!==s.type){if("TransitionChunk"===s.type){let e=this.assembleTransition(s);if(!e)return;s=e,this._logVerbose(`assembled full ws message of type ${s.type}`)}null!==this.transitionChunkBuffer&&(this.transitionChunkBuffer=null,this.logger.log(`Received unexpected ${s.type} while buffering TransitionChunks`)),"Transition"===s.type&&this.reportLargeTransition({messageLength:t,transition:s}),this.onMessage(s).hasSyncedPastLastReconnect&&(this.retries=0,this.markConnectionStateDirty())}},e.onclose=e=>{if(this._logVerbose("begin ws.onclose"),this.transitionChunkBuffer=null,null===this.lastCloseReason&&(this.lastCloseReason=e.reason||`closed with code ${e.code}`),1e3!==e.code&&1001!==e.code&&1005!==e.code&&4040!==e.code){let t=`WebSocket closed with code ${e.code}`;e.reason&&(t+=`: ${e.reason}`),this.logger.log(t),this.onServerDisconnectError&&e.reason&&this.onServerDisconnectError(t)}let t=function(e){if(void 0===e)return"Unknown";for(let t of Object.keys(eT))if(e.startsWith(t))return t;return"Unknown"}(e.reason);this.scheduleReconnect(t)}}socketState(){return this.socket.state}sendMessage(e){let t={type:e.type,..."Authenticate"===e.type&&"User"===e.tokenType?{value:`...${e.value.slice(-7)}`}:{}};if("ready"===this.socket.state&&"no"===this.socket.paused){let s=JSON.stringify(function(e){switch(e.type){case"Authenticate":case"ModifyQuerySet":case"Mutation":case"Action":case"Event":return{...e};case"Connect":if(void 0===e.maxObservedTimestamp)return{...e,maxObservedTimestamp:void 0};return{...e,maxObservedTimestamp:f(new Uint8Array(e.maxObservedTimestamp.toBytesLE()))}}}(e)),i=!1;try{this.socket.ws.send(s),i=!0}catch(e){this.logger.log(`Failed to send message on WebSocket, reconnecting: ${e}`),this.closeAndReconnect("FailedToSendMessage")}return this._logVerbose(`${i?"sent":"failed to send"} message with type ${e.type}: ${JSON.stringify(t)}`),!0}return this._logVerbose(`message not sent (socket state: ${this.socket.state}, paused: ${"paused"in this.socket?this.socket.paused:void 0}): ${JSON.stringify(t)}`),!1}resetServerInactivityTimeout(){"terminated"!==this.socket.state&&(null!==this.reconnectDueToServerInactivityTimeout&&(clearTimeout(this.reconnectDueToServerInactivityTimeout),this.reconnectDueToServerInactivityTimeout=null),this.reconnectDueToServerInactivityTimeout=setTimeout(()=>{this.closeAndReconnect("InactiveServer")},this.serverInactivityThreshold))}scheduleReconnect(e){this.scheduledReconnect&&(clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null),this.socket={state:"disconnected"};let t=this.nextBackoff(e);this.markConnectionStateDirty(),this.logger.log(`Attempting reconnect in ${Math.round(t)}ms`);let s=eR(),i=setTimeout(()=>{this.scheduledReconnect?.timeout===i&&(this.scheduledReconnect=null,this.connect())},t);this.scheduledReconnect={timeout:i,scheduledAt:s,backoffMs:t}}closeAndReconnect(e){switch(this._logVerbose(`begin closeAndReconnect with reason ${e}`),this.socket.state){case"disconnected":case"terminated":case"stopped":return;case"connecting":case"ready":this.lastCloseReason=e,this.close(),this.scheduleReconnect("client");return;default:this.socket}}close(){switch(this.transitionChunkBuffer=null,this.socket.state){case"disconnected":case"terminated":case"stopped":return Promise.resolve();case"connecting":{let e=this.socket.ws;return e.onmessage=e=>{this._logVerbose("Ignoring message received after close")},new Promise(t=>{e.onclose=()=>{this._logVerbose("Closed after connecting"),t()},e.onopen=()=>{this._logVerbose("Opened after connecting"),e.close()}})}case"ready":{this._logVerbose("ws.close called");let e=this.socket.ws;e.onmessage=e=>{this._logVerbose("Ignoring message received after close")};let t=new Promise(t=>{e.onclose=()=>{t()}});return e.close(),t}default:return this.socket,Promise.resolve()}}terminate(){switch(this.reconnectDueToServerInactivityTimeout&&clearTimeout(this.reconnectDueToServerInactivityTimeout),this.scheduledReconnect&&(clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null),this.cleanupNetworkListener(),this.socket.state){case"terminated":case"stopped":case"disconnected":case"connecting":case"ready":{let e=this.close();return this.setSocketState({state:"terminated"}),e}default:throw this.socket,Error(`Invalid websocket state: ${this.socket.state}`)}}stop(){switch(this.socket.state){case"terminated":return Promise.resolve();case"connecting":case"stopped":case"disconnected":case"ready":{this.cleanupNetworkListener();let e=this.close();return this.socket={state:"stopped"},e}default:return this.socket,Promise.resolve()}}tryRestart(){switch(this.socket.state){case"stopped":break;case"terminated":case"connecting":case"ready":case"disconnected":this.logger.logVerbose("Restart called without stopping first");return;default:this.socket}this.setupNetworkListener(),this.connect()}pause(){switch(this.socket.state){case"disconnected":case"stopped":case"terminated":return;case"connecting":case"ready":this.socket={...this.socket,paused:"yes"};return;default:return void this.socket}}tryReconnectImmediately(){if(this._logVerbose("tryReconnectImmediately called"),"disconnected"!==this.socket.state)return void this._logVerbose(`tryReconnectImmediately called but socket state is ${this.socket.state}, no action taken`);let e=null;if(this.scheduledReconnect){let t=eR()-this.scheduledReconnect.scheduledAt;e=Math.max(0,this.scheduledReconnect.backoffMs-t),this._logVerbose(`would have waited ${Math.round(e)}ms more (backoff was ${Math.round(this.scheduledReconnect.backoffMs)}ms, elapsed ${Math.round(t)}ms)`),clearTimeout(this.scheduledReconnect.timeout),this.scheduledReconnect=null,this._logVerbose("canceled scheduled reconnect")}this.logger.log("Network recovery detected, reconnecting immediately"),this.pendingNetworkRecoveryInfo=null!==e?{timeSavedMs:e}:null,this.connect()}resume(){switch(this.socket.state){case"connecting":this.socket={...this.socket,paused:"no"};return;case"ready":"uninitialized"===this.socket.paused?(this.socket={...this.socket,paused:"no"},this._hasEverConnected=!0,this.onOpen({connectionCount:this.connectionCount,lastCloseReason:this.lastCloseReason,clientTs:eR()})):"yes"===this.socket.paused&&(this.socket={...this.socket,paused:"no"},this.onResume());return;case"terminated":case"stopped":case"disconnected":return;default:this.socket}this.connect()}connectionState(){return{isConnected:"ready"===this.socket.state,hasEverConnected:this._hasEverConnected,connectionCount:this.connectionCount,connectionRetries:this.retries}}_logVerbose(e){this.logger.logVerbose(e)}nextBackoff(e){let t=("client"===e?100:"Unknown"===e?this.defaultInitialBackoff:eT[e].timeout)*Math.pow(2,this.retries);this.retries+=1;let s=Math.min(t,this.maxBackoff),i=s*(Math.random()-.5);return s+i}reportLargeTransition({transition:e,messageLength:t}){if(void 0===e.clientClockSkew||void 0===e.serverTs)return;let s=eR()-e.clientClockSkew-e.serverTs/1e6,i=`${Math.round(s)}ms`,n=`${Math.round(t/1e4)/100}MB`,r=t/(s/1e3),o=`${Math.round(r/1e4)/100}MB per second`;this._logVerbose(`received ${n} transition in ${i} at ${o}`),t>2e7?this.logger.log(`received query results totaling more that 20MB (${n}) which will take a long time to download on slower connections`):s>2e4&&this.logger.log(`received query results totaling ${n} which took more than 20s to arrive (${i})`),this.debug&&this.sendMessage({type:"Event",eventType:"ClientReceivedTransition",event:{transitionTransitTime:s,messageLength:t}})}}class eq extends Error{}function eM(e,t){let s;if("string"!=typeof e)throw new eq("Invalid token specified: must be a string");t||(t={});let i=+(!0!==t.header),n=e.split(".")[i];if("string"!=typeof n)throw new eq(`Invalid token specified: missing part #${i+1}`);try{s=function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw Error("base64 string is not of the correct length")}try{var s;return s=t,decodeURIComponent(atob(s).replace(/(.)/g,(e,t)=>{let s=t.charCodeAt(0).toString(16).toUpperCase();return s.length<2&&(s="0"+s),"%"+s}))}catch{return atob(t)}}(n)}catch(e){throw new eq(`Invalid token specified: invalid base64 for part #${i+1} (${e.message})`)}try{return JSON.parse(s)}catch(e){throw new eq(`Invalid token specified: invalid json for part #${i+1} (${e.message})`)}}eq.prototype.name="InvalidTokenError";var eI=Object.defineProperty,e$=(e,t,s)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?eI(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s};class eQ{constructor(e,t,s){e$(this,"authState",{state:"noAuth"}),e$(this,"configVersion",0),e$(this,"syncState"),e$(this,"authenticate"),e$(this,"stopSocket"),e$(this,"tryRestartSocket"),e$(this,"pauseSocket"),e$(this,"resumeSocket"),e$(this,"clearAuth"),e$(this,"logger"),e$(this,"refreshTokenLeewaySeconds"),e$(this,"initialAuthTokenReuse"),e$(this,"lastRefreshChange"),e$(this,"tokenConfirmationAttempts",0),this.syncState=e,this.authenticate=t.authenticate,this.stopSocket=t.stopSocket,this.tryRestartSocket=t.tryRestartSocket,this.pauseSocket=t.pauseSocket,this.resumeSocket=t.resumeSocket,this.clearAuth=t.clearAuth,this.logger=s.logger,this.refreshTokenLeewaySeconds=s.refreshTokenLeewaySeconds,this.initialAuthTokenReuse=s.initialAuthTokenReuse,this.lastRefreshChange=!1}notifyRefreshChange(e){"noAuth"!==this.authState.state&&"initialRefetch"!==this.authState.state&&this.authState.config.onRefreshChange&&this.lastRefreshChange!==e&&(this.lastRefreshChange=e,this.authState.config.onRefreshChange(e))}async setConfig(e,t,s){this.resetAuthState(),this._logVerbose("pausing WS for auth token fetch"),this.pauseSocket();let i=await this.fetchTokenAndGuardAgainstRace(e,{forceRefreshToken:!1});if(i.isFromOutdatedConfig)return;let n={fetchToken:e,onAuthChange:t,onRefreshChange:s};i.value?(this.setAuthState({state:"waitingForServerConfirmationOfCachedToken",config:n,hasRetried:!1}),this.authenticate(i.value)):(this.setAuthState({state:"initialRefetch",config:n}),await this.refetchToken()),this._logVerbose("resuming WS after auth token fetch"),this.resumeSocket()}onTransition(e){if(this.syncState.isCurrentOrNewerAuthVersion(e.endVersion.identity)&&!(e.endVersion.identity<=e.startVersion.identity)){if(this._logVerbose(`auth state is ${this.authState.state} when handling transition`),this.syncState.markAuthCompletion(),"waitingForServerConfirmationOfCachedToken"===this.authState.state){this._logVerbose("server confirmed auth token is valid");let t=this.syncState.getAuth()?.value;this.initialAuthTokenReuse&&t?this.scheduleTokenRefetch(t,e.clientClockSkew):this.refetchToken(),this.authState.config.onAuthChange(!0);return}"waitingForServerConfirmationOfFreshToken"===this.authState.state&&(this._logVerbose("server confirmed new auth token is valid"),this.notifyRefreshChange(!1),this.scheduleTokenRefetch(this.authState.token),this.tokenConfirmationAttempts=0,this.authState.hadAuth||this.authState.config.onAuthChange(!0))}}onAuthError(e){if(!1===e.authUpdateAttempted&&("waitingForServerConfirmationOfFreshToken"===this.authState.state||"waitingForServerConfirmationOfCachedToken"===this.authState.state))return void this._logVerbose("ignoring non-auth token expired error");let{baseVersion:t}=e;this.syncState.isCurrentOrNewerAuthVersion(t+1)?this.tryToReauthenticate(e):this._logVerbose("ignoring auth error for previous auth attempt")}async tryToReauthenticate(e){if(this._logVerbose(`attempting to reauthenticate: ${e.error}`),"noAuth"===this.authState.state||"waitingForServerConfirmationOfFreshToken"===this.authState.state&&this.tokenConfirmationAttempts>=2){this.logger.error(`Failed to authenticate: "${e.error}", check your server auth config`),this.syncState.hasAuth()&&this.syncState.clearAuth(),"noAuth"!==this.authState.state&&this.setAndReportAuthFailed(this.authState.config.onAuthChange);return}if("waitingForServerConfirmationOfFreshToken"===this.authState.state&&(this.tokenConfirmationAttempts++,this._logVerbose(`retrying reauthentication, ${2-this.tokenConfirmationAttempts} attempts remaining`)),this.notifyRefreshChange(!0),await this.stopSocket(),"noAuth"===this.authState.state)return;let t=await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken,{forceRefreshToken:!0});t.isFromOutdatedConfig||(t.value&&this.syncState.isNewAuth(t.value)?(this.authenticate(t.value),this.setAuthState({state:"waitingForServerConfirmationOfFreshToken",config:this.authState.config,token:t.value,hadAuth:"notRefetching"===this.authState.state||"waitingForScheduledRefetch"===this.authState.state})):(this._logVerbose("reauthentication failed, could not fetch a new token"),this.syncState.hasAuth()&&this.syncState.clearAuth(),this.setAndReportAuthFailed(this.authState.config.onAuthChange)),this.tryRestartSocket())}async refetchToken(){if("noAuth"===this.authState.state)return;this._logVerbose("refetching auth token");let e=await this.fetchTokenAndGuardAgainstRace(this.authState.config.fetchToken,{forceRefreshToken:!0});e.isFromOutdatedConfig||(e.value?this.syncState.isNewAuth(e.value)?(this.setAuthState({state:"waitingForServerConfirmationOfFreshToken",hadAuth:this.syncState.hasAuth(),token:e.value,config:this.authState.config}),this.authenticate(e.value)):this.setAuthState({state:"notRefetching",config:this.authState.config}):(this._logVerbose("refetching token failed"),this.syncState.hasAuth()&&this.clearAuth(),this.setAndReportAuthFailed(this.authState.config.onAuthChange)),this._logVerbose("restarting WS after auth token fetch (if currently stopped)"),this.tryRestartSocket())}scheduleTokenRefetch(e,t){let s;if("noAuth"===this.authState.state)return;let i=this.decodeToken(e);if(!i)return void this.logger.error("Auth token is not a valid JWT, cannot refetch the token");let{iat:n,exp:r}=i;if(!n||!r)return void this.logger.error("Auth token does not have required fields, cannot refetch the token");let o=r-n;if(o<=2)return void this.logger.error("Auth token does not live long enough, cannot refetch the token");void 0!==t?(s=r-(Date.now()-t)/1e3)<=0&&(s=0):s=o;let a=Math.min(1728e6,(s-this.refreshTokenLeewaySeconds)*1e3);a<=0&&(this.logger.warn(`Refetching auth token immediately, configured leeway ${this.refreshTokenLeewaySeconds}s is larger than the token's lifetime ${s}s`),a=0);let u=setTimeout(()=>{this._logVerbose("running scheduled token refetch"),this.refetchToken()},a);this.setAuthState({state:"waitingForScheduledRefetch",refetchTokenTimeoutId:u,config:this.authState.config}),this._logVerbose(`scheduled preemptive auth token refetching in ${a}ms`)}async fetchTokenAndGuardAgainstRace(e,t){let s=++this.configVersion;this._logVerbose(`fetching token with config version ${s}`);let i=await e(t);return this.configVersion!==s?(this._logVerbose(`stale config version, expected ${s}, got ${this.configVersion}`),{isFromOutdatedConfig:!0}):{isFromOutdatedConfig:!1,value:i}}stop(){this.resetAuthState(),this.configVersion++,this._logVerbose(`config version bumped to ${this.configVersion}`)}setAndReportAuthFailed(e){e(!1),this.resetAuthState()}resetAuthState(){this.notifyRefreshChange(!1),this.setAuthState({state:"noAuth"})}setAuthState(e){let t="waitingForServerConfirmationOfFreshToken"===e.state?{hadAuth:e.hadAuth,state:e.state,token:`...${e.token.slice(-7)}`}:{state:e.state};switch(this._logVerbose(`setting auth state to ${JSON.stringify(t)}`),e.state){case"waitingForScheduledRefetch":case"notRefetching":case"noAuth":this.tokenConfirmationAttempts=0}"waitingForScheduledRefetch"===this.authState.state&&clearTimeout(this.authState.refetchTokenTimeoutId),this.authState=e}decodeToken(e){try{return eM(e)}catch(e){return this._logVerbose(`Error decoding token: ${e instanceof Error?e.message:"Unknown error"}`),null}}_logVerbose(e){this.logger.logVerbose(`${e} [v${this.configVersion}]`)}}let eO=["convexClientConstructed","convexWebSocketOpen","convexFirstMessageReceived"];function ex(e){let t=e.name.slice(6);return{name:t=t.charAt(0).toLowerCase()+t.slice(1),startTime:e.startTime}}var eE=Object.defineProperty,eP=(e,t,s)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?eE(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s};class eV{constructor(e,t,s){let i;if(eP(this,"address"),eP(this,"state"),eP(this,"requestManager"),eP(this,"webSocketManager"),eP(this,"authenticationManager"),eP(this,"remoteQuerySet"),eP(this,"optimisticQueryResults"),eP(this,"_transitionHandlerCounter",0),eP(this,"_nextRequestId"),eP(this,"_onTransitionFns",new Map),eP(this,"_sessionId"),eP(this,"firstMessageReceived",!1),eP(this,"debug"),eP(this,"logger"),eP(this,"maxObservedTimestamp"),eP(this,"connectionStateSubscribers",new Map),eP(this,"nextConnectionStateSubscriberId",0),eP(this,"_lastPublishedConnectionState"),eP(this,"markConnectionStateDirty",()=>{Promise.resolve().then(()=>{let e=this.connectionState();if(JSON.stringify(e)!==JSON.stringify(this._lastPublishedConnectionState))for(let t of(this._lastPublishedConnectionState=e,this.connectionStateSubscribers.values()))t(e)})}),eP(this,"mark",e=>{var t;this.debug&&(t=this.sessionId,"u">typeof performance&&performance.mark&&performance.mark(e,{detail:{sessionId:t}}))}),"object"==typeof e)throw Error("Passing a ClientConfig object is no longer supported. Pass the URL of the Convex deployment as a string directly.");s?.skipConvexDeploymentUrlCheck!==!0&&function(e){if(void 0===e)throw Error("Client created with undefined deployment address. If you used an environment variable, check that it's set.");if("string"!=typeof e)throw Error(`Invalid deployment address: found ${e}".`);if(!(e.startsWith("http:")||e.startsWith("https:")))throw Error(`Invalid deployment address: Must start with "https://" or "http://". Found "${e}".`);try{new URL(e)}catch{throw Error(`Invalid deployment address: "${e}" is not a valid URL. If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`)}if(e.endsWith(".convex.site"))throw Error(`Invalid deployment address: "${e}" ends with .convex.site, which is used for HTTP Actions. Convex deployment URLs typically end with .convex.cloud? If you believe this URL is correct, use the \`skipConvexDeploymentUrlCheck\` option to bypass this.`)}(e);const n=(s={...s}).authRefreshTokenLeewaySeconds??10;let r=s.webSocketConstructor;if(!r&&"u"<typeof WebSocket)throw Error("No WebSocket global variable defined! To use Convex in an environment without WebSocket try the HTTP client: https://docs.convex.dev/api/classes/browser.ConvexHttpClient");r=r||WebSocket,this.debug=s.reportDebugInfoToConvex??!1,this.address=e,this.logger=!1===s.logger?function(e){return new U(e)}({verbose:s.verbose??!1}):!0!==s.logger&&s.logger?s.logger:D({verbose:s.verbose??!1});const o=e.search("://");if(-1===o)throw Error("Provided address was not an absolute URL.");const a=e.substring(o+3),u=e.substring(0,o);if("http"===u)i="ws";else if("https"===u)i="wss";else throw Error(`Unknown parent protocol ${u}`);const h=`${i}://${a}/api/${_}/sync`;this.state=new Y,this.remoteQuerySet=new ev(e=>this.state.queryPath(e),this.logger),this.requestManager=new et(this.logger,this.markConnectionStateDirty);const l=()=>{this.webSocketManager.pause(),this.state.pause()};this.authenticationManager=new eQ(this.state,{authenticate:e=>{let t=this.state.setAuth(e);return this.webSocketManager.sendMessage(t),t.baseVersion},stopSocket:()=>this.webSocketManager.stop(),tryRestartSocket:()=>this.webSocketManager.tryRestart(),pauseSocket:l,resumeSocket:()=>this.webSocketManager.resume(),clearAuth:()=>{this.clearAuth()}},{logger:this.logger,refreshTokenLeewaySeconds:n,initialAuthTokenReuse:s.initialAuthTokenReuse??!1}),this.optimisticQueryResults=new eu,this.addOnTransitionHandler(e=>{t(e.queries.map(e=>e.token))}),this._nextRequestId=0,this._sessionId="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});const{unsavedChangesWarning:c}=s;if("u"<typeof window||void 0===window.addEventListener){if(!0===c)throw Error("unsavedChangesWarning requested, but window.addEventListener not found! Remove {unsavedChangesWarning: true} from Convex client options.")}else!1!==c&&window.addEventListener("beforeunload",e=>{if(this.requestManager.hasIncompleteRequests()){e.preventDefault();let t="Are you sure you want to leave? Your changes may not be saved.";return(e||window.event).returnValue=t,t}});this.webSocketManager=new eA(h,{onOpen:e=>{this.mark("convexWebSocketOpen"),this.webSocketManager.sendMessage({...e,type:"Connect",sessionId:this._sessionId,maxObservedTimestamp:this.maxObservedTimestamp}),this.remoteQuerySet=new ev(e=>this.state.queryPath(e),this.logger);let[t,s]=this.state.restart();for(let e of(s&&this.webSocketManager.sendMessage(s),this.webSocketManager.sendMessage(t),this.requestManager.restart()))this.webSocketManager.sendMessage(e)},onResume:()=>{let[e,t]=this.state.resume();for(let s of(t&&this.webSocketManager.sendMessage(t),e&&this.webSocketManager.sendMessage(e),this.requestManager.resume()))this.webSocketManager.sendMessage(s)},onMessage:e=>{switch(!this.firstMessageReceived&&(this.firstMessageReceived=!0,this.mark("convexFirstMessageReceived"),this.reportMarks()),e.type){case"Transition":{this.observedTimestamp(e.endVersion.ts),this.authenticationManager.onTransition(e),this.remoteQuerySet.transition(e),this.state.transition(e);let t=this.requestManager.removeCompleted(this.remoteQuerySet.timestamp());this.notifyOnQueryResultChanges(t);break}case"MutationResponse":{e.success&&this.observedTimestamp(e.ts);let t=this.requestManager.onResponse(e);null!==t&&this.notifyOnQueryResultChanges(new Map([[t.requestId,t.result]]));break}case"ActionResponse":this.requestManager.onResponse(e);break;case"AuthError":this.authenticationManager.onAuthError(e);break;case"FatalError":{var t,s;let i,n=(t=this.logger,s=e.error,i=`[CONVEX FATAL ERROR] ${s}`,t.error(i),Error(i));throw this.webSocketManager.terminate(),n}}return{hasSyncedPastLastReconnect:this.hasSyncedPastLastReconnect()}},onServerDisconnectError:s.onServerDisconnectError},r,this.logger,this.markConnectionStateDirty,this.debug),this.mark("convexClientConstructed"),s.expectAuth&&l()}hasSyncedPastLastReconnect(){return this.requestManager.hasSyncedPastLastReconnect()&&this.state.hasSyncedPastLastReconnect()}observedTimestamp(e){(void 0===this.maxObservedTimestamp||this.maxObservedTimestamp.lessThanOrEqual(e))&&(this.maxObservedTimestamp=e)}getMaxObservedTimestamp(){return this.maxObservedTimestamp}notifyOnQueryResultChanges(e){let t=this.remoteQuerySet.remoteQueryResults(),s=new Map;for(let[e,i]of t){let t=this.state.queryToken(e);if(null!==t){let n={result:i,udfPath:this.state.queryPath(e),args:this.state.queryArgs(e)};s.set(t,n)}}let i=this.optimisticQueryResults.ingestQueryResultsFromServer(s,new Set(e.keys()));this.handleTransition({queries:i.map(e=>{let t=this.optimisticQueryResults.rawQueryResult(e);return{token:e,modification:{kind:"Updated",result:t}}}),reflectedMutations:Array.from(e).map(([e,t])=>({requestId:e,result:t})),timestamp:this.remoteQuerySet.timestamp()})}handleTransition(e){for(let t of this._onTransitionFns.values())t(e)}addOnTransitionHandler(e){let t=this._transitionHandlerCounter++;return this._onTransitionFns.set(t,e),()=>this._onTransitionFns.delete(t)}getCurrentAuthClaims(){let e=this.state.getAuth(),t={};if(e&&"User"===e.tokenType){try{t=e?eM(e.value):{}}catch{t={}}return{token:e.value,decoded:t}}}setAuth(e,t,s){this.authenticationManager.setConfig(e,t,s)}hasAuth(){return this.state.hasAuth()}setAdminAuth(e,t){let s=this.state.setAdminAuth(e,t);this.webSocketManager.sendMessage(s)}clearAuth(){let e=this.state.clearAuth();this.webSocketManager.sendMessage(e)}subscribe(e,t,s){let i=y(t),{modification:n,queryToken:r,unsubscribe:o}=this.state.subscribe(e,i,s?.journal,s?.componentPath);return null!==n&&this.webSocketManager.sendMessage(n),{queryToken:r,unsubscribe:()=>{let e=o();e&&this.webSocketManager.sendMessage(e)}}}localQueryResult(e,t){let s=K(e,y(t));return this.optimisticQueryResults.queryResult(s)}localQueryResultByToken(e){return this.optimisticQueryResults.queryResult(e)}hasLocalQueryResultByToken(e){return this.optimisticQueryResults.hasQueryResult(e)}localQueryLogs(e,t){let s=K(e,y(t));return this.optimisticQueryResults.queryLogs(s)}queryJournal(e,t){let s=K(e,y(t));return this.state.queryJournal(s)}connectionState(){let e=this.webSocketManager.connectionState();return{hasInflightRequests:this.requestManager.hasInflightRequests(),isWebSocketConnected:e.isConnected,hasEverConnected:e.hasEverConnected,connectionCount:e.connectionCount,connectionRetries:e.connectionRetries,timeOfOldestInflightRequest:this.requestManager.timeOfOldestInflightRequest(),inflightMutations:this.requestManager.inflightMutations(),inflightActions:this.requestManager.inflightActions()}}subscribeToConnectionState(e){let t=this.nextConnectionStateSubscriberId++;return this.connectionStateSubscribers.set(t,e),()=>{this.connectionStateSubscribers.delete(t)}}async mutation(e,t,s){let i=await this.mutationInternal(e,t,s);if(!i.success){if(void 0!==i.errorData)throw H(i,new V(W("mutation",e,i)));throw Error(W("mutation",e,i))}return i.value}async mutationInternal(e,t,s,i){let{mutationPromise:n}=this.enqueueMutation(e,t,s,i);return n}enqueueMutation(e,t,s,i){let n=y(t);this.tryReportLongDisconnect();let r=this.nextRequestId;if(this._nextRequestId++,void 0!==s){let e=s.optimisticUpdate;if(void 0!==e){let t=t=>{e(t,n)instanceof Promise&&this.logger.warn("Optimistic update handler returned a Promise. Optimistic updates should be synchronous.")},s=this.optimisticQueryResults.applyOptimisticUpdate(t,r).map(e=>{let t=this.localQueryResultByToken(e);return{token:e,modification:{kind:"Updated",result:void 0===t?void 0:{success:!0,value:t,logLines:[]}}}});this.handleTransition({queries:s,reflectedMutations:[],timestamp:this.remoteQuerySet.timestamp()})}}let o={type:"Mutation",requestId:r,udfPath:e,componentPath:i,args:[O(n)]},a=this.webSocketManager.sendMessage(o);return{requestId:r,mutationPromise:this.requestManager.request(o,a)}}async action(e,t){let s=await this.actionInternal(e,t);if(!s.success){if(void 0!==s.errorData)throw H(s,new V(W("action",e,s)));throw Error(W("action",e,s))}return s.value}async actionInternal(e,t,s){let i=y(t),n=this.nextRequestId;this._nextRequestId++,this.tryReportLongDisconnect();let r={type:"Action",requestId:n,udfPath:e,componentPath:s,args:[O(i)]},o=this.webSocketManager.sendMessage(r);return this.requestManager.request(r,o)}async close(){return this.authenticationManager.stop(),this.webSocketManager.terminate()}get url(){return this.address}get nextRequestId(){return this._nextRequestId}get sessionId(){return this._sessionId}reportMarks(){if(this.debug){let e=function(e){if("u"<typeof performance||!performance.getEntriesByName)return[];let t=[];for(let s of eO){let i=performance.getEntriesByName(s).filter(e=>"mark"===e.entryType).filter(t=>t.detail.sessionId===e);t.push(...i)}return t.map(ex)}(this.sessionId);this.webSocketManager.sendMessage({type:"Event",eventType:"ClientConnect",event:e})}}tryReportLongDisconnect(){if(!this.debug)return;let e=this.connectionState().timeOfOldestInflightRequest;null===e||Date.now()-e.getTime()<=6e4||fetch(`${this.address}/api/debug_event`,{method:"POST",headers:{"Content-Type":"application/json","Convex-Client":`npm-${_}`},body:JSON.stringify({event:"LongWebsocketDisconnect"})}).then(e=>{e.ok||this.logger.warn("Analytics request failed with response:",e.body)}).catch(e=>{this.logger.warn("Analytics response failed with error:",e)})}}function eL(e){if("object"!=typeof e||null===e||!Array.isArray(e.page)||"boolean"!=typeof e.isDone||"string"!=typeof e.continueCursor)throw Error(`Not a valid paginated query result: ${e?.toString()}`);return e}var e_=Object.defineProperty,eN=(e,t,s)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?e_(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s};class eF{constructor(e,t){this.client=e,this.onTransition=t,eN(this,"paginatedQuerySet",new Map),eN(this,"lastTransitionTs"),this.lastTransitionTs=ec.fromNumber(0),this.client.addOnTransitionHandler(e=>this.onBaseTransition(e))}subscribe(e,t,s){let i=J(e),n=z(i,t,s),r=()=>this.removePaginatedQuerySubscriber(n),o=this.paginatedQuerySet.get(n);return o?o.numSubscribers+=1:(this.paginatedQuerySet.set(n,{token:n,canonicalizedUdfPath:i,args:t,numSubscribers:1,options:{initialNumItems:s.initialNumItems},nextPageKey:0,pageKeys:[],pageKeyToQuery:new Map,ongoingSplits:new Map,skip:!1,id:s.id}),this.addPageToPaginatedQuery(n,null,s.initialNumItems)),{paginatedQueryToken:n,unsubscribe:r}}localQueryResult(e,t,s){let i=z(J(e),t,s);return this.localQueryResultByToken(i)}localQueryResultByToken(e){let t,s=this.paginatedQuerySet.get(e);if(!s)return;let i=this.activePageQueryTokens(s);if(0===i.length)return{results:[],status:"LoadingFirstPage",loadMore:t=>this.loadMoreOfPaginatedQuery(e,t)};let n=[],r=!1,o=!1;for(let e of i){let t=this.client.localQueryResultByToken(e);if(void 0===t){r=!0,o=!1;continue}let s=eL(t);n=n.concat(s.page),o=!!s.isDone}return t=r?0===n.length?"LoadingFirstPage":"LoadingMore":o?"Exhausted":"CanLoadMore",{results:n,status:t,loadMore:t=>this.loadMoreOfPaginatedQuery(e,t)}}onBaseTransition(e){let t=e.queries.map(e=>e.token),s=this.queriesContainingTokens(t),i=[];s.length>0&&(this.processPaginatedQuerySplits(s,e=>this.client.localQueryResultByToken(e)),i=s.map(e=>({token:e,modification:{kind:"Updated",result:this.localQueryResultByToken(e)}})));let n={...e,paginatedQueries:i};this.onTransition(n)}loadMoreOfPaginatedQuery(e,t){this.mustGetPaginatedQuery(e);let s=this.queryTokenForLastPageOfPaginatedQuery(e),i=this.client.localQueryResultByToken(s);if(!i)return!1;let n=eL(i);if(n.isDone)return!1;this.addPageToPaginatedQuery(e,n.continueCursor,t);let r={timestamp:this.lastTransitionTs,reflectedMutations:[],queries:[],paginatedQueries:[{token:e,modification:{kind:"Updated",result:this.localQueryResultByToken(e)}}]};return this.onTransition(r),!0}queriesContainingTokens(e){if(0===e.length)return[];let t=[],s=new Set(e);for(let[e,i]of this.paginatedQuerySet)for(let n of this.allQueryTokens(i))if(s.has(n)){t.push(e);break}return t}processPaginatedQuerySplits(e,t){for(let s of e){let e=this.mustGetPaginatedQuery(s),{ongoingSplits:i,pageKeyToQuery:n,pageKeys:r}=e;for(let[s,[r,o]]of i)void 0!==t(n.get(r).queryToken)&&void 0!==t(n.get(o).queryToken)&&this.completePaginatedQuerySplit(e,s,r,o);for(let s of r){if(i.has(s))continue;let r=n.get(s);if(!r)throw Error(`No page query for active pageKey ${s}`);let o=t(r.queryToken);if(!o)continue;let a=eL(o);a.splitCursor&&("SplitRecommended"===a.pageStatus||"SplitRequired"===a.pageStatus||a.page.length>2*e.options.initialNumItems)&&this.splitPaginatedQueryPage(e,s,r.cursor,a.splitCursor,a.continueCursor)}}}splitPaginatedQueryPage(e,t,s,i,n){let r=e.nextPageKey++,o=e.nextPageKey++,a={numItems:e.options.initialNumItems,id:e.id},u=this.client.subscribe(e.canonicalizedUdfPath,{...e.args,paginationOpts:{...a,cursor:s,endCursor:i}});e.pageKeyToQuery.set(r,{...u,cursor:s});let h=this.client.subscribe(e.canonicalizedUdfPath,{...e.args,paginationOpts:{...a,cursor:i,endCursor:n}});e.pageKeyToQuery.set(o,{...h,cursor:i}),e.ongoingSplits.set(t,[r,o])}addPageToPaginatedQuery(e,t,s){let i=this.mustGetPaginatedQuery(e),n=i.nextPageKey++,r={cursor:t,numItems:s,id:i.id},o={...i.args,paginationOpts:r},a=this.client.subscribe(i.canonicalizedUdfPath,o);return i.pageKeys.push(n),i.pageKeyToQuery.set(n,{...a,cursor:t}),a}removePaginatedQuerySubscriber(e){let t=this.paginatedQuerySet.get(e);if(t&&(t.numSubscribers-=1,!(t.numSubscribers>0))){for(let e of t.pageKeyToQuery.values())e.unsubscribe();this.paginatedQuerySet.delete(e)}}completePaginatedQuerySplit(e,t,s,i){let n=e.pageKeyToQuery.get(t);e.pageKeyToQuery.delete(t);let r=e.pageKeys.indexOf(t);e.pageKeys.splice(r,1,s,i),e.ongoingSplits.delete(t),n.unsubscribe()}activePageQueryTokens(e){return e.pageKeys.map(t=>e.pageKeyToQuery.get(t).queryToken)}allQueryTokens(e){return Array.from(e.pageKeyToQuery.values()).map(e=>e.queryToken)}queryTokenForLastPageOfPaginatedQuery(e){let t=this.mustGetPaginatedQuery(e),s=t.pageKeys[t.pageKeys.length-1];if(void 0===s)throw Error(`No pages for paginated query ${e}`);return t.pageKeyToQuery.get(s).queryToken}mustGetPaginatedQuery(e){let t=this.paginatedQuerySet.get(e);if(!t)throw Error("paginated query no longer exists for token "+e);return t}}var eB=Object.defineProperty,eU=(e,t,s)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?eB(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s};if(void 0===o)throw Error("Required dependency 'react' not found");class eD{constructor(e,t){if(eU(this,"address"),eU(this,"cachedSync"),eU(this,"cachedPaginatedQueryClient"),eU(this,"listeners"),eU(this,"options"),eU(this,"closed",!1),eU(this,"_logger"),eU(this,"adminAuth"),eU(this,"fakeUserIdentity"),void 0===e)throw Error("No address provided to ConvexReactClient.\nIf trying to deploy to production, make sure to follow all the instructions found at https://docs.convex.dev/production/hosting/\nIf running locally, make sure to run `convex dev` and ensure the .env.local file is populated.");if("string"!=typeof e)throw Error(`ConvexReactClient requires a URL like 'https://happy-otter-123.convex.cloud', received something of type ${typeof e} instead.`);if(!e.includes("://"))throw Error("Provided address was not an absolute URL.");this.address=e,this.listeners=new Map,this._logger=t?.logger===!1?function(e){return new U(e)}({verbose:t?.verbose??!1}):t?.logger!==!0&&t?.logger?t.logger:D({verbose:t?.verbose??!1}),this.options={...t,logger:this._logger}}get url(){return this.address}get sync(){if(this.closed)throw Error("ConvexReactClient has already been closed.");return this.cachedSync||(this.cachedSync=this.options.baseClient??new eV(this.address,()=>{},this.options),this.adminAuth&&this.cachedSync.setAdminAuth(this.adminAuth,this.fakeUserIdentity),this.cachedPaginatedQueryClient=new eF(this.cachedSync,e=>this.handleTransition(e))),this.cachedSync}get paginatedQueryClient(){if(this.sync,this.cachedPaginatedQueryClient)return this.cachedPaginatedQueryClient;throw Error("Should already be instantiated")}setAuth(e,t,s){if("string"==typeof e)throw Error("Passing a string to ConvexReactClient.setAuth is no longer supported, please upgrade to passing in an async function to handle reauthentication.");this.sync.setAuth(e,t??(()=>{}),s)}clearAuth(){this.sync.clearAuth()}setAdminAuth(e,t){if(this.adminAuth=e,this.fakeUserIdentity=t,this.closed)throw Error("ConvexReactClient has already been closed.");this.cachedSync&&this.sync.setAdminAuth(e,t)}watchQuery(e,...t){let[s,i]=t,n=en(e);return{onUpdate:e=>{let{queryToken:t,unsubscribe:r}=this.sync.subscribe(n,s,i),o=this.listeners.get(t);return void 0!==o?o.add(e):this.listeners.set(t,new Set([e])),()=>{if(this.closed)return;let s=this.listeners.get(t);s.delete(e),0===s.size&&this.listeners.delete(t),r()}},localQueryResult:()=>{if(this.cachedSync)return this.cachedSync.localQueryResult(n,s)},localQueryLogs:()=>{if(this.cachedSync)return this.cachedSync.localQueryLogs(n,s)},journal:()=>{if(this.cachedSync)return this.cachedSync.queryJournal(n,s)}}}prewarmQuery(e){let t=e.extendSubscriptionFor??5e3;setTimeout(this.watchQuery(e.query,e.args||{}).onUpdate(()=>{}),t)}watchPaginatedQuery(e,t,s){let i=en(e);return{onUpdate:e=>{let{paginatedQueryToken:n,unsubscribe:r}=this.paginatedQueryClient.subscribe(i,t||{},s),o=this.listeners.get(n);return void 0!==o?o.add(e):this.listeners.set(n,new Set([e])),()=>{if(this.closed)return;let t=this.listeners.get(n);t.delete(e),0===t.size&&this.listeners.delete(n),r()}},localQueryResult:()=>this.paginatedQueryClient.localQueryResult(i,t,s)}}mutation(e,...t){let[s,i]=t,n=en(e);return this.sync.mutation(n,s,i)}action(e,...t){let s=en(e);return this.sync.action(s,...t)}query(e,...t){let s=this.watchQuery(e,...t),i=s.localQueryResult();return void 0!==i?Promise.resolve(i):new Promise((e,t)=>{let i=s.onUpdate(()=>{i();try{e(s.localQueryResult())}catch(e){t(e)}})})}connectionState(){return this.sync.connectionState()}subscribeToConnectionState(e){return this.sync.subscribeToConnectionState(e)}get logger(){return this._logger}async close(){if(this.closed=!0,this.listeners=new Map,this.cachedPaginatedQueryClient&&(this.cachedPaginatedQueryClient=void 0),this.cachedSync){let e=this.cachedSync;this.cachedSync=void 0,await e.close()}}handleTransition(e){let t=e.queries.map(e=>e.token),s=e.paginatedQueries.map(e=>e.token);this.transition([...t,...s])}transition(e){for(let t of e){let e=this.listeners.get(t);if(e)for(let t of e)t()}}}let ej=o.createContext(void 0),eW=({client:e,children:t})=>o.createElement(ej.Provider,{value:e},t);Symbol("includePageKeys"),Symbol("page"),(0,o.createContext)(void 0)}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6091],{6059:(e,t,a)=>{a.d(t,{A:()=>n});let n=(0,a(99537).A)("git-compare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]])},33807:(e,t,a)=>{a.d(t,{J:()=>r});var n=a(95155);a(12115);var o=a(40980);function r({className:e,...t}){return(0,n.jsx)("label",{"data-slot":"label",className:(0,o.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}},42763:(e,t,a)=>{a.d(t,{Cf:()=>x,Es:()=>v,L3:()=>j,c7:()=>b,lG:()=>f,rr:()=>k});var n=a(95155);a(12115);var o=a(98408),r=a(32949),d=a(45477),i=a(88593),s=a(52579),l=a(11975),c=a(31799),u=a(40980),m=a(89239),p=a(9005);function f({...e}){return(0,n.jsx)(o.D,{"data-slot":"dialog",...e})}function g({...e}){return(0,n.jsx)(r.Z,{"data-slot":"dialog-portal",...e})}function h({className:e,...t}){return(0,n.jsx)(d.X,{"data-slot":"dialog-overlay",className:(0,u.cn)("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function x({className:e,children:t,showCloseButton:a=!0,...o}){return(0,n.jsxs)(g,{children:[(0,n.jsx)(h,{}),(0,n.jsxs)(i.h,{"data-slot":"dialog-content",className:(0,u.cn)("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o,children:[t,a&&(0,n.jsxs)(s.H,{"data-slot":"dialog-close",render:(0,n.jsx)(m.$,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm"}),children:[(0,n.jsx)(p.A,{}),(0,n.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function b({className:e,...t}){return(0,n.jsx)("div",{"data-slot":"dialog-header",className:(0,u.cn)("flex flex-col gap-2",e),...t})}function v({className:e,showCloseButton:t=!1,children:a,...o}){return(0,n.jsxs)("div",{"data-slot":"dialog-footer",className:(0,u.cn)("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",e),...o,children:[a,t&&(0,n.jsx)(s.H,{render:(0,n.jsx)(m.$,{variant:"outline"}),children:"Close"})]})}function j({className:e,...t}){return(0,n.jsx)(l.L,{"data-slot":"dialog-title",className:(0,u.cn)("font-heading text-base leading-none font-medium",e),...t})}function k({className:e,...t}){return(0,n.jsx)(c.r,{"data-slot":"dialog-description",className:(0,u.cn)("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}},51128:(e,t,a)=>{a.d(t,{A:()=>n});let n=(0,a(99537).A)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]])},60529:(e,t,a)=>{a.d(t,{p:()=>d});var n=a(95155);a(12115);var o=a(64878),r=a(40980);function d({className:e,type:t,...a}){return(0,n.jsx)(o.p,{type:t,"data-slot":"input",className:(0,r.cn)("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...a})}},67385:(e,t,a)=>{a.d(t,{f:()=>g});var n=a(95155),o=a(12115),r=a(51128),d=a(64577),i=a(40980),s=a(32538),l=a(69586),c=a(89239),u=a(42763),m=a(60529),p=a(33807),f=a(72194);function g({open:e,onOpenChange:t,connectionId:a,initial:o,onSubmit:r}){return(0,n.jsx)(u.lG,{open:e,onOpenChange:t,children:(0,n.jsx)(u.Cf,{className:"sm:max-w-md",children:(0,n.jsx)(h,{connectionId:a,initial:o,onSubmit:e=>{r(e),t(!1)}},a??"new")})})}function h({connectionId:e,initial:t,onSubmit:a}){let g=(0,l.Z)(e=>e.connections),x=g.filter(t=>t.id!==e),[b,v]=(0,o.useState)(()=>t?{...t,color:(0,s.yQ)(t.color)?t.color:(0,s.XU)(g.map(e=>(0,s.Mq)(e))),shareWith:t.shareWith}:{name:"",url:"",color:(0,s.XU)(g.map(e=>(0,s.Mq)(e))),shareWith:[]}),j=b.name.trim().length>0&&b.url.trim().length>0;return(0,n.jsxs)("form",{onSubmit:function(e){e.preventDefault(),j&&a({name:b.name.trim(),url:b.url.trim(),color:b.color,shareWith:b.shareWith})},className:"flex flex-col gap-5",children:[(0,n.jsx)(u.c7,{children:(0,n.jsx)(u.L3,{children:t?"Edit connection":"New connection"})}),(0,n.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,n.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,n.jsx)(p.J,{htmlFor:"connection-name",children:"Name"}),(0,n.jsx)(m.p,{id:"connection-name",autoFocus:!0,autoComplete:"off",value:b.name,onChange:e=>v({...b,name:e.target.value})})]}),(0,n.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,n.jsx)(p.J,{htmlFor:"connection-url",children:"Database URL"}),(0,n.jsx)(m.p,{id:"connection-url",autoComplete:"off",spellCheck:!1,placeholder:"postgresql://user:password@host:5432/db",className:"font-mono",value:b.url,onChange:e=>v({...b,url:e.target.value})})]}),(0,n.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,n.jsx)(p.J,{id:"connection-color",children:"Color"}),(0,n.jsx)("div",{role:"group","aria-labelledby":"connection-color",className:"flex flex-wrap gap-2",children:s.I_.map(e=>{let t=b.color===e;return(0,n.jsx)("button",{type:"button","aria-label":`Use color ${e}`,"aria-pressed":t,onClick:()=>v({...b,color:e}),className:(0,i.cn)("size-6 cursor-pointer rounded-full outline-none ring-offset-2 ring-offset-background transition-[box-shadow,transform] hover:scale-105 focus-visible:ring-2 focus-visible:ring-ring",t&&"ring-2 ring-foreground"),style:{background:e}},e)})})]}),x.length>0&&(0,n.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,n.jsxs)(p.J,{id:"connection-share",className:"flex items-center gap-1.5",children:[(0,n.jsx)(r.A,{className:"size-3.5 text-muted-foreground"}),"Share layout with"]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Pins, hidden columns, column widths, schema filters, and pinned tables. Filters and search stay per connection."}),(0,n.jsx)("div",{role:"group","aria-labelledby":"connection-share",className:"flex flex-col gap-1 rounded-lg border p-1",children:x.map(e=>{let t=b.shareWith.includes(e.id);return(0,n.jsxs)("button",{type:"button","aria-pressed":t,onClick:()=>{var t;return t=e.id,void v(e=>({...e,shareWith:e.shareWith.includes(t)?e.shareWith.filter(e=>e!==t):[...e.shareWith,t]}))},className:(0,i.cn)("flex h-8 items-center gap-2 rounded-md px-2 text-left text-sm outline-none hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring/60",t&&"bg-muted/40"),children:[(0,n.jsx)("span",{className:(0,i.cn)("flex size-4 items-center justify-center rounded-[5px] border border-input",t&&"border-foreground bg-foreground text-background"),children:t&&(0,n.jsx)(d.A,{className:"size-3",strokeWidth:3})}),(0,n.jsx)(f.F,{connection:e}),(0,n.jsx)("span",{className:"min-w-0 truncate",children:e.name})]},e.id)})})]})]}),(0,n.jsx)(u.Es,{children:(0,n.jsx)(c.$,{type:"submit",disabled:!j,children:t?"Save":"Add"})})]})}},72194:(e,t,a)=>{a.d(t,{F:()=>d});var n=a(95155),o=a(40980),r=a(32538);function d({connection:e,className:t}){return(0,n.jsx)("span",{"aria-hidden":!0,className:(0,o.cn)("size-2.5 shrink-0 rounded-full",t),style:{background:(0,r.Mq)(e)}})}},72264:(e,t,a)=>{a.d(t,{I:()=>y,M5:()=>A,SQ:()=>w,_2:()=>z,hO:()=>W,lp:()=>N,lv:()=>C,mB:()=>S,nV:()=>_,rI:()=>j,ty:()=>k});var n=a(95155);a(12115);var o=a(31139),r=a(45824),d=a(90469),i=a(56385),s=a(8613),l=a(43981),c=a(88564),u=a(83227),m=a(97450),p=a(48348),f=a(83112),g=a(10505),h=a(30030),x=a(40980),b=a(76721),v=a(64577);function j({...e}){return(0,n.jsx)(o.i,{"data-slot":"dropdown-menu",...e})}function k({...e}){return(0,n.jsx)(r.c,{"data-slot":"dropdown-menu-trigger",...e})}function w({align:e="start",alignOffset:t=0,side:a="bottom",sideOffset:o=4,className:r,...l}){return(0,n.jsx)(d.g,{children:(0,n.jsx)(i.y,{className:"isolate z-50 outline-none",align:e,alignOffset:t,side:a,sideOffset:o,children:(0,n.jsx)(s._,{"data-slot":"dropdown-menu-content",className:(0,x.cn)("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-xl bg-popover p-1.5 text-popover-foreground shadow-xl ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95",r),...l})})})}function y({...e}){return(0,n.jsx)(l.r,{"data-slot":"dropdown-menu-group",...e})}function N({className:e,inset:t,...a}){return(0,n.jsx)(c.N,{"data-slot":"dropdown-menu-label","data-inset":t,className:(0,x.cn)("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",e),...a})}function z({className:e,inset:t,variant:a="default",...o}){return(0,n.jsx)(u.D,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":a,className:(0,x.cn)("group/dropdown-menu-item relative flex h-8 cursor-pointer items-center gap-2 rounded-lg px-2 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",e),...o})}function C({...e}){return(0,n.jsx)(m.h,{"data-slot":"dropdown-menu-sub",...e})}function _({className:e,inset:t,children:a,...o}){return(0,n.jsxs)(p.f,{"data-slot":"dropdown-menu-sub-trigger","data-inset":t,className:(0,x.cn)("flex h-8 cursor-pointer items-center gap-2 rounded-lg px-2 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...o,children:[a,(0,n.jsx)(b.A,{className:"ml-auto"})]})}function A({align:e="start",alignOffset:t=-3,side:a="right",sideOffset:o=0,className:r,...d}){return(0,n.jsx)(w,{"data-slot":"dropdown-menu-sub-content",className:(0,x.cn)("w-auto min-w-[96px] rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",r),align:e,alignOffset:t,side:a,sideOffset:o,...d})}function W({className:e,children:t,checked:a,inset:o,...r}){return(0,n.jsxs)(f.s,{"data-slot":"dropdown-menu-checkbox-item","data-inset":o,className:(0,x.cn)("group/checkbox-item relative flex h-8 cursor-pointer items-center gap-2 rounded-lg pr-2 pl-8 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:a,...r,children:[(0,n.jsx)("span",{className:"pointer-events-none absolute left-2 flex size-4 items-center justify-center rounded-[5px] border border-input text-transparent transition-colors group-data-checked/checkbox-item:border-foreground group-data-checked/checkbox-item:bg-foreground group-data-checked/checkbox-item:text-background","data-slot":"dropdown-menu-checkbox-item-indicator",children:(0,n.jsx)(g.F,{children:(0,n.jsx)(v.A,{className:"size-3",strokeWidth:3})})}),t]})}function S({className:e,...t}){return(0,n.jsx)(h.w,{"data-slot":"dropdown-menu-separator",className:(0,x.cn)("-mx-1 my-1 h-px bg-border",e),...t})}},86989:(e,t,a)=>{a.d(t,{AZ:()=>s,Ff:()=>i,mS:()=>o,wN:()=>n,zG:()=>r});let n="ytdb:theme",o="dark",r=[{id:"dark",name:"Dark",appearance:"dark",swatch:"#242424",keywords:["default","black","neutral"]},{id:"light",name:"Light",appearance:"light",swatch:"#ffffff",keywords:["day","white"]},{id:"one-dark-pro",name:"One Dark Pro",appearance:"dark",swatch:"#23272e",keywords:["onedark","atom","pro"]},{id:"nord",name:"Nord",appearance:"dark",swatch:"#2e3440",keywords:["arctic","frost","blue"]},{id:"dracula",name:"Dracula",appearance:"dark",swatch:"#282a36",keywords:["purple","vampire"]},{id:"tokyo-night",name:"Tokyo Night",appearance:"dark",swatch:"#1a1b26",keywords:["tokyo","night","japan"]}],d=r.map(e=>e.id);function i(e){return"string"==typeof e&&d.includes(e)}function s(e){let t=r.find(t=>t.id===e);if(!t)return;let a=document.documentElement;a.dataset.theme=t.id,a.classList.toggle("dark","dark"===t.appearance)}r.filter(e=>"light"===e.appearance).map(e=>e.id)},88406:(e,t,a)=>{a.d(t,{C:()=>d});var n=a(1934),o=a(31692),r=a(86989);(0,a(63307).q)("db-studio:theme",r.wN);let d=(0,n.v)()((0,o.Zr)(e=>({theme:r.mS,setTheme:t=>e({theme:t})}),{name:r.wN,partialize:e=>({theme:e.theme}),merge:(e,t)=>({...t,theme:(0,r.Ff)(e?.theme)?e.theme:t.theme})}))},95377:(e,t,a)=>{a.d(t,{p:()=>r});var n=a(12115);let o=()=>()=>{};function r(){return(0,n.useSyncExternalStore)(o,()=>!0,()=>!1)}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6842],{9005:(e,t,n)=>{n.d(t,{A:()=>o});let o=(0,n(99537).A)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},11975:(e,t,n)=>{n.d(t,{L:()=>i});var o=n(12115),r=n(85516),a=n(69938),s=n(62955);let i=o.forwardRef(function(e,t){let{render:n,className:o,style:i,id:l,...u}=e,d=(0,r.P)(),p=(0,s.e)(l);return d.useSyncedValueWithCleanup("titleElementId",p),(0,a.o)("h2",e,{ref:t,props:[{id:p},u]})})},31799:(e,t,n)=>{n.d(t,{r:()=>i});var o=n(12115),r=n(85516),a=n(69938),s=n(62955);let i=o.forwardRef(function(e,t){let{render:n,className:o,style:i,id:l,...u}=e,d=(0,r.P)(),p=(0,s.e)(l);return d.useSyncedValueWithCleanup("descriptionElementId",p),(0,a.o)("p",e,{ref:t,props:[{id:p},u]})})},32949:(e,t,n)=>{n.d(t,{Z:()=>d});var o=n(12115),r=n(96354),a=n(34934),s=n(85516),i=n(38220),l=n(53976),u=n(95155);let d=o.forwardRef(function(e,t){let{keepMounted:n=!1,...o}=e,d=(0,s.P)(),p=d.useState("mounted"),c=d.useState("modal"),f=d.useState("open");return p||n?(0,u.jsx)(i.m.Provider,{value:n,children:(0,u.jsxs)(a.XF,{ref:t,...o,children:[p&&!0===c&&(0,u.jsx)(l.W,{ref:d.context.internalBackdropRef,inert:(0,r.Y)(!f)}),e.children]})}):null})},38220:(e,t,n)=>{n.d(t,{m:()=>a,p:()=>s});var o=n(25803),r=n(12115);let a=r.createContext(void 0);function s(){let e=r.useContext(a);if(void 0===e)throw Error((0,o.A)(26));return e}},45477:(e,t,n)=>{n.d(t,{X:()=>i});var o=n(12115),r=n(85516),a=n(69938),s=n(84052);let i=o.forwardRef(function(e,t){let{render:n,className:o,style:i,forceRender:l=!1,...u}=e,d=(0,r.P)(),p=d.useState("open"),c=d.useState("nested"),f=d.useState("mounted"),g=d.useState("transitionStatus");return(0,a.o)("div",e,{state:{open:p,transitionStatus:g},ref:[d.context.backdropRef,t],stateAttributesMapping:s.LM,props:[{role:"presentation",hidden:!f,style:{userSelect:"none",WebkitUserSelect:"none"}},u],enabled:l||!c})})},52579:(e,t,n)=>{n.d(t,{H:()=>u});var o=n(12115),r=n(85516),a=n(69938),s=n(27091),i=n(7049),l=n(76175);let u=o.forwardRef(function(e,t){let{render:n,className:o,style:u,disabled:d=!1,nativeButton:p=!0,...c}=e,f=(0,r.P)(),g=f.useState("open"),{getButtonProps:h,buttonRef:m}=(0,s.s)({disabled:d,native:p});return(0,a.o)("button",e,{state:{disabled:d},ref:[t,m],props:[{onClick:function(e){g&&f.setOpen(!1,(0,i.d)(l.SR,e.nativeEvent))}},c,h]})})},85516:(e,t,n)=>{n.d(t,{P:()=>s,a:()=>a});var o=n(25803),r=n(12115);let a=r.createContext(void 0);function s(e){let t=r.useContext(a);if(!e&&void 0===t)throw Error((0,o.A)(27));return t}},88593:(e,t,n)=>{n.d(t,{h:()=>g});var o=n(12115),r=n(2052),a=n(85516),s=n(69938),i=n(38220),l=n(72924),u=n(5313),d=n(26713),p=n(41900);let c={...n(84052).GW,...p.G,nestedDialogOpen:e=>e?{"data-nested-dialog-open":""}:null};var f=n(95155);let g=o.forwardRef(function(e,t){let{render:n,className:o,style:p,finalFocus:g,initialFocus:h,...m}=e,v=(0,a.P)(),C=v.useState("descriptionElementId"),S=v.useState("disablePointerDismissal"),x=v.useState("floatingRootContext"),b=v.useState("popupProps"),O=v.useState("modal"),P=v.useState("mounted"),R=v.useState("nested"),D=v.useState("nestedOpenDialogCount"),E=v.useState("open"),w=v.useState("openMethod"),k=v.useState("titleElementId"),y=v.useState("transitionStatus"),I=v.useState("role"),M=x.useState("floatingId");(0,i.p)(),(0,l.v)({open:E,ref:v.context.popupRef,onComplete(){E&&v.context.onOpenChangeComplete?.(!0)}});let j=void 0===h?(0,d.UM)(v.context.popupRef):h,A=v.useStateSetter("popupElement"),N=(0,s.o)("div",e,{state:{open:E,nested:R,transitionStatus:y,nestedDialogOpen:D>0},props:[b,{id:M,"aria-labelledby":k,"aria-describedby":C,role:I,...d.Ls,hidden:!P,onKeyDown(e){u.jF.has(e.key)&&e.stopPropagation()},style:{"--nested-dialogs":D}},m],ref:[t,v.context.popupRef,A],stateAttributesMapping:c});return(0,f.jsx)(r.s,{context:x,openInteractionType:w,disabled:!P,closeOnFocusOut:!S,initialFocus:j,returnFocus:g,modal:!1!==O,restoreFocus:"popup",children:N})})},98408:(e,t,n)=>{n.d(t,{D:()=>S});var o=n(12115),r=n(66652),a=n(31814),s=n(87541),i=n(51464),l=n(26713);function u({store:e,parentContext:t,isDrawer:n}){let d=e.useState("open"),p=e.useState("disablePointerDismissal"),c=e.useState("modal"),f=e.useState("popupElement"),g=e.useState("floatingRootContext"),[h,m]=o.useState(0),[v,C]=o.useState(0),S=0===h,x=(0,s.s)(g,{outsidePressEvent:()=>e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:"trap-focus"===c?"sloppy":"intentional",touch:"sloppy"},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||"button"in t&&0!==t.button)return!1;if("touches"in t){if("touchend"===t.type){if(1!==t.changedTouches.length||0!==t.touches.length)return!1}else if(1!==t.touches.length)return!1}let n=(0,i.EW)(t);if(S&&!p){if(c){let t=e.context.internalBackdropRef.current,o=e.context.backdropRef.current;return!t&&!o||t===n||o===n||(0,i.gR)(n,f)&&!n?.hasAttribute("data-base-ui-portal")}return!0}return!1},escapeKey:S});return(0,a.K)(d&&!0===c,f),e.useContextCallback("onNestedDialogOpen",(e,t)=>{m(e),C(t)}),(0,r.g)(()=>(t?.onNestedDialogOpen&&(d?t.onNestedDialogOpen(h+1,v+ +!!n):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&d&&t.onNestedDialogOpen(0,0)}),[n,d,h,v,t]),(0,l.i6)(e,{activeTriggerProps:x.reference,inactiveTriggerProps:x.trigger,popupProps:x.floating,nestedOpenDialogCount:h,nestedOpenDrawerCount:v}),null}var d=n(85516),p=n(98419),c=n(34785),f=n(52313);let g={...c.ol,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role};class h extends p.H{constructor(e,t,n){const r=new f.Z;super(function(e,t,n,o=!1){let r={...(0,c.rJ)(),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...e};return r.floatingRootContext=(0,c.OB)(t,n,o),r}(e,r,t,n),function(e){return{popupRef:o.createRef(),backdropRef:o.createRef(),internalBackdropRef:o.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}(r),g)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},e||null!=t.trigger||null==this.state.activeTriggerId||(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let n={open:e};(0,l.i)(n,e,t.trigger),this.update(n)}}var m=n(7049),v=n(76175),C=n(95155);function S(e){return function(e,t){let{children:n,open:r,defaultOpen:a=!1,onOpenChange:s,onOpenChangeComplete:i,disablePointerDismissal:p=!1,modal:c=!0,actionsRef:f,handle:g,triggerId:S,defaultTriggerId:x=null}=t,b="alert-dialog"===e,O=(0,d.P)(!0),P={modal:!!b||c,disablePointerDismissal:b||p,nested:null!=O,role:b?"alertdialog":"dialog"},R=(0,l.xp)((e,t)=>new h({open:a,openProp:r,activeTriggerId:x,triggerIdProp:S,...P},e,t),!0);R.useControlledProp("openProp",r),R.useControlledProp("triggerIdProp",S),R.useSyncedValues(P),R.useContextCallback("onOpenChange",s),R.useContextCallback("onOpenChangeComplete",i);let D=R.useState("open"),E=R.useState("mounted"),w=R.useState("payload");(0,l.xs)(R,D),(0,l.tr)(R);let{forceUnmount:k}=(0,l.l$)(D,R);o.useImperativeHandle(f,()=>({unmount:k,close:()=>R.setOpen(!1,(0,m.d)(v.zJ))}),[k,R]);let y=D||E;return(0,C.jsxs)(d.a.Provider,{value:R,children:[g&&(0,C.jsx)(l.Ae,{handle:g,store:R}),y&&(0,C.jsx)(u,{store:R,parentContext:O?.context,isDrawer:"drawer"===e}),"function"==typeof n?n({payload:w}):n]})}("dialog",e)}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7449],{25:(e,t,r)=>{r.d(t,{Ol:()=>o,TA:()=>d,qb:()=>c});let n=/^[ \t]*--+[ \t]*ytdb:[ \t]*no-?transaction\b/im,a=new Set(["begin","start"]),i=new Set(["commit","end"]),s=new Set(["rollback"]);function l(e){return void 0!==e&&(e>="A"&&e<="Z"||e>="a"&&e<="z"||"_"===e)||void 0!==e&&e>="0"&&e<="9"}function o(e){if(n.test(e))return{mode:"unwrapped",sql:e,atomic:!1};let t=function(e){let t=[],r=0,n=0,a=n=>{let a=function(e,t){let r=t;for(;r<e.length;){let t=e[r];if(" "===t||" "===t||"\n"===t||"\r"===t){r+=1;continue}if("-"===t&&"-"===e[r+1]){for(;r<e.length&&"\n"!==e[r];)r+=1;continue}if("/"===t&&"*"===e[r+1]){let t=e.indexOf("*/",r+2);r=-1===t?e.length:t+2;continue}break}return r}(e,r);if(a>=n)return;let i=a;for(;i<e.length&&l(e[i]);)i+=1;t.push({at:a,end:n,keyword:e.slice(a,i).toLowerCase()})};for(;n<e.length;){let t=e[n];if("-"===t&&"-"===e[n+1]){for(;n<e.length&&"\n"!==e[n];)n+=1;continue}if("/"===t&&"*"===e[n+1]){let t=e.indexOf("*/",n+2);n=-1===t?e.length:t+2;continue}if("'"===t||'"'===t){n=function(e,t,r){let n=t+1;for(;n<e.length;){if(e[n]===r){if(e[n+1]===r){n+=2;continue}return n+1}n+=1}return n}(e,n,t);continue}if("$"===t){let t=function(e,t){if("$"!==e[t])return null;let r=t+1;for(;r<e.length&&l(e[r]);)r+=1;return"$"!==e[r]?null:e.slice(t,r+1)}(e,n);if(t){let r=e.indexOf(t,n+t.length);n=-1===r?e.length:r+t.length;continue}}if(";"===t){a(n+1),n+=1,r=n;continue}n+=1}return a(e.length),t}(e),r=t.filter(e=>a.has(e.keyword)||i.has(e.keyword)||s.has(e.keyword));if(0===r.length)return{mode:"wrapped-by-ytdb",sql:e,atomic:!0};let o=t[0],d=t[t.length-1];return 2===r.length&&r[0]===o&&r[1]===d&&a.has(o.keyword)&&i.has(d.keyword)?{mode:"self-wrapped",sql:e.slice(0,o.at)+e.slice(o.end,d.at)+e.slice(d.end),atomic:!0}:{mode:"self-managed",sql:e,atomic:!1}}function d(e){switch(e){case"unwrapped":return"Marked `-- ytdb:no-transaction`, so it runs with no transaction. A failure partway leaves the statements before it applied.";case"self-managed":return"This file commits more than once, so YTDB runs it as written and records it afterwards. A failure partway can leave it half applied and unrecorded.";default:return null}}function c(e){return"unwrapped"===e?"no transaction":"self-managed"===e?"self-managed":null}},8479:(e,t,r)=>{r.d(t,{A:()=>n});let n=(0,r(99537).A)("undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]])},9385:(e,t,r)=>{r.d(t,{x:()=>n});function n(e,t){let r=new Map(e.map(e=>[e.connection.id,e])),n=t.filter(e=>r.has(e.connectionId)).map(e=>({id:e.id,connectionId:e.connectionId,connectionName:e.connectionName,version:e.version,name:e.name,at:e.ranAt,kind:"failed"===e.status?"failed":e.recorded?"apply"===e.direction?"marked":"unmarked":"apply"===e.direction?"applied":"reverted",durationMs:e.durationMs,error:e.error,setName:e.setName,fromLedger:!1})),a=new Map;for(let e of n){let t=`${e.connectionId}:${e.version}`,r=a.get(t);(!r||e.at>r.at)&&a.set(t,e)}let i=[...n];for(let t of e)for(let e of t.ledger?.entries??[]){let r=`${t.connection.id}:${e.version}`,n=a.get(r);if(n&&("applied"===n.kind||"marked"===n.kind)){n.appliedBy=e.appliedBy;continue}i.push({id:`ledger:${t.connection.id}:${e.version}`,connectionId:t.connection.id,connectionName:t.connection.name,version:e.version,name:e.name||e.version,at:function(e){let t=Date.parse(e);return Number.isNaN(t)?0:t}(e.appliedAt),kind:"applied",durationMs:e.durationMs,setName:e.setName,appliedBy:e.appliedBy,fromLedger:!0})}return i.sort((e,t)=>t.at-e.at)}},20642:(e,t,r)=>{r.d(t,{Ai:()=>m,Nz:()=>f,Zy:()=>u,mj:()=>h});var n=r(40980),a=r(25);let i=new Set(["apply","up","forward"]),s=new Set(["revert","down","rollback","undo"]),l=[".up",".apply",".forward"],o=[".down",".revert",".rollback",".undo"];function d(e){return e.split("/").filter(e=>e.length>0)}function c(e){return e.replace(/[-_]+/g," ").trim()}function u(e,t){let r=/(\d+)|(\D+)/g,n=e.match(r)??[],a=t.match(r)??[],i=Math.min(n.length,a.length);for(let e=0;e<i;e+=1){let t=n[e],r=a[e],i=/^\d+$/.test(t)&&/^\d+$/.test(r)?Number(t)-Number(r):t.localeCompare(r);if(0!==i)return i}return n.length-a.length}function p(e){let t=e.replace(/\r\n/g,"\n").trim(),r=0x811c9dc5,n=0x1000193;for(let e=0;e<t.length;e+=1){let a=t.charCodeAt(e);r=Math.imul(r^a,0x1000193)>>>0,n=Math.imul(n+a,0x85ebca6b)>>>0}return`${r.toString(16).padStart(8,"0")}${n.toString(16).padStart(8,"0")}`}function f(e){let t={applies:new Map,reverts:new Map,skipped:[],errors:[]},r=e.filter(e=>{var t;let r=d(t=e.path).at(-1)??t;return!r.startsWith(".")&&/\.sql$/i.test(r)});if(0===r.length)return t.errors.push("No .sql files in there."),t;let n=r.reduce((e,t)=>e+t.text.length,0);if(n>4e6)return t.errors.push(`That is ${g(n)} of SQL, over the ${g(4e6)} limit.`),t;for(let e of r){if(e.text.length>5e5){t.skipped.push(`${e.path} — over ${g(5e5)}`);continue}if(e.text.includes("\0")){t.skipped.push(`${e.path} — not text`);continue}if(!e.text.trim()){t.skipped.push(`${e.path} — empty`);continue}let{direction:r,stem:n}=function(e){let t=d(e),r=(t.at(-1)??e).replace(/\.sql$/i,"");for(let e of t.slice(0,-1)){let t=e.toLowerCase();if(s.has(t))return{direction:"revert",stem:r};if(i.has(t))return{direction:"apply",stem:r}}let n=r.toLowerCase();for(let e of o)if(n.endsWith(e))return{direction:"revert",stem:r.slice(0,-e.length)};for(let e of l)if(n.endsWith(e))return{direction:"apply",stem:r.slice(0,-e.length)};return{direction:"apply",stem:r}}(e.path),{version:a,name:u}=function(e){let t=/^[Vv](\d+(?:[._]\d+)*)__(.*)$/.exec(e);if(t)return{version:t[1].replace(/_/g,"."),name:c(t[2])};let r=/^(\d+)(?:[-_.\s]+(.*))?$/.exec(e);return r?{version:r[1],name:c(r[2]??"")}:{version:e,name:c(e)}}(n),p=("apply"===r?t.applies:t.reverts).get(a);if(p){t.skipped.push(`${e.path} — ${p.path} is already version ${a}`);continue}"apply"===r?t.applies.set(a,{path:e.path,sql:e.text,name:u}):t.reverts.set(a,{path:e.path,sql:e.text})}return 0===t.applies.size&&0===t.reverts.size&&t.errors.push("None of those .sql files could be read as a migration."),t}function m(e,t){let r=new Map(e.map(e=>[e.version,{...e}])),n=[...t.skipped],i=0,s=0,l=0;for(let[e,l]of t.applies){let t=r.get(e);if(t){t.applySql!==l.sql&&(s+=1),t.name=l.name||t.name,t.applyPath=l.path,t.applySql=l.sql,t.checksum=p(l.sql),t.transaction=(0,a.Ol)(l.sql).mode;continue}if(r.size>=500){n.push(`${l.path} — over 500 migrations`);continue}r.set(e,{version:e,name:l.name||e,applyPath:l.path,applySql:l.sql,checksum:p(l.sql),transaction:(0,a.Ol)(l.sql).mode}),i+=1}for(let[e,a]of t.reverts){let t=r.get(e);if(!t){n.push(`${a.path} — no migration ${e} to revert`);continue}t.revertPath=a.path,t.revertSql=a.sql,l+=1}return{steps:[...r.values()].sort((e,t)=>u(e.version,t.version)),added:i,updated:s,reverts:l,skipped:n}}function h(e){return{id:(0,n.z)(),name:e.trim().replace(/\s+/g," ").slice(0,80)||"Migrations",importedAt:Date.now(),steps:[],skipped:[]}}function g(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}},29741:(e,t,r)=>{r.d(t,{k:()=>h,$:()=>m});var n=r(95155),a=r(12115),i=r(92571),s=r(53039);let l=(0,r(99537).A)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);var o=r(89239);function d(e){let t=e.createReader?.();return t?new Promise((e,r)=>{let n=[],a=()=>{t.readEntries(t=>{0===t.length||n.length>=2e3?e(n):(n.push(...t),a())},r)};a()}):Promise.resolve([])}async function c(e,t,r,n){if(n.length>=2e3||r>6||e.name.startsWith("."))return;let a=t?`${t}/${e.name}`:e.name;if(e.isFile){if(!/\.sql$/i.test(e.name))return;let t=await new Promise((t,r)=>{e.file?e.file(t,r):r(Error(`Could not read ${e.name}`))});n.push({path:a,text:await t.text()});return}if(e.isDirectory)for(let t of(await d(e)))await c(t,a,r+1,n)}async function u(e){let t=[];for(let r of Array.from(e.items)){if("file"!==r.kind)continue;let e=r.webkitGetAsEntry?.();e&&t.push(e)}if(0===t.length){let t=Array.from(e.files).filter(e=>/\.sql$/i.test(e.name));return 0===t.length?null:{name:"Migrations",files:await Promise.all(t.map(async e=>({path:e.name,text:await e.text()})))}}let r=1===t.length&&t[0].isDirectory?t[0]:null,n=[];if(r){for(let e of(await d(r)))await c(e,"",1,n);return{name:r.name,files:n}}for(let e of t)await c(e,"",0,n);return n.length>0?{name:"Migrations",files:n}:null}async function p(e){let t,r=Array.from(e).filter(e=>/\.sql$/i.test(e.name));if(0===r.length)return null;let n=new Set(r.map(e=>(e.webkitRelativePath||e.name).split("/")[0])),a=1===n.size&&((t=r[0]).webkitRelativePath||t.name).includes("/")?[...n][0]:null;return{name:a??"Migrations",files:await Promise.all(r.slice(0,2e3).map(async e=>{let t=e.webkitRelativePath||e.name;return{path:a?t.slice(a.length+1):t,text:await e.text()}}))}}var f=r(40980);function m(e){let[t,r]=(0,a.useState)(!1),[n,i]=(0,a.useState)(null);return{importFrom:(0,a.useCallback)(async t=>{r(!0),i(null);try{let r=t instanceof FileList?await p(t):await u(t);if(!r||0===r.files.length)return void i("No .sql files in there.");e(r)}catch(e){i(e instanceof Error?e.message:"Couldn’t read that folder.")}finally{r(!1)}},[e]),busy:t,error:n,clearError:()=>i(null)}}function h({onFiles:e,hint:t,className:r,compact:d=!1}){let{importFrom:c,busy:u,error:p}=m(e),[g,x]=(0,a.useState)(!1),v=(0,a.useRef)(null),y=(0,a.useRef)(null);return(0,a.useEffect)(()=>{v.current?.setAttribute("webkitdirectory",""),v.current?.setAttribute("directory","")},[]),(0,n.jsxs)("div",{onDragOver:e=>{e.preventDefault(),x(!0)},onDragLeave:()=>x(!1),onDrop:e=>{e.preventDefault(),x(!1),c(e.dataTransfer)},className:(0,f.cn)("flex flex-col items-center justify-center gap-3 rounded-lg border border-dashed text-center transition-colors",d?"gap-2 px-4 py-6":"px-6 py-10",g?"border-primary bg-primary/5":"border-border",r),children:[u?(0,n.jsx)(i.A,{className:"size-5 animate-spin text-muted-foreground"}):(0,n.jsx)(s.A,{className:"size-5 text-muted-foreground"}),(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("p",{className:"text-sm font-medium",children:"Drop migrations here"}),(0,n.jsx)("p",{className:"max-w-md text-xs text-muted-foreground",children:t??"A folder of .sql files, or one split into apply/ and revert/ (or up/ and down/). Revert files are optional, and you can add more files later."})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)(o.$,{size:"sm",variant:"outline",disabled:u,onClick:()=>v.current?.click(),children:[(0,n.jsx)(l,{"data-icon":"inline-start"}),"Choose folder"]}),(0,n.jsx)(o.$,{size:"sm",variant:"ghost",disabled:u,onClick:()=>y.current?.click(),children:"Choose files"})]}),p&&(0,n.jsx)("p",{className:"max-w-sm text-xs text-destructive",children:p}),(0,n.jsx)("input",{ref:v,type:"file",multiple:!0,className:"sr-only",onChange:e=>{let{files:t}=e.target;t&&t.length>0&&c(t),e.target.value=""}}),(0,n.jsx)("input",{ref:y,type:"file",multiple:!0,accept:".sql",className:"sr-only",onChange:e=>{let{files:t}=e.target;t&&t.length>0&&c(t),e.target.value=""}})]})}},35942:(e,t,r)=>{r.d(t,{F:()=>c});var n=r(95155);r(12115);var a=r(76166),i=r(13220),s=r(84588),l=r(66784),o=r(64084),d=r(40980);function c({className:e,children:t,...r}){return(0,n.jsxs)(a.V,{"data-slot":"scroll-area",className:(0,d.cn)("relative",e),...r,children:[(0,n.jsx)(i.B,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:t}),(0,n.jsx)(u,{}),(0,n.jsx)(s.I,{})]})}function u({className:e,orientation:t="vertical",...r}){return(0,n.jsx)(l.V,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:(0,d.cn)("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",e),...r,children:(0,n.jsx)(o.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},36672:(e,t,r)=>{r.d(t,{A:()=>n});let n=(0,r(99537).A)("clipboard-check",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]])},41069:(e,t,r)=>{r.d(t,{l:()=>i});var n=r(95155),a=r(30374);function i({caption:e,pane:t,onPaneChange:r,historyCount:s,migrationsLabel:l="Migrations"}){return(0,n.jsxs)("footer",{className:"flex shrink-0 items-center gap-2 border-t px-4 py-1.5 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:"min-w-0 truncate",children:e}),(0,n.jsx)("div",{className:"ml-auto",children:(0,n.jsx)(a.x,{label:"Migrations pane",value:t,onChange:r,options:[{value:"migrations",label:l},{value:"history",label:s>0?`History (${s})`:"History"}]})})]})}},42611:(e,t,r)=>{r.d(t,{H:()=>g});var n=r(95155),a=r(9005),i=r(8479),s=r(36672),l=r(65740),o=r(64577),d=r(72194),c=r(89239),u=r(79668),p=r(40980);let f={applied:"applied",reverted:"reverted",marked:"marked",unmarked:"unmarked",failed:"failed"};function m({kind:e}){switch(e){case"failed":return(0,n.jsx)(a.A,{className:"size-3.5 shrink-0 text-destructive"});case"reverted":return(0,n.jsx)(i.A,{className:"size-3.5 shrink-0 text-amber-600 dark:text-amber-400"});case"marked":return(0,n.jsx)(s.A,{className:"size-3.5 shrink-0 text-muted-foreground"});case"unmarked":return(0,n.jsx)(l.A,{className:"size-3.5 shrink-0 text-muted-foreground"});default:return(0,n.jsx)(o.A,{className:"size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400"})}}function h({event:e,connection:t}){return(0,n.jsxs)("div",{className:"flex items-start gap-2 border-b px-4 py-2 text-xs last:border-b-0",children:[(0,n.jsx)("span",{className:"mt-0.5",children:(0,n.jsx)(m,{kind:e.kind})}),(0,n.jsx)("span",{className:(0,p.cn)("mt-px shrink-0 rounded-md px-1.5 text-[11px]","failed"===e.kind?"bg-destructive/10 text-destructive":"reverted"===e.kind?"bg-amber-500/15 text-amber-700 dark:text-amber-400":"bg-muted text-muted-foreground"),children:f[e.kind]}),(0,n.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:e.version}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"truncate",children:e.name}),e.error&&(0,n.jsx)("span",{className:"mt-1 block font-mono text-[11px] whitespace-pre-wrap text-destructive",children:e.error})]}),e.setName&&(0,n.jsx)("span",{className:"hidden max-w-32 shrink-0 truncate text-muted-foreground/60 lg:inline",children:e.setName}),(0,n.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-muted-foreground",children:[t&&(0,n.jsx)(d.F,{connection:t,className:"size-1.5"}),e.connectionName]}),e.appliedBy&&(0,n.jsx)("span",{className:"hidden shrink-0 text-muted-foreground/60 xl:inline",children:e.appliedBy}),(0,n.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground/70",children:null===e.durationMs?"":`${e.durationMs} ms`}),(0,n.jsx)("span",{className:"shrink-0 text-muted-foreground/70",title:e.fromLedger?"Read from the database's own ledger":"Run from this browser",children:new Date(e.at).toLocaleString()})]})}function g({events:e,connections:t,loading:r}){let a=(0,u.j)(e=>e.clearHistory),i=new Map(t.map(e=>[e.id,e])),s=e.filter(e=>!e.fromLedger).length;return 0===e.length?(0,n.jsx)("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:r?"Reading ledgers…":"Nothing has been applied to these databases yet. Every run shows up here, along with what each database's own ledger already records."}):(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2 px-4 py-1.5",children:[(0,n.jsxs)("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:[e.length," event",1===e.length?"":"s",", newest first \xb7 from each database’s ledger and this browser’s own log"]}),s>0&&(0,n.jsx)(c.$,{size:"xs",variant:"ghost",title:"Clears this browser's log. The databases' ledgers are untouched.",onClick:()=>a(),children:"Clear local log"})]}),(0,n.jsx)("div",{className:"border-t",children:e.map(e=>(0,n.jsx)(h,{event:e,connection:i.get(e.connectionId)},e.id))})]})}},53039:(e,t,r)=>{r.d(t,{A:()=>n});let n=(0,r(99537).A)("folder-up",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m9 13 3-3 3 3",key:"1pxg3c"}]])},56012:(e,t,r)=>{r.d(t,{R9:()=>a,aC:()=>n,hD:()=>i});let n="maintenance",a="ytdb_migrations";function i(e){return"string"==typeof e&&e.length>0&&e.length<=63&&/^[A-Za-z_][A-Za-z0-9_$]*$/.test(e)}},62417:(e,t,r)=>{r.d(t,{FY:()=>l,ay:()=>s,e:()=>u,eh:()=>o,gj:()=>c,kB:()=>p,lF:()=>f,nb:()=>d});var n=r(20642);let a={steps:[],blockedBy:null};function i(e){let t=new Map;for(let r of e?.entries??[])t.set(r.version,r);return t}function s(e,t){return t?t.entries.find(t=>t.version===e.version)??null:null}function l(e,t){if(!t)return"unknown";let r=s(e,t);return r?r.checksum&&r.checksum!==e.checksum?"drifted":"applied":"pending"}function o(e,t){let r={total:e?.steps.length??0,applied:0,drifted:0,pending:0,foreign:0};if(!e)return r;for(let n of e.steps){let e=l(n,t);"applied"===e?r.applied+=1:"drifted"===e?r.drifted+=1:"pending"===e&&(r.pending+=1)}return r.foreign=d(e,t).length,r}function d(e,t){if(!t)return[];let r=new Set((e?.steps??[]).map(e=>e.version));return t.entries.filter(e=>!r.has(e.version)).sort((e,t)=>(0,n.Zy)(e.version,t.version))}function c(e,t,r){if(!e||!t)return a;let n=[];for(let a of e.steps)if("pending"===l(a,t)&&n.push(a),void 0!==r&&a.version===r)break;return{steps:n,blockedBy:null}}function u(e,t,r){if(!e||!t)return a;let s=i(t),l=[];for(let t of[...e.steps].reverse()){if(void 0!==r&&0>(0,n.Zy)(t.version,r))break;if(s.has(t.version)){if(!t.revertSql)return{steps:l,blockedBy:t};l.push(t)}}return{steps:l,blockedBy:null}}function p(e,t){if(!e||!t)return null;let r=i(t);for(let t of[...e.steps].reverse())if(r.has(t.version))return t;return null}function f(e,t){let r=new Set(t.map(e=>e.toLowerCase())),a=new Map;for(let t of e)for(let e of t.ledger?.entries??[]){let n=e.setName?.trim();if(!n||r.has(n.toLowerCase()))continue;let i=a.get(n)??new Map,s=i.get(t.connection.id)??new Set;s.add(e.version),i.set(t.connection.id,s),a.set(n,i)}return[...a.entries()].map(([t,r])=>{let a=new Set;for(let e of r.values())for(let t of e)a.add(t);return{name:t,versions:[...a].sort(n.Zy),total:a.size,applied:e.map(e=>({connectionId:e.connection.id,connectionName:e.connection.name,count:r.get(e.connection.id)?.size??0}))}}).sort((e,t)=>e.name.localeCompare(t.name))}},65740:(e,t,r)=>{r.d(t,{A:()=>n});let n=(0,r(99537).A)("clipboard-x",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m14.5 11.5-5 5",key:"1eaq8h"}],["path",{d:"m9.5 11.5 5 5",key:"1exjew"}]])},72194:(e,t,r)=>{r.d(t,{F:()=>s});var n=r(95155),a=r(40980),i=r(32538);function s({connection:e,className:t}){return(0,n.jsx)("span",{"aria-hidden":!0,className:(0,a.cn)("size-2.5 shrink-0 rounded-full",t),style:{background:(0,i.Mq)(e)}})}},72278:(e,t,r)=>{r.d(t,{A:()=>n});let n=(0,r(99537).A)("layers-2",[["path",{d:"M13 13.74a2 2 0 0 1-2 0L2.5 8.87a1 1 0 0 1 0-1.74L11 2.26a2 2 0 0 1 2 0l8.5 4.87a1 1 0 0 1 0 1.74z",key:"15q6uc"}],["path",{d:"m20 14.285 1.5.845a1 1 0 0 1 0 1.74L13 21.74a2 2 0 0 1-2 0l-8.5-4.87a1 1 0 0 1 0-1.74l1.5-.845",key:"byia6g"}]])},79668:(e,t,r)=>{r.d(t,{S:()=>c,j:()=>d});var n=r(1934),a=r(31692),i=r(42256),s=r(20642),l=r(56012),o=r(40980);let d=(0,n.v)()((0,a.Zr)((e,t)=>({sets:[],history:[],ledgerSchema:l.aC,setLedgerSchema:t=>{(0,l.hD)(t)&&e({ledgerSchema:t})},createSet:t=>{let r=(0,s.mj)(t);return e(e=>({sets:[...e.sets,r]})),r.id},addFiles:(r,n)=>{let a=t().sets.find(e=>e.id===r),l=(0,s.Nz)(n),o=(0,s.Ai)(a?.steps??[],l);return a&&e(e=>({sets:e.sets.map(e=>e.id===r?{...e,steps:o.steps,skipped:o.skipped,importedAt:Date.now()}:e)})),(0,i.L)("migrations.import",{name:a?.name,added:o.added,updated:o.updated,reverts:o.reverts,skipped:o.skipped.length}),o},renameSet:(t,r)=>{let n=r.trim().replace(/\s+/g," ").slice(0,80);n&&e(e=>({sets:e.sets.map(e=>e.id===t?{...e,name:n}:e)}))},removeStep:(t,r)=>e(e=>({sets:e.sets.map(e=>e.id===t?{...e,steps:e.steps.filter(e=>e.version!==r)}:e)})),removeSet:r=>{let n=t().sets.find(e=>e.id===r);e(e=>({sets:e.sets.filter(e=>e.id!==r)})),(0,i.L)("migrations.remove",{name:n?.name})},record:t=>e(e=>({history:[{...t,id:(0,o.z)(),ranAt:Date.now()},...e.history].slice(0,300)})),clearHistory:t=>e(e=>({history:t?e.history.filter(e=>e.setId!==t):[]}))}),{name:"ytdb:migrations"}));function c(e){return d(t=>t.sets.find(t=>t.id===e)??null)}},92571:(e,t,r)=>{r.d(t,{A:()=>n});let n=(0,r(99537).A)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8322],{2378:(e,t,r)=>{r.d(t,{Pv:()=>l,Qw:()=>i,XF:()=>o});var n=r(68445);let l=1;function o(e,t){return Math.max(0,e-t)}function i(e,t){if(t<=0)return 0;let r=(0,n.q)(e,0,t),o=t-r,i=r<=l,a=o<=l;return i&&a?r<=o?0:t:i?0:a?t:r}},13220:(e,t,r)=>{r.d(t,{B:()=>E});var n=r(12115),l=r(23068),o=r(66652),i=r(15495),a=r(64951),u=r(82441);let c=n.createContext(void 0);var s=r(69938),f=r(30458),d=r(52482),h=r(77246),p=r(68445),v=r(28539),x=r(93152),y=r(2378),g=r(95155);let w=["--scroll-area-overflow-x-start","--scroll-area-overflow-x-end","--scroll-area-overflow-y-start","--scroll-area-overflow-y-end"],m=!1,E=n.forwardRef(function(e,t){let{render:r,className:p,style:E,...P}=e,{viewportRef:R,scrollbarYRef:M,scrollbarXRef:W,thumbYRef:H,thumbXRef:N,cornerRef:A,cornerSize:C,setCornerSize:T,setThumbSize:I,rootId:$,setHiddenState:X,hiddenState:L,setHasMeasuredScrollbar:Y,handleScroll:k,touchModality:K,setHovering:_,setOverflowEdges:j,overflowEdgeThreshold:D,viewportState:F}=(0,u.p)(),O=(0,f.j)(),q=n.useRef(!0),G=n.useRef([NaN,NaN,NaN,NaN]),Z=(0,a.Z)(),B=(0,a.Z)(),Q=(0,l.K)(()=>{var e;let t,r,n=R.current,l=M.current,o=W.current,i=H.current,a=N.current,u=A.current;if(!n)return;let c=n.scrollHeight,s=n.scrollWidth,f=n.clientHeight,p=n.clientWidth,v=n.scrollTop,x=n.scrollLeft,g=G.current,m=Number.isNaN(g[0]);if(g[0]=f,g[1]=c,g[2]=p,g[3]=s,m&&Y(!0),0===c||0===s)return;let E=(t=(e=n).clientHeight>=e.scrollHeight,{y:t,x:r=e.clientWidth>=e.scrollWidth,corner:t||r}),P=E.y,$=E.x,L=p/s,k=f/c,K=Math.max(0,s-p),_=Math.max(0,c-f),F=0,q=0;$||(F=(0,y.Qw)("rtl"===O?-x:x,K),q=K-F);let Z=P?0:(0,y.Qw)(v,_),B=P?0:_-Z,Q=$?0:p,U=P?0:f,V=0,z=0;$||P||(V=l?.offsetWidth||0,z=o?.offsetHeight||0);let J=0===C.width&&0===C.height,ee=J?V:0,et=J?z:0,er=(0,d.A)(o,"padding","x"),en=(0,d.A)(l,"padding","y"),el=(0,d.A)(a,"margin","x"),eo=(0,d.A)(i,"margin","y"),ei=Q-er-el,ea=U-en-eo,eu=o?Math.min(o.offsetWidth-ee,ei):ei,ec=l?Math.min(l.offsetHeight-et,ea):ea,es=Math.max(h.i,eu*L),ef=Math.max(h.i,ec*k);if(I(e=>S(e,{width:es,height:ef})),l&&i){let e=l.offsetHeight-ef-en-eo,t=b(i,"--scroll-area-thumb-height",v,_,c,ef,e);i.style.transform=`translate3d(0,${t}px,0)`}if(o&&a){let e=o.offsetWidth-es-er-el,t=b(a,"--scroll-area-thumb-width","rtl"===O?-x:x,K,s,es,e);a.style.transform=`translate3d(${"rtl"===O?-t:t}px,0,0)`}let ed=[F,q,Z,B];w.forEach((e,t)=>{n.style.setProperty(e,`${ed[t]}px`)}),u&&T(e=>S(e,{width:V,height:z})),X(e=>S(e,E));let eh={xStart:!$&&F>D.xStart,xEnd:!$&&q>D.xEnd,yStart:!P&&Z>D.yStart,yEnd:!P&&B>D.yEnd};j(e=>S(e,eh))});function U(){q.current=!1}(0,o.g)(()=>{m||i.Fp||("u">typeof CSS&&"registerProperty"in CSS&&w.forEach(e=>{try{CSS.registerProperty({name:e,syntax:"<length>",inherits:!1,initialValue:"0px"})}catch{}}),m=!0)},[]),(0,o.g)(()=>{queueMicrotask(Q)},[Q,L,O,D.xStart,D.xEnd,D.yStart,D.yEnd]),(0,o.g)(()=>{R.current?.matches(":hover")&&_(!0)},[R,_]),(0,o.g)(()=>{let e=R.current;if("u"<typeof ResizeObserver||!e)return;let t=!1,r=new ResizeObserver(()=>{if(!t){t=!0;let r=G.current;if(r[0]===e.clientHeight&&r[1]===e.scrollHeight&&r[2]===e.clientWidth&&r[3]===e.scrollWidth)return}Q()});return r.observe(e),B.start(0,()=>{let t=e.getAnimations({subtree:!0});0!==t.length&&Promise.allSettled(t.map(e=>e.finished)).then(Q).catch(()=>{})}),()=>{r.disconnect(),B.clear()}},[Q,R,B]);let V={role:"presentation",...$&&{"data-id":`${$}-viewport`},tabIndex:L.x&&L.y?-1:0,className:v.E.className,style:{overflow:"scroll"},onScroll(){R.current&&(Q(),(K||!q.current)&&k({x:R.current.scrollLeft,y:R.current.scrollTop}),Z.start(100,()=>{q.current=!0}))},onWheel:U,onPointerMove:U,onPointerEnter:U,onKeyDown:U},z=(0,s.o)("div",e,{ref:[t,R],state:F,props:[V,P],stateAttributesMapping:x.r}),J=n.useMemo(()=>({computeThumbPosition:Q}),[Q]);return(0,g.jsx)(c.Provider,{value:J,children:z})});function S(e,t){for(let r in t)if(e[r]!==t[r])return t;return e}function b(e,t,r,n,l,o,i){let a=(0,p.q)(r,0,n),u=r-a,c=Math.max(h.i,o*l/(l+Math.abs(u)));return e.style.setProperty(t,u?`${c}px`:""),(n?a/n*i:0)+(u>0?o-c:0)}},17094:(e,t,r)=>{r.d(t,{n:()=>i});var n=r(12115);let l=n.createContext(void 0),o={disableStyleElements:!1};function i(){return n.useContext(l)??o}},28539:(e,t,r)=>{r.d(t,{E:()=>o});var n=r(95155);let l="base-ui-disable-scrollbar",o={className:l,getElement:e=>(0,n.jsx)("style",{nonce:e,href:l,precedence:"base-ui:low",children:`.${l}{scrollbar-width:none}.${l}::-webkit-scrollbar{display:none}`})}},52482:(e,t,r)=>{r.d(t,{A:()=>n});function n(e,t,r){if(!e)return 0;let n=getComputedStyle(e),l=`${t}${"x"===r?"Inline":"Block"}`,o=parseFloat(n[`${l}Start`]);return"x"===r&&"margin"===t?2*o:o+parseFloat(n[`${l}End`])}},64084:(e,t,r)=>{r.d(t,{l:()=>a});var n=r(12115),l=r(82441),o=r(94627),i=r(69938);let a=n.forwardRef(function(e,t){let{render:r,className:n,style:a,...u}=e,{thumbYRef:c,thumbXRef:s,handlePointerDown:f,handlePointerMove:d,handlePointerUp:h,scrollingX:p,scrollingY:v,hasMeasuredScrollbar:x}=(0,l.p)(),y=(0,o.r)(),g="vertical"===y;return(0,i.o)("div",e,{ref:[t,g?c:s],state:{scrolling:g?v:p,orientation:y},props:[{onPointerDown:f,onPointerMove:d,onPointerUp:h,onPointerCancel:h,style:{visibility:x?void 0:"hidden",...g?{height:"var(--scroll-area-thumb-height)"}:{width:"var(--scroll-area-thumb-width)"}}},u]})})},66784:(e,t,r)=>{r.d(t,{V:()=>h});var n=r(12115),l=r(14718),o=r(51464),i=r(82441),a=r(94627),u=r(69938),c=r(52482),s=r(30458),f=r(93152),d=r(95155);let h=n.forwardRef(function(e,t){let{render:r,className:h,orientation:p="vertical",keepMounted:v=!1,style:x,...y}=e,{hovering:g,scrollingX:w,scrollingY:m,hiddenState:E,scrollbarYRef:S,scrollbarXRef:b,viewportRef:P,thumbYRef:R,thumbXRef:M,handlePointerDown:W,handlePointerUp:H,handleScroll:N,disableViewportSnap:A,rootId:C,thumbSize:T,hasMeasuredScrollbar:I,viewportState:$}=(0,i.p)(),X="vertical"===p,L={...$,hovering:g,scrolling:X?m:w,orientation:p},Y=(0,s.j)(),k=!I&&!v,K=X?E.y:E.x,_=v||!K;n.useEffect(()=>{if(!_)return;let e=P.current,t=X?S.current:b.current;if(t)return(0,l.q)(t,"wheel",function(t){if(!e||t.ctrlKey)return;let r=!X,n=r?"scrollLeft":"scrollTop",l=r?t.deltaX:t.deltaY;if(0===l)return;let o=r?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight,i=r&&"rtl"===Y?-o:0,a=r&&"rtl"===Y?0:o,u=e[n];u<=i&&l<0||u>=a&&l>0||(t.preventDefault(),e[n]=Math.min(a,Math.max(i,u+l)),N({x:e.scrollLeft,y:e.scrollTop}))},{passive:!1})},[Y,N,X,b,S,_,P]);let j={...C&&{"data-id":`${C}-scrollbar`},onPointerDown(e){if(0!==e.button)return;let t=(0,o.EW)(e.nativeEvent),r=X?R.current:M.current;if(r&&(0,o.gR)(r,t))return;let n=P.current;if(!n)return;let l=X?S.current:b.current;if(!r||!l)return;let i=X?"y":"x",a=(0,c.A)(r,"margin",i),u=(0,c.A)(l,"padding",i),s=X?r.offsetHeight:r.offsetWidth,f=l.getBoundingClientRect(),d=X?e.clientY-f.top-s/2-u+a/2:e.clientX-f.left-s/2-u+a/2,h=X?n.scrollHeight:n.scrollWidth,p=X?n.clientHeight:n.clientWidth,v=(X?l.offsetHeight:l.offsetWidth)-s-u-a;if(v<=0)return;let x=d/v,y=h-p;A(),X?n.scrollTop=x*y:"rtl"===Y?n.scrollLeft=-(1-x)*y:n.scrollLeft=x*y,N({x:n.scrollLeft,y:n.scrollTop}),W(e)},onPointerUp:H,onPointerCancel:H,style:{position:"absolute",touchAction:"none",WebkitUserSelect:"none",userSelect:"none",visibility:k?"hidden":void 0,...X?{top:0,bottom:"var(--scroll-area-corner-height)",insetInlineEnd:0,"--scroll-area-thumb-height":`${T.height}px`}:{insetInlineStart:0,insetInlineEnd:"var(--scroll-area-corner-width)",bottom:0,"--scroll-area-thumb-width":`${T.width}px`}}},D=(0,u.o)("div",e,{ref:[t,X?S:b],state:L,props:[j,y],stateAttributesMapping:f.r});return _?(0,d.jsx)(a.G.Provider,{value:p,children:D}):null})},68445:(e,t,r)=>{r.d(t,{q:()=>n});function n(e,t=Number.MIN_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,r))}},73321:(e,t,r)=>{var n=r(74645);r.o(n,"useParams")&&r.d(t,{useParams:function(){return n.useParams}}),r.o(n,"usePathname")&&r.d(t,{usePathname:function(){return n.usePathname}}),r.o(n,"useRouter")&&r.d(t,{useRouter:function(){return n.useRouter}})},76166:(e,t,r)=>{r.d(t,{V:()=>m});var n=r(12115),l=r(23068),o=r(64951),i=r(82441),a=r(69938),u=r(77246),c=r(52482),s=r(28539),f=r(62955),d=r(93152),h=r(51464),p=r(17094),v=r(95155);let x={x:0,y:0},y={width:0,height:0},g={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},w={x:!0,y:!0,corner:!0},m=n.forwardRef(function(e,t){var r;let m,{render:E,className:S,overflowEdgeThreshold:b,style:P,...R}=e,{xStart:M,xEnd:W,yStart:H,yEnd:N}=(m="number"==typeof(r=b)?{xStart:r,xEnd:r,yStart:r,yEnd:r}:r,{xStart:Math.max(0,m?.xStart||0),xEnd:Math.max(0,m?.xEnd||0),yStart:Math.max(0,m?.yStart||0),yEnd:Math.max(0,m?.yEnd||0)}),A=(0,f.e)(),C=(0,o.Z)(),T=(0,o.Z)(),{nonce:I,disableStyleElements:$}=(0,p.n)(),[X,L]=n.useState(!1),[Y,k]=n.useState(!1),[K,_]=n.useState(!1),[j,D]=n.useState(!1),[F,O]=n.useState(!1),[q,G]=n.useState(y),[Z,B]=n.useState(y),[Q,U]=n.useState(g),[V,z]=n.useState(w),J=n.useRef(null),ee=n.useRef(null),et=n.useRef(null),er=n.useRef(null),en=n.useRef(null),el=n.useRef(null),eo=n.useRef(null),ei=n.useRef(null),ea=n.useRef(0),eu=n.useRef(0),ec=n.useRef(0),es=n.useRef(0),ef=n.useRef("vertical"),ed=n.useRef(x),eh=n.useRef(null);function ep(e){let t=e?_:k;t(!0),(e?C:T).start(u.u,()=>{t(!1)})}let ev=(0,l.K)(e=>{let t=e.x-ed.current.x,r=e.y-ed.current.y;ed.current=e,0!==r&&ep(!0),0!==t&&ep(!1)}),ex=(0,l.K)(()=>{let e=ee.current;e&&null===eh.current&&(eh.current=e.style.scrollSnapType,e.style.scrollSnapType="none")}),ey=(0,l.K)(e=>{if(0!==e.button)return;if(null!==ei.current){let e="vertical"===ef.current?en.current:el.current;if(e?.hasPointerCapture(ei.current))return}ei.current=e.pointerId,ea.current=e.clientY,eu.current=e.clientX,ef.current=e.currentTarget.getAttribute("data-orientation");let t=ee.current;t&&(ec.current=t.scrollTop,es.current=t.scrollLeft,ex());let r="vertical"===ef.current?en.current:el.current;r?.setPointerCapture(e.pointerId)}),eg=(0,l.K)(e=>{if(e.pointerId!==ei.current)return;ei.current=null,("vertical"===ef.current?_:k)(!1),null!==eh.current&&(ee.current&&(ee.current.style.scrollSnapType=eh.current),eh.current=null);let t="vertical"===ef.current?en.current:el.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),ew=(0,l.K)(e=>{if(e.pointerId!==ei.current)return;if(e.buttons%2==0)return void eg(e);let t=ee.current;if(!t)return;let r="vertical"===ef.current,n=r?en.current:el.current,l=r?et.current:er.current;if(!n||!l)return;let o=r?"y":"x",i=(0,c.A)(l,"padding",o),a=(0,c.A)(n,"margin",o),u=r?n.offsetHeight:n.offsetWidth,s=(r?l.offsetHeight:l.offsetWidth)-u-i-a,f=r?e.clientY-ea.current:e.clientX-eu.current,d=r?t.scrollHeight:t.scrollWidth,h=r?t.clientHeight:t.clientWidth,p=(r?ec.current:es.current)+(s<=0?0:f/s)*(d-h);r?t.scrollTop=p:t.scrollLeft=p,e.preventDefault(),ep(r)});function em(e){D("touch"===e.pointerType)}function eE(e){em(e),"touch"!==e.pointerType&&L((0,h.gR)(J.current,e.target))}let eS=n.useMemo(()=>({scrolling:Y||K,hasOverflowX:!V.x,hasOverflowY:!V.y,overflowXStart:Q.xStart,overflowXEnd:Q.xEnd,overflowYStart:Q.yStart,overflowYEnd:Q.yEnd,cornerHidden:V.corner}),[Y,K,V.x,V.y,V.corner,Q]),eb={role:"presentation",onPointerEnter:eE,onPointerMove:eE,onPointerDown:em,onPointerLeave(){L(!1)},style:{position:"relative","--scroll-area-corner-height":`${q.height}px`,"--scroll-area-corner-width":`${q.width}px`}},eP=(0,a.o)("div",e,{state:eS,ref:[t,J],props:[eb,R],stateAttributesMapping:d.r}),eR=n.useMemo(()=>({handlePointerDown:ey,handlePointerMove:ew,handlePointerUp:eg,handleScroll:ev,disableViewportSnap:ex,cornerSize:q,setCornerSize:G,thumbSize:Z,setThumbSize:B,hasMeasuredScrollbar:F,setHasMeasuredScrollbar:O,touchModality:j,cornerRef:eo,scrollingX:Y,scrollingY:K,hovering:X,setHovering:L,viewportRef:ee,scrollbarYRef:et,scrollbarXRef:er,thumbYRef:en,thumbXRef:el,rootId:A,hiddenState:V,setHiddenState:z,overflowEdges:Q,setOverflowEdges:U,viewportState:eS,overflowEdgeThreshold:{xStart:M,xEnd:W,yStart:H,yEnd:N}}),[ey,ew,eg,ev,ex,q,Z,F,j,Y,K,X,A,V,Q,eS,M,W,H,N]);return(0,v.jsxs)(i.a.Provider,{value:eR,children:[!$&&s.E.getElement(I),eP]})})},77246:(e,t,r)=>{r.d(t,{i:()=>l,u:()=>n});let n=500,l=16},82441:(e,t,r)=>{r.d(t,{a:()=>o,p:()=>i});var n=r(25803),l=r(12115);let o=l.createContext(void 0);function i(){let e=l.useContext(o);if(void 0===e)throw Error((0,n.A)(53));return e}},84588:(e,t,r)=>{r.d(t,{I:()=>i});var n=r(12115),l=r(82441),o=r(69938);let i=n.forwardRef(function(e,t){let{render:r,className:n,style:i,...a}=e,{cornerRef:u,cornerSize:c,hiddenState:s}=(0,l.p)(),f=(0,o.o)("div",e,{ref:[t,u],props:[{style:{position:"absolute",bottom:0,insetInlineEnd:0,width:c.width,height:c.height}},a]});return s.corner?null:f})},93152:(e,t,r)=>{r.d(t,{r:()=>l});let n=e=>t=>t?{[e]:""}:null,l={hasOverflowX:n("data-has-overflow-x"),hasOverflowY:n("data-has-overflow-y"),overflowXStart:n("data-overflow-x-start"),overflowXEnd:n("data-overflow-x-end"),overflowYStart:n("data-overflow-y-start"),overflowYEnd:n("data-overflow-y-end"),cornerHidden:()=>null}},94627:(e,t,r)=>{r.d(t,{G:()=>o,r:()=>i});var n=r(25803),l=r(12115);let o=l.createContext(void 0);function i(){let e=l.useContext(o);if(void 0===e)throw Error((0,n.A)(54));return e}}}]);