@theobourgeois/ytdb 0.2.20 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +2 -1
  3. package/.next/build-manifest.json +3 -3
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/react-loadable-manifest.json +12 -1
  6. package/.next/routes-manifest.json +9 -0
  7. package/.next/server/app/[connectionId]/[schema]/[table]/page.js +1 -1
  8. package/.next/server/app/[connectionId]/[schema]/[table]/page_client-reference-manifest.js +1 -1
  9. package/.next/server/app/[connectionId]/diff/page.js +2 -2
  10. package/.next/server/app/[connectionId]/diff/page_client-reference-manifest.js +1 -1
  11. package/.next/server/app/[connectionId]/migrations/(index)/page.js +1 -1
  12. package/.next/server/app/[connectionId]/migrations/(index)/page_client-reference-manifest.js +1 -1
  13. package/.next/server/app/[connectionId]/migrations/(index)/timeline/page.js +1 -1
  14. package/.next/server/app/[connectionId]/migrations/(index)/timeline/page_client-reference-manifest.js +1 -1
  15. package/.next/server/app/[connectionId]/migrations/[setId]/diagram/page.js +1 -0
  16. package/.next/server/app/[connectionId]/migrations/[setId]/diagram/page.js.nft.json +1 -0
  17. package/.next/server/app/[connectionId]/migrations/[setId]/diagram/page_client-reference-manifest.js +1 -0
  18. package/.next/server/app/[connectionId]/migrations/[setId]/page.js +1 -1
  19. package/.next/server/app/[connectionId]/migrations/[setId]/page_client-reference-manifest.js +1 -1
  20. package/.next/server/app/[connectionId]/migrations/[setId]/schema/page.js +1 -1
  21. package/.next/server/app/[connectionId]/migrations/[setId]/schema/page_client-reference-manifest.js +1 -1
  22. package/.next/server/app/[connectionId]/migrations/[setId]/timeline/page.js +1 -1
  23. package/.next/server/app/[connectionId]/migrations/[setId]/timeline/page_client-reference-manifest.js +1 -1
  24. package/.next/server/app/[connectionId]/page.js +1 -1
  25. package/.next/server/app/[connectionId]/page_client-reference-manifest.js +1 -1
  26. package/.next/server/app/[connectionId]/query/page.js +1 -1
  27. package/.next/server/app/[connectionId]/query/page_client-reference-manifest.js +1 -1
  28. package/.next/server/app/_global-error/page.js +2 -2
  29. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  30. package/.next/server/app/_global-error.html +1 -1
  31. package/.next/server/app/_global-error.rsc +1 -1
  32. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  33. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  34. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  35. package/.next/server/app/_not-found/page.js +1 -1
  36. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  37. package/.next/server/app/_not-found.html +1 -1
  38. package/.next/server/app/_not-found.rsc +7 -7
  39. package/.next/server/app/_not-found.segments/_full.segment.rsc +7 -7
  40. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +7 -7
  41. package/.next/server/app/_not-found.segments/_tree.segment.rsc +3 -3
  42. package/.next/server/app/api/activity/route.js +2 -2
  43. package/.next/server/app/api/adopt/route.js +1 -1
  44. package/.next/server/app/api/cell/route.js +3 -3
  45. package/.next/server/app/api/definition/route.js +2 -2
  46. package/.next/server/app/api/delete-rows/route.js +1 -1
  47. package/.next/server/app/api/detect/route.js +1 -1
  48. package/.next/server/app/api/health/route.js +1 -1
  49. package/.next/server/app/api/insert-row/route.js +2 -2
  50. package/.next/server/app/api/ledger/route.js +1 -1
  51. package/.next/server/app/api/lookup/route.js +2 -2
  52. package/.next/server/app/api/migrate/route.js +1 -1
  53. package/.next/server/app/api/note/route.js +1 -1
  54. package/.next/server/app/api/query/route.js +2 -2
  55. package/.next/server/app/api/reconcile/route.js +2 -2
  56. package/.next/server/app/api/rehearse/route.js +1 -1
  57. package/.next/server/app/api/related/route.js +2 -2
  58. package/.next/server/app/api/repo/route.js +1 -1
  59. package/.next/server/app/api/rows/route.js +2 -2
  60. package/.next/server/app/api/schema/route.js +1 -1
  61. package/.next/server/app/api/tables/route.js +2 -2
  62. package/.next/server/app/api/timeline/route.js +1 -1
  63. package/.next/server/app/api/update-row/route.js +1 -1
  64. package/.next/server/app/favicon.ico/route.js +1 -1
  65. package/.next/server/app/icon.svg/route.js +1 -1
  66. package/.next/server/app/index.html +1 -1
  67. package/.next/server/app/index.rsc +8 -8
  68. package/.next/server/app/index.segments/__PAGE__.segment.rsc +8 -8
  69. package/.next/server/app/index.segments/_full.segment.rsc +8 -8
  70. package/.next/server/app/index.segments/_tree.segment.rsc +3 -3
  71. package/.next/server/app/page.js +2 -2
  72. package/.next/server/app/page_client-reference-manifest.js +1 -1
  73. package/.next/server/app-paths-manifest.json +2 -1
  74. package/.next/server/chunks/1421.js +1 -1
  75. package/.next/server/chunks/4809.js +1 -1
  76. package/.next/server/chunks/5816.js +1 -1
  77. package/.next/server/chunks/6729.js +1 -1
  78. package/.next/server/chunks/7928.js +1 -1
  79. package/.next/server/middleware-build-manifest.js +1 -1
  80. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  81. package/.next/server/middleware.js +1 -1
  82. package/.next/server/pages/404.html +1 -1
  83. package/.next/server/pages/500.html +1 -1
  84. package/.next/server/server-reference-manifest.json +1 -1
  85. package/.next/static/{XOKG1sVlYC-O8M7Qf5aWE → NB4JOC2i3ctixKpjpc7WH}/_buildManifest.js +1 -1
  86. package/.next/static/chunks/1a258343.4407cfad5d6b3688.js +1 -0
  87. package/.next/static/chunks/{223-a4fca67d979d899d.js → 223-ae41c085e76173d8.js} +1 -1
  88. package/.next/static/chunks/228-332e8b6e327f10da.js +1 -0
  89. package/.next/static/chunks/{544-9e1c454c8313699f.js → 544-624e05bf7e7a38d4.js} +1 -1
  90. package/.next/static/chunks/6090-97474bba31339e8e.js +1 -0
  91. package/.next/static/chunks/9146.9656b5ec316de71a.js +1 -0
  92. package/.next/static/chunks/91dbc596.26f4ecb79a1f7c01.js +1 -0
  93. package/.next/static/chunks/9406.9203511499c8bf43.js +1 -0
  94. package/.next/static/chunks/app/[connectionId]/migrations/(index)/page-e85d6ff71aeabe8d.js +1 -0
  95. package/.next/static/chunks/app/[connectionId]/migrations/(index)/timeline/page-e85d6ff71aeabe8d.js +1 -0
  96. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/diagram/page-e85d6ff71aeabe8d.js +1 -0
  97. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/layout-31e703f1a9beebf7.js +1 -0
  98. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/page-e85d6ff71aeabe8d.js +1 -0
  99. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/schema/page-e85d6ff71aeabe8d.js +1 -0
  100. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/timeline/page-e85d6ff71aeabe8d.js +1 -0
  101. package/.next/static/chunks/app/[connectionId]/page-78a06e32a2658d3b.js +1 -0
  102. package/.next/static/chunks/app/[connectionId]/query/page-53c2d6f97a05d957.js +1 -0
  103. package/.next/static/chunks/app/_global-error/page-e85d6ff71aeabe8d.js +1 -0
  104. package/.next/static/chunks/app/api/activity/route-e85d6ff71aeabe8d.js +1 -0
  105. package/.next/static/chunks/app/api/adopt/route-e85d6ff71aeabe8d.js +1 -0
  106. package/.next/static/chunks/app/api/cell/route-e85d6ff71aeabe8d.js +1 -0
  107. package/.next/static/chunks/app/api/definition/route-e85d6ff71aeabe8d.js +1 -0
  108. package/.next/static/chunks/app/api/delete-rows/route-e85d6ff71aeabe8d.js +1 -0
  109. package/.next/static/chunks/app/api/detect/route-e85d6ff71aeabe8d.js +1 -0
  110. package/.next/static/chunks/app/api/health/route-e85d6ff71aeabe8d.js +1 -0
  111. package/.next/static/chunks/app/api/insert-row/route-e85d6ff71aeabe8d.js +1 -0
  112. package/.next/static/chunks/app/api/ledger/route-e85d6ff71aeabe8d.js +1 -0
  113. package/.next/static/chunks/app/api/lookup/route-e85d6ff71aeabe8d.js +1 -0
  114. package/.next/static/chunks/app/api/migrate/route-e85d6ff71aeabe8d.js +1 -0
  115. package/.next/static/chunks/app/api/note/route-e85d6ff71aeabe8d.js +1 -0
  116. package/.next/static/chunks/app/api/query/route-e85d6ff71aeabe8d.js +1 -0
  117. package/.next/static/chunks/app/api/reconcile/route-e85d6ff71aeabe8d.js +1 -0
  118. package/.next/static/chunks/app/api/rehearse/route-e85d6ff71aeabe8d.js +1 -0
  119. package/.next/static/chunks/app/api/related/route-e85d6ff71aeabe8d.js +1 -0
  120. package/.next/static/chunks/app/api/repo/route-e85d6ff71aeabe8d.js +1 -0
  121. package/.next/static/chunks/app/api/rows/route-e85d6ff71aeabe8d.js +1 -0
  122. package/.next/static/chunks/app/api/schema/route-e85d6ff71aeabe8d.js +1 -0
  123. package/.next/static/chunks/app/api/tables/route-e85d6ff71aeabe8d.js +1 -0
  124. package/.next/static/chunks/app/api/timeline/route-e85d6ff71aeabe8d.js +1 -0
  125. package/.next/static/chunks/app/api/update-row/route-e85d6ff71aeabe8d.js +1 -0
  126. package/.next/static/chunks/app/layout-2ed8b1f837adb32a.js +1 -0
  127. package/.next/static/chunks/next/dist/client/components/builtin/app-error-e85d6ff71aeabe8d.js +1 -0
  128. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-e85d6ff71aeabe8d.js +1 -0
  129. package/.next/static/chunks/next/dist/client/components/builtin/not-found-e85d6ff71aeabe8d.js +1 -0
  130. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-e85d6ff71aeabe8d.js +1 -0
  131. package/.next/static/chunks/webpack-6451386e3f1b2ec9.js +1 -0
  132. package/.next/static/css/0e3fe8b2c0252430.css +1 -0
  133. package/.next/static/css/{e02ab5db9ff2dca2.css → 5df9ea52964d1443.css} +1 -1
  134. package/.next/static/css/6ada1421df91d770.css +21 -0
  135. package/README.md +5 -351
  136. package/bin/ytdb.mjs +4 -9
  137. package/package.json +3 -1
  138. package/.next/static/chunks/228-e9e3a928efbebb89.js +0 -1
  139. package/.next/static/chunks/6090-6764126dba5d4d96.js +0 -1
  140. package/.next/static/chunks/app/[connectionId]/migrations/(index)/page-34cb852b3259a90b.js +0 -1
  141. package/.next/static/chunks/app/[connectionId]/migrations/(index)/timeline/page-34cb852b3259a90b.js +0 -1
  142. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/layout-cdb8e5d125828828.js +0 -1
  143. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/page-34cb852b3259a90b.js +0 -1
  144. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/schema/page-34cb852b3259a90b.js +0 -1
  145. package/.next/static/chunks/app/[connectionId]/migrations/[setId]/timeline/page-34cb852b3259a90b.js +0 -1
  146. package/.next/static/chunks/app/[connectionId]/page-188bdfaba4f04923.js +0 -1
  147. package/.next/static/chunks/app/[connectionId]/query/page-ef40d6213057d671.js +0 -1
  148. package/.next/static/chunks/app/_global-error/page-34cb852b3259a90b.js +0 -1
  149. package/.next/static/chunks/app/api/activity/route-34cb852b3259a90b.js +0 -1
  150. package/.next/static/chunks/app/api/adopt/route-34cb852b3259a90b.js +0 -1
  151. package/.next/static/chunks/app/api/cell/route-34cb852b3259a90b.js +0 -1
  152. package/.next/static/chunks/app/api/definition/route-34cb852b3259a90b.js +0 -1
  153. package/.next/static/chunks/app/api/delete-rows/route-34cb852b3259a90b.js +0 -1
  154. package/.next/static/chunks/app/api/detect/route-34cb852b3259a90b.js +0 -1
  155. package/.next/static/chunks/app/api/health/route-34cb852b3259a90b.js +0 -1
  156. package/.next/static/chunks/app/api/insert-row/route-34cb852b3259a90b.js +0 -1
  157. package/.next/static/chunks/app/api/ledger/route-34cb852b3259a90b.js +0 -1
  158. package/.next/static/chunks/app/api/lookup/route-34cb852b3259a90b.js +0 -1
  159. package/.next/static/chunks/app/api/migrate/route-34cb852b3259a90b.js +0 -1
  160. package/.next/static/chunks/app/api/note/route-34cb852b3259a90b.js +0 -1
  161. package/.next/static/chunks/app/api/query/route-34cb852b3259a90b.js +0 -1
  162. package/.next/static/chunks/app/api/reconcile/route-34cb852b3259a90b.js +0 -1
  163. package/.next/static/chunks/app/api/rehearse/route-34cb852b3259a90b.js +0 -1
  164. package/.next/static/chunks/app/api/related/route-34cb852b3259a90b.js +0 -1
  165. package/.next/static/chunks/app/api/repo/route-34cb852b3259a90b.js +0 -1
  166. package/.next/static/chunks/app/api/rows/route-34cb852b3259a90b.js +0 -1
  167. package/.next/static/chunks/app/api/schema/route-34cb852b3259a90b.js +0 -1
  168. package/.next/static/chunks/app/api/tables/route-34cb852b3259a90b.js +0 -1
  169. package/.next/static/chunks/app/api/timeline/route-34cb852b3259a90b.js +0 -1
  170. package/.next/static/chunks/app/api/update-row/route-34cb852b3259a90b.js +0 -1
  171. package/.next/static/chunks/app/layout-e3fdecae5544dc60.js +0 -1
  172. package/.next/static/chunks/next/dist/client/components/builtin/app-error-34cb852b3259a90b.js +0 -1
  173. package/.next/static/chunks/next/dist/client/components/builtin/forbidden-34cb852b3259a90b.js +0 -1
  174. package/.next/static/chunks/next/dist/client/components/builtin/not-found-34cb852b3259a90b.js +0 -1
  175. package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-34cb852b3259a90b.js +0 -1
  176. package/.next/static/chunks/webpack-34eb118f56295776.js +0 -1
  177. package/.next/static/css/ab9c0ea2c2569929.css +0 -1
  178. package/public/screenshots/ytdb-command-palette.png +0 -0
  179. package/public/screenshots/ytdb-connection.png +0 -0
  180. package/public/screenshots/ytdb-explorer.png +0 -0
  181. /package/.next/static/{XOKG1sVlYC-O8M7Qf5aWE → NB4JOC2i3ctixKpjpc7WH}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9406],{2367:()=>{},61278:(t,e,n)=>{"use strict";n.d(e,{Do:()=>p,WZ:()=>h,TG:()=>y,ny:()=>f,yX:()=>g,xN:()=>m,Qc:()=>d,I$:()=>rv,aQ:()=>rM,di:()=>rE,kO:()=>rI,rN:()=>n1,bi:()=>rl,_s:()=>nH,_7:()=>nf,aE:()=>na,kr:()=>nM,Hm:()=>rn,tM:()=>e8,tn:()=>e3,xc:()=>e2,us:()=>nP,IO:()=>no,e_:()=>nK,Fp:()=>nZ,Mi:()=>nv,HF:()=>nO,Eo:()=>nD,b5:()=>n6,Tq:()=>nu,qX:()=>nG,q1:()=>nV,M_:()=>n7,oj:()=>nX,aZ:()=>nr,aW:()=>re,uD:()=>nT,Jo:()=>nn,U$:()=>ni,X6:()=>nw,oN:()=>n8,ah:()=>n2,R4:()=>nz,WQ:()=>nC,r8:()=>rh,ZO:()=>e5,bK:()=>e4,b$:()=>e9,uj:()=>nJ,v5:()=>nq,Ue:()=>nN,Er:()=>nY,oB:()=>e7,kf:()=>nb,mW:()=>n_,Q6:()=>nL,QE:()=>nI,kM:()=>ng,No:()=>rd,Ff:()=>nk,zj:()=>n$,s_:()=>nE,vS:()=>ra,qn:()=>ry,uL:()=>rf,YN:()=>nB});var r,i,o,a,u,l,s,c,h,f,d,p,y,g,m,v={value:()=>{}};function x(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw Error("illegal type: "+t);r[t]=[]}return new w(r)}function w(t){this._=t}function _(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=v,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}function b(){}function M(t){return null==t?b:function(){return this.querySelector(t)}}function E(){return[]}function k(t){return null==t?E:function(){return this.querySelectorAll(t)}}function $(t){return function(){return this.matches(t)}}function A(t){return function(e){return e.matches(t)}}w.prototype=x.prototype={constructor:w,on:function(t,e){var n,r=this._,i=(t+"").trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw Error("unknown type: "+t);return{type:t,name:e}}),o=-1,a=i.length;if(arguments.length<2){for(;++o<a;)if((n=(t=i[o]).type)&&(n=function(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}(r[n],t.name)))return n;return}if(null!=e&&"function"!=typeof e)throw Error("invalid callback: "+e);for(;++o<a;)if(n=(t=i[o]).type)r[n]=_(r[n],t.name,e);else if(null==e)for(n in r)r[n]=_(r[n],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new w(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=Array(n),o=0;o<n;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw Error("unknown type: "+t);for(r=this._[t],o=0,n=r.length;o<n;++o)r[o].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};var z=Array.prototype.find;function N(){return this.firstElementChild}var S=Array.prototype.filter;function T(){return Array.from(this.children)}function I(t){return Array(t.length)}function P(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function H(t,e,n,r,i,o){for(var a,u=0,l=e.length,s=o.length;u<s;++u)(a=e[u])?(a.__data__=o[u],r[u]=a):n[u]=new P(t,o[u]);for(;u<l;++u)(a=e[u])&&(i[u]=a)}function B(t,e,n,r,i,o,a){var u,l,s,c=new Map,h=e.length,f=o.length,d=Array(h);for(u=0;u<h;++u)(l=e[u])&&(d[u]=s=a.call(l,l.__data__,u,e)+"",c.has(s)?i[u]=l:c.set(s,l));for(u=0;u<f;++u)s=a.call(t,o[u],u,o)+"",(l=c.get(s))?(r[u]=l,l.__data__=o[u],c.delete(s)):n[u]=new P(t,o[u]);for(u=0;u<h;++u)(l=e[u])&&c.get(d[u])===l&&(i[u]=l)}function L(t){return t.__data__}function C(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}P.prototype={constructor:P,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};var O="http://www.w3.org/1999/xhtml";let R={svg:"http://www.w3.org/2000/svg",xhtml:O,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function D(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),R.hasOwnProperty(e)?{space:R[e],local:t}:t}function X(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function j(t,e){return t.style.getPropertyValue(e)||X(t).getComputedStyle(t,null).getPropertyValue(e)}function q(t){return t.trim().split(/^|\s+/)}function Y(t){return t.classList||new V(t)}function V(t){this._node=t,this._names=q(t.getAttribute("class")||"")}function F(t,e){for(var n=Y(t),r=-1,i=e.length;++r<i;)n.add(e[r])}function K(t,e){for(var n=Y(t),r=-1,i=e.length;++r<i;)n.remove(e[r])}function W(){this.textContent=""}function U(){this.innerHTML=""}function Z(){this.nextSibling&&this.parentNode.appendChild(this)}function Q(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function G(t){var e=D(t);return(e.local?function(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}:function(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===O&&e.documentElement.namespaceURI===O?e.createElement(t):e.createElementNS(n,t)}})(e)}function J(){return null}function tt(){var t=this.parentNode;t&&t.removeChild(this)}function te(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function tn(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function tr(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,o=e.length;r<o;++r)(n=e[r],t.type&&n.type!==t.type||n.name!==t.name)?e[++i]=n:this.removeEventListener(n.type,n.listener,n.options);++i?e.length=i:delete this.__on}}}function ti(t,e,n){return function(){var r,i=this.__on,o=function(t){e.call(this,t,this.__data__)};if(i){for(var a=0,u=i.length;a<u;++a)if((r=i[a]).type===t.type&&r.name===t.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=n),r.value=e;return}}this.addEventListener(t.type,o,n),r={type:t.type,name:t.name,value:e,listener:o,options:n},i?i.push(r):this.__on=[r]}}function to(t,e,n){var r=X(t),i=r.CustomEvent;"function"==typeof i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i)}V.prototype={add:function(t){0>this._names.indexOf(t)&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var ta=[null];function tu(t,e){this._groups=t,this._parents=e}function tl(){return new tu([[document.documentElement]],ta)}function ts(t){return"string"==typeof t?new tu([[document.querySelector(t)]],[document.documentElement]):new tu([[t]],ta)}function tc(t,e){if(t=function(t){let e;for(;e=t.sourceEvent;)t=e;return t}(t),void 0===e&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,[(r=r.matrixTransform(e.getScreenCTM().inverse())).x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}tu.prototype=tl.prototype={constructor:tu,select:function(t){"function"!=typeof t&&(t=M(t));for(var e=this._groups,n=e.length,r=Array(n),i=0;i<n;++i)for(var o,a,u=e[i],l=u.length,s=r[i]=Array(l),c=0;c<l;++c)(o=u[c])&&(a=t.call(o,o.__data__,c,u))&&("__data__"in o&&(a.__data__=o.__data__),s[c]=a);return new tu(r,this._parents)},selectAll:function(t){if("function"==typeof t){var e;e=t,t=function(){var t;return t=e.apply(this,arguments),null==t?[]:Array.isArray(t)?t:Array.from(t)}}else t=k(t);for(var n=this._groups,r=n.length,i=[],o=[],a=0;a<r;++a)for(var u,l=n[a],s=l.length,c=0;c<s;++c)(u=l[c])&&(i.push(t.call(u,u.__data__,c,l)),o.push(u));return new tu(i,o)},selectChild:function(t){var e;return this.select(null==t?N:(e="function"==typeof t?t:A(t),function(){return z.call(this.children,e)}))},selectChildren:function(t){var e;return this.selectAll(null==t?T:(e="function"==typeof t?t:A(t),function(){return S.call(this.children,e)}))},filter:function(t){"function"!=typeof t&&(t=$(t));for(var e=this._groups,n=e.length,r=Array(n),i=0;i<n;++i)for(var o,a=e[i],u=a.length,l=r[i]=[],s=0;s<u;++s)(o=a[s])&&t.call(o,o.__data__,s,a)&&l.push(o);return new tu(r,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,L);var n=e?B:H,r=this._parents,i=this._groups;"function"!=typeof t&&(v=t,t=function(){return v});for(var o=i.length,a=Array(o),u=Array(o),l=Array(o),s=0;s<o;++s){var c=r[s],h=i[s],f=h.length,d="object"==typeof(m=t.call(c,c&&c.__data__,s,r))&&"length"in m?m:Array.from(m),p=d.length,y=u[s]=Array(p),g=a[s]=Array(p);n(c,h,y,g,l[s]=Array(f),d,e);for(var m,v,x,w,_=0,b=0;_<p;++_)if(x=y[_]){for(_>=b&&(b=_+1);!(w=g[b])&&++b<p;);x._next=w||null}}return(a=new tu(a,r))._enter=u,a._exit=l,a},enter:function(){return new tu(this._enter||this._groups.map(I),this._parents)},exit:function(){return new tu(this._exit||this._groups.map(I),this._parents)},join:function(t,e,n){var r=this.enter(),i=this,o=this.exit();return"function"==typeof t?(r=t(r))&&(r=r.selection()):r=r.append(t+""),null!=e&&(i=e(i))&&(i=i.selection()),null==n?o.remove():n(o),r&&i?r.merge(i).order():i},merge:function(t){for(var e=t.selection?t.selection():t,n=this._groups,r=e._groups,i=n.length,o=r.length,a=Math.min(i,o),u=Array(i),l=0;l<a;++l)for(var s,c=n[l],h=r[l],f=c.length,d=u[l]=Array(f),p=0;p<f;++p)(s=c[p]||h[p])&&(d[p]=s);for(;l<i;++l)u[l]=n[l];return new tu(u,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var r,i=t[e],o=i.length-1,a=i[o];--o>=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=C);for(var n=this._groups,r=n.length,i=Array(r),o=0;o<r;++o){for(var a,u=n[o],l=u.length,s=i[o]=Array(l),c=0;c<l;++c)(a=u[c])&&(s[c]=a);s.sort(e)}return new tu(i,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r=t[e],i=0,o=r.length;i<o;++i){var a=r[i];if(a)return a}return null},size:function(){let t=0;for(let e of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i,o=e[n],a=0,u=o.length;a<u;++a)(i=o[a])&&t.call(i,i.__data__,a,o);return this},attr:function(t,e){var n=D(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((null==e?n.local?function(t){return function(){this.removeAttributeNS(t.space,t.local)}}:function(t){return function(){this.removeAttribute(t)}}:"function"==typeof e?n.local?function(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}:function(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}:n.local?function(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}:function(t,e){return function(){this.setAttribute(t,e)}})(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?function(t){return function(){this.style.removeProperty(t)}}:"function"==typeof e?function(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}:function(t,e,n){return function(){this.style.setProperty(t,e,n)}})(t,e,null==n?"":n)):j(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?function(t){return function(){delete this[t]}}:"function"==typeof e?function(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}:function(t,e){return function(){this[t]=e}})(t,e)):this.node()[t]},classed:function(t,e){var n=q(t+"");if(arguments.length<2){for(var r=Y(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each(("function"==typeof e?function(t,e){return function(){(e.apply(this,arguments)?F:K)(this,t)}}:e?function(t){return function(){F(this,t)}}:function(t){return function(){K(this,t)}})(n,e))},text:function(t){return arguments.length?this.each(null==t?W:("function"==typeof t?function(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}:function(t){return function(){this.textContent=t}})(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?U:("function"==typeof t?function(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}:function(t){return function(){this.innerHTML=t}})(t)):this.node().innerHTML},raise:function(){return this.each(Z)},lower:function(){return this.each(Q)},append:function(t){var e="function"==typeof t?t:G(t);return this.select(function(){return this.appendChild(e.apply(this,arguments))})},insert:function(t,e){var n="function"==typeof t?t:G(t),r=null==e?J:"function"==typeof e?e:M(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})},remove:function(){return this.each(tt)},clone:function(t){return this.select(t?tn:te)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var r,i,o=(t+"").trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}),a=o.length;if(arguments.length<2){var u=this.node().__on;if(u){for(var l,s=0,c=u.length;s<c;++s)for(r=0,l=u[s];r<a;++r)if((i=o[r]).type===l.type&&i.name===l.name)return l.value}return}for(u=e?ti:tr,r=0;r<a;++r)this.each(u(o[r],e,n));return this},dispatch:function(t,e){return this.each(("function"==typeof e?function(t,e){return function(){return to(this,t,e.apply(this,arguments))}}:function(t,e){return function(){return to(this,t,e)}})(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var r,i=t[e],o=0,a=i.length;o<a;++o)(r=i[o])&&(yield r)}};let th={passive:!1},tf={capture:!0,passive:!1};function td(t){t.stopImmediatePropagation()}function tp(t){t.preventDefault(),t.stopImmediatePropagation()}function ty(t){var e=t.document.documentElement,n=ts(t).on("dragstart.drag",tp,tf);"onselectstart"in e?n.on("selectstart.drag",tp,tf):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function tg(t,e){var n=t.document.documentElement,r=ts(t).on("dragstart.drag",null);e&&(r.on("click.drag",tp,tf),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}let tm=t=>()=>t;function tv(t,{sourceEvent:e,subject:n,target:r,identifier:i,active:o,x:a,y:u,dx:l,dy:s,dispatch:c}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:s,enumerable:!0,configurable:!0},_:{value:c}})}function tx(t){return!t.ctrlKey&&!t.button}function tw(){return this.parentNode}function t_(t,e){return null==e?{x:t.x,y:t.y}:e}function tb(){return navigator.maxTouchPoints||"ontouchstart"in this}function tM(t){return((t=Math.exp(t))+1/t)/2}tv.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};let tE=function t(e,n,r){function i(t,i){var o,a,u=t[0],l=t[1],s=t[2],c=i[0],h=i[1],f=i[2],d=c-u,p=h-l,y=d*d+p*p;if(y<1e-12)a=Math.log(f/s)/e,o=function(t){return[u+t*d,l+t*p,s*Math.exp(e*t*a)]};else{var g=Math.sqrt(y),m=(f*f-s*s+r*y)/(2*s*n*g),v=(f*f-s*s-r*y)/(2*f*n*g),x=Math.log(Math.sqrt(m*m+1)-m);a=(Math.log(Math.sqrt(v*v+1)-v)-x)/e,o=function(t){var r,i,o=t*a,c=tM(x),h=s/(n*g)*(c*(((r=Math.exp(2*(r=e*o+x)))-1)/(r+1))-((i=Math.exp(i=x))-1/i)/2);return[u+h*d,l+h*p,s*c/tM(e*o+x)]}}return o.duration=1e3*a*e/Math.SQRT2,o}return i.rho=function(e){var n=Math.max(.001,+e),r=n*n;return t(n,r,r*r)},i}(Math.SQRT2,2,4);var tk,t$,tA=0,tz=0,tN=0,tS=0,tT=0,tI=0,tP="object"==typeof performance&&performance.now?performance:Date,tH="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function tB(){return tT||(tH(tL),tT=tP.now()+tI)}function tL(){tT=0}function tC(){this._call=this._time=this._next=null}function tO(t,e,n){var r=new tC;return r.restart(t,e,n),r}function tR(){tT=(tS=tP.now())+tI,tA=tz=0;try{tB(),++tA;for(var t,e=tk;e;)(t=tT-e._time)>=0&&e._call.call(void 0,t),e=e._next;--tA}finally{tA=0,function(){for(var t,e,n=tk,r=1/0;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:tk=e);t$=t,tX(r)}(),tT=0}}function tD(){var t=tP.now(),e=t-tS;e>1e3&&(tI-=e,tS=t)}function tX(t){!tA&&(tz&&(tz=clearTimeout(tz)),t-tT>24?(t<1/0&&(tz=setTimeout(tR,t-tP.now()-tI)),tN&&(tN=clearInterval(tN))):(tN||(tS=tP.now(),tN=setInterval(tD,1e3)),tA=1,tH(tR)))}function tj(t,e,n){var r=new tC;return e=null==e?0:+e,r.restart(n=>{r.stop(),t(n+e)},e,n),r}tC.prototype=tO.prototype={constructor:tC,restart:function(t,e,n){if("function"!=typeof t)throw TypeError("callback is not a function");n=(null==n?tB():+n)+(null==e?0:+e),this._next||t$===this||(t$?t$._next=this:tk=this,t$=this),this._call=t,this._time=n,tX()},stop:function(){this._call&&(this._call=null,this._time=1/0,tX())}};var tq=x("start","end","cancel","interrupt"),tY=[];function tV(t,e,n,r,i,o){var a=t.__transition;if(a){if(n in a)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function o(l){var s,c,h,f;if(1!==n.state)return u();for(s in i)if((f=i[s]).name===n.name){if(3===f.state)return tj(o);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete i[s]):+s<e&&(f.state=6,f.timer.stop(),f.on.call("cancel",t,t.__data__,f.index,f.group),delete i[s])}if(tj(function(){3===n.state&&(n.state=4,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=2,n.on.call("start",t,t.__data__,n.index,n.group),2===n.state){for(n.state=3,r=Array(h=n.tween.length),s=0,c=-1;s<h;++s)(f=n.tween[s].value.call(t,t.__data__,n.index,n.group))&&(r[++c]=f);r.length=c+1}}function a(e){for(var i=e<n.duration?n.ease.call(null,e/n.duration):(n.timer.restart(u),n.state=5,1),o=-1,a=r.length;++o<a;)r[o].call(t,i);5===n.state&&(n.on.call("end",t,t.__data__,n.index,n.group),u())}function u(){for(var r in n.state=6,n.timer.stop(),delete i[e],i)return;delete t.__transition}i[e]=n,n.timer=tO(function(t){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=t&&o(t-n.delay)},0,n.time)}(t,n,{name:e,index:r,group:i,on:tq,tween:tY,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:0})}function tF(t,e){var n=tW(t,e);if(n.state>0)throw Error("too late; already scheduled");return n}function tK(t,e){var n=tW(t,e);if(n.state>3)throw Error("too late; already running");return n}function tW(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw Error("transition not found");return n}function tU(t,e){var n,r,i,o=t.__transition,a=!0;if(o){for(i in e=null==e?null:e+"",o){if((n=o[i]).name!==e){a=!1;continue}r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete o[i]}a&&delete t.__transition}}function tZ(t,e){return t*=1,e*=1,function(n){return t*(1-n)+e*n}}var tQ=180/Math.PI,tG={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function tJ(t,e,n,r,i,o){var a,u,l;return(a=Math.sqrt(t*t+e*e))&&(t/=a,e/=a),(l=t*n+e*r)&&(n-=t*l,r-=e*l),(u=Math.sqrt(n*n+r*r))&&(n/=u,r/=u,l/=u),t*r<e*n&&(t=-t,e=-e,l=-l,a=-a),{translateX:i,translateY:o,rotate:Math.atan2(e,t)*tQ,skewX:Math.atan(l)*tQ,scaleX:a,scaleY:u}}function t0(t,e,n,r){function i(t){return t.length?t.pop()+" ":""}return function(o,a){var u,l,s,c,h=[],f=[];return o=t(o),a=t(a),!function(t,r,i,o,a,u){if(t!==i||r!==o){var l=a.push("translate(",null,e,null,n);u.push({i:l-4,x:tZ(t,i)},{i:l-2,x:tZ(r,o)})}else(i||o)&&a.push("translate("+i+e+o+n)}(o.translateX,o.translateY,a.translateX,a.translateY,h,f),u=o.rotate,l=a.rotate,u!==l?(u-l>180?l+=360:l-u>180&&(u+=360),f.push({i:h.push(i(h)+"rotate(",null,r)-2,x:tZ(u,l)})):l&&h.push(i(h)+"rotate("+l+r),s=o.skewX,c=a.skewX,s!==c?f.push({i:h.push(i(h)+"skewX(",null,r)-2,x:tZ(s,c)}):c&&h.push(i(h)+"skewX("+c+r),!function(t,e,n,r,o,a){if(t!==n||e!==r){var u=o.push(i(o)+"scale(",null,",",null,")");a.push({i:u-4,x:tZ(t,n)},{i:u-2,x:tZ(e,r)})}else(1!==n||1!==r)&&o.push(i(o)+"scale("+n+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,h,f),o=a=null,function(t){for(var e,n=-1,r=f.length;++n<r;)h[(e=f[n]).i]=e.x(t);return h.join("")}}}var t1=t0(function(t){let e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?tG:tJ(e.a,e.b,e.c,e.d,e.e,e.f)},"px, ","px)","deg)"),t2=t0(function(t){return null==t?tG:(c||(c=document.createElementNS("http://www.w3.org/2000/svg","g")),c.setAttribute("transform",t),t=c.transform.baseVal.consolidate())?tJ((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):tG},", ",")",")");function t5(t,e,n){var r=t._id;return t.each(function(){var t=tK(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)}),function(t){return tW(t,r).value[e]}}function t3(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function t8(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function t4(){}var t6="\\s*([+-]?\\d+)\\s*",t9="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",t7="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",et=/^#([0-9a-f]{3,8})$/,ee=RegExp(`^rgb\\(${t6},${t6},${t6}\\)$`),en=RegExp(`^rgb\\(${t7},${t7},${t7}\\)$`),er=RegExp(`^rgba\\(${t6},${t6},${t6},${t9}\\)$`),ei=RegExp(`^rgba\\(${t7},${t7},${t7},${t9}\\)$`),eo=RegExp(`^hsl\\(${t9},${t7},${t7}\\)$`),ea=RegExp(`^hsla\\(${t9},${t7},${t7},${t9}\\)$`),eu={aliceblue:0xf0f8ff,antiquewhite:0xfaebd7,aqua:65535,aquamarine:8388564,azure:0xf0ffff,beige:0xf5f5dc,bisque:0xffe4c4,black:0,blanchedalmond:0xffebcd,blue:255,blueviolet:9055202,brown:0xa52a2a,burlywood:0xdeb887,cadetblue:6266528,chartreuse:8388352,chocolate:0xd2691e,coral:0xff7f50,cornflowerblue:6591981,cornsilk:0xfff8dc,crimson:0xdc143c,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:0xb8860b,darkgray:0xa9a9a9,darkgreen:25600,darkgrey:0xa9a9a9,darkkhaki:0xbdb76b,darkmagenta:9109643,darkolivegreen:5597999,darkorange:0xff8c00,darkorchid:0x9932cc,darkred:9109504,darksalmon:0xe9967a,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:0xff1493,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:0xb22222,floralwhite:0xfffaf0,forestgreen:2263842,fuchsia:0xff00ff,gainsboro:0xdcdcdc,ghostwhite:0xf8f8ff,gold:0xffd700,goldenrod:0xdaa520,gray:8421504,green:32768,greenyellow:0xadff2f,grey:8421504,honeydew:0xf0fff0,hotpink:0xff69b4,indianred:0xcd5c5c,indigo:4915330,ivory:0xfffff0,khaki:0xf0e68c,lavender:0xe6e6fa,lavenderblush:0xfff0f5,lawngreen:8190976,lemonchiffon:0xfffacd,lightblue:0xadd8e6,lightcoral:0xf08080,lightcyan:0xe0ffff,lightgoldenrodyellow:0xfafad2,lightgray:0xd3d3d3,lightgreen:9498256,lightgrey:0xd3d3d3,lightpink:0xffb6c1,lightsalmon:0xffa07a,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:0xb0c4de,lightyellow:0xffffe0,lime:65280,limegreen:3329330,linen:0xfaf0e6,magenta:0xff00ff,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:0xba55d3,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:0xc71585,midnightblue:1644912,mintcream:0xf5fffa,mistyrose:0xffe4e1,moccasin:0xffe4b5,navajowhite:0xffdead,navy:128,oldlace:0xfdf5e6,olive:8421376,olivedrab:7048739,orange:0xffa500,orangered:0xff4500,orchid:0xda70d6,palegoldenrod:0xeee8aa,palegreen:0x98fb98,paleturquoise:0xafeeee,palevioletred:0xdb7093,papayawhip:0xffefd5,peachpuff:0xffdab9,peru:0xcd853f,pink:0xffc0cb,plum:0xdda0dd,powderblue:0xb0e0e6,purple:8388736,rebeccapurple:6697881,red:0xff0000,rosybrown:0xbc8f8f,royalblue:4286945,saddlebrown:9127187,salmon:0xfa8072,sandybrown:0xf4a460,seagreen:3050327,seashell:0xfff5ee,sienna:0xa0522d,silver:0xc0c0c0,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:0xfffafa,springgreen:65407,steelblue:4620980,tan:0xd2b48c,teal:32896,thistle:0xd8bfd8,tomato:0xff6347,turquoise:4251856,violet:0xee82ee,wheat:0xf5deb3,white:0xffffff,whitesmoke:0xf5f5f5,yellow:0xffff00,yellowgreen:0x9acd32};function el(){return this.rgb().formatHex()}function es(){return this.rgb().formatRgb()}function ec(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=et.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?eh(e):3===n?new ep(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?ef(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?ef(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=ee.exec(t))?new ep(e[1],e[2],e[3],1):(e=en.exec(t))?new ep(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=er.exec(t))?ef(e[1],e[2],e[3],e[4]):(e=ei.exec(t))?ef(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=eo.exec(t))?ew(e[1],e[2]/100,e[3]/100,1):(e=ea.exec(t))?ew(e[1],e[2]/100,e[3]/100,e[4]):eu.hasOwnProperty(t)?eh(eu[t]):"transparent"===t?new ep(NaN,NaN,NaN,0):null}function eh(t){return new ep(t>>16&255,t>>8&255,255&t,1)}function ef(t,e,n,r){return r<=0&&(t=e=n=NaN),new ep(t,e,n,r)}function ed(t,e,n,r){var i;return 1==arguments.length?((i=t)instanceof t4||(i=ec(i)),i)?new ep((i=i.rgb()).r,i.g,i.b,i.opacity):new ep:new ep(t,e,n,null==r?1:r)}function ep(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function ey(){return`#${ex(this.r)}${ex(this.g)}${ex(this.b)}`}function eg(){let t=em(this.opacity);return`${1===t?"rgb(":"rgba("}${ev(this.r)}, ${ev(this.g)}, ${ev(this.b)}${1===t?")":`, ${t})`}`}function em(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ev(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ex(t){return((t=ev(t))<16?"0":"")+t.toString(16)}function ew(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new eb(t,e,n,r)}function e_(t){if(t instanceof eb)return new eb(t.h,t.s,t.l,t.opacity);if(t instanceof t4||(t=ec(t)),!t)return new eb;if(t instanceof eb)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),a=NaN,u=o-i,l=(o+i)/2;return u?(a=e===o?(n-r)/u+(n<r)*6:n===o?(r-e)/u+2:(e-n)/u+4,u/=l<.5?o+i:2-o-i,a*=60):u=l>0&&l<1?0:a,new eb(a,u,l,t.opacity)}function eb(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function eM(t){return(t=(t||0)%360)<0?t+360:t}function eE(t){return Math.max(0,Math.min(1,t||0))}function ek(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}function e$(t,e,n,r,i){var o=t*t,a=o*t;return((1-3*t+3*o-a)*e+(4-6*o+3*a)*n+(1+3*t+3*o-3*a)*r+a*i)/6}t3(t4,ec,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:el,formatHex:el,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return e_(this).formatHsl()},formatRgb:es,toString:es}),t3(ep,ed,t8(t4,{brighter(t){return t=null==t?1.4285714285714286:Math.pow(1.4285714285714286,t),new ep(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?.7:Math.pow(.7,t),new ep(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new ep(ev(this.r),ev(this.g),ev(this.b),em(this.opacity))},displayable(){return -.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ey,formatHex:ey,formatHex8:function(){return`#${ex(this.r)}${ex(this.g)}${ex(this.b)}${ex((isNaN(this.opacity)?1:this.opacity)*255)}`},formatRgb:eg,toString:eg})),t3(eb,function(t,e,n,r){return 1==arguments.length?e_(t):new eb(t,e,n,null==r?1:r)},t8(t4,{brighter(t){return t=null==t?1.4285714285714286:Math.pow(1.4285714285714286,t),new eb(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?.7:Math.pow(.7,t),new eb(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new ep(ek(t>=240?t-240:t+120,i,r),ek(t,i,r),ek(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new eb(eM(this.h),eE(this.s),eE(this.l),em(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let t=em(this.opacity);return`${1===t?"hsl(":"hsla("}${eM(this.h)}, ${100*eE(this.s)}%, ${100*eE(this.l)}%${1===t?")":`, ${t})`}`}}));let eA=t=>()=>t;function ez(t,e){var n=e-t;return n?function(e){return t+e*n}:eA(isNaN(t)?e:t)}let eN=function t(e){var n,r=1==(n=+e)?ez:function(t,e){var r,i,o;return e-t?(r=t,i=e,r=Math.pow(r,o=n),i=Math.pow(i,o)-r,o=1/o,function(t){return Math.pow(r+t*i,o)}):eA(isNaN(t)?e:t)};function i(t,e){var n=r((t=ed(t)).r,(e=ed(e)).r),i=r(t.g,e.g),o=r(t.b,e.b),a=ez(t.opacity,e.opacity);return function(e){return t.r=n(e),t.g=i(e),t.b=o(e),t.opacity=a(e),t+""}}return i.gamma=t,i}(1);function eS(t){return function(e){var n,r,i=e.length,o=Array(i),a=Array(i),u=Array(i);for(n=0;n<i;++n)r=ed(e[n]),o[n]=r.r||0,a[n]=r.g||0,u[n]=r.b||0;return o=t(o),a=t(a),u=t(u),r.opacity=1,function(t){return r.r=o(t),r.g=a(t),r.b=u(t),r+""}}}eS(function(t){var e=t.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,e-1):Math.floor(n*e),i=t[r],o=t[r+1],a=r>0?t[r-1]:2*i-o,u=r<e-1?t[r+2]:2*o-i;return e$((n-r/e)*e,a,i,o,u)}}),eS(function(t){var e=t.length;return function(n){var r=Math.floor(((n%=1)<0?++n:n)*e),i=t[(r+e-1)%e],o=t[r%e],a=t[(r+1)%e],u=t[(r+2)%e];return e$((n-r/e)*e,i,o,a,u)}});var eT=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,eI=RegExp(eT.source,"g");function eP(t,e){var n,r,i,o,a,u=eT.lastIndex=eI.lastIndex=0,l=-1,s=[],c=[];for(t+="",e+="";(i=eT.exec(t))&&(o=eI.exec(e));)(a=o.index)>u&&(a=e.slice(u,a),s[l]?s[l]+=a:s[++l]=a),(i=i[0])===(o=o[0])?s[l]?s[l]+=o:s[++l]=o:(s[++l]=null,c.push({i:l,x:tZ(i,o)})),u=eI.lastIndex;return u<e.length&&(a=e.slice(u),s[l]?s[l]+=a:s[++l]=a),s.length<2?c[0]?(n=c[0].x,function(t){return n(t)+""}):(r=e,function(){return r}):(e=c.length,function(t){for(var n,r=0;r<e;++r)s[(n=c[r]).i]=n.x(t);return s.join("")})}function eH(t,e){var n;return("number"==typeof e?tZ:e instanceof ec?eN:(n=ec(e))?(e=n,eN):eP)(t,e)}var eB=tl.prototype.constructor;function eL(t){return function(){this.style.removeProperty(t)}}var eC=0;function eO(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}var eR=tl.prototype;eO.prototype=(function(t){return tl().transition(t)}).prototype={constructor:eO,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=M(t));for(var r=this._groups,i=r.length,o=Array(i),a=0;a<i;++a)for(var u,l,s=r[a],c=s.length,h=o[a]=Array(c),f=0;f<c;++f)(u=s[f])&&(l=t.call(u,u.__data__,f,s))&&("__data__"in u&&(l.__data__=u.__data__),h[f]=l,tV(h[f],e,n,f,h,tW(u,n)));return new eO(o,this._parents,e,n)},selectAll:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=k(t));for(var r=this._groups,i=r.length,o=[],a=[],u=0;u<i;++u)for(var l,s=r[u],c=s.length,h=0;h<c;++h)if(l=s[h]){for(var f,d=t.call(l,l.__data__,h,s),p=tW(l,n),y=0,g=d.length;y<g;++y)(f=d[y])&&tV(f,e,n,y,d,p);o.push(d),a.push(l)}return new eO(o,a,e,n)},selectChild:eR.selectChild,selectChildren:eR.selectChildren,filter:function(t){"function"!=typeof t&&(t=$(t));for(var e=this._groups,n=e.length,r=Array(n),i=0;i<n;++i)for(var o,a=e[i],u=a.length,l=r[i]=[],s=0;s<u;++s)(o=a[s])&&t.call(o,o.__data__,s,a)&&l.push(o);return new eO(r,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw Error();for(var e=this._groups,n=t._groups,r=e.length,i=n.length,o=Math.min(r,i),a=Array(r),u=0;u<o;++u)for(var l,s=e[u],c=n[u],h=s.length,f=a[u]=Array(h),d=0;d<h;++d)(l=s[d]||c[d])&&(f[d]=l);for(;u<r;++u)a[u]=e[u];return new eO(a,this._parents,this._name,this._id)},selection:function(){return new eB(this._groups,this._parents)},transition:function(){for(var t=this._name,e=this._id,n=++eC,r=this._groups,i=r.length,o=0;o<i;++o)for(var a,u=r[o],l=u.length,s=0;s<l;++s)if(a=u[s]){var c=tW(a,e);tV(a,t,n,s,u,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new eO(r,this._parents,t,n)},call:eR.call,nodes:eR.nodes,node:eR.node,size:eR.size,empty:eR.empty,each:eR.each,on:function(t,e){var n,r,i,o,a,u,l=this._id;return arguments.length<2?tW(this.node(),l).on.on(t):this.each((n=l,r=t,i=e,u=(r+"").trim().split(/^|\s+/).every(function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||"start"===t})?tF:tK,function(){var t=u(this,n),e=t.on;e!==o&&(a=(o=e).copy()).on(r,i),t.on=a}))},attr:function(t,e){var n=D(t),r="transform"===n?t2:eH;return this.attrTween(t,"function"==typeof e?(n.local?function(t,e,n){var r,i,o;return function(){var a,u,l=n(this);return null==l?void this.removeAttributeNS(t.space,t.local):(a=this.getAttributeNS(t.space,t.local))===(u=l+"")?null:a===r&&u===i?o:(i=u,o=e(r=a,l))}}:function(t,e,n){var r,i,o;return function(){var a,u,l=n(this);return null==l?void this.removeAttribute(t):(a=this.getAttribute(t))===(u=l+"")?null:a===r&&u===i?o:(i=u,o=e(r=a,l))}})(n,r,t5(this,"attr."+t,e)):null==e?(n.local?function(t){return function(){this.removeAttributeNS(t.space,t.local)}}:function(t){return function(){this.removeAttribute(t)}})(n):(n.local?function(t,e,n){var r,i,o=n+"";return function(){var a=this.getAttributeNS(t.space,t.local);return a===o?null:a===r?i:i=e(r=a,n)}}:function(t,e,n){var r,i,o=n+"";return function(){var a=this.getAttribute(t);return a===o?null:a===r?i:i=e(r=a,n)}})(n,r,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw Error();var r=D(t);return this.tween(n,(r.local?function(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(e){this.setAttributeNS(t.space,t.local,i.call(this,e))}),n}return i._value=e,i}:function(t,e){var n,r;function i(){var i=e.apply(this,arguments);return i!==r&&(n=(r=i)&&function(e){this.setAttribute(t,i.call(this,e))}),n}return i._value=e,i})(r,e))},style:function(t,e,n){var r,i,o,a,u,l,s,c,h,f,d,p,y,g,m,v,x,w,_,b,M,E="transform"==(t+="")?t1:eH;return null==e?this.styleTween(t,(r=t,function(){var t=j(this,r),e=(this.style.removeProperty(r),j(this,r));return t===e?null:t===i&&e===o?a:a=E(i=t,o=e)})).on("end.style."+t,eL(t)):"function"==typeof e?this.styleTween(t,(u=t,l=t5(this,"style."+t,e),function(){var t=j(this,u),e=l(this),n=e+"";return null==e&&(this.style.removeProperty(u),n=e=j(this,u)),t===n?null:t===s&&n===c?h:(c=n,h=E(s=t,e))})).each((f=this._id,x="end."+(v="style."+(d=t)),function(){var t=tK(this,f),e=t.on,n=null==t.value[v]?m||(m=eL(d)):void 0;(e!==p||g!==n)&&(y=(p=e).copy()).on(x,g=n),t.on=y})):this.styleTween(t,(w=t,M=e+"",function(){var t=j(this,w);return t===M?null:t===_?b:b=E(_=t,e)}),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw Error();return this.tween(r,function(t,e,n){var r,i;function o(){var o=e.apply(this,arguments);return o!==i&&(r=(i=o)&&function(e){this.style.setProperty(t,o.call(this,e),n)}),r}return o._value=e,o}(t,e,null==n?"":n))},text:function(t){var e,n;return this.tween("text","function"==typeof t?(e=t5(this,"text",t),function(){var t=e(this);this.textContent=null==t?"":t}):(n=null==t?"":t+"",function(){this.textContent=n}))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw Error();return this.tween(e,function(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&function(t){this.textContent=r.call(this,t)}),e}return r._value=t,r}(t))},remove:function(){var t;return this.on("end.remove",(t=this._id,function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,i=tW(this.node(),n).tween,o=0,a=i.length;o<a;++o)if((r=i[o]).name===t)return r.value;return null}return this.each((null==e?function(t,e){var n,r;return function(){var i=tK(this,t),o=i.tween;if(o!==n){r=n=o;for(var a=0,u=r.length;a<u;++a)if(r[a].name===e){(r=r.slice()).splice(a,1);break}}i.tween=r}}:function(t,e,n){var r,i;if("function"!=typeof n)throw Error();return function(){var o=tK(this,t),a=o.tween;if(a!==r){i=(r=a).slice();for(var u={name:e,value:n},l=0,s=i.length;l<s;++l)if(i[l].name===e){i[l]=u;break}l===s&&i.push(u)}o.tween=i}})(n,t,e))},delay:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?function(t,e){return function(){tF(this,t).delay=+e.apply(this,arguments)}}:function(t,e){return e*=1,function(){tF(this,t).delay=e}})(e,t)):tW(this.node(),e).delay},duration:function(t){var e=this._id;return arguments.length?this.each(("function"==typeof t?function(t,e){return function(){tK(this,t).duration=+e.apply(this,arguments)}}:function(t,e){return e*=1,function(){tK(this,t).duration=e}})(e,t)):tW(this.node(),e).duration},ease:function(t){var e=this._id;return arguments.length?this.each(function(t,e){if("function"!=typeof e)throw Error();return function(){tK(this,t).ease=e}}(e,t)):tW(this.node(),e).ease},easeVarying:function(t){var e;if("function"!=typeof t)throw Error();return this.each((e=this._id,function(){var n=t.apply(this,arguments);if("function"!=typeof n)throw Error();tK(this,e).ease=n}))},end:function(){var t,e,n=this,r=n._id,i=n.size();return new Promise(function(o,a){var u={value:a},l={value:function(){0==--i&&o()}};n.each(function(){var n=tK(this,r),i=n.on;i!==t&&((e=(t=i).copy())._.cancel.push(u),e._.interrupt.push(u),e._.end.push(l)),n.on=e}),0===i&&o()})},[Symbol.iterator]:eR[Symbol.iterator]};var eD={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};tl.prototype.interrupt=function(t){return this.each(function(){tU(this,t)})},tl.prototype.transition=function(t){var e,n;t instanceof eO?(e=t._id,t=t._name):(e=++eC,(n=eD).time=tB(),t=null==t?null:t+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var a,u=r[o],l=u.length,s=0;s<l;++s)(a=u[s])&&tV(a,t,e,s,u,n||function(t,e){for(var n;!(n=t.__transition)||!(n=n[e]);)if(!(t=t.parentNode))throw Error(`transition ${e} not found`);return n}(a,e));return new eO(r,this._parents,t,e)};let eX=t=>()=>t;function ej(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function eq(t,e,n){this.k=t,this.x=e,this.y=n}eq.prototype={constructor:eq,scale:function(t){return 1===t?this:new eq(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new eq(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var eY=new eq(1,0,0);function eV(t){for(;!t.__zoom;)if(!(t=t.parentNode))return eY;return t.__zoom}function eF(t){t.stopImmediatePropagation()}function eK(t){t.preventDefault(),t.stopImmediatePropagation()}function eW(t){return(!t.ctrlKey||"wheel"===t.type)&&!t.button}function eU(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function eZ(){return this.__zoom||eY}function eQ(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function eG(){return navigator.maxTouchPoints||"ontouchstart"in this}function eJ(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],a=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function e0(){var t,e,n,r=eW,i=eU,o=eJ,a=eQ,u=eG,l=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],c=250,h=tE,f=x("start","zoom","end"),d=0,p=10;function y(t){t.property("__zoom",eZ).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",E).on("dblclick.zoom",k).filter(u).on("touchstart.zoom",$).on("touchmove.zoom",A).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(t,e){return(e=Math.max(l[0],Math.min(l[1],e)))===t.k?t:new eq(e,t.x,t.y)}function m(t,e,n){var r=e[0]-n[0]*t.k,i=e[1]-n[1]*t.k;return r===t.x&&i===t.y?t:new eq(t.k,r,i)}function v(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function w(t,e,n,r){t.on("start.zoom",function(){_(this,arguments).event(r).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(r).end()}).tween("zoom",function(){var t=arguments,o=_(this,t).event(r),a=i.apply(this,t),u=null==n?v(a):"function"==typeof n?n.apply(this,t):n,l=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),s=this.__zoom,c="function"==typeof e?e.apply(this,t):e,f=h(s.invert(u).concat(l/s.k),c.invert(u).concat(l/c.k));return function(t){if(1===t)t=c;else{var e=f(t),n=l/e[2];t=new eq(n,u[0]-e[0]*n,u[1]-e[1]*n)}o.zoom(null,t)}})}function _(t,e,n){return!n&&t.__zooming||new b(t,e)}function b(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,e),this.taps=0}function M(t,...e){if(r.apply(this,arguments)){var n=_(this,e).event(t),i=this.__zoom,u=Math.max(l[0],Math.min(l[1],i.k*Math.pow(2,a.apply(this,arguments)))),c=tc(t);if(n.wheel)(n.mouse[0][0]!==c[0]||n.mouse[0][1]!==c[1])&&(n.mouse[1]=i.invert(n.mouse[0]=c)),clearTimeout(n.wheel);else{if(i.k===u)return;n.mouse=[c,i.invert(c)],tU(this),n.start()}eK(t),n.wheel=setTimeout(function(){n.wheel=null,n.end()},150),n.zoom("mouse",o(m(g(i,u),n.mouse[0],n.mouse[1]),n.extent,s))}}function E(t,...e){if(!n&&r.apply(this,arguments)){var i=t.currentTarget,a=_(this,e,!0).event(t),u=ts(t.view).on("mousemove.zoom",function(t){if(eK(t),!a.moved){var e=t.clientX-c,n=t.clientY-h;a.moved=e*e+n*n>d}a.event(t).zoom("mouse",o(m(a.that.__zoom,a.mouse[0]=tc(t,i),a.mouse[1]),a.extent,s))},!0).on("mouseup.zoom",function(t){u.on("mousemove.zoom mouseup.zoom",null),tg(t.view,a.moved),eK(t),a.event(t).end()},!0),l=tc(t,i),c=t.clientX,h=t.clientY;ty(t.view),eF(t),a.mouse=[l,this.__zoom.invert(l)],tU(this),a.start()}}function k(t,...e){if(r.apply(this,arguments)){var n=this.__zoom,a=tc(t.changedTouches?t.changedTouches[0]:t,this),u=n.invert(a),l=n.k*(t.shiftKey?.5:2),h=o(m(g(n,l),a,u),i.apply(this,e),s);eK(t),c>0?ts(this).transition().duration(c).call(w,h,a,t):ts(this).call(y.transform,h,a,t)}}function $(n,...i){if(r.apply(this,arguments)){var o,a,u,l,s=n.touches,c=s.length,h=_(this,i,n.changedTouches.length===c).event(n);for(eF(n),a=0;a<c;++a)l=[l=tc(u=s[a],this),this.__zoom.invert(l),u.identifier],h.touch0?h.touch1||h.touch0[2]===l[2]||(h.touch1=l,h.taps=0):(h.touch0=l,o=!0,h.taps=1+!!t);t&&(t=clearTimeout(t)),o&&(h.taps<2&&(e=l[0],t=setTimeout(function(){t=null},500)),tU(this),h.start())}}function A(t,...e){if(this.__zooming){var n,r,i,a,u=_(this,e).event(t),l=t.changedTouches,c=l.length;for(eK(t),n=0;n<c;++n)i=tc(r=l[n],this),u.touch0&&u.touch0[2]===r.identifier?u.touch0[0]=i:u.touch1&&u.touch1[2]===r.identifier&&(u.touch1[0]=i);if(r=u.that.__zoom,u.touch1){var h=u.touch0[0],f=u.touch0[1],d=u.touch1[0],p=u.touch1[1],y=(y=d[0]-h[0])*y+(y=d[1]-h[1])*y,v=(v=p[0]-f[0])*v+(v=p[1]-f[1])*v;r=g(r,Math.sqrt(y/v)),i=[(h[0]+d[0])/2,(h[1]+d[1])/2],a=[(f[0]+p[0])/2,(f[1]+p[1])/2]}else{if(!u.touch0)return;i=u.touch0[0],a=u.touch0[1]}u.zoom("touch",o(m(r,i,a),u.extent,s))}}function z(t,...r){if(this.__zooming){var i,o,a=_(this,r).event(t),u=t.changedTouches,l=u.length;for(eF(t),n&&clearTimeout(n),n=setTimeout(function(){n=null},500),i=0;i<l;++i)o=u[i],a.touch0&&a.touch0[2]===o.identifier?delete a.touch0:a.touch1&&a.touch1[2]===o.identifier&&delete a.touch1;if(a.touch1&&!a.touch0&&(a.touch0=a.touch1,delete a.touch1),a.touch0)a.touch0[1]=this.__zoom.invert(a.touch0[0]);else if(a.end(),2===a.taps&&(o=tc(o,this),Math.hypot(e[0]-o[0],e[1]-o[1])<p)){var s=ts(this).on("dblclick.zoom");s&&s.apply(this,arguments)}}}return y.transform=function(t,e,n,r){var i=t.selection?t.selection():t;i.property("__zoom",eZ),t!==i?w(t,e,n,r):i.interrupt().each(function(){_(this,arguments).event(r).start().zoom(null,"function"==typeof e?e.apply(this,arguments):e).end()})},y.scaleBy=function(t,e,n,r){y.scaleTo(t,function(){var t=this.__zoom.k,n="function"==typeof e?e.apply(this,arguments):e;return t*n},n,r)},y.scaleTo=function(t,e,n,r){y.transform(t,function(){var t=i.apply(this,arguments),r=this.__zoom,a=null==n?v(t):"function"==typeof n?n.apply(this,arguments):n,u=r.invert(a),l="function"==typeof e?e.apply(this,arguments):e;return o(m(g(r,l),a,u),t,s)},n,r)},y.translateBy=function(t,e,n,r){y.transform(t,function(){return o(this.__zoom.translate("function"==typeof e?e.apply(this,arguments):e,"function"==typeof n?n.apply(this,arguments):n),i.apply(this,arguments),s)},null,r)},y.translateTo=function(t,e,n,r,a){y.transform(t,function(){var t=i.apply(this,arguments),a=this.__zoom,u=null==r?v(t):"function"==typeof r?r.apply(this,arguments):r;return o(eY.translate(u[0],u[1]).scale(a.k).translate("function"==typeof e?-e.apply(this,arguments):-e,"function"==typeof n?-n.apply(this,arguments):-n),t,s)},r,a)},b.prototype={event:function(t){return t&&(this.sourceEvent=t),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(t,e){return this.mouse&&"mouse"!==t&&(this.mouse[1]=e.invert(this.mouse[0])),this.touch0&&"touch"!==t&&(this.touch0[1]=e.invert(this.touch0[0])),this.touch1&&"touch"!==t&&(this.touch1[1]=e.invert(this.touch1[0])),this.that.__zoom=e,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(t){var e=ts(this.that).datum();f.call(t,this.that,new ej(t,{sourceEvent:this.sourceEvent,target:y,type:t,transform:this.that.__zoom,dispatch:f}),e)}},y.wheelDelta=function(t){return arguments.length?(a="function"==typeof t?t:eX(+t),y):a},y.filter=function(t){return arguments.length?(r="function"==typeof t?t:eX(!!t),y):r},y.touchable=function(t){return arguments.length?(u="function"==typeof t?t:eX(!!t),y):u},y.extent=function(t){return arguments.length?(i="function"==typeof t?t:eX([[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]]),y):i},y.scaleExtent=function(t){return arguments.length?(l[0]=+t[0],l[1]=+t[1],y):[l[0],l[1]]},y.translateExtent=function(t){return arguments.length?(s[0][0]=+t[0][0],s[1][0]=+t[1][0],s[0][1]=+t[0][1],s[1][1]=+t[1][1],y):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},y.constrain=function(t){return arguments.length?(o=t,y):o},y.duration=function(t){return arguments.length?(c=+t,y):c},y.interpolate=function(t){return arguments.length?(h=t,y):h},y.on=function(){var t=f.on.apply(f,arguments);return t===f?y:t},y.clickDistance=function(t){return arguments.length?(d=(t*=1)*t,y):Math.sqrt(d)},y.tapDistance=function(t){return arguments.length?(p=+t,y):p},y}function e1(t,e){var n,r,i=typeof e;return null==e||"boolean"===i?eA(e):("number"===i?tZ:"string"===i?(r=ec(e))?(e=r,eN):eP:e instanceof ec?eN:e instanceof Date?function(t,e){var n=new Date;return t*=1,e*=1,function(r){return n.setTime(t*(1-r)+e*r),n}}:!ArrayBuffer.isView(n=e)||n instanceof DataView?Array.isArray(e)?function(t,e){var n,r=e?e.length:0,i=t?Math.min(r,t.length):0,o=Array(i),a=Array(r);for(n=0;n<i;++n)o[n]=e1(t[n],e[n]);for(;n<r;++n)a[n]=e[n];return function(t){for(n=0;n<i;++n)a[n]=o[n](t);return a}}:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?function(t,e){var n,r={},i={};for(n in(null===t||"object"!=typeof t)&&(t={}),(null===e||"object"!=typeof e)&&(e={}),e)n in t?r[n]=e1(t[n],e[n]):i[n]=e[n];return function(t){for(n in r)i[n]=r[n](t);return i}}:tZ:function(t,e){e||(e=[]);var n,r=t?Math.min(e.length,t.length):0,i=e.slice();return function(o){for(n=0;n<r;++n)i[n]=t[n]*(1-o)+e[n]*o;return i}})(t,e)}eV.prototype=eq.prototype;let e2={error001:(t="react")=>`Seems like you have not used ${"svelte"===t?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:e,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${t} handle id: "${"source"===t?n:r}", edge id: ${e}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},e5=[[-1/0,-1/0],[1/0,1/0]],e3=["Enter"," ","Escape"],e8={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:e,y:n})=>`Moved selected node ${t}. New position, x: ${e}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};(r=h||(h={})).Strict="strict",r.Loose="loose",(i=f||(f={})).Free="free",i.Vertical="vertical",i.Horizontal="horizontal",(o=d||(d={})).Partial="partial",o.Full="full";let e4={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};(a=p||(p={})).Bezier="default",a.Straight="straight",a.Step="step",a.SmoothStep="smoothstep",a.SimpleBezier="simplebezier",(u=y||(y={})).Arrow="arrow",u.ArrowClosed="arrowclosed",(l=g||(g={})).Left="left",l.Top="top",l.Right="right",l.Bottom="bottom";let e6={[g.Left]:g.Right,[g.Right]:g.Left,[g.Top]:g.Bottom,[g.Bottom]:g.Top},e9=t=>!!t&&"object"==typeof t&&"id"in t&&"source"in t&&"target"in t,e7=t=>!!t&&"object"==typeof t&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),nt=t=>!!t&&"object"==typeof t&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),ne=(t,e=[0,0])=>{let{width:n,height:r}=nT(t),i=t.origin??e,o=n*i[0],a=r*i[1];return{x:t.position.x-o,y:t.position.y-a}},nn=(t,e={nodeOrigin:[0,0]})=>{if(0===t.length)return{x:0,y:0,width:0,height:0};let n=!1,r=t.reduce((t,r)=>{let i="string"==typeof r,o=e.nodeLookup||i?void 0:r;return(e.nodeLookup&&(o=i?e.nodeLookup.get(r):nt(r)?r:e.nodeLookup.get(r.id)),o)?(n=!0,nd(t,nm(o,e.nodeOrigin))):t},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?ny(r):{x:0,y:0,width:0,height:0}},nr=(t,e={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return t.forEach(t=>{(void 0===e.filter||e.filter(t))&&(n=nd(n,nm(t)),r=!0)}),r?ny(n):{x:0,y:0,width:0,height:0}},ni=(t,e,[n,r,i]=[0,0,1],o=!1,a=!1)=>{let u=(e.x-n)/i,l=(e.y-r)/i,s=e.width/i,c=e.height/i,h=[];for(let e of t.values()){let{measured:t,selectable:n=!0,hidden:r=!1}=e;if(a&&!n||r)continue;let i=t.width??e.width??e.initialWidth??0,f=t.height??e.height??e.initialHeight??0,{x:d,y:p}=e.internals.positionAbsolute,y=nx(u,l,s,c,d,p,i,f),g=i*f,m=o&&y>0;(!e.internals.handleBounds||m||y>=g||e.dragging)&&h.push(e)}return h};async function no({nodes:t,width:e,height:n,panZoom:r,minZoom:i,maxZoom:o},a){let u,l;if(0===t.size)return!0;let s=nz(nr((u=new Map,l=a?.nodes?new Set(a.nodes.map(t=>t.id)):null,t.forEach(t=>{let e;if(a?.includeHiddenNodes){let{width:n,height:r}=nT(t);e=n>0&&r>0}else e=!!(t.measured.width&&t.measured.height&&!t.hidden);e&&(!l||l.has(t.id))&&u.set(t.id,t)}),u)),e,n,a?.minZoom??i,a?.maxZoom??o,a?.padding??.1);return await r.setViewport(s,{duration:a?.duration,ease:a?.ease,interpolate:a?.interpolate}),!0}function na({nodeId:t,nextPosition:e,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:o}){let a=n.get(t),u=a.parentId?n.get(a.parentId):void 0,{x:l,y:s}=u?u.internals.positionAbsolute:{x:0,y:0},c=a.origin??r,h=a.extent||i;if("parent"!==a.extent||a.expandParent)u&&nS(a.extent)&&(h=[[a.extent[0][0]+l,a.extent[0][1]+s],[a.extent[1][0]+l,a.extent[1][1]+s]]);else if(u){let{width:t,height:e}=nT(u);t&&e&&(h=[[l,s],[l+t,s+e]])}else o?.("005",e2.error005());let f=nS(h)?ns(e,h,a.measured):e;return(void 0===a.measured.width||void 0===a.measured.height)&&o?.("015",e2.error015()),{position:{x:f.x-l+(a.measured.width??0)*c[0],y:f.y-s+(a.measured.height??0)*c[1]},positionAbsolute:f}}async function nu({nodesToRemove:t=[],edgesToRemove:e=[],nodes:n,edges:r,onBeforeDelete:i}){let o,a=new Set(t.map(t=>t.id)),u=[];for(let t of n){if(!1===t.deletable)continue;let e=a.has(t.id),n=!e&&t.parentId&&u.find(e=>e.id===t.parentId);(e||n)&&u.push(t)}let l=new Set(e.map(t=>t.id)),s=r.filter(t=>!1!==t.deletable),c=(o=new Set,u.forEach(t=>{o.add(t.id)}),s.filter(t=>o.has(t.source)||o.has(t.target)));for(let t of s)l.has(t.id)&&!c.find(e=>e.id===t.id)&&c.push(t);if(!i)return{edges:c,nodes:u};let h=await i({nodes:u,edges:c});return"boolean"==typeof h?h?{edges:c,nodes:u}:{edges:[],nodes:[]}:h}let nl=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),ns=(t={x:0,y:0},e,n)=>({x:nl(t.x,e[0][0],e[1][0]-(n?.width??0)),y:nl(t.y,e[0][1],e[1][1]-(n?.height??0))});function nc(t,e,n){let{width:r,height:i}=nT(n),{x:o,y:a}=n.internals.positionAbsolute;return ns(t,[[o,a],[o+r,a+i]],e)}let nh=(t,e,n)=>t<e?nl(Math.abs(t-e),1,e)/e:t>n?-nl(Math.abs(t-n),1,e)/e:0,nf=(t,e,n=15,r=40)=>[nh(t.x,r,e.width-r)*n,nh(t.y,r,e.height-r)*n],nd=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x2,e.x2),y2:Math.max(t.y2,e.y2)}),np=({x:t,y:e,width:n,height:r})=>({x:t,y:e,x2:t+n,y2:e+r}),ny=({x:t,y:e,x2:n,y2:r})=>({x:t,y:e,width:n-t,height:r-e}),ng=(t,e=[0,0])=>{let{x:n,y:r}=nt(t)?t.internals.positionAbsolute:ne(t,e);return{x:n,y:r,width:t.measured?.width??t.width??t.initialWidth??0,height:t.measured?.height??t.height??t.initialHeight??0}},nm=(t,e=[0,0])=>{let{x:n,y:r}=nt(t)?t.internals.positionAbsolute:ne(t,e);return{x:n,y:r,x2:n+(t.measured?.width??t.width??t.initialWidth??0),y2:r+(t.measured?.height??t.height??t.initialHeight??0)}},nv=(t,e)=>ny(nd(np(t),np(e))),nx=(t,e,n,r,i,o,a,u)=>Math.ceil(Math.max(0,Math.min(t+n,i+a)-Math.max(t,i))*Math.max(0,Math.min(e+r,o+u)-Math.max(e,o))),nw=(t,e)=>nx(t.x,t.y,t.width,t.height,e.x,e.y,e.width,e.height),n_=t=>nb(t.width)&&nb(t.height)&&nb(t.x)&&nb(t.y),nb=t=>!isNaN(t)&&isFinite(t),nM=(t,e)=>(t,e)=>{},nE=(t,e=[1,1])=>({x:e[0]*Math.round(t.x/e[0]),y:e[1]*Math.round(t.y/e[1])}),nk=({x:t,y:e},[n,r,i],o=!1,a=[1,1])=>{let u={x:(t-n)/i,y:(e-r)/i};return o?nE(u,a):u},n$=({x:t,y:e},[n,r,i])=>({x:t*i+n,y:e*i+r});function nA(t,e){if("number"==typeof t)return Math.floor((e-e/(1+t))*.5);if("string"==typeof t&&t.endsWith("px")){let e=parseFloat(t);if(!Number.isNaN(e))return Math.floor(e)}if("string"==typeof t&&t.endsWith("%")){let n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(e*n*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}let nz=(t,e,n,r,i,o)=>{let a=function(t,e,n){if("string"==typeof t||"number"==typeof t){let r=nA(t,n),i=nA(t,e);return{top:r,right:i,bottom:r,left:i,x:2*i,y:2*r}}if("object"==typeof t){let r=nA(t.top??t.y??0,n),i=nA(t.bottom??t.y??0,n),o=nA(t.left??t.x??0,e),a=nA(t.right??t.x??0,e);return{top:r,right:a,bottom:i,left:o,x:o+a,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}(o,e,n),u=nl(Math.min((e-a.x)/t.width,(n-a.y)/t.height),r,i),l=t.x+t.width/2,s=t.y+t.height/2,c=e/2-l*u,h=n/2-s*u,f=function(t,e,n,r,i,o){let{x:a,y:u}=n$(t,[e,n,r]),{x:l,y:s}=n$({x:t.x+t.width,y:t.y+t.height},[e,n,r]);return{left:Math.floor(a),top:Math.floor(u),right:Math.floor(i-l),bottom:Math.floor(o-s)}}(t,c,h,u,e,n),d={left:Math.min(f.left-a.left,0),top:Math.min(f.top-a.top,0),right:Math.min(f.right-a.right,0),bottom:Math.min(f.bottom-a.bottom,0)};return{x:c-d.left+d.right,y:h-d.top+d.bottom,zoom:u}},nN=()=>"u">typeof navigator&&navigator?.userAgent?.indexOf("Mac")>=0;function nS(t){return null!=t&&"parent"!==t}function nT(t){return{width:t.measured?.width??t.width??t.initialWidth??0,height:t.measured?.height??t.height??t.initialHeight??0}}function nI(t){return(t.measured?.width??t.width??t.initialWidth)!==void 0&&(t.measured?.height??t.height??t.initialHeight)!==void 0}function nP(t,e={width:0,height:0},n,r,i){let o={...t},a=r.get(n);if(a){let t=a.origin||i;o.x+=a.internals.positionAbsolute.x-(e.width??0)*t[0],o.y+=a.internals.positionAbsolute.y-(e.height??0)*t[1]}return o}function nH(t,e){if(t.size!==e.size)return!1;for(let n of t)if(!e.has(n))return!1;return!0}function nB(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}}function nL(t){return{...e8,...t||{}}}function nC(t){}function nO(t){return null===t?null:t?"valid":"invalid"}function nR(t,{snapGrid:e=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:o,y:a}=nV(t),u=nk({x:o-(i?.left??0),y:a-(i?.top??0)},r),{x:l,y:s}=n?nE(u,e):u;return{xSnapped:l,ySnapped:s,...u}}let nD=t=>({width:t.offsetWidth,height:t.offsetHeight}),nX=t=>t?.getRootNode?.()||window?.document,nj=["INPUT","SELECT","TEXTAREA"];function nq(t){let e=t.composedPath?.()?.[0]||t.target;return e?.nodeType===1&&(nj.includes(e.nodeName)||e.hasAttribute("contenteditable")||!!e.closest(".nokey"))}let nY=t=>"clientX"in t,nV=(t,e)=>{let n=nY(t),r=n?t.clientX:t.touches?.[0].clientX,i=n?t.clientY:t.touches?.[0].clientY;return{x:r-(e?.left??0),y:i-(e?.top??0)}},nF=(t,e,n,r,i)=>{let o=e.querySelectorAll(`.${t}`);return o&&o.length?Array.from(o).map(e=>{let o=e.getBoundingClientRect();return{id:e.getAttribute("data-handleid"),type:t,nodeId:i,position:e.getAttribute("data-handlepos"),x:(o.left-n.left)/r,y:(o.top-n.top)/r,...nD(e)}}):null};function nK({sourceX:t,sourceY:e,targetX:n,targetY:r,sourceControlX:i,sourceControlY:o,targetControlX:a,targetControlY:u}){let l=.125*t+.375*i+.375*a+.125*n,s=.125*e+.375*o+.375*u+.125*r,c=Math.abs(l-t),h=Math.abs(s-e);return[l,s,c,h]}function nW(t,e){return t>=0?.5*t:25*e*Math.sqrt(-t)}function nU({pos:t,x1:e,y1:n,x2:r,y2:i,c:o}){switch(t){case g.Left:return[e-nW(e-r,o),n];case g.Right:return[e+nW(r-e,o),n];case g.Top:return[e,n-nW(n-i,o)];case g.Bottom:return[e,n+nW(i-n,o)]}}function nZ({sourceX:t,sourceY:e,sourcePosition:n=g.Bottom,targetX:r,targetY:i,targetPosition:o=g.Top,curvature:a=.25}){let[u,l]=nU({pos:n,x1:t,y1:e,x2:r,y2:i,c:a}),[s,c]=nU({pos:o,x1:r,y1:i,x2:t,y2:e,c:a}),[h,f,d,p]=nK({sourceX:t,sourceY:e,targetX:r,targetY:i,sourceControlX:u,sourceControlY:l,targetControlX:s,targetControlY:c});return[`M${t},${e} C${u},${l} ${s},${c} ${r},${i}`,h,f,d,p]}function nQ({sourceX:t,sourceY:e,targetX:n,targetY:r}){let i=Math.abs(n-t)/2,o=Math.abs(r-e)/2;return[n<t?n+i:n-i,r<e?r+o:r-o,i,o]}function nG({sourceNode:t,targetNode:e,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:o="basic"}){if("manual"===o)return r;let a=Math.max(t.parentId||i&&t.selected?t.internals.z:0,e.parentId||i&&e.selected?e.internals.z:0);return(i&&n?r+1e3:r)+a}function nJ({sourceNode:t,targetNode:e,width:n,height:r,transform:i}){let o=nd(nm(t),nm(e));return o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1),nw({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},ny(o))>0}let n0=({source:t,sourceHandle:e,target:n,targetHandle:r})=>`xy-edge__${t}${e||""}-${n}${r||""}`,n1=(t,e,n={})=>{let r,i;if(!t.source||!t.target)return n.onError?.("006",e2.error006()),e;let o=n.getEdgeId||n0;return(i=r=e9(t)?{...t}:{...t,id:o(t)},e.some(t=>t.source===i.source&&t.target===i.target&&(t.sourceHandle===i.sourceHandle||!t.sourceHandle&&!i.sourceHandle)&&(t.targetHandle===i.targetHandle||!t.targetHandle&&!i.targetHandle)))?e:(null===r.sourceHandle&&delete r.sourceHandle,null===r.targetHandle&&delete r.targetHandle,e.concat(r))};function n2({sourceX:t,sourceY:e,targetX:n,targetY:r}){let[i,o,a,u]=nQ({sourceX:t,sourceY:e,targetX:n,targetY:r});return[`M ${t},${e}L ${n},${r}`,i,o,a,u]}let n5={[g.Left]:{x:-1,y:0},[g.Right]:{x:1,y:0},[g.Top]:{x:0,y:-1},[g.Bottom]:{x:0,y:1}},n3=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function n8({sourceX:t,sourceY:e,sourcePosition:n=g.Bottom,targetX:r,targetY:i,targetPosition:o=g.Top,borderRadius:a=5,centerX:u,centerY:l,offset:s=20,stepPosition:c=.5}){let[h,f,d,p,y]=function({source:t,sourcePosition:e=g.Bottom,target:n,targetPosition:r=g.Top,center:i,offset:o,stepPosition:a}){let u,l,s=n5[e],c=n5[r],h={x:t.x+s.x*o,y:t.y+s.y*o},f={x:n.x+c.x*o,y:n.y+c.y*o},d=(({source:t,sourcePosition:e=g.Bottom,target:n})=>e===g.Left||e===g.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1})({source:h,sourcePosition:e,target:f}),p=0!==d.x?"x":"y",y=d[p],m=[],v={x:0,y:0},x={x:0,y:0},[,,w,_]=nQ({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(s[p]*c[p]==-1){"x"===p?(u=i.x??h.x+(f.x-h.x)*a,l=i.y??(h.y+f.y)/2):(u=i.x??(h.x+f.x)/2,l=i.y??h.y+(f.y-h.y)*a);let t=[{x:u,y:h.y},{x:u,y:f.y}],e=[{x:h.x,y:l},{x:f.x,y:l}];m=s[p]===y?"x"===p?t:e:"x"===p?e:t}else{let i=[{x:h.x,y:f.y}],a=[{x:f.x,y:h.y}];if(m="x"===p?s.x===y?a:i:s.y===y?i:a,e===r){let e=Math.abs(t[p]-n[p]);if(e<=o){let r=Math.min(o-1,o-e);s[p]===y?v[p]=(h[p]>t[p]?-1:1)*r:x[p]=(f[p]>n[p]?-1:1)*r}}if(e!==r){let t="x"===p?"y":"x",e=s[p]===c[t],n=h[t]>f[t],r=h[t]<f[t];(1===s[p]&&(!e&&n||e&&r)||1!==s[p]&&(!e&&r||e&&n))&&(m="x"===p?i:a)}let d={x:h.x+v.x,y:h.y+v.y},g={x:f.x+x.x,y:f.y+x.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(g.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(g.y-m[0].y))?(u=(d.x+g.x)/2,l=m[0].y):(u=m[0].x,l=(d.y+g.y)/2)}let b={x:h.x+v.x,y:h.y+v.y},M={x:f.x+x.x,y:f.y+x.y};return[[t,...b.x!==m[0].x||b.y!==m[0].y?[b]:[],...m,...M.x!==m[m.length-1].x||M.y!==m[m.length-1].y?[M]:[],n],u,l,w,_]}({source:{x:t,y:e},sourcePosition:n,target:{x:r,y:i},targetPosition:o,center:{x:u,y:l},offset:s,stepPosition:c}),m=`M${h[0].x} ${h[0].y}`;for(let t=1;t<h.length-1;t++)m+=function(t,e,n,r){let i=Math.min(n3(t,e)/2,n3(e,n)/2,r),{x:o,y:a}=e;if(t.x===o&&o===n.x||t.y===a&&a===n.y)return`L${o} ${a}`;if(t.y===a){let e=t.x<n.x?-1:1,r=t.y<n.y?1:-1;return`L ${o+i*e},${a}Q ${o},${a} ${o},${a+i*r}`}let u=t.x<n.x?1:-1,l=t.y<n.y?-1:1;return`L ${o},${a+i*l}Q ${o},${a} ${o+i*u},${a}`}(h[t-1],h[t],h[t+1],a);return[m+=`L${h[h.length-1].x} ${h[h.length-1].y}`,f,d,p,y]}function n4(t){return t&&!!(t.internals.handleBounds||t.handles?.length)&&!!(t.measured.width||t.width||t.initialWidth)}function n6(t){let{sourceNode:e,targetNode:n}=t;if(!n4(e)||!n4(n))return null;let r=e.internals.handleBounds||n9(e.handles),i=n.internals.handleBounds||n9(n.handles),o=rt(r?.source??[],t.sourceHandle),a=rt(t.connectionMode===h.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),t.targetHandle);if(!o||!a)return t.onError?.("008",e2.error008(!o?"source":"target",{id:t.id,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle})),null;let u=o?.position||g.Bottom,l=a?.position||g.Top,s=n7(e,o,u),c=n7(n,a,l);return{sourceX:s.x,sourceY:s.y,targetX:c.x,targetY:c.y,sourcePosition:u,targetPosition:l}}function n9(t){if(!t)return null;let e=[],n=[];for(let r of t)r.width=r.width??1,r.height=r.height??1,"source"===r.type?e.push(r):"target"===r.type&&n.push(r);return{source:e,target:n}}function n7(t,e,n=g.Left,r=!1){let i=(e?.x??0)+t.internals.positionAbsolute.x,o=(e?.y??0)+t.internals.positionAbsolute.y,{width:a,height:u}=e??nT(t);if(r)return{x:i+a/2,y:o+u/2};switch(e?.position??n){case g.Top:return{x:i+a/2,y:o};case g.Right:return{x:i+a,y:o+u/2};case g.Bottom:return{x:i+a/2,y:o+u};case g.Left:return{x:i,y:o+u/2}}}function rt(t,e){return t&&(e?t.find(t=>t.id===e):t[0])||null}function re(t,e){if(!t)return"";if("string"==typeof t)return t;let n=e?`${e}__`:"";return`${n}${Object.keys(t).sort().map(e=>`${e}=${t[e]}`).join("&")}`}function rn(t,{id:e,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let o=new Set;return t.reduce((t,a)=>([a.markerStart||r,a.markerEnd||i].forEach(r=>{if(r&&"object"==typeof r){let i=re(r,e);o.has(i)||(t.push({id:i,color:r.color||n,...r}),o.add(i))}}),t),[]).sort((t,e)=>t.id.localeCompare(e.id))}let rr={nodeOrigin:[0,0],nodeExtent:e5,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ri={...rr,checkEquality:!0};function ro(t,e){let n={...t};for(let t in e)void 0!==e[t]&&(n[t]=e[t]);return n}function ra(t,e,n){let r=ro(rr,n);for(let n of t.values())if(n.parentId)rs(n,t,e,r);else{let t=ns(ne(n,r.nodeOrigin),nS(n.extent)?n.extent:r.nodeExtent,nT(n));n.internals.positionAbsolute=t}}function ru(t){return"manual"===t}function rl(t,e,n,r={}){let i=ro(ri,r),o={i:0},a=new Map(e),u=i?.elevateNodesOnSelect&&!ru(i.zIndexMode)?1e3:0,l=t.length>0,s=!1;for(let c of(e.clear(),n.clear(),t)){let t=a.get(c.id);if(i.checkEquality&&c===t?.internals.userNode)e.set(c.id,t);else{let n=ns(ne(c,i.nodeOrigin),nS(c.extent)?c.extent:i.nodeExtent,nT(c));t={...i.defaults,...c,measured:{width:c.measured?.width,height:c.measured?.height},internals:{positionAbsolute:n,handleBounds:function(t,e){if(!t.handles)return t.measured?e?.internals.handleBounds:void 0;let n=[],r=[];for(let e of t.handles){let i={id:e.id,width:e.width??1,height:e.height??1,nodeId:t.id,x:e.x,y:e.y,position:e.position,type:e.type};"source"===e.type?n.push(i):"target"===e.type&&r.push(i)}return{source:n,target:r}}(c,t),z:rc(c,u,i.zIndexMode),userNode:c}},e.set(c.id,t)}void 0!==t.measured&&void 0!==t.measured.width&&void 0!==t.measured.height||t.hidden||(l=!1),c.parentId&&rs(t,e,n,r,o),s||=c.selected??!1}return{nodesInitialized:l,hasSelectedNodes:s}}function rs(t,e,n,r,i){let{elevateNodesOnSelect:o,nodeOrigin:a,nodeExtent:u,zIndexMode:l}=ro(rr,r),s=t.parentId,c=e.get(s);if(!c)return void console.warn(`Parent node ${s} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);!function(t,e){if(!t.parentId)return;let n=e.get(t.parentId);n?n.set(t.id,t):e.set(t.parentId,new Map([[t.id,t]]))}(t,n),i&&!c.parentId&&void 0===c.internals.rootParentIndex&&"auto"===l&&(c.internals.rootParentIndex=++i.i,c.internals.z=c.internals.z+10*i.i),i&&void 0!==c.internals.rootParentIndex&&(i.i=c.internals.rootParentIndex);let{x:h,y:f,z:d}=function(t,e,n,r,i,o){let{x:a,y:u}=e.internals.positionAbsolute,l=nT(t),s=ne(t,n),c=nS(t.extent)?ns(s,t.extent,l):s,h=ns({x:a+c.x,y:u+c.y},r,l);"parent"===t.extent&&(h=nc(h,l,e));let f=rc(t,i,o),d=e.internals.z??0;return{x:h.x,y:h.y,z:d>=f?d+1:f}}(t,c,a,u,o&&!ru(l)?1e3:0,l),{positionAbsolute:p}=t.internals,y=h!==p.x||f!==p.y;(y||d!==t.internals.z)&&e.set(t.id,{...t,internals:{...t.internals,positionAbsolute:y?{x:h,y:f}:p,z:d}})}function rc(t,e,n){let r=nb(t.zIndex)?t.zIndex:0;return ru(n)?r:r+(t.selected?e:0)}function rh(t,e,n,r=[0,0]){let i=[],o=new Map;for(let n of t){let t=e.get(n.parentId);if(!t)continue;let r=nv(o.get(n.parentId)?.expandedRect??ng(t),n.rect);o.set(n.parentId,{expandedRect:r,parent:t})}return o.size>0&&o.forEach(({expandedRect:e,parent:o},a)=>{let u=o.internals.positionAbsolute,l=nT(o),s=o.origin??r,c=e.x<u.x?Math.round(Math.abs(u.x-e.x)):0,h=e.y<u.y?Math.round(Math.abs(u.y-e.y)):0,f=Math.max(l.width,Math.round(e.width)),d=Math.max(l.height,Math.round(e.height)),p=(f-l.width)*s[0],y=(d-l.height)*s[1];(c>0||h>0||p||y)&&(i.push({id:a,type:"position",position:{x:o.position.x-c+p,y:o.position.y-h+y}}),n.get(a)?.forEach(e=>{t.some(t=>t.id===e.id)||i.push({id:e.id,type:"position",position:{x:e.position.x+c,y:e.position.y+h}})})),(l.width<e.width||l.height<e.height||c||h)&&i.push({id:a,type:"dimensions",setAttributes:!0,dimensions:{width:f+(c?s[0]*c-p:0),height:d+(h?s[1]*h-y:0)}})}),i}function rf(t,e,n,r,i,o,a){let u=r?.querySelector(".xyflow__viewport"),l=!1;if(!u)return{changes:[],updatedInternals:l};let s=[],c=window.getComputedStyle(u),{m22:h}=new window.DOMMatrixReadOnly(c.transform),f=[];for(let r of t.values()){let t=e.get(r.id);if(!t)continue;if(t.hidden){e.set(t.id,{...t,internals:{...t.internals,handleBounds:void 0}}),l=!0;continue}let u=nD(r.nodeElement),c=t.measured.width!==u.width||t.measured.height!==u.height;if(u.width&&u.height&&(c||!t.internals.handleBounds||r.force)){let d=r.nodeElement.getBoundingClientRect(),p=nS(t.extent)?t.extent:o,{positionAbsolute:y}=t.internals;if(t.parentId&&"parent"===t.extent){let n=e.get(t.parentId);n&&(y=nc(y,u,n))}else p&&(y=ns(y,p,u));let g={...t,measured:u,internals:{...t.internals,positionAbsolute:y,handleBounds:{source:nF("source",r.nodeElement,d,h,t.id),target:nF("target",r.nodeElement,d,h,t.id)}}};e.set(t.id,g),t.parentId&&rs(g,e,n,{nodeOrigin:i,zIndexMode:a}),l=!0,c&&(s.push({id:t.id,type:"dimensions",dimensions:u}),t.expandParent&&t.parentId&&f.push({id:t.id,parentId:t.parentId,rect:ng(g,i)}))}}if(f.length>0){let t=rh(f,e,n,i);s.push(...t)}return{changes:s,updatedInternals:l}}async function rd({delta:t,panZoom:e,transform:n,translateExtent:r,width:i,height:o}){if(!e||!t.x&&!t.y)return!1;let a=await e.setViewportConstrained({x:n[0]+t.x,y:n[1]+t.y,zoom:n[2]},[[0,0],[i,o]],r);return!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2])}function rp(t,e,n,r,i,o){let a=i,u=r.get(a)||new Map;r.set(a,u.set(n,e)),a=`${i}-${t}`;let l=r.get(a)||new Map;if(r.set(a,l.set(n,e)),o){a=`${i}-${t}-${o}`;let u=r.get(a)||new Map;r.set(a,u.set(n,e))}}function ry(t,e,n){for(let r of(t.clear(),e.clear(),n)){let{source:n,target:i,sourceHandle:o=null,targetHandle:a=null}=r,u={edgeId:r.id,source:n,target:i,sourceHandle:o,targetHandle:a},l=`${n}-${o}--${i}-${a}`;rp("source",u,`${i}-${a}--${n}-${o}`,t,n,o),rp("target",u,l,t,i,a),e.set(r.id,r)}}function rg(t,e,n){let r=t;do{if(r?.matches?.(e))return!0;if(r===n)break;r=r?.parentElement}while(r);return!1}function rm({nodeId:t,dragItems:e,nodeLookup:n,dragging:r=!0}){let i=[];for(let[t,o]of e){let e=n.get(t)?.internals.userNode;e&&i.push({...e,position:o.position,dragging:r})}if(!t)return[i[0],i];let o=n.get(t)?.internals.userNode;return[o?{...o,position:e.get(t)?.position||o.position,dragging:r}:i[0],i]}function rv({onNodeMouseDown:t,getStoreItems:e,onDragStart:n,onDrag:r,onDragStop:i}){let o={x:null,y:null},a=0,u=new Map,l=!1,s={x:0,y:0},c=null,h=!1,f=null,d=!1,p=!1,y=null;return{update:function({noDragClassName:g,handleSelector:m,domNode:v,isSelectable:w,nodeId:_,nodeClickDistance:b=0}){function M({x:t,y:n}){let{nodeLookup:i,nodeExtent:a,snapGrid:l,snapToGrid:s,nodeOrigin:c,onNodeDrag:h,onSelectionDrag:f,onError:d,updateNodePositions:g}=e();o={x:t,y:n};let m=!1,v=u.size>1,x=v&&a?np(nr(u)):null,w=v&&s?function({dragItems:t,snapGrid:e,x:n,y:r}){let i=t.values().next().value;if(!i)return null;let o={x:n-i.distance.x,y:r-i.distance.y},a=nE(o,e);return{x:a.x-o.x,y:a.y-o.y}}({dragItems:u,snapGrid:l,x:t,y:n}):null;for(let[e,r]of u){if(!i.has(e))continue;let o={x:t-r.distance.x,y:n-r.distance.y};s&&(o=w?{x:Math.round(o.x+w.x),y:Math.round(o.y+w.y)}:nE(o,l));let u=null;if(v&&a&&!r.extent&&x){let{positionAbsolute:t}=r.internals,e=t.x-x.x+a[0][0],n=t.x+r.measured.width-x.x2+a[1][0];u=[[e,t.y-x.y+a[0][1]],[n,t.y+r.measured.height-x.y2+a[1][1]]]}let{position:h,positionAbsolute:f}=na({nodeId:e,nextPosition:o,nodeLookup:i,nodeExtent:u||a,nodeOrigin:c,onError:d});m=m||r.position.x!==h.x||r.position.y!==h.y,r.position=h,r.internals.positionAbsolute=f}if(p=p||m,m&&(g(u,!0),y&&(r||h||!_&&f))){let[t,e]=rm({nodeId:_,dragItems:u,nodeLookup:i});r?.(y,u,t,e),h?.(y,t,e),_||f?.(y,e)}}async function E(){if(!c)return;let{transform:t,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=e();if(!i){l=!1,cancelAnimationFrame(a);return}let[u,h]=nf(s,c,r);(0!==u||0!==h)&&(o.x=(o.x??0)-u/t[2],o.y=(o.y??0)-h/t[2],await n({x:u,y:h})&&M(o)),a=requestAnimationFrame(E)}function k(r){let{nodeLookup:i,multiSelectionActive:a,nodesDraggable:l,transform:s,snapGrid:f,snapToGrid:d,selectNodesOnDrag:p,onNodeDragStart:y,onSelectionDragStart:g,unselectNodesAndEdges:m}=e();h=!0,p&&w||a||!_||i.get(_)?.selected||m(),w&&p&&_&&t?.(_);let v=nR(r.sourceEvent,{transform:s,snapGrid:f,snapToGrid:d,containerBounds:c});if(o=v,(u=function(t,e,n,r){let i=new Map;for(let[o,a]of t)if((a.selected||a.id===r)&&(!a.parentId||!function t(e,n){if(!e.parentId)return!1;let r=n.get(e.parentId);return!!r&&(!!r.selected||t(r,n))}(a,t))&&(a.draggable||e&&void 0===a.draggable)){let e=t.get(o);e&&i.set(o,{id:o,position:e.position||{x:0,y:0},distance:{x:n.x-e.internals.positionAbsolute.x,y:n.y-e.internals.positionAbsolute.y},extent:e.extent,parentId:e.parentId,origin:e.origin,expandParent:e.expandParent,internals:{positionAbsolute:e.internals.positionAbsolute||{x:0,y:0}},measured:{width:e.measured.width??0,height:e.measured.height??0}})}return i}(i,l,v,_)).size>0&&(n||y||!_&&g)){let[t,e]=rm({nodeId:_,dragItems:u,nodeLookup:i});n?.(r.sourceEvent,u,t,e),y?.(r.sourceEvent,t,e),_||g?.(r.sourceEvent,e)}}f=ts(v);let $=(function(){var t,e,n,r,i=tx,o=tw,a=t_,u=tb,l={},s=x("start","drag","end"),c=0,h=0;function f(t){t.on("mousedown.drag",d).filter(u).on("touchstart.drag",g).on("touchmove.drag",m,th).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(a,u){if(!r&&i.call(this,a,u)){var l=w(this,o.call(this,a,u),a,u,"mouse");l&&(ts(a.view).on("mousemove.drag",p,tf).on("mouseup.drag",y,tf),ty(a.view),td(a),n=!1,t=a.clientX,e=a.clientY,l("start",a))}}function p(r){if(tp(r),!n){var i=r.clientX-t,o=r.clientY-e;n=i*i+o*o>h}l.mouse("drag",r)}function y(t){ts(t.view).on("mousemove.drag mouseup.drag",null),tg(t.view,n),tp(t),l.mouse("end",t)}function g(t,e){if(i.call(this,t,e)){var n,r,a=t.changedTouches,u=o.call(this,t,e),l=a.length;for(n=0;n<l;++n)(r=w(this,u,t,e,a[n].identifier,a[n]))&&(td(t),r("start",t,a[n]))}}function m(t){var e,n,r=t.changedTouches,i=r.length;for(e=0;e<i;++e)(n=l[r[e].identifier])&&(tp(t),n("drag",t,r[e]))}function v(t){var e,n,i=t.changedTouches,o=i.length;for(r&&clearTimeout(r),r=setTimeout(function(){r=null},500),e=0;e<o;++e)(n=l[i[e].identifier])&&(td(t),n("end",t,i[e]))}function w(t,e,n,r,i,o){var u,h,d,p=s.copy(),y=tc(o||n,e);if(null!=(d=a.call(t,new tv("beforestart",{sourceEvent:n,target:f,identifier:i,active:c,x:y[0],y:y[1],dx:0,dy:0,dispatch:p}),r)))return u=d.x-y[0]||0,h=d.y-y[1]||0,function n(o,a,s){var g,m=y;switch(o){case"start":l[i]=n,g=c++;break;case"end":delete l[i],--c;case"drag":y=tc(s||a,e),g=c}p.call(o,t,new tv(o,{sourceEvent:a,subject:d,target:f,identifier:i,active:g,x:y[0]+u,y:y[1]+h,dx:y[0]-m[0],dy:y[1]-m[1],dispatch:p}),r)}}return f.filter=function(t){return arguments.length?(i="function"==typeof t?t:tm(!!t),f):i},f.container=function(t){return arguments.length?(o="function"==typeof t?t:tm(t),f):o},f.subject=function(t){return arguments.length?(a="function"==typeof t?t:tm(t),f):a},f.touchable=function(t){return arguments.length?(u="function"==typeof t?t:tm(!!t),f):u},f.on=function(){var t=s.on.apply(s,arguments);return t===s?f:t},f.clickDistance=function(t){return arguments.length?(h=(t*=1)*t,f):Math.sqrt(h)},f})().clickDistance(b).on("start",t=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:a,snapToGrid:u}=e();c=n?.getBoundingClientRect()||null,d=!1,p=!1,y=t.sourceEvent,0===r&&k(t),o=nR(t.sourceEvent,{transform:i,snapGrid:a,snapToGrid:u,containerBounds:c}),s=nV(t.sourceEvent,c)}).on("drag",t=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:a,nodeDragThreshold:f,nodeLookup:p}=e(),g=nR(t.sourceEvent,{transform:r,snapGrid:i,snapToGrid:a,containerBounds:c});if(y=t.sourceEvent,("touchmove"===t.sourceEvent.type&&t.sourceEvent.touches.length>1||_&&!p.has(_))&&(d=!0),!d){if(!l&&n&&h&&(l=!0,E()),!h){let e=nV(t.sourceEvent,c),n=e.x-s.x,r=e.y-s.y;Math.sqrt(n*n+r*r)>f&&k(t)}(o.x!==g.xSnapped||o.y!==g.ySnapped)&&u&&h&&(s=nV(t.sourceEvent,c),M(g))}}).on("end",t=>{if(!h||d){d&&u.size>0&&e().updateNodePositions(u,!1);return}if(l=!1,h=!1,cancelAnimationFrame(a),u.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:o,onSelectionDragStop:a}=e();if(p&&(r(u,!1),p=!1),i||o||!_&&a){let[e,r]=rm({nodeId:_,dragItems:u,nodeLookup:n,dragging:!1});i?.(t.sourceEvent,u,e,r),o?.(t.sourceEvent,e,r),_||a?.(t.sourceEvent,r)}}}).filter(t=>{let e=t.target;return!t.button&&(!g||!rg(e,`.${g}`,v))&&(!m||rg(e,m,v))});f.call($)},destroy:function(){f?.on(".drag",null)}}}function rx(t,e,n,r,i,o=!1){let a=r.get(t);if(!a)return null;let u="strict"===i?a.internals.handleBounds?.[e]:[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]],l=(n?u?.find(t=>t.id===n):u?.[0])??null;return l&&o?{...l,...n7(a,l,l.position,!0)}:l}function rw(t,e){return t?t:e?.classList.contains("target")?"target":e?.classList.contains("source")?"source":null}let r_=()=>!0;function rb(t,{handle:e,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:o,doc:a,lib:u,flowId:l,isValidConnection:s=r_,nodeLookup:c}){let f="target"===o,d=e?a.querySelector(`.${u}-flow__handle[data-id="${l}-${e?.nodeId}-${e?.id}-${e?.type}"]`):null,{x:p,y}=nV(t),g=a.elementFromPoint(p,y),m=g?.classList.contains(`${u}-flow__handle`)?g:d,v={handleDomNode:m,isValid:!1,connection:null,toHandle:null};if(m){let t=rw(void 0,m),e=m.getAttribute("data-nodeid"),o=m.getAttribute("data-handleid"),a=m.classList.contains("connectable"),u=m.classList.contains("connectableend");if(!e||!t)return v;let l={source:f?e:r,sourceHandle:f?o:i,target:f?r:e,targetHandle:f?i:o};v.connection=l,v.isValid=a&&u&&(n===h.Strict?f&&"source"===t||!f&&"target"===t:e!==r||o!==i)&&s(l),v.toHandle=rx(e,t,o,c,n,!0)}return v}let rM={onPointerDown:function(t,{connectionMode:e,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:o,isTarget:a,domNode:u,nodeLookup:l,lib:s,autoPanOnConnect:c,flowId:h,panBy:f,cancelConnection:d,onConnectStart:p,onConnect:y,onConnectEnd:m,isValidConnection:v=r_,onReconnectEnd:x,updateConnection:w,getTransform:_,getFromHandle:b,autoPanSpeed:M,dragThreshold:E=1,handleDomNode:k}){let $,A=nX(t.target),z=0,{x:N,y:S}=nV(t),T=rw(o,k),I=u?.getBoundingClientRect(),P=!1;if(!I||!T)return;let H=rx(i,T,r,l,e);if(!H)return;let B=nV(t,I),L=!1,C=null,O=!1,R=null,D={...H,nodeId:i,type:T,position:H.position},X=l.get(i),j={inProgress:!0,isValid:null,from:n7(X,D,g.Left,!0),fromHandle:D,fromPosition:D.position,fromNode:X,to:B,toHandle:null,toPosition:e6[D.position],toNode:null,pointer:B};function q(){P=!0,w(j),p?.(t,{nodeId:i,handleId:r,handleType:T})}function Y(t){var o,u;let d;if(!P){let{x:e,y:n}=nV(t),r=e-N,i=n-S;if(!(r*r+i*i>E*E))return;q()}if(!b()||!D)return void V(t);let p=_();$=function(t,e,n,r){let i=[],o=1/0;for(let a of function(t,e,n){let r=[],i={x:t.x-n,y:t.y-n,width:2*n,height:2*n};for(let t of e.values())nw(i,ng(t))>0&&r.push(t);return r}(t,n,e+250))for(let n of[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]]){if(r.nodeId===n.nodeId&&r.type===n.type&&r.id===n.id)continue;let{x:u,y:l}=n7(a,n,n.position,!0),s=Math.sqrt(Math.pow(u-t.x,2)+Math.pow(l-t.y,2));s>e||(s<o?(i=[{...n,x:u,y:l}],o=s):s===o&&i.push({...n,x:u,y:l}))}if(!i.length)return null;if(i.length>1){let t="source"===r.type?"target":"source";return i.find(e=>e.type===t)??i[0]}return i[0]}(nk(B=nV(t,I),p,!1,[1,1]),n,l,D),L||(!function t(){if(!c||!I)return;let[e,n]=nf(B,I,M);f({x:e,y:n}),z=requestAnimationFrame(t)}(),L=!0);let y=rb(t,{handle:$,connectionMode:e,fromNodeId:i,fromHandleId:r,fromType:a?"target":"source",isValidConnection:v,doc:A,lib:s,flowId:h,nodeLookup:l});R=y.handleDomNode,C=y.connection,o=!!$,u=y.isValid,d=null,u?d=!0:o&&!u&&(d=!1),O=d;let m=l.get(i),x=m?n7(m,D,g.Left,!0):j.from,k={...j,from:x,isValid:O,to:y.toHandle&&O?n$({x:y.toHandle.x,y:y.toHandle.y},p):B,toHandle:y.toHandle,toPosition:O&&y.toHandle?y.toHandle.position:e6[D.position],toNode:y.toHandle?l.get(y.toHandle.nodeId):null,pointer:B};w(k),j=k}function V(t){if(!("touches"in t)||!(t.touches.length>0)){if(P){($||R)&&C&&O&&y?.(C);let{inProgress:e,...n}=j,r={...n,toPosition:j.toHandle?j.toPosition:null};m?.(t,r),o&&x?.(t,r)}d(),cancelAnimationFrame(z),L=!1,O=!1,C=null,R=null,A.removeEventListener("mousemove",Y),A.removeEventListener("mouseup",V),A.removeEventListener("touchmove",Y),A.removeEventListener("touchend",V)}}0===E&&q(),A.addEventListener("mousemove",Y),A.addEventListener("mouseup",V),A.addEventListener("touchmove",Y),A.addEventListener("touchend",V)},isValid:rb};function rE({domNode:t,panZoom:e,getTransform:n,getViewScale:r}){let i=ts(t);return{update:function({translateExtent:t,width:o,height:a,zoomStep:u=1,pannable:l=!0,zoomable:s=!0,inversePan:c=!1}){let h=[0,0],f=e0().on("start",t=>{("mousedown"===t.sourceEvent.type||"touchstart"===t.sourceEvent.type)&&(h=[t.sourceEvent.clientX??t.sourceEvent.touches[0].clientX,t.sourceEvent.clientY??t.sourceEvent.touches[0].clientY])}).on("zoom",l?i=>{let u=n();if("mousemove"!==i.sourceEvent.type&&"touchmove"!==i.sourceEvent.type||!e)return;let l=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],s=[l[0]-h[0],l[1]-h[1]];h=l;let f=r()*Math.max(u[2],Math.log(u[2]))*(c?-1:1),d={x:u[0]-s[0]*f,y:u[1]-s[1]*f};e.setViewportConstrained({x:d.x,y:d.y,zoom:u[2]},[[0,0],[o,a]],t)}:null).on("zoom.wheel",s?t=>{if("wheel"!==t.sourceEvent.type||!e)return;let r=n(),i=t.sourceEvent.ctrlKey&&nN()?10:1,o=-t.sourceEvent.deltaY*(1===t.sourceEvent.deltaMode?.05:t.sourceEvent.deltaMode?1:.002)*u,a=r[2]*Math.pow(2,o*i);e.scaleTo(a)}:null);i.call(f,{})},destroy:function(){i.on("zoom",null)},pointer:tc}}let rk=t=>({x:t.x,y:t.y,zoom:t.k}),r$=({x:t,y:e,zoom:n})=>eY.translate(t,e).scale(n),rA=(t,e)=>t.target.closest(`.${e}`),rz=(t,e)=>2===e&&Array.isArray(t)&&t.includes(2),rN=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,rS=(t,e=0,n=rN,r=()=>{})=>{let i="number"==typeof e&&e>0;return i||r(),i?t.transition().duration(e).ease(n).on("end",r):t},rT=t=>{let e=t.ctrlKey&&nN()?10:1;return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*e};function rI({domNode:t,minZoom:e,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:o,onPanZoomStart:a,onPanZoomEnd:u,onDraggingChange:l}){let s={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},c=t.getBoundingClientRect(),h=[[0,0],[c.width,c.height]],d="u">typeof ResizeObserver?new ResizeObserver(t=>{let e=t[0];e&&(h=[[0,0],[e.contentRect.width,e.contentRect.height]])}):null;d?.observe(t);let p=e0().extent(()=>h).scaleExtent([e,n]).translateExtent(r),y=ts(t).call(p);w({x:i.x,y:i.y,zoom:nl(i.zoom,e,n)},[[0,0],[c.width,c.height]],r);let g=y.on("wheel.zoom"),m=y.on("dblclick.zoom");async function v(t,e){return!!y&&new Promise(n=>{p?.interpolate(e?.interpolate==="linear"?e1:tE).transform(rS(y,e?.duration,e?.ease,()=>n(!0)),t)})}function x(){p.on("zoom",null)}async function w(t,e,n){let r=r$(t),i=p?.constrain()(r,e,n);return i&&await v(i),i}return p.wheelDelta(rT),{update:function({noWheelClassName:t,noPanClassName:e,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:c,panOnScrollMode:h,panOnScrollSpeed:d,preventScrolling:v,zoomOnPinch:w,zoomOnScroll:_,zoomOnDoubleClick:b,panActivationKeyPressed:M=!1,zoomActivationKeyPressed:E,lib:k,onTransformChange:$,connectionInProgress:A,paneClickDistance:z,selectionOnDrag:N}){r&&!s.isZoomingOrPanning&&x();let S=i&&!E&&!r;p.clickDistance(N?1/0:!nb(z)||z<0?0:z);let T=S?function({zoomPanValues:t,noWheelClassName:e,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:o,zoomOnPinch:a,onPanZoomStart:u,onPanZoom:l,onPanZoomEnd:s}){return c=>{if(rA(c,e))return c.ctrlKey&&c.preventDefault(),!1;c.preventDefault(),c.stopImmediatePropagation();let h=n.property("__zoom").k||1;if(c.ctrlKey&&a){let t=tc(c),e=h*Math.pow(2,rT(c));r.scaleTo(n,e,t,c);return}let d=1===c.deltaMode?20:1,p=i===f.Vertical?0:c.deltaX*d,y=i===f.Horizontal?0:c.deltaY*d;!nN()&&c.shiftKey&&i!==f.Vertical&&(p=c.deltaY*d,y=0),r.translateBy(n,-(p/h)*o,-(y/h)*o,{internal:!0});let g=rk(n.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?l?.(c,g):(t.isPanScrolling=!0,u?.(c,g)),t.panScrollTimeout=setTimeout(()=>{s?.(c,g),t.isPanScrolling=!1},150)}}({zoomPanValues:s,noWheelClassName:t,d3Selection:y,d3Zoom:p,panOnScrollMode:h,panOnScrollSpeed:d,zoomOnPinch:w,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:u}):function({noWheelClassName:t,preventScrolling:e,d3ZoomHandler:n}){return function(r,i){let o="wheel"===r.type,a=!e&&o&&!r.ctrlKey,u=rA(r,t);if(r.ctrlKey&&o&&u&&r.preventDefault(),a||u)return null;r.preventDefault(),n.call(this,r,i)}}({noWheelClassName:t,preventScrolling:v,d3ZoomHandler:g});y.on("wheel.zoom",T,{passive:!1});let I=function({zoomPanValues:t,onDraggingChange:e,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=rk(r.transform);t.mouseButton=r.sourceEvent?.button||0,t.isZoomingOrPanning=!0,t.prevViewport=i,r.sourceEvent?.type==="mousedown"&&e(!0),n&&n?.(r.sourceEvent,i)}}({zoomPanValues:s,onDraggingChange:l,onPanZoomStart:a});p.on("start",I);let P=function({zoomPanValues:t,panOnDrag:e,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return o=>{t.usedRightMouseButton=!!(n&&rz(e,t.mouseButton??0)),o.sourceEvent?.sync||r([o.transform.x,o.transform.y,o.transform.k]),i&&!o.sourceEvent?.internal&&i?.(o.sourceEvent,rk(o.transform))}}({zoomPanValues:s,panOnDrag:c,onPaneContextMenu:!!n,onPanZoom:o,onTransformChange:$});p.on("zoom",P);let H=function({zoomPanValues:t,panOnDrag:e,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:o}){return a=>{if(!a.sourceEvent?.internal&&(t.isZoomingOrPanning=!1,o&&rz(e,t.mouseButton??0)&&!t.usedRightMouseButton&&a.sourceEvent&&o(a.sourceEvent),t.usedRightMouseButton=!1,r(!1),i)){let e=rk(a.transform);t.prevViewport=e,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{i?.(a.sourceEvent,e)},150*!!n)}}}({zoomPanValues:s,panOnDrag:c,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:u,onDraggingChange:l});p.on("end",H);let B=function({panActivationKeyPressed:t,zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:i,panOnScroll:o,zoomOnDoubleClick:a,userSelectionActive:u,noWheelClassName:l,noPanClassName:s,lib:c,connectionInProgress:h}){return f=>{let d=e||n,p=r&&f.ctrlKey,y="wheel"===f.type;if(1===f.button&&"mousedown"===f.type&&(rA(f,`${c}-flow__node`)||rA(f,`${c}-flow__edge`)||rA(f,`${c}-flow__selection`)||rA(f,`${c}-flow__nodesselection`)))return!0;if(!i&&!d&&!o&&!a&&!r||u||h&&!y||rA(f,l)&&y||rA(f,s)&&(!y||o&&y&&!e)||!r&&f.ctrlKey&&y)return!1;if(!r&&"touchstart"===f.type&&f.touches?.length>1)return f.preventDefault(),!1;if(!d&&!o&&!p&&y||!i&&("mousedown"===f.type||"touchstart"===f.type)||Array.isArray(i)&&!i.includes(f.button)&&"mousedown"===f.type)return!1;let g=Array.isArray(i)&&i.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||y||t)&&g}}({panActivationKeyPressed:M,zoomActivationKeyPressed:E,panOnDrag:c,zoomOnScroll:_,panOnScroll:i,zoomOnDoubleClick:b,zoomOnPinch:w,userSelectionActive:r,noPanClassName:e,noWheelClassName:t,lib:k,connectionInProgress:A});p.filter(B),b?y.on("dblclick.zoom",m):y.on("dblclick.zoom",null)},destroy:x,setViewport:async function t(t,e){let n=r$(t);return await v(n,e),n},setViewportConstrained:w,getViewport:function(){let t=y?eV(y.node()):{x:0,y:0,k:1};return{x:t.x,y:t.y,zoom:t.k}},scaleTo:async function t(t,e){return!!y&&new Promise(n=>{p?.interpolate(e?.interpolate==="linear"?e1:tE).scaleTo(rS(y,e?.duration,e?.ease,()=>n(!0)),t)})},scaleBy:async function t(t,e){return!!y&&new Promise(n=>{p?.interpolate(e?.interpolate==="linear"?e1:tE).scaleBy(rS(y,e?.duration,e?.ease,()=>n(!0)),t)})},setScaleExtent:function(t){p?.scaleExtent(t)},setTranslateExtent:function(t){p?.translateExtent(t)},syncViewport:function(t){if(y){let e=r$(t),n=y.property("__zoom");(n.k!==t.zoom||n.x!==t.x||n.y!==t.y)&&p?.transform(y,e,null,{sync:!0})}},setClickDistance:function(t){let e=!nb(t)||t<0?0:t;p?.clickDistance(e)}}}(s=m||(m={})).Line="line",s.Handle="handle"},69684:(t,e,n)=>{"use strict";n.d(e,{A:()=>function t(e){if("string"==typeof e||"number"==typeof e)return""+e;let n="";if(Array.isArray(e))for(let r=0,i;r<e.length;r++)""!==(i=t(e[r]))&&(n+=(n&&" ")+i);else for(let t in e)e[t]&&(n+=(n&&" ")+t);return n}})},82282:(t,e,n)=>{"use strict";n.d(e,{h:()=>h,n:()=>s});var r=n(12115),i=n(94577);let o=t=>{let e,n=new Set,r=(t,r)=>{let i="function"==typeof t?t(e):t;if(!Object.is(i,e)){let t=e;e=(null!=r?r:"object"!=typeof i||null===i)?i:Object.assign({},e,i),n.forEach(n=>n(e,t))}},i=()=>e,o={setState:r,getState:i,getInitialState:()=>a,subscribe:t=>(n.add(t),()=>n.delete(t)),destroy:()=>{console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},a=e=t(r,i,o);return o},{useDebugValue:a}=r,{useSyncExternalStoreWithSelector:u}=i,l=t=>t;function s(t,e=l,n){let r=u(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return a(r),r}let c=(t,e)=>{let n=t?o(t):o,r=(t,r=e)=>s(n,t,r);return Object.assign(r,n),r},h=(t,e)=>t?c(t,e):c},94907:(t,e,n)=>{"use strict";function r(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(let[n,r]of t)if(!Object.is(r,e.get(n)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(let n of t)if(!e.has(n))return!1;return!0}let n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(e,r)||!Object.is(t[r],e[r]))return!1;return!0}n.d(e,{x:()=>r})}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[106,828,831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4908,4909,4956,5047,5374,5721,5794,5838,6053,6258,6306,6636,6819,6986,6988,7761,7851,7981,8167,8464,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[106,828,831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4908,4909,4956,5047,5374,5721,5794,5838,6053,6258,6306,6636,6819,6986,6988,7761,7851,7981,8167,8464,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[106,828,831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4908,4909,4956,5047,5374,5721,5794,5838,6053,6258,6306,6636,6819,6986,6988,7761,7851,7981,8167,8464,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9385],{5214:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"workAsyncStorage",{enumerable:!0,get:function(){return r.workAsyncStorageInstance}});let r=n(17828)},15923:(e,t,n)=>{"use strict";n.d(t,{T:()=>a,r:()=>i});let r=new Set;function a(e){return r.add(e),()=>{r.delete(e)}}function i(){for(let e of r)e()}},17828:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"workAsyncStorageInstance",{enumerable:!0,get:function(){return r}});let r=(0,n(64054).createAsyncLocalStorage)()},21957:(e,t,n)=>{"use strict";function r({moduleIds:e}){return null}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"PreloadChunks",{enumerable:!0,get:function(){return r}}),n(95155),n(47650),n(5214),n(2451),n(53887)},34263:(e,t,n)=>{"use strict";n.d(t,{En:()=>d,Pc:()=>c,jl:()=>o});var r=n(1934),a=n(31692),i=n(40980),s=n(63307);let l="ytdb:queries";(0,s.q)("db-studio:queries",l);let o=144,c=800,d=(0,r.v)()((0,a.Zr)(e=>({drafts:{},editorHeight:224,history:[],setDraft:(t,n)=>e(e=>({drafts:{...e.drafts,[t]:n}})),setEditorHeight:t=>e({editorHeight:Math.min(c,Math.max(o,Math.round(t)))}),record:(t,n)=>e(e=>{let r=n.trim();if(!r)return e;let a=e.history.find(e=>e.connectionId===t&&e.sql===r),s={id:a?.id??(0,i.z)(),connectionId:t,sql:r,executedAt:Date.now()},l=0,o=0;return{history:[s,...e.history.filter(e=>e.id!==s.id)].filter(e=>!(l>=200)&&!(o+e.sql.length>1e6)&&(l+=1,o+=e.sql.length,!0))}}),remove:t=>e(e=>({history:e.history.filter(e=>e.id!==t)}))}),{name:l}))},41112:(e,t,n)=>{"use strict";function r({reason:e,children:t}){return t}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"BailoutToCSR",{enumerable:!0,get:function(){return r}}),n(1980)},52310:(e,t,n)=>{Promise.resolve().then(n.bind(n,62592))},62592:(e,t,n)=>{"use strict";n.d(t,{MigrationDetail:()=>en});var r=n(95155),a=n(75707),i=n.n(a),s=n(98500),l=n.n(s),o=n(73321),c=n(12115),d=n(13267),u=n(36331),p=n(79781),m=n(17491),f=n(89239),h=n(72264),g=n(35942),x=n(87364),v=n(27529),k=n(25),b=n(62417),j=n(56012),y=n(40544),w=n(9385),$=n(85904),N=n(79668),q=n(34263),S=n(40980),C=n(72194),_=n(40891),O=n(30374),z=n(67369),R=n(28335);let P="w-24",A="w-[104px]";function E({checked:e,label:t,onToggle:n}){return(0,r.jsx)("button",{type:"button",role:"checkbox","aria-checked":e,"aria-label":t,title:t,onMouseDown:e=>e.shiftKey&&e.preventDefault(),onClick:e=>n(e.shiftKey),className:(0,S.cn)("flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-[5px] border outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring/60",e?"border-foreground bg-foreground text-background":"border-input hover:border-foreground/50"),children:"mixed"===e?(0,r.jsx)(d.uPM,{className:"size-3"}):e?(0,r.jsx)(d.wiW,{className:"size-3"}):null})}let M={applied:"applied",drifted:"applied, but the file changed since",pending:"not applied",unknown:"not read yet"};function F({status:e}){return"applied"===e?(0,r.jsx)(d.wiW,{className:"size-4 text-emerald-600 dark:text-emerald-400"}):"drifted"===e?(0,r.jsx)(d.e5t,{className:"size-3.5 text-amber-600 dark:text-amber-400"}):"unknown"===e?(0,r.jsx)("span",{className:"size-1.5 rounded-full bg-muted-foreground/30"}):(0,r.jsx)(d.uPM,{className:"size-3.5 text-muted-foreground/40"})}function D({step:e,environments:t,targetId:n,status:a,isNewestApplied:i,expanded:s,busy:l,editable:o=!0,drift:u,selected:p,onSelect:m,onToggle:g,actions:x}){let[v,b]=(0,c.useState)(null),j="changes"!==v||u?v??(u?"changes":"schema"):"schema",y="revert"===j?"revert":"apply",w=(0,c.useMemo)(()=>s?(0,$.DT)([{version:e.version,sql:e.applySql}]):null,[s,e.version,e.applySql]),[N,q]=(0,c.useState)(!1),C="revert"===y?e.revertSql??"":e.applySql,I=(0,k.qb)(e.transaction),T=(0,k.TA)(e.transaction),L=[];async function B(){await (0,_.mw)(C),q(!0),window.setTimeout(()=>q(!1),1500)}return"drifted"===a&&"changes"!==j&&L.push("This file changed after it was applied here, so it is no longer the migration that ran."),T&&L.push(T),(0,r.jsxs)("div",{id:`migration-${e.version}`,className:"scroll-mt-2 border-b last:border-b-0",children:[(0,r.jsxs)("div",{className:(0,S.cn)("flex h-10 items-center transition-colors hover:bg-muted/40",p&&"bg-muted/30",l&&"opacity-60"),children:[(0,r.jsx)("span",{className:"flex h-10 shrink-0 items-center pl-3",children:(0,r.jsx)(E,{checked:p,label:p?`Deselect ${e.version}`:`Select ${e.version}`,onToggle:m})}),(0,r.jsxs)("button",{type:"button","aria-expanded":s,"aria-label":s?`Hide SQL for ${e.version}`:`Show SQL for ${e.version}`,onClick:g,className:"flex h-8 min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md px-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[(0,r.jsx)(d.nNJ,{className:(0,S.cn)("size-3.5 shrink-0 text-muted-foreground/70 transition-transform",s&&"rotate-90")}),(0,r.jsx)("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:e.version}),(0,r.jsx)("span",{className:"min-w-0 truncate text-sm",children:e.name}),I&&(0,r.jsx)("span",{className:"shrink-0 rounded border border-amber-600/25 bg-amber-500/10 px-1.5 text-[10px] text-amber-700 dark:text-amber-400",children:I})]}),t.map(t=>{let a=t.connection.id===n;return(0,r.jsx)("span",{title:t.error?`${t.connection.name}: ${t.error}`:`${e.version} is ${M[t.status]} on ${t.connection.name}${t.entry?` — ${function(e){if(!e)return"";let t=new Date(e.appliedAt);return Number.isNaN(t.getTime())?e.appliedAt:t.toLocaleString()}(t.entry)}`:""}`,className:(0,S.cn)("flex h-10 shrink-0 items-center justify-center",P,a&&"bg-foreground/[0.04]"),children:(0,r.jsx)(F,{status:t.status})},t.connection.id)}),(0,r.jsxs)("div",{className:(0,S.cn)("flex shrink-0 items-center justify-end gap-1 pr-2 pl-1",A),children:["pending"===a&&(0,r.jsx)(f.$,{size:"xs",variant:"outline",disabled:l,onClick:x.onApplyThrough,children:"Apply"}),i&&e.revertSql&&(0,r.jsxs)(f.$,{size:"xs",variant:"ghost",disabled:l,onClick:x.onRevertThrough,children:[(0,r.jsx)(d.ij9,{"data-icon":"inline-start"}),"Revert"]}),(0,r.jsxs)(h.rI,{children:[(0,r.jsx)(h.ty,{render:(0,r.jsx)(f.$,{size:"icon-xs",variant:"ghost","aria-label":`Actions for ${e.version}`}),className:"cursor-pointer",children:(0,r.jsx)(d.YKd,{})}),(0,r.jsxs)(h.SQ,{align:"end",className:"min-w-56",children:[(0,r.jsx)(h._2,{disabled:l||"applied"===a,onClick:x.onApplyThrough,children:"Apply everything through here"}),(0,r.jsx)(h._2,{disabled:l||"applied"===a,onClick:x.onApplyOne,children:"Apply only this one"}),(0,r.jsx)(h._2,{disabled:l||"pending"===a||!e.revertSql,onClick:x.onRevertThrough,children:"Revert back through here"}),(0,r.jsx)(h.mB,{}),(0,r.jsxs)(h._2,{disabled:l||"applied"===a,onClick:x.onMarkApplied,children:[(0,r.jsx)(d.nXx,{}),"Mark as already applied"]}),(0,r.jsxs)(h._2,{disabled:l||"pending"===a,onClick:x.onMarkPending,children:[(0,r.jsx)(d.fJ4,{}),"Mark as not applied"]}),(0,r.jsx)(h.mB,{}),o&&(0,r.jsxs)(h._2,{onClick:x.onAttachRevert,children:[(0,r.jsx)(d.W4E,{}),e.revertSql?"Replace revert file…":"Add a revert file…"]}),(0,r.jsxs)(h._2,{onClick:()=>x.onOpenInEditor(C),children:[(0,r.jsx)(d.Uoo,{}),"Open ",y," SQL in editor"]}),(0,r.jsxs)(h._2,{onClick:()=>void B(),children:[(0,r.jsx)(d.hX7,{}),"Copy ",y," SQL"]}),o&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(h.mB,{}),(0,r.jsx)(h._2,{variant:"destructive",onClick:x.onRemove,children:"Remove from this set"})]})]})]})]})]}),s&&(0,r.jsxs)("div",{className:"border-t bg-muted/25",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5",children:[(0,r.jsx)(O.x,{label:`SQL for ${e.version}`,value:j,onChange:b,options:[...u?[{value:"changes",label:"Changes"}]:[],{value:"schema",label:"Schema"},{value:"apply",label:"Apply"},{value:"revert",label:"Revert"}]}),"changes"===j&&u?(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-3 font-mono text-[11px]",children:[(0,r.jsxs)("span",{className:"shrink-0 text-red-600 dark:text-red-400",children:["− ran on ",u.connectionName]}),(0,r.jsxs)("span",{className:"truncate text-emerald-600 dark:text-emerald-400",children:["+ ",e.applyPath]})]}):(0,r.jsx)("span",{className:"min-w-0 truncate font-mono text-[11px] text-muted-foreground",children:"revert"===j?e.revertPath??"no revert file":e.applyPath}),"schema"===j&&(0,r.jsxs)(f.$,{size:"xs",variant:"ghost",className:"ml-auto",onClick:x.onShowDiagram,children:[(0,r.jsx)(d.XE6,{"data-icon":"inline-start"}),"Diagram"]}),("apply"===j||"revert"===j)&&(0,r.jsxs)(f.$,{size:"xs",variant:"ghost",className:"ml-auto",onClick:()=>void B(),children:[N?(0,r.jsx)(d.wiW,{"data-icon":"inline-start"}):(0,r.jsx)(d.hX7,{"data-icon":"inline-start"}),N?"Copied":"Copy"]})]}),L.length>0&&(0,r.jsx)("ul",{className:"space-y-1 px-3 pb-2",children:L.map(e=>(0,r.jsxs)("li",{className:"flex gap-1.5 text-[11px] text-amber-700 dark:text-amber-400",children:[(0,r.jsx)(d.e5t,{className:"mt-px size-3 shrink-0"}),(0,r.jsx)("span",{children:e})]},e))}),"schema"===j&&w?(0,r.jsx)(z.ku,{changes:w,className:"max-h-96 overflow-auto pb-2"}):"changes"===j&&u?u.error?(0,r.jsx)("p",{className:"px-3 pb-3 font-mono text-xs text-destructive",children:u.error}):void 0===u.appliedSql?(0,r.jsxs)("p",{className:"px-3 pb-3 text-xs text-muted-foreground",children:["Reading what ran on ",u.connectionName,"…"]}):null===u.appliedSql?(0,r.jsxs)("p",{className:"px-3 pb-3 text-xs text-muted-foreground",children:[u.connectionName," did not keep the SQL it ran, so there is nothing to compare against."]}):(0,r.jsx)(R.u,{before:u.appliedSql,after:e.applySql,className:"max-h-96 pb-2"}):C?(0,r.jsx)(_.os,{sql:C,className:"max-h-72 overflow-auto px-3 pb-3"}):(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-3 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{children:"No revert file, so this one cannot be undone from here."}),o&&(0,r.jsxs)(f.$,{size:"xs",variant:"outline",onClick:x.onAttachRevert,children:[(0,r.jsx)(d.W4E,{"data-icon":"inline-start"}),"Add one"]})]})]})]})}function I({environments:e,targetId:t,onSelect:n}){let a=e.find(e=>e.connection.id===t);return a?(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"Running against"}),(0,r.jsxs)(h.rI,{children:[(0,r.jsxs)(h.ty,{disabled:e.length<2,className:"flex h-7 cursor-pointer items-center gap-1.5 rounded-lg border bg-background px-2 text-xs font-medium outline-none hover:bg-muted/60 focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-default data-open:bg-muted/60",children:[(0,r.jsx)(C.F,{connection:a.connection}),(0,r.jsx)("span",{className:"max-w-32 truncate",children:a.connection.name})]}),(0,r.jsx)(h.SQ,{align:"start",className:"min-w-52",children:e.map(e=>(0,r.jsxs)(h._2,{onClick:()=>n(e.connection.id),className:e.connection.id===t?"font-medium":void 0,children:[(0,r.jsx)(C.F,{connection:e.connection}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.connection.name}),(0,r.jsxs)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:[e.summary.applied,"/",e.summary.total]})]},e.connection.id))})]})]}):null}function T({environments:e,targetId:t,caption:n,loading:a,selection:i,onSelect:s,onCompare:l}){return(0,r.jsxs)("div",{className:"flex h-11 shrink-0 items-center border-b bg-muted/20",children:[(0,r.jsx)("span",{className:"flex h-11 shrink-0 items-center pl-3",children:(0,r.jsx)(E,{checked:i.checked,label:i.checked?"Clear selection":"Select all",onToggle:()=>i.onToggle()})}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate px-2 text-xs text-muted-foreground",children:n}),e.map(e=>{let{connection:n,summary:i,ledger:l,error:o}=e,c=n.id===t;return(0,r.jsxs)("button",{type:"button",disabled:c,"aria-current":c?"true":void 0,title:c?`${n.name} is what Apply and Revert run against`:`Run against ${n.name} instead`,onClick:()=>s(n.id),className:(0,S.cn)("flex h-11 shrink-0 flex-col items-center justify-center gap-0.5 border-l text-[11px] outline-none",P,c?"cursor-default bg-foreground/[0.04] font-medium":"cursor-pointer text-muted-foreground hover:bg-muted/60 hover:text-foreground",a&&"opacity-60"),children:[(0,r.jsxs)("span",{className:"flex max-w-full items-center gap-1",children:[(0,r.jsx)(C.F,{connection:n,className:"size-1.5"}),(0,r.jsx)("span",{className:"truncate",children:n.name})]}),o?(0,r.jsx)("span",{className:"text-destructive",children:"unreachable"}):l?(0,r.jsxs)("span",{className:"tabular-nums text-muted-foreground/80",children:[i.applied,"/",i.total,i.drifted>0&&(0,r.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:" !"})]}):(0,r.jsx)("span",{className:"text-muted-foreground/70",children:"reading…"})]},n.id)}),(0,r.jsx)("div",{className:(0,S.cn)("flex shrink-0 items-center justify-end border-l pr-2 pl-1",A),children:e.length>1&&(0,r.jsx)(f.$,{size:"icon-xs",variant:"ghost",title:"Compare the two schemas","aria-label":"Compare schemas",onClick:()=>{let n=e.find(e=>e.connection.id!==t);n&&l(n.connection.id)},children:(0,r.jsx)(d.R4X,{})})})]})}var L=n(42763),B=n(60529),W=n(33807);function V({schema:e,found:t,onOpenChange:n,onSave:a}){let[i,s]=(0,c.useState)(e),l=i.trim(),o=(0,j.hD)(l),d=t.filter(e=>e.schema!==l);function u(){o&&(a(l),n(!1))}return(0,r.jsx)(L.lG,{open:!0,onOpenChange:n,children:(0,r.jsxs)(L.Cf,{className:"sm:max-w-md",children:[(0,r.jsxs)(L.c7,{children:[(0,r.jsx)(L.L3,{children:"Ledger schema"}),(0,r.jsx)(L.rr,{children:"Where each database keeps its record of what has run. Created on the first apply."})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)(W.J,{htmlFor:"ledger-schema",children:"Schema"}),(0,r.jsx)(B.p,{id:"ledger-schema",value:i,spellCheck:!1,autoComplete:"off","aria-invalid":l.length>0&&!o,onChange:e=>s(e.target.value),onKeyDown:e=>"Enter"===e.key&&u()}),(0,r.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:o?`${l}.${j.R9}`:"\xa0"}),l.length>0&&!o&&(0,r.jsx)("p",{className:"text-xs text-destructive",children:"Letters, digits and underscores only, starting with a letter or underscore."})]}),d.length>0&&(0,r.jsxs)("p",{className:"rounded-md border border-amber-600/25 bg-amber-500/8 px-3 py-2 text-xs",children:[d.map(e=>`${e.name} keeps its ledger in ${e.schema}`).join("; "),". That one stays where it is."]}),(0,r.jsxs)(L.Es,{children:[l!==j.aC&&(0,r.jsx)(f.$,{variant:"ghost",onClick:()=>s(j.aC),children:"Reset"}),(0,r.jsx)(f.$,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),(0,r.jsx)(f.$,{disabled:!o,onClick:u,children:"Save"})]})]})})}var G=n(17021),K=n(41069),X=n(20185),Y=n(77649),Z=n(27013),H=n(18349);function Q({initial:e,file:t,onOpenChange:n,onSave:a}){let[i,s]=(0,c.useState)(e),[l,o]=(0,c.useState)(!1),[d,u]=(0,c.useState)(null),p=i.trim()!==e.trim();async function m(e){if(e?.preventDefault(),p&&!l){o(!0),u(null);try{await a(i.trim()),n(!1)}catch(e){u(e instanceof Error?e.message:String(e))}finally{o(!1)}}}return(0,r.jsx)(L.lG,{open:!0,onOpenChange:e=>!l&&n(e),children:(0,r.jsx)(L.Cf,{className:"sm:max-w-lg",showCloseButton:!1,children:(0,r.jsxs)("form",{onSubmit:e=>void m(e),className:"flex flex-col gap-4",children:[(0,r.jsx)(L.c7,{children:(0,r.jsxs)("div",{className:"flex items-baseline gap-3",children:[(0,r.jsx)(L.L3,{children:"Note"}),t&&(0,r.jsx)("span",{className:"ml-auto truncate font-mono text-[11px] text-muted-foreground",title:"Written into the migration's folder, to commit with the SQL",children:t})]})}),(0,r.jsx)(H.T,{autoFocus:!0,"aria-label":"Note",value:i,maxLength:j.XG,placeholder:"Apply 0001–0007, deploy the app, then apply 0008.",className:"max-h-[50vh] min-h-32",onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&m()}}),d&&(0,r.jsx)("p",{className:"text-xs text-destructive",children:d}),(0,r.jsxs)(L.Es,{children:[(0,r.jsx)(f.$,{type:"button",variant:"ghost",disabled:l,onClick:()=>n(!1),children:"Cancel"}),(0,r.jsx)(f.$,{type:"submit",disabled:!p||l,children:l?"Saving…":"Save"})]})]})})})}var U=n(59221),J=n(83504),ee=n(71612);let et=i()(()=>Promise.all([n.e(7446),n.e(8238),n.e(3862),n.e(9406),n.e(9146)]).then(n.bind(n,79146)).then(e=>e.SchemaDiagram),{loadableGenerated:{webpack:()=>[79146]},ssr:!1});function en({setId:e}){let t=(0,o.useRouter)(),{connection:n,tables:a}=(0,u.k)(),i=(0,N.jV)(e=>e.addFiles),s=(0,N.jV)(e=>e.renameSet),m=(0,N.jV)(e=>e.setNote),C=(0,N.jV)(e=>e.removeSet),_=(0,N.jV)(e=>e.removeStep),O=(0,N.jV)(e=>e.record),R=(0,N.jV)(e=>e.ledgerSchema),P=(0,N.jV)(e=>e.setLedgerSchema),A=(0,N.Ss)(e),{root:E,checkout:M}=(0,N.ox)(n.id),F=(0,ee.y)((0,j.km)(e)?E:null,M),L=(0,j.km)(e)?F.data?.sets.find(t=>t.id===e)??null:A,B=!!L?.source,W=(0,y.gz)(n.id),H=(0,q.En)(e=>e.setDraft),U=(0,p.$C)(),el=(0,X.ZG)((0,o.usePathname)()),eo=(0,K.hX)("migration"===el.kind?el.view:void 0),ec=(0,c.useCallback)(r=>{r!==eo&&t.push((0,X.Jn)({kind:"migration",connectionId:n.id,setId:e,view:(0,K.z2)(r)}),{scroll:!1})},[eo,t,n.id,e]),ed=(0,c.useRef)(null);(0,c.useEffect)(()=>{let e=ed.current;"migrations"===eo&&e&&(ed.current=null,window.requestAnimationFrame(()=>document.getElementById(`migration-${e}`)?.scrollIntoView({block:"start",behavior:"smooth"})))},[eo]);let[eu,ep]=(0,c.useState)([]),[em,ef]=(0,c.useState)([]),eh=(0,c.useRef)(null),[eg,ex]=(0,c.useState)(null),[ev,ek]=(0,c.useState)(null),[eb,ej]=(0,c.useState)(!1),[ey,ew]=(0,c.useState)(!1),[e$,eN]=(0,c.useState)(!1),[eq,eS]=(0,c.useState)(null),[eC,e_]=(0,c.useState)(null),[eO,ez]=(0,c.useState)(!1),[eR,eP]=(0,c.useState)(!1),[eA,eE]=(0,c.useState)(!1),eM=(0,c.useRef)(null),eF=(0,c.useRef)(!1),eD=(0,c.useMemo)(()=>[n,...W],[n,W]),eI=eD.map(e=>e.url).join("|"),eT=(0,x.Y)(`ledgers:${R}:${eI}`,async e=>Object.fromEntries(await Promise.all(eD.map(async t=>{try{return[t.id,{ledger:await v.F.ledger(t.url,R,e),error:null}]}catch(n){if(e.aborted)throw n;return[t.id,{ledger:null,error:n instanceof Error?n.message:String(n)}]}})))),eL=eT.data?.[n.id]??null,eB=L?.name??"",eW=(0,c.useMemo)(()=>(0,b.Gf)(eL?.ledger,eB),[eL?.ledger,eB]),eV=(0,c.useMemo)(()=>eD.map(e=>{let t=eT.data?.[e.id]??null,n=(0,b.Gf)(t?.ledger,eB);return{connection:e,ledger:n,error:t?.error??null,summary:(0,b.eh)(L,n)}}),[eD,eT.data,L,eB]),eG=(0,c.useMemo)(()=>{let e=new Set;for(let t of L?.steps??[])if(eu.includes(t.version))for(let n of eV)"drifted"===(0,b.FY)(t,n.ledger)&&e.add(n.connection.id);return eD.filter(t=>e.has(t.id))},[L,eu,eV,eD]),eK=(0,x.Y)(`stored:${R}:${eG.map(e=>e.url).join("|")}`,async e=>Object.fromEntries(await Promise.all(eG.map(async t=>{try{return[t.id,{ledger:await v.F.ledger(t.url,R,e,!0),error:null}]}catch(n){if(e.aborted)throw n;return[t.id,{ledger:null,error:n instanceof Error?n.message:String(n)}]}})))),eX=`/${encodeURIComponent(n.id)}/migrations`,eY=(0,N.jV)(e=>e.history),eZ=(0,c.useMemo)(()=>(0,w.x)(eV.map(e=>({connection:e.connection,ledger:e.ledger})),eY).filter(e=>e.setName===eB),[eV,eY,eB]),eH=(0,c.useMemo)(()=>"schema"===eo&&L?(0,$.DT)(L.steps.map(e=>({version:e.version,sql:e.applySql}))):null,[eo,L]),[eQ,eU]=(0,c.useState)(null),eJ=(0,c.useCallback)(e=>{eU(e),ec("diagram")},[ec]),e0=(0,c.useCallback)(e=>{ed.current=e,ep(t=>t.includes(e)?t:[...t,e]),ec("migrations")},[ec]),e1=(0,b.eh)(L,eW),e2=(0,c.useMemo)(()=>(0,b.nb)(L,eW),[L,eW]),e5=(0,b.kB)(L,eW),e3=(0,c.useCallback)(e=>{ec("migrations"),ek(null),ew(!1),ex({steps:[e],blockedBy:null,direction:"apply"})},[ec]),e4=(0,c.useCallback)((e,t)=>L&&L.name===e?L.steps.find(e=>e.version===t)??null:null,[L]),e6=(0,c.useCallback)(t=>{eS(i(e,t.files)),ec("migrations")},[i,e,ec]),e7=(0,Y.$)(e6);function e9(e,t,n=!1){(0!==t.steps.length||t.blockedBy)&&(ek(null),ew(!1),ex({...t,direction:e,recordOnly:n}))}function e8(e,t){return"apply"===t?e.applySql:e.revertSql}async function te(){if(!eg||!L)return;ew(!0),ej(!0);let e=eg.steps.map(e=>({version:e.version,name:e.name,status:"running"}));ek(e);try{let t=await v.F.rehearse(n.url,{steps:eg.steps.map(e=>({version:e.version,name:e.name,sql:e8(e,eg.direction)??""}))}),r=new Map(t.steps.map(e=>[e.version,e]));e=e.map(e=>{let n=r.get(e.version);return n?{...e,status:"ok",durationMs:n.durationMs}:t.failed?.version===e.version?{...e,status:"failed",error:t.failed.error}:{...e,status:"skipped"}})}catch(n){let t=n instanceof Error?n.message:String(n);e=e.map((e,n)=>0===n?{...e,status:"failed",error:t}:{...e,status:"skipped"})}ek(e),ej(!1)}function tt(e){return{steps:e,blockedBy:null}}async function tn(){if(!eg||!L)return;eF.current=!1,ew(!1),ej(!0);let e=eg.steps.map(e=>({version:e.version,name:e.name,status:"waiting"}));ek(e);let t=(t,n)=>{ek(e=e.map((e,r)=>r===t?{...e,...n}:e))},r=t=>{ek(e=e.map((e,n)=>n>=t&&"waiting"===e.status?{...e,status:"skipped"}:e))};for(let[e,a]of eg.steps.entries()){if(eF.current){r(e);break}let i="apply"===eg.direction?a.applySql:a.revertSql;if(!i&&!eg.recordOnly){t(e,{status:"failed",error:"No revert file for this migration."}),r(e+1);break}t(e,{status:"running"});let s=crypto.randomUUID();try{let r=await v.F.migrate(n.url,{runId:s,direction:eg.direction,version:a.version,name:a.name,checksum:a.checksum,setName:L.name,sql:i??"",revertSql:"apply"===eg.direction?a.revertSql:void 0,ledgerSchema:R,recordOnly:eg.recordOnly});t(e,{status:"ok",durationMs:r.durationMs}),O({runId:r.runId??s,setId:L.id,setName:L.name,connectionId:n.id,connectionName:n.name,direction:eg.direction,version:a.version,name:a.name,status:"ok",recorded:eg.recordOnly,durationMs:r.durationMs})}catch(l){let i=l instanceof Error?l.message:String(l);t(e,{status:"failed",error:i}),r(e+1),O({runId:s,setId:L.id,setName:L.name,connectionId:n.id,connectionName:n.name,direction:eg.direction,version:a.version,name:a.name,status:"failed",durationMs:0,error:i});break}}ej(!1),eT.reload(),eK.reload(),a.reload(),e.every(e=>"ok"===e.status)&&ef([])}function tr(e){H(n.id,e),t.push(`/${encodeURIComponent(n.id)}/query`)}function ta(e){U(e)}async function ti(e){L&&(L.source?(await v.F.note(L.source.root,L.source.path,e),F.reload()):m(L.id,e))}async function ts(e){let t=e?.[0];e_(null),t&&eC&&L&&eS(i(L.id,[{path:`revert/${eC}_${t.name}`,text:await t.text()}]))}if(!L){let t=(0,j.km)(e)&&F.loading;return(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,r.jsx)(er,{name:t?"Reading…":"Not found"}),(0,r.jsx)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 text-muted-foreground",children:t?(0,r.jsx)("p",{className:"text-sm",children:"Reading the folder…"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-sm",children:F.error?F.error:(0,j.km)(e)?"That migration is not in the folder on the branch you have checked out.":"That migration is no longer here."}),(0,r.jsx)(l(),{href:eX,className:"text-foreground underline underline-offset-4",children:"All migrations"})]})})]})}let tl=new Set(em),to=L.steps.filter(e=>tl.has(e.version)).length,tc=to>0,td=tc?(0,b.DM)(L,eW,tl):(0,b.gj)(L,eW),tu=tc?(0,b.n9)(L,eW,tl):(0,b.e)(L,eW),tp=eb||eT.loading||F.loading;return(0,r.jsxs)("div",{className:"relative flex min-h-0 flex-1 flex-col",onDragOver:e=>{!B&&e.dataTransfer.types.includes("Files")&&(e.preventDefault(),eN(!0))},children:[(0,r.jsxs)(er,{name:L?.name??"",indexHref:eX,children:[L.source&&(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground",title:`Read from ${L.source.path}`,children:[(0,r.jsx)(d.WzY,{className:"size-3.5 shrink-0"}),(0,r.jsx)("span",{className:"max-w-48 truncate font-mono",children:L.source.path}),F.data?.git&&(0,r.jsxs)("span",{className:"shrink-0 rounded border px-1.5 font-mono text-[10px]",children:[F.data.git.branch,F.data.git.dirty&&"*"]})]}),(0,r.jsx)(I,{environments:eV,targetId:n.id,onSelect:ta}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,r.jsx)(f.$,{size:"icon-sm",variant:"ghost",disabled:eT.loading||F.loading,"aria-label":"Refresh",title:B?"Re-read the files and every environment's ledger":"Re-read every environment's ledger",onClick:function(){eT.reload(),eK.reload(),B&&F.reload()},children:(0,r.jsx)(d.oS8,{className:(0,S.cn)((eT.loading||F.loading)&&"animate-spin")})}),!B&&(0,r.jsxs)(f.$,{size:"sm",variant:"ghost",onClick:()=>eN(!0),children:[(0,r.jsx)(d.FeY,{"data-icon":"inline-start"}),"Import"]}),(0,r.jsxs)(h.rI,{children:[(0,r.jsx)(h.ty,{render:(0,r.jsx)(f.$,{size:"icon-sm",variant:"ghost","aria-label":"More migration actions"}),className:"cursor-pointer",children:(0,r.jsx)(d.YKd,{})}),(0,r.jsxs)(h.SQ,{align:"end",className:"min-w-64",children:[(0,r.jsxs)(h._2,{disabled:tp||0===td.steps.length,onClick:()=>e9("apply",tt(td.steps),!0),children:[(0,r.jsx)(d.nXx,{}),"Mark ",td.steps.length," as already applied"]}),(0,r.jsx)(h.mB,{}),(0,r.jsxs)(h._2,{disabled:tp||0===tu.steps.length,onClick:()=>e9("revert",tu),children:[(0,r.jsx)(d.ij9,{}),tc?`Revert ${tu.steps.length} selected on ${n.name}`:`Revert everything on ${n.name}`]}),(0,r.jsx)(h.mB,{}),(0,r.jsxs)(h._2,{onClick:()=>eE(!0),children:[(0,r.jsx)(d.UA_,{}),L.note?"Edit note":"Add note"]}),!B&&(0,r.jsxs)(h._2,{onClick:()=>eP(!0),children:[(0,r.jsx)(d.NOV,{}),"Rename"]}),(0,r.jsxs)(h._2,{onClick:()=>ez(!0),children:[(0,r.jsx)(d.ooN,{}),"Ledger table",(0,r.jsxs)("span",{className:"ml-auto pl-3 font-mono text-[11px] text-muted-foreground",children:[R,".",j.R9]})]}),!B&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(h.mB,{}),(0,r.jsx)(h._2,{variant:"destructive",onClick:function(){L&&(C(L.id),t.push(eX))},children:"Forget this migration"})]})]})]}),(0,r.jsxs)(f.$,{size:"sm",disabled:tp||0===td.steps.length,onClick:()=>e9("apply",td),children:[(0,r.jsx)(d.eGB,{"data-icon":"inline-start"}),0===td.steps.length?tc?"Nothing selected to apply":"Up to date":`Apply ${td.steps.length}${tc?" selected":""} to ${n.name}`]})]})]}),eq&&(0,r.jsx)(ei,{report:eq,onDismiss:()=>eS(null)}),e7.error&&(0,r.jsx)("p",{className:"border-b bg-destructive/5 px-4 py-1.5 text-xs text-destructive",children:e7.error}),"migrations"===eo&&L.note&&(0,r.jsx)(ea,{note:L.note,notePath:L.source?.notePath??null,onEdit:()=>eE(!0)}),(0,r.jsxs)("div",{className:"relative flex min-h-0 flex-1 flex-col",children:["history"===eo?(0,r.jsx)(g.F,{className:"min-h-0 flex-1",children:(0,r.jsx)(G.H,{events:eZ,connections:eD,loading:eT.loading,ledgerSchema:R,setName:eB,findStep:e4,onLedgerChange:eT.reload,onRetry:e3})}):"schema"===eo&&eH?(0,r.jsx)(g.F,{className:"min-h-0 flex-1",children:(0,r.jsx)(z.ku,{changes:eH,onVersion:e0,className:"py-2"})}):"diagram"===eo?(0,r.jsx)(et,{steps:L.steps,live:a.data??null,at:eQ,onAt:eU,onVersion:e0}):eL?.error?(0,r.jsx)("p",{className:"flex-1 px-4 py-6 font-mono text-xs text-destructive",children:eL.error}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(T,{environments:eV,targetId:n.id,caption:tc?`${to} selected`:function(e,t){if(t&&0===e.total)return"Reading…";let n=`${e.total} migration${1===e.total?"":"s"}`;return e.foreign>0?`${n} \xb7 ${e.foreign} not in this folder`:n}(e1,eT.loading),loading:eT.loading,selection:{checked:0!==to&&(to===L.steps.length||"mixed"),onToggle:function(){if(!L)return;let e=L.steps.map(e=>e.version);ef(t=>t.some(t=>e.includes(t))?[]:e)}},onSelect:ta,onCompare:function(e){y.lz.getState().setCompareTarget(n.id,e),t.push(`/${encodeURIComponent(n.id)}/diff`)}}),(0,r.jsxs)(g.F,{className:(0,S.cn)("min-h-0 flex-1",eT.loading&&"opacity-70"),children:[(L?.steps.length??0)===0&&!B&&(0,r.jsx)("div",{className:"p-6",children:(0,r.jsx)(Y.k,{onFiles:e6,compact:!0})}),L.skipped.length>0&&B&&(0,r.jsxs)("div",{className:"border-b bg-muted/20 px-4 py-2 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(d.e5t,{className:"size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}),"Skipped ",L.skipped.length," file",1===L.skipped.length?"":"s"]}),(0,r.jsx)("ul",{className:"mt-1 space-y-0.5 pl-5 font-mono text-[11px]",children:L.skipped.map(e=>(0,r.jsx)("li",{children:e},e))})]}),(L?.steps??[]).map(e=>(0,r.jsx)(D,{step:e,targetId:n.id,status:(0,b.FY)(e,eW),environments:eV.map(t=>({connection:t.connection,status:(0,b.FY)(e,t.ledger),entry:(0,b.ay)(e,t.ledger),error:t.error})),isNewestApplied:e5?.version===e.version,expanded:eu.includes(e.version),busy:tp,editable:!B,drift:function(e){let t=eV.filter(t=>"drifted"===(0,b.FY)(e,t.ledger)),r=t.find(e=>e.connection.id===n.id)??t[0];if(!r)return null;let a=eK.data?.[r.connection.id],i=a?.ledger?.entries.find(t=>t.setName===eB&&t.version===e.version);return{connectionName:r.connection.name,appliedSql:a?.ledger?i?.applySql??null:void 0,error:a?.error??null}}(e),selected:tl.has(e.version),onSelect:t=>(function(e,t){if(!L)return;let n=L.steps.map(e=>e.version),r=eh.current;eh.current=e,ef(a=>{let i=!a.includes(e),s=[e];if(t&&r&&r!==e&&n.includes(r)){let[t,a]=[n.indexOf(r),n.indexOf(e)].sort((e,t)=>e-t);s=n.slice(t,a+1)}let l=new Set(a);for(let e of s)i?l.add(e):l.delete(e);return n.filter(e=>l.has(e))})})(e.version,t),onToggle:()=>{var t;return t=e.version,void ep(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},actions:{onApplyThrough:()=>e9("apply",(0,b.gj)(L,eW,e.version)),onApplyOne:()=>e9("apply",{steps:[e],blockedBy:null}),onRevertThrough:()=>e9("revert",(0,b.e)(L,eW,e.version)),onMarkApplied:()=>e9("apply",tt([e]),!0),onMarkPending:()=>e9("revert",tt([e]),!0),onAttachRevert:()=>{e_(e.version),window.requestAnimationFrame(()=>eM.current?.click())},onRemove:()=>L&&_(L.id,e.version),onOpenInEditor:tr,onShowDiagram:()=>eJ(e.version)}},e.version)),e2.length>0&&(0,r.jsx)(es,{entries:e2,connectionName:n.name})]})]}),e$&&!B&&(0,r.jsx)("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-background/85 p-6",onDragOver:e=>e.preventDefault(),onDragLeave:()=>eN(!1),onDrop:e=>{e.preventDefault(),eN(!1),e7.importFrom(e.dataTransfer)},children:(0,r.jsx)(Y.k,{onFiles:e6,className:"w-full max-w-xl bg-background"})})]}),(0,r.jsx)(K.lj,{pane:eo,onPaneChange:ec,historyCount:eZ.length,migrationsLabel:"Files",showSchema:!0,caption:eH?(0,z.Zg)(eH):function({connectionName:e,summary:t,initialized:n,loading:r,foundIn:a,configuredSchema:i}){if(r&&null===n)return"Reading ledgers…";let s=[];return!1===n||t.pending>0?s.push(`${t.pending} of ${t.total} pending on ${e}`):s.push(`${e} is up to date`),t.drifted>0&&s.push(`${t.drifted} changed since applied`),a&&a!==i&&s.push(`ledger in ${a}`),s.join(" \xb7 ")}({connectionName:n.name,summary:e1,initialized:eW?.initialized??null,loading:eT.loading,foundIn:eW?.initialized?eW.schema:null,configuredSchema:R})}),(0,r.jsx)("input",{ref:eM,type:"file",accept:".sql",className:"sr-only",onChange:e=>{ts(e.target.files),e.target.value=""}}),(0,r.jsx)(Z.K,{open:eR,title:"Rename migration",initial:L.name,submitLabel:"Rename",onOpenChange:eP,onSubmit:function(e){L&&s(L.id,e)}}),eA&&(0,r.jsx)(Q,{initial:L.note??"",file:L.source?L.source.notePath?.split(/[\\/]/).at(-1)??"README.md":null,onOpenChange:eE,onSave:ti}),eO&&(0,r.jsx)(V,{schema:R,found:eV.filter(e=>e.ledger?.initialized).map(e=>({name:e.connection.name,schema:e.ledger?.schema??R})),onOpenChange:ez,onSave:e=>{P(e),eT.reload()}}),eg&&(0,r.jsx)(J.I,{open:!0,direction:eg.direction,connection:n,steps:eg.steps,blockedBy:eg.blockedBy,progress:ev,running:eb,recordOnly:eg.recordOnly??!1,note:L.note,outOfOrder:"apply"!==eg.direction||eg.recordOnly?null:(0,b.nj)(eW,eg.steps),rehearsal:ey,onRun:()=>void tn(),onRehearse:!eg.recordOnly&&0!==eg.steps.length&&eg.steps.every(e=>{let t=e8(e,eg.direction);return!!t&&(0,k.Ol)(t).atomic})?()=>void te():null,onStop:()=>{eF.current=!0},onClose:function(){eb||(ex(null),ek(null),ew(!1))}})]})}function er({name:e,indexHref:t,children:n}){let a=(0,r.jsx)(d.olY,{className:"size-4 shrink-0 text-muted-foreground"});return(0,r.jsxs)(m.X,{children:[t?(0,r.jsx)(l(),{href:t,title:"All migrations","aria-label":"All migrations",className:"flex size-6 shrink-0 items-center justify-center rounded-md outline-none hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring/60",children:a}):a,(0,r.jsx)("span",{className:"min-w-0 truncate font-medium",children:e}),n]})}function ea({note:e,notePath:t,onEdit:n}){return(0,r.jsxs)("div",{title:t?`${t} \xb7 click to edit`:"Click to edit",onClick:e=>{e.target.closest("a")||n()},className:"group flex w-full cursor-pointer items-start gap-2 border-b px-4 py-2.5 text-left text-xs hover:bg-muted/30",children:[(0,r.jsx)(d.UA_,{className:"mt-px size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)(U.o,{text:e,className:"max-h-40 min-w-0 flex-1 overflow-y-auto"}),(0,r.jsx)("button",{type:"button","aria-label":"Edit note",onClick:e=>{e.stopPropagation(),n()},className:"mt-px shrink-0 rounded-sm text-muted-foreground opacity-0 outline-none group-hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring",children:(0,r.jsx)(d.NOV,{className:"size-3.5"})})]})}function ei({report:e,onDismiss:t}){let n=[];return e.added>0&&n.push(`added ${e.added}`),e.updated>0&&n.push(`updated ${e.updated}`),e.reverts>0&&n.push(`${e.reverts} revert file${1===e.reverts?"":"s"}`),(0,r.jsxs)("div",{className:"flex items-start gap-2 border-b bg-muted/30 px-4 py-1.5 text-xs",children:[(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[n.length>0?`Imported: ${n.join(", ")}`:"Nothing new in those files",e.skipped.length>0&&(0,r.jsxs)("span",{className:"text-muted-foreground",children:[" ","\xb7 skipped ",e.skipped.slice(0,2).join(", "),e.skipped.length>2&&` and ${e.skipped.length-2} more`]})]}),(0,r.jsx)(f.$,{size:"xs",variant:"ghost",onClick:t,children:"Dismiss"})]})}function es({entries:e,connectionName:t}){return(0,r.jsxs)("div",{className:"border-t bg-muted/20",children:[(0,r.jsxs)("p",{className:"flex items-center gap-2 px-4 py-2 text-xs text-muted-foreground",children:[(0,r.jsx)(d.e5t,{className:"size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}),"Applied on ",t,", not in this folder"]}),e.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-1.5 text-xs opacity-70",children:[(0,r.jsx)(F,{status:"applied"}),(0,r.jsx)("span",{className:"shrink-0 font-mono text-muted-foreground",children:e.version}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.name||"—"}),(0,r.jsx)("span",{className:"shrink-0 text-muted-foreground/70",children:new Date(e.appliedAt).toLocaleString()})]},e.version))]})}},64054:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n={bindSnapshot:function(){return o},createAsyncLocalStorage:function(){return l},createSnapshot:function(){return c}};for(var r in n)Object.defineProperty(t,r,{enumerable:!0,get:n[r]});let a=Object.defineProperty(Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available"),"__NEXT_ERROR_CODE",{value:"E504",enumerable:!1,configurable:!0});class i{disable(){throw a}getStore(){}run(){throw a}exit(){throw a}enterWith(){throw a}static bind(e){return e}}let s="u">typeof globalThis&&globalThis.AsyncLocalStorage;function l(){return s?new s:new i}function o(e){return s?s.bind(e):i.bind(e)}function c(){return s?s.snapshot():function(e,...t){return e(...t)}}},67369:(e,t,n)=>{"use strict";n.d(t,{Rj:()=>u,Xq:()=>d,Zg:()=>k,jj:()=>c,ku:()=>p});var r=n(95155),a=n(13267),i=n(85904),s=n(40980);let l={table:a.ooN,view:a.H0j,"materialized-view":a.H0j,function:a._1S,procedure:a._1S,enum:a.E81,type:a.s3x,domain:a.s3x,sequence:a.AnM,index:a.Ht9,schema:a.XE6,extension:a.Ync},o={table:"table",view:"view","materialized-view":"materialized view",function:"function",procedure:"procedure",enum:"enum",type:"type",domain:"domain",sequence:"sequence",index:"index",schema:"schema",extension:"extension"},c="text-emerald-600 dark:text-emerald-400",d="text-red-600 dark:text-red-400",u="text-amber-600 dark:text-amber-400";function p({changes:e,onVersion:t,className:n}){return 0===e.subjects.length&&0===e.other.length?(0,r.jsx)("p",{className:(0,s.cn)("px-3 py-2 text-xs text-muted-foreground",n),children:"No schema changes"}):(0,r.jsxs)("div",{className:(0,s.cn)("space-y-0.5 py-1",n),children:[e.subjects.map(e=>(0,r.jsx)(f,{subject:e,onVersion:t},`${e.kind}:${e.schema}.${e.name}:${e.detail??""}`)),e.other.length>0&&(0,r.jsx)(v,{other:e.other,onVersion:t})]})}function m({subject:e}){let t=e.from,n=t&&t.schema!==e.schema,a=t&&t.name!==e.name;switch(e.effect){case"created":return(0,r.jsx)("span",{className:(0,s.cn)("shrink-0 text-[11px]",c),children:"new"});case"replaced":return(0,r.jsx)("span",{className:(0,s.cn)("shrink-0 text-[11px]",c),title:"CREATE OR REPLACE: new, or redefined in place",children:"new or replaced"});case"dropped":return(0,r.jsx)("span",{className:(0,s.cn)("shrink-0 text-[11px]",d),children:"dropped"});case"altered":if(!t)return null;return(0,r.jsx)("span",{className:(0,s.cn)("shrink-0 font-mono text-[11px]",u),children:a?`renamed from ${n?(0,i.OL)(t.schema,t.name):t.name}`:`moved from ${t.schema}`})}}function f({subject:e,onVersion:t}){let n=l[e.kind],a="dropped"===e.effect;return(0,r.jsxs)("div",{className:"px-3 py-1",children:[(0,r.jsxs)("div",{className:"flex h-6 min-w-0 items-center gap-2",children:[(0,r.jsx)("span",{title:o[e.kind],className:"flex shrink-0",children:(0,r.jsx)(n,{className:"size-3.5 text-muted-foreground"})}),(0,r.jsx)("span",{className:(0,s.cn)("min-w-0 shrink-0 truncate font-mono text-xs font-medium",a&&"text-muted-foreground line-through decoration-red-500/60"),children:"schema"===e.kind||"extension"===e.kind?e.name:(0,i.OL)(e.schema,e.name)}),(0,r.jsx)(m,{subject:e}),e.detail&&(0,r.jsx)("span",{className:"min-w-0 truncate font-mono text-[11px] text-muted-foreground",title:e.detail,children:e.detail}),t&&0===e.parts.length&&(0,r.jsx)(x,{versions:e.versions,onVersion:t,className:"ml-auto"})]}),e.parts.length>0&&(0,r.jsx)("div",{className:(0,s.cn)("ml-[6px] grid items-baseline gap-x-3 border-l pl-3",t?"grid-cols-[0.75rem_auto_minmax(0,max-content)_minmax(0,1fr)_auto]":"grid-cols-[0.75rem_auto_minmax(0,max-content)_minmax(0,1fr)]"),children:e.parts.map((e,n)=>(0,r.jsx)(g,{part:e,onVersion:t},`${e.kind}:${e.name}:${n}`))})]})}let h={column:"column",constraint:"constraint",index:"index",trigger:"trigger",policy:"policy",value:"value",rows:"rows",setting:"setting",comment:"comment",grant:"grant"};function g({part:e,onVersion:t}){let n=function(e){if("rows"===e.kind)return{sign:"≡",className:"text-muted-foreground",title:"data"};switch(e.op){case"add":return{sign:"+",className:c,title:"added"};case"drop":return{sign:"−",className:d,title:"dropped"};case"rename":return{sign:"~",className:u,title:"renamed"};case"change":return{sign:"~",className:u,title:"changed"}}}(e),a="grant"===e.kind&&"drop"===e.op?"revoke":h[e.kind],i="value"===e.kind?`'${e.name}'`:e.name,l=void 0!==e.from?"value"===e.kind?`'${e.from}'`:e.from:void 0,o="drop"===e.op&&"grant"!==e.kind&&"comment"!==e.kind?void 0:e.detail;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:(0,s.cn)("text-center font-mono text-xs select-none",n.className),title:n.title,children:n.sign}),(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground/80",children:a}),(0,r.jsxs)("span",{className:(0,s.cn)("min-w-0 truncate py-px font-mono text-xs","drop"===e.op&&"text-muted-foreground"),title:l?`${l} → ${i}`:i,children:[l&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:l}),(0,r.jsx)("span",{className:"px-1 text-muted-foreground/60",children:"→"})]}),i]}),(0,r.jsx)("span",{className:"min-w-0 truncate font-mono text-[11px] text-muted-foreground",title:o,children:o}),t&&(0,r.jsx)(x,{versions:e.versions,onVersion:t})]})}function x({versions:e,onVersion:t,className:n}){let a=e.length>3?[e[0],e[e.length-1]]:e;return(0,r.jsx)("span",{className:(0,s.cn)("flex shrink-0 items-baseline justify-end gap-1.5 font-mono text-[10px]",n),children:a.map((n,a)=>(0,r.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[e.length>3&&1===a&&(0,r.jsx)("span",{className:"text-muted-foreground/50",title:e.join(", "),children:"…"}),(0,r.jsx)("button",{type:"button",title:`Show ${n}`,onClick:()=>t(n),className:"cursor-pointer rounded-sm text-muted-foreground/70 outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60",children:n})]},n))})}function v({other:e,onVersion:t}){return(0,r.jsxs)("div",{className:"px-3 py-1",children:[(0,r.jsxs)("div",{className:"flex h-6 items-center gap-2",children:[(0,r.jsx)(a.hHi,{className:"size-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",title:"Statements that are not a schema change this can describe",children:"Other statements"})]}),(0,r.jsx)("div",{className:"ml-[6px] space-y-px border-l pl-3",children:e.map(e=>(0,r.jsxs)("div",{className:"flex min-w-0 items-baseline gap-3",children:[(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground",title:e.text,children:e.text}),t&&(0,r.jsx)(x,{versions:e.versions,onVersion:t})]},e.text))})]})}function k(e){let t=0,n=0,r=0;for(let a of e.subjects)"created"===a.effect||"replaced"===a.effect?t+=1:"dropped"===a.effect?r+=1:n+=1;let a=[];return t>0&&a.push(`${t} new`),n>0&&a.push(`${n} changed`),r>0&&a.push(`${r} dropped`),a.length>0?a.join(" \xb7 "):"No schema changes"}},68635:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return o}});let r=n(95155),a=n(12115),i=n(41112);function s(e){return{default:e&&"default"in e?e.default:e}}n(21957);let l={loader:()=>Promise.resolve(s(()=>null)),loading:null,ssr:!0},o=function(e){let t={...l,...e},n=(0,a.lazy)(()=>t.loader().then(s)),o=t.loading;function c(e){let s=o?(0,r.jsx)(o,{isLoading:!0,pastDelay:!0,error:null}):null,l=!t.ssr||!!t.loading,c=l?a.Suspense:a.Fragment,d=t.ssr?(0,r.jsxs)(r.Fragment,{children:[null,(0,r.jsx)(n,{...e})]}):(0,r.jsx)(i.BailoutToCSR,{reason:"next/dynamic",children:(0,r.jsx)(n,{...e})});return(0,r.jsx)(c,{...l?{fallback:s}:{},children:d})}return c.displayName="LoadableComponent",c}},75707:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return a}});let r=n(73623)._(n(68635));function a(e,t){let n={};"function"==typeof e&&(n.loader=e);let a={...n,...t};return(0,r.default)({...a,modules:a.loadableGenerated?.modules})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},79781:(e,t,n)=>{"use strict";n.d(t,{$C:()=>d,yG:()=>u});var r=n(73321),a=n(12115),i=n(27529),s=n(15923),l=n(20185),o=n(69586),c=n(36331);function d(){let e=(0,r.useRouter)(),t=(0,r.usePathname)(),{connection:n}=(0,c.k)(),d=(0,o.Z)(e=>e.connections);return(0,a.useCallback)(async r=>{if(r===n.id)return;let a=d.find(e=>e.id===r);if(!a)return;(0,s.r)();let o=(0,l.ZG)(t),c=!!n.layoutGroup&&n.layoutGroup===a.layoutGroup,u=!0;if("table"===o.kind&&!c)try{var p,m;p=await i.F.tables(a.url),m=o.table,u=p.some(e=>e.schema===m.schema&&e.name===m.name)}catch{u=!1}e.push((0,l.gZ)(t,r,{tableExists:u}))},[n.id,n.layoutGroup,d,t,e])}function u(){let{connection:e}=(0,c.k)(),t=(0,o.Z)(e=>e.connections),n=d(),r=function(e,t){let n=e.findIndex(e=>e.id===t);if(!(e.length<2)&&-1!==n)return e[(n+1)%e.length]}(t,e.id);return{run:()=>r?n(r.id):Promise.resolve(),enabled:void 0!==r,next:r}}},85904:(e,t,n)=>{"use strict";function r(e){let t=new b;for(let n of e)!function(e,t,n){let r=e.replace(/^[ \t]*\\[^\n]*$/gm,""),s={builder:n,version:t,schema:a,sql:r};for(let e of N(l(r)))(function e(t,n,r){var a,s;let o,c;if(0===t.length)return!0;let d=new p(t,n.sql);try{o=function(t,n,r){let a=t.peek();if(a?.kind!=="word")return!1;let s=a.value;if(q.has(s))return!0;switch(s){case"set":var o,c,d=t,u=n,f=r;if(d.accept("set"),d.acceptOne(["session","local"]),!d.accept("search_path"))return!0;for(let e of(d.acceptPunct("=")||d.accept("to"),m(d.rest()))){let t=e[0];if(!t)continue;let n="string"===t.kind?t.value.trim():t.value;if(n&&"$user"!==n&&"default"!==n){f.schema=n.replace(/^"(.*)"$/,"$1"),u.schema=f.schema;break}}return!0;case"create":return function(e,t){e.accept("create");let n=e.accept("or","replace"),r=!1,a=!1,s=!1,l=!1;for(;;){let t=e.acceptOne(["temp","temporary","unlogged","global","local","unique","materialized","recursive","constraint","trusted","procedural","foreign"]);if(!t)break;("temp"===t||"temporary"===t)&&(r=!0),"unique"===t&&(a=!0),"materialized"===t&&(s=!0),"constraint"===t&&(l=!0)}let o=e.acceptOne(["table","view","index","type","domain","function","procedure","trigger","policy","schema","extension","sequence"]);switch(o){case"table":return function(e,t,n){e.accept("if","not","exists");let r=e.qualified();if(!r)return!1;if(n||"pg_temp"===r.schema)return!0;let{schema:a,name:s}=S(t,r),l=[],o=null;if(e.accept("partition","of")){let n=e.qualified();n&&l.push(`partition of ${i(S(t,n).schema,n.name)}`),o=e.group();let r=e.until(e=>"word"===e.kind&&"partition"===e.value);r.length>0&&l.push(g(r,t.sql))}else if(e.accept("of")){let t=e.qualified();t&&l.push(`of type ${t.name}`),o=e.group()}else o=e.group();let c=e.rest(),d=e.sub(c);for(;!d.done;)if(d.accept("inherits")){let e=d.group();e&&l.push(`inherits ${x(e,t.sql).join(", ")}`)}else if(d.accept("partition","by")){let e=d.name(),n=d.group();l.push(`partitioned by ${e??""} (${n?x(n,t.sql).join(", "):""})`)}else if(d.accept("as")){l.push("from a query");break}else d.pos+=1;let u=t.builder.create("table",a,s,t.version,{detail:l.length>0?l.join(" \xb7 "):void 0});if(!o)return!0;for(let n of m(o)){let r=e.sub(n);if(r.isWord("like")){r.pos+=1;let e=r.qualified();e&&$(u,{kind:"setting",op:"add",name:"columns like",detail:e.name},t.version);continue}if(C(n[0])){let e=R(r,t,s);e&&P(u,e,t.version);continue}let a=_(r,t,s);a&&$(u,{kind:"column",op:"add",name:a.name,facts:a.facts},t.version)}return!0}(e,t,r);case"view":return function(e,t,n,r,a){e.accept("if","not","exists");let s=e.qualified();if(!s)return!1;if(a)return!0;let{schema:l,name:o}=S(t,s);e.group();let c=e.rest(),d=new Set,u=new Set,m=0;for(let e=0;e<c.length-1;e+=1){let n=c[e];if("punct"===n.kind&&"("===n.value&&(m+=1),"punct"===n.kind&&")"===n.value&&(m-=1),0===m&&("word"===n.kind||"ident"===n.kind)&&c[e+1]?.value==="as"&&c[e+2]?.value==="("&&u.add(n.value),0!==m||"word"!==n.kind||"from"!==n.value&&"join"!==n.value)continue;let r=c[e+1];if("word"!==r.kind&&"ident"!==r.kind)continue;let a=new p(c.slice(e+1),t.sql).qualified();!a||u.has(a.name)||["select","lateral","unnest","only"].includes(a.name)||d.add(i(S(t,a).schema,a.name))}return t.builder.create(n?"materialized-view":"view",l,o,t.version,{replace:r,detail:d.size>0?`from ${[...d].join(", ")}`:void 0}),!0}(e,t,s,n,r);case"index":return function(e,t,n){e.accept("concurrently"),e.accept("if","not","exists");let r=null;if(e.isWord("on")||(r=e.name()),!e.accept("on"))return!1;e.accept("only");let a=e.qualified();if(!a)return!1;let i=S(t,a),s=null;e.accept("using")&&(s=e.name());let l=e.group()??[],o=x(l,t.sql),c=new p(e.rest(),t.sql),d=[];for(;!c.done;)if(c.accept("include")){let e=c.group();e&&d.push(`include (${x(e,t.sql).join(", ")})`)}else c.accept("where")?d.push(`where ${g(c.rest(),t.sql)}`):c.pos+=1;let u=r??`${i.name}_${m(l).map(M).join("_")}_idx`,f=[`${n?"unique ":""}(${o.join(", ")})`,s&&"btree"!==s?`using ${s}`:"",...d].filter(Boolean).join(" \xb7 ");return $(t.builder.alter("table",i.schema,i.name,t.version),{kind:"index",op:"add",name:u,detail:f},t.version),!0}(e,t,a);case"type":return function(e,t){let n=e.qualified();if(!n)return!1;let{schema:r,name:a}=S(t,n);if(!e.accept("as"))return t.builder.create("type",r,a,t.version),!0;if(e.accept("enum")){let n=e.group()??[],i=t.builder.create("enum",r,a,t.version);for(let e of n)"string"===e.kind&&$(i,{kind:"value",op:"add",name:e.value},t.version);return!0}if(e.accept("range")){let n=e.group()??[],i=n.findIndex(e=>"word"===e.kind&&"subtype"===e.value),s=-1!==i?n[i+2]?.value:void 0;return t.builder.create("type",r,a,t.version,{detail:s?`range of ${s}`:"range"}),!0}let i=e.group(),s=t.builder.create("type",r,a,t.version,{detail:"composite"});for(let n of i?m(i):[]){let r=_(e.sub(n),t,a);r&&$(s,{kind:"column",op:"add",name:r.name,facts:r.facts},t.version)}return!0}(e,t);case"domain":return function(e,t){e.accept("if","not","exists");let n=e.qualified();if(!n)return!1;let{schema:r,name:a}=S(t,n);e.accept("as");let i=_(e.sub([{kind:"word",value:a,start:0,end:0},...e.rest()]),t,a);return t.builder.create("domain",r,a,t.version,{detail:i?.facts.map(e=>e.text).join(" \xb7 ")||void 0}),!0}(e,t);case"function":case"procedure":return function(e,t,n,r){let a=e.qualified();if(!a)return!1;let{schema:i,name:s}=S(t,a),l=e.group()??[],o=null;if(e.accept("returns"))if(e.accept("table")){let n=e.group();o=`table(${n?m(n).map(e=>g(e,t.sql)).join(", "):""})`}else o=g(e.until(e=>"word"===e.kind&&["language","as","immutable","stable","volatile","security","strict","called","cost","rows","set","parallel","leakproof","not","begin","return","window","support","transform","external"].includes(e.value)),t.sql);let c=m(l).map(e=>g(e,t.sql)).join(", ");return t.builder.create(n,i,s,t.version,{replace:r,signature:D(l,t.sql),detail:`(${c})${o?` → ${o}`:""}`}),!0}(e,t,o,n);case"trigger":return function(e,t,n){let r=e.name();if(null===r)return!1;let a=e.accept("instead","of")?"instead of":e.acceptOne(["before","after"]),s=[];for(;;){let t=e.acceptOne(["insert","update","delete","truncate"]);if(!t)break;if("update"===t&&e.accept("of")){let t=[];do{let n=e.name();n&&t.push(n)}while(e.acceptPunct(","));s.push(`update of ${t.join(", ")}`)}else s.push(t);if(!e.accept("or"))break}if(!e.accept("on"))return!1;let l=e.qualified();if(!l)return!1;let o=S(t,l),c=new p(e.rest(),t.sql),d=!1,u=null;for(;!c.done;)if(c.accept("for","each","row")||c.accept("for","row"))d=!0;else if(c.accept("execute","function")||c.accept("execute","procedure")){let e=c.qualified();e&&(u=`${i(S(t,e).schema,e.name)}()`)}else c.pos+=1;let m=[[a,s.join(" or ")].filter(Boolean).join(" "),d?"each row":"",n?"constraint":""].filter(Boolean).join(" \xb7 ");return $(t.builder.alter("table",o.schema,o.name,t.version),{kind:"trigger",op:"add",name:r,detail:u?`${m} → ${u}`:m},t.version),!0}(e,t,l);case"policy":var c=e,d=t;let u=c.name();if(null===u||!c.accept("on"))return!1;let f=c.qualified();if(!f)return!1;let h=S(d,f);return $(d.builder.alter("table",h.schema,h.name,d.version),{kind:"policy",op:"add",name:u,detail:I(c,d.sql)},d.version),!0;case"schema":var v=e,k=t;v.accept("if","not","exists");let b=v.isWord("authorization")?null:v.name();if(v.accept("authorization")){let e=v.name();b=b??e}return null!==b&&(k.builder.create("schema",b,b,k.version),!0);case"extension":let j;var y=e,w=t;y.accept("if","not","exists");let N=y.name();if(null===N)return!1;if(y.accept("with"),y.accept("schema")){let e=y.name();e&&(j=`in ${e}`)}return w.builder.create("extension","",N,w.version,{detail:j}),!0;case"sequence":return function(e,t,n){e.accept("if","not","exists");let r=e.qualified();if(!r)return!1;if(n)return!0;let{schema:a,name:i}=S(t,r),s=g(e.rest(),t.sql);return t.builder.create("sequence",a,i,t.version,{detail:s||void 0}),!0}(e,t,r);default:return!1}}(t,n);case"alter":return o=t,c=n,(o.accept("alter"),o.accept("table")||o.accept("foreign","table"))?T(o,c,"table"):o.accept("view")?T(o,c,"view"):o.accept("materialized","view")?T(o,c,"materialized-view"):o.accept("type")?function(e,t){let n=e.qualified();if(!n)return!1;let r=S(t,n),{builder:a,version:i,sql:s}=t,l=a.find("type",r.schema,r.name)?.kind??(e.isWord("add")&&e.isWord("value",1)||e.isWord("rename")&&e.isWord("value",1)?"enum":"type");if(e.accept("rename","to")){let t=e.name();return null!==t&&(a.move(l,r,{schema:r.schema,name:t},i),!0)}if(e.accept("set","schema")){let t=e.name();return null!==t&&(a.move(l,r,{schema:t,name:r.name},i),!0)}let o=a.alter(l,r.schema,r.name,i);if(e.accept("add","value")){e.accept("if","not","exists");let t=e.peek();if(t?.kind!=="string")return!1;e.pos+=1;let n=e.acceptOne(["before","after"]),r=e.peek();return $(o,{kind:"value",op:"add",name:t.value,detail:n&&r?.kind==="string"?`${n} '${r.value}'`:void 0},i),!0}if(e.accept("rename","value")){let t=e.peek();if(t?.kind!=="string")return!1;e.pos+=1,e.accept("to");let n=e.peek();return n?.kind==="string"&&($(o,{kind:"value",op:"rename",name:n.value,from:t.value},i),!0)}if(e.accept("rename","attribute")){let t=e.name();e.accept("to");let n=e.name();return null!==t&&null!==n&&($(o,{kind:"column",op:"rename",name:n,from:t},i),!0)}for(let n of m(e.rest())){let a=e.sub(n);if(a.accept("add","attribute")){let e=_(a,t,r.name);e&&$(o,{kind:"column",op:"add",name:e.name,facts:e.facts},i)}else if(a.accept("drop","attribute")){a.accept("if","exists");let e=a.name();e&&$(o,{kind:"column",op:"drop",name:e},i)}else if(a.accept("alter","attribute")){let e=a.name();if(e){let t=L(a,s);$(o,{kind:"column",op:"change",name:e,facts:[{aspect:t.aspect,text:t.text}]},i)}}else if(a.accept("owner","to"))$(o,{kind:"setting",op:"change",name:"owner",detail:g(a.rest(),s)},i);else{let e=g(n,s);e&&$(o,{kind:"setting",op:"change",name:e},i)}}return!0}(o,c):o.accept("domain")?function(e,t){let n=e.qualified();if(!n)return!1;let r=S(t,n),{builder:a,version:i,sql:s}=t;if(e.accept("rename","to")){let t=e.name();return null!==t&&(a.move("domain",r,{schema:r.schema,name:t},i),!0)}let l=a.alter("domain",r.schema,r.name,i);if(e.accept("add")){let n=R(e.sub(e.rest()),t,r.name);return n&&P(l,n,i),!0}if(e.accept("drop","constraint")){e.accept("if","exists");let t=e.name();return t&&$(l,{kind:"constraint",op:"drop",name:t},i),!0}if(e.accept("rename","constraint")){let t=e.name();e.accept("to");let n=e.name();return t&&n&&$(l,{kind:"constraint",op:"rename",name:n,from:t},i),!0}let o=g(e.rest(),s);return o&&$(l,{kind:"setting",op:"change",name:o},i),!0}(o,c):o.accept("function")?B(o,c,"function"):o.accept("procedure")||o.accept("routine")?B(o,c,"procedure"):o.accept("sequence")?function(e,t){e.accept("if","exists");let n=e.qualified();if(!n)return!1;let r=S(t,n),{builder:a,version:i}=t;if(e.accept("rename","to")){let t=e.name();return null!==t&&(a.move("sequence",r,{schema:r.schema,name:t},i),!0)}if(e.accept("set","schema")){let t=e.name();return null!==t&&(a.move("sequence",r,{schema:t,name:r.name},i),!0)}let s=a.alter("sequence",r.schema,r.name,i),l=g(e.rest(),t.sql);return l&&$(s,{kind:"setting",op:"change",name:l},i),!0}(o,c):o.accept("index")?function(e,t){e.accept("if","exists");let n=e.qualified();if(!n)return!1;let r=S(t,n),{builder:a,version:i}=t;if(e.accept("rename","to")){let t=e.name();if(null===t)return!1;let n=a.findPart("index",r.schema,r.name);return n?(n.subject.versions.add(i),$(n.subject,{kind:"index",op:"rename",name:t,from:r.name},i)):a.move("index",r,{schema:r.schema,name:t},i),!0}let s=a.alter("index",r.schema,r.name,i),l=g(e.rest(),t.sql);return l&&$(s,{kind:"setting",op:"change",name:l},i),!0}(o,c):o.accept("schema")?function(e,t){let n=e.name();if(null===n)return!1;let{builder:r,version:a}=t;if(e.accept("rename","to")){let t=e.name();return null!==t&&(r.move("schema",{schema:n,name:n},{schema:t,name:t},a),!0)}let i=r.alter("schema",n,n,a);return e.accept("owner","to")&&$(i,{kind:"setting",op:"change",name:"owner",detail:g(e.rest(),t.sql)},a),!0}(o,c):o.accept("extension")?function(e,t){let n=e.name();if(null===n)return!1;let r=t.builder.alter("extension","",n,t.version);if(e.accept("update")){let n=e.accept("to")?e.peek():void 0;return $(r,{kind:"setting",op:"change",name:"version",detail:n?n.value:"latest"},t.version),!0}let a=g(e.rest(),t.sql);return a&&$(r,{kind:"setting",op:"change",name:a},t.version),!0}(o,c):o.accept("trigger")?W(o,c,"trigger"):!!o.accept("policy")&&W(o,c,"policy");case"drop":return function(e,t){e.accept("drop");let n=V.find(([t])=>e.accept(...t));if(!n)return!1;let r=n[1];e.accept("concurrently"),e.accept("if","exists");let{builder:a,version:i,sql:s}=t;if("trigger"===r||"policy"===r){let n=e.name();if(null===n||!e.accept("on"))return!1;let s=e.qualified();if(!s)return!1;let l=S(t,s);return $(a.alter("table",l.schema,l.name,i),{kind:r,op:"drop",name:n},i),!0}for(let n of m(e.until(e=>"word"===e.kind&&("cascade"===e.value||"restrict"===e.value)))){let l=e.sub(n);if("schema"===r||"extension"===r){let e=l.name();e&&a.drop(r,"schema"===r?e:"",e,i);continue}let o=l.qualified();if(!o)continue;let c=S(t,o);if("index"===r){let e=a.findPart("index",c.schema,c.name);e?(e.subject.versions.add(i),$(e.subject,{kind:"index",op:"drop",name:c.name},i)):a.drop("index",c.schema,c.name,i);continue}if("function"===r||"procedure"===r){let e=l.group(),t=a.find(r,c.schema,c.name,e?D(e,s):void 0,!0);a.drop(t?.kind??r,c.schema,c.name,i,t?.signature??(e?D(e,s):void 0));continue}let d=a.find(r,c.schema,c.name);a.drop(d&&v(d.kind)===v(r)?d.kind:r,c.schema,c.name,i)}return!0}(t,n);case"comment":return function(e,t){let n;if(!e.accept("comment","on"))return!1;let{builder:r,version:a}=t,i=[[["table"],"table"],[["foreign","table"],"table"],[["materialized","view"],"materialized-view"],[["view"],"view"],[["column"],"column"],[["constraint"],"constraint"],[["trigger"],"trigger"],[["policy"],"policy"],[["index"],"index"],[["sequence"],"sequence"],[["type"],"type"],[["domain"],"domain"],[["function"],"function"],[["procedure"],"procedure"],[["schema"],"schema"],[["extension"],"extension"]].find(([t])=>e.accept(...t));if(!i)return!1;let s=i[1],l=()=>{let t=e.rest(),n=t.findIndex(e=>"word"===e.kind&&"is"===e.value),r=t[n+1];return r?.kind==="string"?{op:"add",detail:r.value}:{op:"drop",detail:"removed"}};if("column"===s){let n=[];do{let t=e.name();if(null===t)return!1;n.push(t)}while(e.acceptPunct("."));if(n.length<2)return!1;let i=n[n.length-1],s=n[n.length-2],o=n.length>2?n[n.length-3]:t.schema,c=r.find("table",o,s);return $(r.alter(c?.kind??"table",o,s,a),{kind:"comment",name:i,...l()},a),!0}if("constraint"===s||"trigger"===s||"policy"===s){let n=e.name();if(null===n||!e.accept("on"))return!1;"constraint"===s&&e.accept("domain");let i=e.qualified();if(!i)return!1;let o=S(t,i),c=r.find("table",o.schema,o.name);return $(r.alter(c?.kind??"table",o.schema,o.name,a),{kind:"comment",name:n,...l()},a),!0}if("schema"===s||"extension"===s){let t=e.name();return null!==t&&($(r.alter(s,"schema"===s?t:"",t,a),{kind:"comment",name:"",...l()},a),!0)}let o=e.qualified();if(!o)return!1;let c=S(t,o);if("function"===s||"procedure"===s){let r=e.group();n=r?D(r,t.sql):void 0}if("index"===s){let e=r.findPart("index",c.schema,c.name);if(e)return $(e.subject,{kind:"comment",name:c.name,...l()},a),!0}let d=r.find(s,c.schema,c.name,n);return $(r.alter(d?.kind??s,c.schema,c.name,a,d?.signature??n),{kind:"comment",name:"",...l()},a),!0}(t,n);case"grant":case"revoke":return function(e,t){let n=e.accept("grant");n||e.accept("revoke"),n||e.accept("grant","option","for");let r=g(e.until(e=>"word"===e.kind&&"on"===e.value),t.sql);if(!e.accept("on"))return!1;let{builder:a,version:i}=t,s=n=>{let r=e.sub(n);return r.acceptOne(["to","from"]),g(r.until(e=>"word"===e.kind&&["with","granted","cascade","restrict"].includes(e.value)),t.sql)};if(e.accept("all")){let t=e.name();if(!e.accept("in","schema"))return!1;let l=m(e.until(e=>"word"===e.kind&&("to"===e.value||"from"===e.value))),o=s(e.rest());for(let e of l){let s=e[0]?.value;s&&$(a.alter("schema",s,s,i),{kind:"grant",op:n?"add":"drop",name:o,detail:`${r} on all ${t??""}`},i)}return!0}let l=e.acceptOne(["table","sequence","function","procedure","routine","schema","type","domain","database","language","tablespace","foreign"]);if("database"===l||"language"===l||"tablespace"===l||"foreign"===l)return!1;let o=m(e.until(e=>"word"===e.kind&&("to"===e.value||"from"===e.value))),c=s(e.rest());for(let s of o){let o,d=e.sub(s);if("schema"===l){let e=d.name();if(!e)continue;o=a.alter("schema",e,e,i)}else{let e=d.qualified();if(!e)continue;let n=S(t,e),r="sequence"===l?"sequence":"function"===l||"routine"===l?"function":"procedure"===l?"procedure":"type"===l||"domain"===l?"type":"table",s="routine"===v(r)?d.group():null,c=s?D(s,t.sql):void 0,u=a.find(r,n.schema,n.name,c);o=a.alter(u?.kind??r,n.schema,n.name,i,u?.signature??c)}$(o,{kind:"grant",op:n?"add":"drop",name:c,detail:r},i)}return!0}(t,n);case"do":var h=t,k=n;h.accept("do"),h.accept("language")&&h.name();let b=h.peek();if(b?.kind!=="string")return!1;let j=b.value,y={...k,sql:j},w=Y(k.builder);for(let t of N(l(j)))!function(t,n){let r=0;for(;;){let e=t[r];if(!e||"word"!==e.kind)break;if(G.has(e.value)){r+=1;continue}if(K.has(e.value)){let e=0,n=-1;for(let a=r+1;a<t.length;a+=1){let r=t[a];if("punct"===r.kind&&"("===r.value)e+=1;else if("punct"===r.kind&&")"===r.value)e-=1;else if(0===e&&"word"===r.kind&&("then"===r.value||"loop"===r.value)){n=a;break}}if(-1===n)return;r=n+1;continue}if(t[r+1]?.value===":"&&t[r+2]?.value==="=")return;break}let a=t[r];if(a&&"word"===a.kind&&!X.has(a.value)){if("execute"===a.value){let a=t[r+1],i=t[r+2],s=!i||"word"===i.kind&&"using"===i.value;if(a?.kind==="string"&&s){let t=a.value;for(let r of N(l(t)))e(r,{...n,sql:t},!0)}return}e(t.slice(r),n,!0)}}(t,y);return Y(k.builder)!==w;case"with":case"insert":case"update":case"delete":case"merge":case"truncate":case"copy":case"select":return function(e,t){if(e.accept("with"))for(e.accept("recursive");;){if(e.name(),e.group(),!e.accept("as")||(e.accept("not"),e.accept("materialized"),!e.group()))return!1;if(!e.acceptPunct(","))break}let n=e.acceptOne(["insert","update","delete","merge","truncate","copy","select"]);if(!n)return!1;let{builder:r,version:a}=t,i=(e,n)=>{if(!e)return!1;let i=S(t,e),s=r.find("table",i.schema,i.name);return $(r.alter(s?.kind??"table",i.schema,i.name,a),{kind:"rows",op:"change",name:n},a),!0};switch(n){case"insert":return e.accept("into"),i(e.qualified(),"insert");case"update":return e.accept("only"),i(e.qualified(),"update");case"delete":return e.accept("from"),e.accept("only"),i(e.qualified(),"delete");case"merge":return e.accept("into"),e.accept("only"),i(e.qualified(),"merge");case"truncate":{e.accept("table");let t=m(e.until(e=>"word"===e.kind&&["restart","continue","cascade","restrict"].includes(e.value)));for(let n of t){let t=e.sub(n);t.accept("only"),i(t.qualified(),"truncate")}return t.length>0}case"copy":{let t=e.qualified();if(e.group(),!e.accept("from"))return!1;return i(t,"copy")}case"select":return function(e,t){if(e.accept("pg_catalog")&&e.acceptPunct("."),e.isWord("set_config"))return!0;if(!e.isWord("setval"))return!1;e.pos+=1;let n=e.group();if(!n)return!1;let[r,a]=m(n),i=r?.find(e=>"string"===e.kind);if(!i)return!1;let s=new p(l(i.value),i.value).qualified();if(!s)return!1;let o=S(t,s);return $(t.builder.alter("sequence",o.schema,o.name,t.version),{kind:"setting",op:"change",name:"value",detail:a?g(a,t.sql):void 0},t.version),!0}(e,t)}return!1}(t,n);case"refresh":var O=t,z=n;if(!O.accept("refresh","materialized","view"))return!1;O.accept("concurrently");let A=O.qualified();if(!A)return!1;let E=S(z,A);return $(z.builder.alter("materialized-view",E.schema,E.name,z.version),{kind:"rows",op:"change",name:"refresh"},z.version),!0;default:return!1}}(d,{...n},n)}catch{o=!1}return o||r||n.builder.note((a=t,s=n.sql,c=g(a.slice(0,24),s),a.length>24||c.length>96?`${c.slice(0,96).trimEnd()}…`:c),n.version),o})(e,s,!1)}(n.sql,n.version,t);return t.result()}n.d(t,{DT:()=>r,OL:()=>i});let a="public";function i(e,t){return e===a?t:`${e}.${t}`}let s="+-*/<>=~!@#%^&|`?";function l(e){let t=[],n=0;for(;n<e.length;){var r;let a=e[n];if(" "===a||" "===a||"\n"===a||"\r"===a||"\f"===a){n+=1;continue}if("-"===a&&"-"===e[n+1]){for(;n<e.length&&"\n"!==e[n];)n+=1;continue}if("/"===a&&"*"===e[n+1]){let t=1;for(n+=2;n<e.length&&t>0;)"/"===e[n]&&"*"===e[n+1]?(t+=1,n+=2):"*"===e[n]&&"/"===e[n+1]?(t-=1,n+=2):n+=1;continue}let i=n;if(/[eEbBxXnN]/.test(a)&&"'"===e[n+1]){let r=o(e,n+1,/[eE]/.test(a));t.push({kind:"string",value:c(e.slice(n+2,r-1)),start:i,end:r}),n=r;continue}if(("u"===a||"U"===a)&&"&"===e[n+1]&&("'"===e[n+2]||'"'===e[n+2])){let r=e[n+2],a=o(e,n+2,!1,r),s=e.slice(n+3,a-1);t.push("'"===r?{kind:"string",value:c(s),start:i,end:a}:{kind:"ident",value:s.replace(/""/g,'"'),start:i,end:a}),n=a;continue}if("'"===a){let r=o(e,n,!1);t.push({kind:"string",value:c(e.slice(n+1,r-1)),start:i,end:r}),n=r;continue}if('"'===a){let r=o(e,n,!1,'"');t.push({kind:"ident",value:e.slice(n+1,r-1).replace(/""/g,'"'),start:i,end:r}),n=r;continue}if("$"===a){let r=/^\$(?:[A-Za-z_][A-Za-z0-9_]*)?\$/.exec(e.slice(n));if(r){let a=e.indexOf(r[0],n+r[0].length),s=-1===a?e.length:a+r[0].length,l=e.slice(n+r[0].length,-1===a?e.length:a);t.push({kind:"string",value:l,start:i,end:s}),n=s;continue}let a=n+1;for(;a<e.length&&/[0-9]/.test(e[a]);)a+=1;t.push({kind:"punct",value:e.slice(n,a),start:i,end:a}),n=Math.max(a,n+1);continue}if(/[A-Za-z_\u0080-\uffff]/.test(a)){let a=n+1;for(;a<e.length&&(r=e[a],/[A-Za-z0-9_$\u0080-\uffff]/.test(r));)a+=1;t.push({kind:"word",value:e.slice(n,a).toLowerCase(),start:i,end:a}),n=a;continue}if(/[0-9]/.test(a)||"."===a&&/[0-9]/.test(e[n+1]??"")){let r=n+1;for(;r<e.length&&/[0-9.eE_]/.test(e[r]);)("e"===e[r]||"E"===e[r])&&/[+-]/.test(e[r+1]??"")&&(r+=1),r+=1;t.push({kind:"number",value:e.slice(n,r),start:i,end:r}),n=r;continue}if(":"===a&&":"===e[n+1]){t.push({kind:"punct",value:"::",start:i,end:n+2}),n+=2;continue}if(s.includes(a)){let r=n+1;for(;r<e.length&&s.includes(e[r])&&("-"!==e[r]||"-"!==e[r+1])&&("/"!==e[r]||"*"!==e[r+1]);)r+=1;t.push({kind:"punct",value:e.slice(n,r),start:i,end:r}),n=r;continue}t.push({kind:"punct",value:a,start:i,end:n+1}),n+=1}return t}function o(e,t,n,r="'"){let a=t+1;for(;a<e.length;){if(n&&"\\"===e[a]){a+=2;continue}if(e[a]===r){if(e[a+1]===r){a+=2;continue}return a+1}a+=1}return e.length}function c(e){return e.replace(/''/g,"'")}let d=new Set(["constraint","not","null","default","primary","unique","references","check","generated","collate","compression","deferrable","initially"]),u=new Set(["and","or","not","in","as","is","exists","any","all","some","check","using","on","select","where","when","then","else","case","from","values","with","distinct"]);class p{constructor(e,t){this.tokens=e,this.sql=t,this.pos=0}get done(){return this.pos>=this.tokens.length}peek(e=0){return this.tokens[this.pos+e]}isWord(e,t=0){let n=this.peek(t);return n?.kind==="word"&&n.value===e}isPunct(e,t=0){let n=this.peek(t);return n?.kind==="punct"&&n.value===e}accept(...e){for(let[t,n]of e.entries())if(!this.isWord(n,t))return!1;return this.pos+=e.length,!0}acceptPunct(e){return!!this.isPunct(e)&&(this.pos+=1,!0)}acceptOne(e){let t=this.peek();return t?.kind==="word"&&e.includes(t.value)?(this.pos+=1,t.value):null}name(){let e=this.peek();return e?.kind==="word"||e?.kind==="ident"?(this.pos+=1,e.value):null}qualified(){let e=[],t=this.name();if(null===t)return null;for(e.push(t);this.isPunct(".")&&(this.peek(1)?.kind==="word"||this.peek(1)?.kind==="ident");)this.pos+=1,e.push(this.name());return 1===e.length?{schema:null,name:e[0]}:{schema:e[e.length-2],name:e[e.length-1]}}group(){if(!this.isPunct("("))return null;let e=this.pos,t=0;for(let n=this.pos;n<this.tokens.length;n+=1){let r=this.tokens[n];if("punct"===r.kind){if("("===r.value||"["===r.value)t+=1;else if((")"===r.value||"]"===r.value)&&0==(t-=1))return this.pos=n+1,this.tokens.slice(e+1,n)}}return this.pos=this.tokens.length,this.tokens.slice(e+1)}until(e){let t=this.pos,n=0;for(;this.pos<this.tokens.length;){let t=this.tokens[this.pos];if(0===n&&e(t,this))break;"punct"===t.kind&&("("===t.value||"["===t.value?n+=1:(")"===t.value||"]"===t.value)&&(n-=1)),this.pos+=1}return this.tokens.slice(t,this.pos)}rest(){let e=this.tokens.slice(this.pos);return this.pos=this.tokens.length,e}sub(e){return new p(e,this.sql)}}function m(e){let t=[],n=[],r=0;for(let a of e){if("punct"===a.kind){if("("===a.value||"["===a.value)r+=1;else if(")"===a.value||"]"===a.value)r-=1;else if(","===a.value&&0===r){t.push(n),n=[];continue}}n.push(a)}return n.length>0&&t.push(n),t}let f=new Set([")",",",".","::","]","[",";"]),h=new Set(["(",".","::","["]);function g(e,t){let n="",r=null;for(let i of e){var a;let e="word"===i.kind?i.value:"ident"===i.kind?(a=i.value,/^[a-z_][a-z0-9_$]*$/.test(a)?a:`"${a.replace(/"/g,'""')}"`):t.slice(i.start,i.end);r&&("punct"===i.kind&&f.has(i.value)||"punct"===r.kind&&h.has(r.value)||"punct"===i.kind&&"("===i.value&&("ident"===r.kind||"word"===r.kind&&!u.has(r.value))||(n+=" ")),n+=e.replace(/\s+/g," "),r=i}return n}function x(e,t){return m(e).map(e=>1===e.length&&("word"===e[0].kind||"ident"===e[0].kind)?e[0].value:g(e,t))}function v(e){switch(e){case"table":case"view":case"materialized-view":return"relation";case"function":case"procedure":return"routine";case"enum":case"type":case"domain":return"type";default:return e}}function k(e,t,n,r){let a=`${v(e)}:${t}.${n}`;return void 0===r?a:`${a}(${r})`}class b{keyOf(e){return k(e.kind,e.schema,e.name,e.signature)}find(e,t,n,r,a=!1){let i=this.byKey.get(k(e,t,n,r));if(i||"routine"!==v(e))return i;if(void 0!==r&&!a)return;let s=this.subjects.filter(e=>"routine"===v(e.kind)&&e.schema===t&&e.name===n);return 1===s.length?s[0]:void 0}add(e){return this.subjects.push(e),this.byKey.set(this.keyOf(e),e),e}remove(e){this.subjects=this.subjects.filter(t=>t!==e),this.byKey.delete(this.keyOf(e))}create(e,t,n,r,a={}){let i=this.find(e,t,n,a.signature);return i?(i.versions.add(r),i.kind=e,void 0!==a.detail&&(i.detail=a.detail),"dropped"===i.effect?(i.effect="replaced",i.parts=[]):"altered"===i.effect?i.effect="replaced":a.replace||(i.parts=[]),i):this.add({kind:e,schema:t,name:n,signature:a.signature,effect:a.replace?"replaced":"created",detail:a.detail,parts:[],versions:new Set([r])})}drop(e,t,n,r,a){let i=this.find(e,t,n,a);i?"created"===i.effect?this.remove(i):(i.effect="dropped",i.parts=[],i.detail=void 0,i.versions.add(r)):this.add({kind:e,schema:t,name:n,signature:a,effect:"dropped",parts:[],versions:new Set([r])})}alter(e,t,n,r,a){let i=this.find(e,t,n,a);return i?(i.versions.add(r),"dropped"===i.effect&&(i.effect="altered"),i):this.add({kind:e,schema:t,name:n,signature:a,effect:"altered",parts:[],versions:new Set([r])})}move(e,t,n,r,a){let i=this.find(e,t.schema,t.name,a)??this.alter(e,t.schema,t.name,r,a);(this.byKey.delete(this.keyOf(i)),"created"===i.effect||i.from||(i.from={...t}),i.schema=n.schema,i.name=n.name,i.versions.add(r),i.from&&i.from.schema===n.schema&&i.from.name===n.name&&(i.from=void 0,"altered"===i.effect&&0===i.parts.length))?this.remove(i):this.byKey.set(this.keyOf(i),i)}note(e,t){let n=this.other.find(t=>t.text===e);n?n.versions.add(t):this.other.push({text:e,versions:new Set([t])})}findPart(e,t,n){for(let r of this.subjects){if(r.schema!==t)continue;let a=r.parts.find(t=>t.kind===e&&t.name===n&&"drop"!==t.op);if(a)return{subject:r,part:a}}return null}result(){let e=[];for(let t of this.subjects)("altered"!==t.effect||0!==t.parts.length||t.from)&&e.push({kind:t.kind,schema:t.schema,name:t.name,effect:t.effect,...void 0!==t.detail?{detail:t.detail}:{},...t.from?{from:t.from}:{},parts:t.parts.map(e=>({kind:e.kind,op:e.op,name:e.name,...void 0!==e.from?{from:e.from}:{},...j(e)?{detail:j(e)}:{},...y(e)?{ref:y(e)}:{},versions:[...e.versions]})),versions:[...t.versions]});return{subjects:e,other:this.other.map(e=>({text:e.text,versions:[...e.versions]}))}}constructor(){this.subjects=[],this.byKey=new Map,this.other=[]}}function j(e){return e.facts?e.facts.map(e=>e.text).join(" \xb7 ")||void 0:e.detail}function y(e){if(!e.facts)return e.ref;let t=e.facts.find(e=>"ref"===e.aspect)?.ref;return t&&{...t,columns:[e.name]}}let w=new Set(["column","constraint","index","trigger","policy","value"]);function $(e,t,n){let{kind:r}=t,a=e.parts,i=(e,t)=>e.kind===r&&e.name===t;if(!w.has(r)){if("rows"===r){let e=a.find(e=>"rows"===e.kind&&e.name===t.name);if(e){e.versions.add(n);let t=Number(e.detail?.replace(/\D/g,"")||"1")+1;e.detail=`\xd7${t}`;return}}if("setting"===r||"comment"===r){let e=a.find(e=>e.kind===r&&e.name===t.name);if(e){e.detail=t.detail,e.op=t.op,e.versions.add(n);return}}if("grant"===r){let e=a.find(e=>"grant"===e.kind&&e.name===t.name&&e.detail===t.detail);if(e){e.op=t.op,e.versions.add(n);return}}a.push({...t,versions:new Set([n])});return}switch(t.op){case"add":{let e=a.findIndex(e=>i(e,t.name));if(-1!==e){let r=a[e],i="drop"===r.op||"change"===r.op?"change":"add";a[e]={...t,op:i,versions:new Set([...r.versions,n])};return}a.push({...t,versions:new Set([n])});return}case"drop":{let s=a.findIndex(e=>i(e,t.name));if(-1!==s){let e=a[s];if("add"===e.op)return void a.splice(s,1);let i="rename"===e.op?e.from:void 0;a[s]={kind:r,op:"drop",name:i??t.name,versions:new Set([...e.versions,n])};return}if("constraint"===r)for(let e of a){let r=e.facts?.find(e=>e.constraint===t.name);if(r&&"add"===e.op){e.facts=e.facts.filter(e=>e!==r),e.versions.add(n);return}}"column"===r&&(e.parts=a.filter(e=>"column"!==e.kind||e.name!==t.name)),e.parts.push({...t,versions:new Set([n])});return}case"rename":{let r=t.from,s=a.find(e=>i(e,r)&&"drop"!==e.op);if(s){if(s.versions.add(n),"rename"===s.op){if(s.from===t.name){e.parts=a.filter(e=>e!==s);return}s.name=t.name;return}"change"===s.op&&(s.op="rename",s.from=r),s.name=t.name;return}a.push({...t,versions:new Set([n])});return}case"change":{let e=a.find(e=>i(e,t.name)&&"drop"!==e.op);if(!e)return void a.push({...t,versions:new Set([n])});if(e.versions.add(n),t.facts){for(let n of t.facts)!function(e,t,n){let r=e.facts??[];if("other"===t.aspect){r.push(t),e.facts=r;return}let a=r.findIndex(e=>e.aspect===t.aspect),i=t.text.startsWith("drop ");if(n){let e=i?"":t.text.replace(/^set (not null)$/,"$1").replace(/^type /,"");-1!==a?e?r[a]={...t,text:e}:r.splice(a,1):e&&r.splice("type"===t.aspect?0:r.length,0,{...t,text:e})}else -1!==a?r[a]=t:r.push(t);e.facts=r}(e,n,"add"===e.op);return}"add"===e.op?e.detail=[e.detail,t.detail].filter(Boolean).join(" \xb7 "):e.detail=t.detail;return}}}function N(e){let t=[],n=[];for(let r of e)"punct"===r.kind&&";"===r.value?(n.length>0&&t.push(n),n=[]):n.push(r);return n.length>0&&t.push(n),t}let q=new Set(["begin","start","commit","end","rollback","abort","savepoint","release","lock","analyze","analyse","vacuum","notify","listen","unlisten","discard","checkpoint","reset","prepare","deallocate","explain"]);function S(e,t){return{schema:t.schema??e.schema,name:t.name}}function C(e){return e?.kind==="word"&&["constraint","primary","unique","foreign","check","exclude"].includes(e.value)}function _(e,t,n){let r,a=e.name();if(null===a)return null;let s=e.until(e=>"word"===e.kind&&d.has(e.value)),l=[];s.length>0&&l.push({aspect:"type",text:g(s,t.sql)});let o=e=>"word"===e.kind&&d.has(e.value);for(;!e.done;){if(e.accept("constraint")){r=e.name()??void 0;continue}if(e.accept("not","null"))l.push({aspect:"null",text:"not null"});else if(e.accept("null"));else if(e.accept("default")){let n=e.isWord("null")?[e.peek()]:[];n.length>0&&(e.pos+=1),n.push(...e.until(o)),l.push({aspect:"default",text:`default ${g(n,t.sql)}`})}else if(e.accept("primary","key"))e.until(o),l.push({aspect:"pk",text:"primary key",constraint:r??`${n}_pkey`});else if(e.accept("unique"))e.until(o),l.push({aspect:"unique",text:"unique",constraint:r??`${n}_${a}_key`});else if(e.accept("references")){let s=e.qualified(),o=e.group(),c=z(e.until(O),t.sql);if(s){let e=S(t,s),d=o?x(o,t.sql):[],u=`${i(e.schema,s.name)}${d.length>0?`.${d.join(", ")}`:""}`;l.push({aspect:"ref",text:`→ ${u}${c?` ${c}`:""}`,constraint:r??`${n}_${a}_fkey`,ref:{columns:[a],schema:e.schema,table:e.name,targetColumns:d}})}}else if(e.accept("check")){let i=e.group();e.until(o),l.push({aspect:"check",text:`check (${i?g(i,t.sql):""})`,constraint:r??`${n}_${a}_check`})}else if(e.accept("generated")){let n=e.until(o),r=e.sub(n);if(n.some(e=>"word"===e.kind&&"identity"===e.value))l.push({aspect:"identity",text:"identity"});else{r.acceptOne(["always","by"]),r.accept("default"),r.accept("as");let e=r.group();l.push({aspect:"generated",text:`generated (${e?g(e,t.sql):""})`})}}else if(e.accept("collate")){let t=e.qualified();t&&l.push({aspect:"collate",text:`collate ${t.name}`})}else e.pos+=1,e.until(o);r=void 0}return{name:a,facts:l}}function O(e,t){if("word"!==e.kind||!d.has(e.value))return!1;let n=t.tokens[t.pos-1];return n?.kind!=="word"||"set"!==n.value||"null"!==e.value&&"default"!==e.value}function z(e,t){let n=new p(e,t),r=[];for(;!n.done;)if(n.accept("on","delete")||n.accept("on","update")){let e=n.tokens[n.pos-1].value,a=n.until(e=>"word"===e.kind&&("on"===e.value||"deferrable"===e.value||"match"===e.value||"not"===e.value||"initially"===e.value));r.push(`on ${e} ${g(a,t)}`)}else n.pos+=1;return r.join(" ")}function R(e,t,n){let r=function(e,t,n){let r=null;e.accept("constraint")&&(r=e.name());let a=t.sql;if(e.accept("primary","key")){let t=e.group(),i=t?x(t,a):[];return{name:r??`${n}_pkey`,detail:`primary key (${i.join(", ")})${E(e,a)}`}}if(e.accept("unique")){if(e.accept("nulls")&&(e.accept("not"),e.accept("distinct")),e.accept("using","index")){let t=e.name();return{name:r??t??`${n}_key`,detail:`unique using index ${t??""}`}}let t=e.group(),i=t?x(t,a):[];return{name:r??`${n}_${i.join("_")}_key`,detail:`unique (${i.join(", ")})${E(e,a)}`}}if(e.accept("foreign","key")){let s=e.group(),l=s?x(s,a):[];e.accept("references");let o=e.qualified(),c=e.group(),d=e.rest(),u=z(d,a),p=o?`${i(S(t,o).schema,o.name)}${c?`(${x(c,a).join(", ")})`:""}`:"",m=A(d)?" \xb7 not valid":"",f=o?S(t,o):null;return{name:r??`${n}_${l.join("_")}_fkey`,detail:`(${l.join(", ")}) → ${p}${u?` ${u}`:""}${m}`,...f?{ref:{columns:l,schema:f.schema,table:f.name,targetColumns:c?x(c,a):[]}}:{}}}if(e.accept("check")){let t=e.group()??[],i=A(e.rest())?" \xb7 not valid":"";return{name:r??`${n}_check`,detail:`check (${g(t,a)})${i}`}}return e.accept("exclude")?{name:r??`${n}_excl`,detail:`exclude ${g(e.rest(),a)}`}:null}(e,t,n);return r?{...r,named:e.tokens[0]?.value==="constraint"}:null}function P(e,t,n){let r=t.name;if(!t.named){let n=t=>e.parts.some(e=>"constraint"===e.kind&&e.name===t&&"drop"!==e.op);for(let e=1;n(r);e+=1)r=`${t.name}${e}`}$(e,{kind:"constraint",op:"add",name:r,detail:t.detail,ref:t.ref},n)}function A(e){return e.some((t,n)=>"word"===t.kind&&"not"===t.value&&e[n+1]?.value==="valid")}function E(e,t){let n=new p(e.rest(),t),r=[];for(;!n.done;)if(n.accept("include")){let e=n.group();e&&r.push(`include (${x(e,t).join(", ")})`)}else n.accept("not","valid")?r.push("not valid"):n.pos+=1;return r.length>0?` \xb7 ${r.join(" \xb7 ")}`:""}function M(e){let[t,n]=e;if(t?.kind==="punct"&&"("===t.value){let t=e[1];return t?.kind==="word"&&e[2]?.kind==="punct"&&"("===e[2].value?t.value:"expr"}return t?.kind!=="word"&&t?.kind!=="ident"?"expr":n?.kind==="punct"&&"("===n.value?t.value:n?.kind==="punct"?"expr":t.value}let F=new Set(["double","character","char","bit","timestamp","time","interval","national","setof"]);function D(e,t){let n=[];for(let r of m(e)){let e=new p(r,t);if("out"===e.acceptOne(["in","out","inout","variadic"]))continue;let a=e.until(e=>"word"===e.kind&&"default"===e.value||"punct"===e.kind&&"="===e.value),i=a;a.length>1&&("ident"===a[0].kind||"word"===a[0].kind&&!F.has(a[0].value))&&("punct"!==a[1].kind||"("!==a[1].value&&"."!==a[1].value&&"["!==a[1].value)&&(i=a.slice(1)),n.push(function(e){let t={int:"integer",int4:"integer",int8:"bigint",int2:"smallint",bool:"boolean",float8:"double precision",float4:"real",varchar:"character varying",timestamptz:"timestamp with time zone",timetz:"time with time zone",decimal:"numeric"};return e.replace(/^[a-z0-9_]+/,e=>t[e]??e)}(g(i,t)))}return n.join(", ")}function I(e,t){let n=[];for(;!e.done;)if(e.accept("as"))"restrictive"===e.name()&&n.push("restrictive");else if(e.accept("for")){let t=e.name();t&&"all"!==t&&n.push(`for ${t}`)}else if(e.accept("to")){let r=g(e.until(e=>"word"===e.kind&&["using","with"].includes(e.value)),t);"public"!==r&&n.push(`to ${r}`)}else if(e.accept("using")){let r=e.group();n.push(`using (${r?g(r,t):""})`)}else if(e.accept("with","check")){let r=e.group();n.push(`check (${r?g(r,t):""})`)}else e.accept("rename","to")?n.push(`renamed to ${e.name()??""}`):e.pos+=1;return n.join(" \xb7 ")}function T(e,t,n){e.accept("if","exists"),e.accept("only");let r=e.qualified();if(!r)return!1;e.acceptPunct("*");let a=S(t,r),i=t.builder.find(n,a.schema,a.name),s=i?.kind??n,{builder:l,version:o}=t;if(e.accept("rename","to")){let t=e.name();return null!==t&&(l.move(s,a,{schema:a.schema,name:t},o),!0)}if(e.accept("set","schema")){let t=e.name();return null!==t&&(l.move(s,a,{schema:t,name:a.name},o),!0)}if(e.accept("rename","constraint")){let t=e.name();if(null===t||!e.accept("to"))return!1;let n=e.name();return null!==n&&($(l.alter(s,a.schema,a.name,o),{kind:"constraint",op:"rename",name:n,from:t},o),!0)}if(e.isWord("rename")){e.accept("rename"),e.accept("column");let t=e.name();if(null===t||!e.accept("to"))return!1;let n=e.name();return null!==n&&($(l.alter(s,a.schema,a.name,o),{kind:"column",op:"rename",name:n,from:t},o),!0)}let c=l.alter(s,a.schema,a.name,o);for(let n of m(e.rest()))!function(e,t,n){let{version:r,sql:a}={version:t.version,sql:t.sql},i=n.name;if(e.accept("add")){if(C(e.peek())){let a=R(e.sub(e.rest()),t,i);a&&P(n,a,r);return}e.accept("column"),e.accept("if","not","exists");let a=_(e,t,i);a&&$(n,{kind:"column",op:"add",name:a.name,facts:a.facts},r);return}if(e.accept("drop")){if(e.accept("constraint")){e.accept("if","exists");let t=e.name();t&&$(n,{kind:"constraint",op:"drop",name:t},r);return}e.accept("column"),e.accept("if","exists");let t=e.name();t&&$(n,{kind:"column",op:"drop",name:t},r);return}if(e.accept("alter")){if(e.accept("constraint")){let t=e.name();t&&$(n,{kind:"constraint",op:"change",name:t,detail:g(e.rest(),a)},r);return}e.accept("column");let t=e.name();if(null===t)return;let i=L(e,a);$(n,{kind:"column",op:"change",name:t,facts:[{aspect:i.aspect,text:i.text}]},r);return}if(e.accept("validate","constraint")){let t=e.name();t&&$(n,{kind:"constraint",op:"change",name:t,detail:"validated"},r);return}let s=/^(enable|disable|force|no force) row level security$/.exec(g(e.tokens,a));if(s)return $(n,{kind:"setting",op:"change",name:"row level security",detail:{enable:"enabled",disable:"disabled",force:"forced","no force":"not forced"}[s[1]]},r);let l=e.acceptOne(["enable","disable"]);if(l){let t=e.acceptOne(["replica","always"]);if(e.accept("trigger")){let a=e.name()??"",i=`${l}d${t?` (${t})`:""}`;"all"===a||"user"===a?$(n,{kind:"setting",op:"change",name:`${a} triggers`,detail:i},r):$(n,{kind:"trigger",op:"change",name:a,detail:i},r);return}if(e.accept("rule"))return $(n,{kind:"setting",op:"change",name:`rule ${e.name()??""}`,detail:`${l}d`},r)}if(e.accept("owner","to"))return $(n,{kind:"setting",op:"change",name:"owner",detail:g(e.rest(),a)},r);if(e.accept("attach","partition")){let t=e.qualified();$(n,{kind:"setting",op:"add",name:`partition ${t?.name??""}`,detail:g(e.rest(),a)||void 0},r);return}if(e.accept("detach","partition")){let t=e.qualified();$(n,{kind:"setting",op:"drop",name:`partition ${t?.name??""}`},r);return}let o=g(e.tokens,a);o&&$(n,{kind:"setting",op:"change",name:o},r)}(e.sub(n),t,c);return!0}function L(e,t){if(e.accept("set","data","type")||e.accept("type")){let n=g(e.until(e=>"word"===e.kind&&("using"===e.value||"collate"===e.value)),t);return{aspect:"type",value:n,text:`type ${n}`}}if(e.accept("set","default")){let n=g(e.rest(),t);return{aspect:"default",value:n,text:`default ${n}`}}if(e.accept("drop","default"))return{aspect:"default",value:null,text:"drop default"};if(e.accept("set","not","null"))return{aspect:"null",value:"not null",text:"set not null"};if(e.accept("drop","not","null"))return{aspect:"null",value:null,text:"drop not null"};if(e.accept("add","generated"))return{aspect:"identity",value:"identity",text:"identity"};if(e.accept("drop","identity"))return{aspect:"identity",value:null,text:"drop identity"};if(e.accept("drop","expression"))return{aspect:"generated",value:null,text:"drop expression"};let n=g(e.rest(),t);return{aspect:"other",value:n,text:n}}function B(e,t,n){let r=e.qualified();if(!r)return!1;let a=S(t,r),i=e.group(),s=i?D(i,t.sql):void 0,{builder:l,version:o}=t,c=l.find(n,a.schema,a.name,s)?.kind??n;if(e.accept("rename","to")){let t=e.name();return null!==t&&(l.move(c,a,{schema:a.schema,name:t},o,s),!0)}if(e.accept("set","schema")){let t=e.name();return null!==t&&(l.move(c,a,{schema:t,name:a.name},o,s),!0)}let d=l.alter(c,a.schema,a.name,o,s);if(e.accept("owner","to"))return $(d,{kind:"setting",op:"change",name:"owner",detail:g(e.rest(),t.sql)},o),!0;let u=g(e.rest(),t.sql);return u&&$(d,{kind:"setting",op:"change",name:u},o),!0}function W(e,t,n){let r=e.name();if(null===r||!e.accept("on"))return!1;let a=e.qualified();if(!a)return!1;let i=S(t,a),s=t.builder.alter("table",i.schema,i.name,t.version);if(e.accept("rename","to")){let a=e.name();return null!==a&&($(s,{kind:n,op:"rename",name:a,from:r},t.version),!0)}let l="policy"===n?I(e,t.sql):g(e.rest(),t.sql);return $(s,{kind:n,op:"change",name:r,detail:l},t.version),!0}let V=[[["table"],"table"],[["foreign","table"],"table"],[["materialized","view"],"materialized-view"],[["view"],"view"],[["index"],"index"],[["sequence"],"sequence"],[["type"],"type"],[["domain"],"domain"],[["function"],"function"],[["procedure"],"procedure"],[["routine"],"function"],[["trigger"],"trigger"],[["policy"],"policy"],[["schema"],"schema"],[["extension"],"extension"]],G=new Set(["begin","else","loop","declare"]),K=new Set(["if","elsif","elseif","when","exception","for","foreach","while","case"]),X=new Set(["perform","raise","return","null","end","get","exit","continue","assert","open","close","fetch","move","call"]);function Y(e){return JSON.stringify(e.result())}}},e=>{e.O(0,[4506,1731,8026,2435,8361,8322,544,6090,1413,228,8441,3794,7358],()=>e(e.s=52310)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[106,828,831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4908,4909,4956,5047,5374,5721,5794,5838,6053,6258,6306,6636,6819,6986,6988,7761,7851,7981,8167,8464,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[106,828,831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4908,4909,4956,5047,5374,5721,5794,5838,6053,6258,6306,6636,6819,6986,6988,7761,7851,7981,8167,8464,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[106,828,831,1047,2042,2772,3058,3219,3577,4688,4707,4896,4908,4909,4956,5047,5374,5721,5794,5838,6053,6258,6306,6636,6819,6986,6988,7761,7851,7981,8167,8464,9433],{84441:()=>{}},_=>{_.O(0,[8441,3794,7358],()=>_(_.s=84441)),_N_E=_.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2336],{4108:(e,t,r)=>{Promise.resolve().then(r.bind(r,21890))},20185:(e,t,r)=>{"use strict";function n(e){let t=e.split("/").filter(Boolean).map(decodeURIComponent);if(0===t.length)return{kind:"home"};let[r,n,i,a]=t;if(1===t.length)return{kind:"connection",connectionId:r};if(2===t.length){if("query"===n)return{kind:"query",connectionId:r};if("diff"===n)return{kind:"diff",connectionId:r};if("migrations"===n)return{kind:"migrations",connectionId:r}}if(3===t.length)return"migrations"===n?"timeline"===i?{kind:"migrations",connectionId:r,view:"timeline"}:{kind:"migration",connectionId:r,setId:i}:{kind:"table",connectionId:r,table:{schema:n,name:i}};return 4===t.length&&"migrations"===n&&("schema"===a||"diagram"===a||"timeline"===a)?{kind:"migration",connectionId:r,setId:i,view:a}:{kind:"connection",connectionId:r}}function i(e){let t=encodeURIComponent;switch(e.kind){case"home":return"/";case"connection":return`/${t(e.connectionId)}`;case"query":case"diff":return`/${t(e.connectionId)}/${e.kind}`;case"migrations":return`/${t(e.connectionId)}/migrations${e.view?`/${e.view}`:""}`;case"migration":return`/${t(e.connectionId)}/migrations/${t(e.setId)}${e.view?`/${e.view}`:""}`;case"table":return`/${t(e.connectionId)}/${t(e.table.schema)}/${t(e.table.name)}`}}function a(e,t,{tableExists:r=!0}={}){let o=n(e);return"home"!==o.kind&&("table"!==o.kind||r)?i({...o,connectionId:t}):i({kind:"connection",connectionId:t})}r.d(t,{Jn:()=>i,ZG:()=>n,gZ:()=>a})},21890:(e,t,r)=>{"use strict";r.d(t,{ConnectionHome:()=>m});var n=r(95155),i=r(73321),a=r(12115),o=r(40544),s=r(88263),l=r(20185),c=r(43262),d=r(95848),u=r(36331);function m(){let e=(0,i.useRouter)(),{connection:t,tables:r}=(0,u.k)(),[m]=(0,o.DE)(t.id),p=m.recentTables[0]??null,f=p?(r.data??[]).find(e=>(0,d.i)(e)===p):void 0;return((0,a.useEffect)(()=>{f&&(s.c.getState().markReplace(),e.replace((0,l.Jn)({kind:"table",connectionId:t.id,table:{schema:f.schema,name:f.name}})))},[f,t.id,e]),!r.data||f)?null:(0,n.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-1.5 text-muted-foreground",children:[(0,n.jsx)("p",{className:"text-sm",children:"Select a table"}),(0,n.jsx)("kbd",{className:"font-mono text-[11px] text-muted-foreground/60",children:c.Ar.tableSearch})]})}},27529:(e,t,r)=>{"use strict";r.d(t,{F:()=>a});var n=r(72914);async function i(e,t,r){let i,a=await (0,n.Qv)(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:r}),o=await a.text();if(!o)throw Error(`YTDB bridge returned an empty response (HTTP ${a.status}). Restart YTDB to update the local bridge.`);try{i=JSON.parse(o)}catch{if(404===a.status)throw Error("The YTDB running on your machine is older than this page and does not know this request. Restart it with `npx @theobourgeois/ytdb@latest`.");throw Error(`YTDB bridge returned an invalid response (HTTP ${a.status}).`)}if(!a.ok)throw Error((i&&"object"==typeof i&&"error"in i&&"string"==typeof i.error?i.error:a.statusText)||`YTDB bridge request failed with HTTP ${a.status}.`);return i}let a={timeline:(e,t,r,n)=>i("/api/timeline",{connectionUrl:e,ledgerSchema:t,query:r},n),timelineDetail:(e,t,r,n)=>i("/api/timeline",{connectionUrl:e,ledgerSchema:t,eventId:r},n),tables:(e,t)=>i("/api/tables",{connectionUrl:e},t),rows:(e,t,r)=>i("/api/rows",{connectionUrl:e,query:t},r),query:(e,t,r)=>i("/api/query",{connectionUrl:e,sql:t},r),updateCell:(e,t,r)=>i("/api/cell",{connectionUrl:e,update:t},r),insertRow:(e,t,r)=>i("/api/insert-row",{connectionUrl:e,insertion:t},r),updateRow:(e,t,r)=>i("/api/update-row",{connectionUrl:e,update:t},r),deleteRows:(e,t,r)=>i("/api/delete-rows",{connectionUrl:e,deletion:t},r),related:(e,t,r)=>i("/api/related",{connectionUrl:e,lookups:t},r),lookup:(e,t,r)=>i("/api/lookup",{connectionUrl:e,query:t},r),definition:(e,t,r)=>i("/api/definition",{connectionUrl:e,table:t},r),schema:(e,t)=>i("/api/schema",{connectionUrl:e},t),ledger:(e,t,r,n=!1)=>i("/api/ledger",{connectionUrl:e,ledgerSchema:t,withSql:n},r),migrate:(e,t,r)=>i("/api/migrate",{connectionUrl:e,migration:t},r),adopt:(e,t,r)=>i("/api/adopt",{connectionUrl:e,adopt:t},r),rehearse:(e,t,r)=>i("/api/rehearse",{connectionUrl:e,rehearsal:t},r),reconcile:(e,t,r,n)=>i("/api/reconcile",{connectionUrl:e,ledgerSchema:t,eventId:r},n),resolve:(e,t,r,n)=>i("/api/reconcile",{connectionUrl:e,ledgerSchema:t,...r},n),detect:(e,t,r)=>i("/api/detect",{connectionUrl:e,migrations:t},r),repo:(e,t,r)=>i("/api/repo",{root:e,checkout:t},r),note:(e,t,r,n)=>i("/api/note",{root:e,path:t,note:r},n)}},36331:(e,t,r)=>{"use strict";r.d(t,{Z:()=>l,k:()=>c});var n=r(95155),i=r(12115),a=r(27529),o=r(87364);let s=(0,i.createContext)(null);function l({connection:e,children:t}){let r=(0,o.Y)(e.url,t=>a.F.tables(e.url,t));return(0,n.jsx)(s.Provider,{value:{connection:e,tables:r},children:t})}function c(){let e=(0,i.useContext)(s);if(!e)throw Error("useExplorerContext must be used inside ExplorerProvider");return e}},43262:(e,t,r)=>{"use strict";r.d(t,{Ar:()=>n,US:()=>s,s5:()=>c,tT:()=>d,vI:()=>l});let n={commandPalette:"⌘⇧P",tableSearch:"⌘P",columnSearch:"⌘/",sqlEditor:"⌘E",switchConnection:"⌘⇧E",compareSchema:"⌘⇧D",migrations:"⌘⇧M",back:"⌘[",forward:"⌘]"};function i(){let e=new Set;return{register:t=>(e.add(t),()=>{e.delete(t)}),open(){for(let t of e)t()}}}let a=i(),o=i(),s=a.register,l=a.open,c=o.register,d=o.open},73321:(e,t,r)=>{"use strict";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}})},87364:(e,t,r)=>{"use strict";r.d(t,{Y:()=>i});var n=r(12115);function i(e,t){let[r,i]=(0,n.useState)(0),[a,o]=(0,n.useState)({key:"",error:null}),s=`${r}:${e}`;(0,n.useEffect)(()=>{let e=new AbortController;return t(e.signal).then(e=>o({key:s,data:e,error:null})).catch(t=>{if(e.signal.aborted)return;let r=t instanceof Error?t.message:String(t);o(e=>({key:s,data:e.data,error:r}))}),()=>e.abort()},[s]);let l=(0,n.useCallback)(()=>i(e=>e+1),[]),c=a.key!==s;return{data:a.data,error:c?null:a.error,loading:c,reload:l}}},88263:(e,t,r)=>{"use strict";r.d(t,{c:()=>s});var n=r(1934),i=r(31692);let a="ytdbNav";function o(e){let t=window.history.state;t&&"object"==typeof t&&t[a]===e||window.history.replaceState({...t??{},[a]:e},"")}let s=(0,n.v)()((0,i.Zr)((e,t)=>({entries:[],index:-1,traversing:!1,replaceNext:!1,markTraversal:()=>e({traversing:!0}),markReplace:()=>e({replaceNext:!0}),arrive:r=>{let n,{entries:i,index:s,traversing:l,replaceNext:c}=t(),d=function(){let e=window.history.state;if(!e||"object"!=typeof e)return;let t=e[a];return"number"==typeof t?t:void 0}();if(i[s]===r&&!c){e({traversing:!1}),o(s);return}let u=i;void 0!==d&&i[d]===r?n=d:l&&i[s-1]===r?n=s-1:l&&i[s+1]===r?n=s+1:c&&s>=0?(u=i.map((e,t)=>t===s?r:e),n=s):n=(u=[...i.slice(0,s+1),r]).length-1,e({entries:u,index:n,traversing:!1,replaceNext:!1}),o(n)}}),{name:"ytdb:navigation",storage:(0,i.KU)(()=>sessionStorage),partialize:e=>({entries:e.entries,index:e.index})}))}},e=>{e.O(0,[1731,544,8441,3794,7358],()=>e(e.s=4108)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1083],{7412:(e,t,r)=>{"use strict";r.d(t,{L:()=>i});var n=r(95155),o=r(13267),l=r(40980);function i({trailing:e,className:t,...r}){return(0,n.jsxs)("div",{className:(0,l.cn)("flex h-8 items-center gap-1.5 rounded-lg px-2 text-muted-foreground transition-colors focus-within:bg-muted/60 hover:bg-muted/60",t),children:[(0,n.jsx)(o.TfF,{className:"size-3.5 shrink-0"}),(0,n.jsx)("input",{type:"text",spellCheck:!1,autoComplete:"off",...r,className:"h-full min-w-0 flex-1 bg-transparent text-[0.8rem] text-foreground outline-none placeholder:text-muted-foreground"}),e]})}},17491:(e,t,r)=>{"use strict";r.d(t,{X:()=>d});var n=r(95155),o=r(40980),l=r(13267),i=r(89239),s=r(43262),a=r(36331),c=r(48861);function u({className:e}){let{connection:t}=(0,a.k)(),{back:r,forward:d,goBack:m,goForward:h}=(0,c.Q)(t.id);return(0,n.jsxs)("div",{className:(0,o.cn)("flex items-center",e),children:[(0,n.jsx)(i.$,{variant:"ghost",size:"icon-sm",disabled:!r,"aria-label":r?`Back to ${r.label}`:"Back",title:r?`Back to ${r.label} (${s.Ar.back})`:void 0,className:"disabled:opacity-30",onClick:m,children:(0,n.jsx)(l.SI1,{})}),(0,n.jsx)(i.$,{variant:"ghost",size:"icon-sm",disabled:!d,"aria-label":d?`Forward to ${d.label}`:"Forward",title:d?`Forward to ${d.label} (${s.Ar.forward})`:void 0,className:"disabled:opacity-30",onClick:h,children:(0,n.jsx)(l.nNJ,{})})]})}function d({children:e,className:t}){return(0,n.jsxs)("header",{className:(0,o.cn)("flex h-11 shrink-0 items-center gap-2 border-b pr-3 pl-1.5",t),children:[(0,n.jsx)(u,{className:"mr-0.5"}),e]})}},19065:(e,t,r)=>{"use strict";function n(e,t){if(0===t)return!0;let r=e[t-1];return"_"===r||"-"===r||" "===r||"."===r}function o(e,t,r){return l(e,t,e=>[r(e)])}function l(e,t,r){if(!e.trim())return[];let o=[];for(let l of t){let t=r(l),i=null;for(let r of t){let t=function(e,t){let r=e.trim().toLocaleLowerCase(),o=t.toLocaleLowerCase();if(!r)return 0;if(0===o.length)return null;if(o===r)return 1e4;if(o.startsWith(r))return 5e3-o.length;let l=o.indexOf(r);if(-1!==l)return 2400+1200*!!n(t,l)-l-o.length;let i=0,s=0,a=0;for(let e=0;e<o.length&&i<r.length;e+=1){if(o[e]!==r[i]){a=0;continue}s+=12,(a+=1)>1&&(s+=18*a),n(t,e)&&(s+=40),i+=1}if(i<r.length)return null;let c=t.split(/[_\-\s.]+/).map(e=>e[0]??"").join("").toLocaleLowerCase();return c.startsWith(r)?s+=2200:c.includes(r)&&(s+=700),s-(o.length-r.length)}(e,r);null!==t&&(null===i||t>i)&&(i=t)}null!==i&&o.push({item:l,score:i})}return o.sort((e,t)=>t.score!==e.score?t.score-e.score:r(e.item)[0]?.localeCompare(r(t.item)[0]??"")??0)}r.d(t,{R6:()=>o,UO:()=>l})},21281:(e,t,r)=>{Promise.resolve().then(r.bind(r,96365))},32538:(e,t,r)=>{"use strict";r.d(t,{I_:()=>n,Mq:()=>i,XU:()=>l,yQ:()=>o});let n=["#e11d48","#f97316","#d97706","#65a30d","#0d9488","#0284c7","#4f46e5","#7c3aed","#c026d3","#57534e"];function o(e){return n.some(t=>t===e)}function l(e){let t=n.find(t=>!e.includes(t));return t||(n[e.length%n.length]??n[0])}function i(e){if(o(e.color))return e.color;var t=e.id;let r=0;for(let e of t)r=31*r+e.charCodeAt(0)>>>0;return n[r%n.length]??n[0]}},34263:(e,t,r)=>{"use strict";r.d(t,{En:()=>u,Pc:()=>c,jl:()=>a});var n=r(1934),o=r(31692),l=r(40980),i=r(63307);let s="ytdb:queries";(0,i.q)("db-studio:queries",s);let a=144,c=800,u=(0,n.v)()((0,o.Zr)(e=>({drafts:{},editorHeight:224,history:[],setDraft:(t,r)=>e(e=>({drafts:{...e.drafts,[t]:r}})),setEditorHeight:t=>e({editorHeight:Math.min(c,Math.max(a,Math.round(t)))}),record:(t,r)=>e(e=>{let n=r.trim();if(!n)return e;let o=e.history.find(e=>e.connectionId===t&&e.sql===n),i={id:o?.id??(0,l.z)(),connectionId:t,sql:n,executedAt:Date.now()},s=0,a=0;return{history:[i,...e.history.filter(e=>e.id!==i.id)].filter(e=>!(s>=200)&&!(a+e.sql.length>1e6)&&(s+=1,a+=e.sql.length,!0))}}),remove:t=>e(e=>({history:e.history.filter(e=>e.id!==t)}))}),{name:s}))},40980:(e,t,r)=>{"use strict";r.d(t,{cn:()=>l,z:()=>i});var n=r(29722),o=r(622);function l(...e){return(0,o.QP)((0,n.$)(e))}function i(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=15&e[6]|64,e[8]=63&e[8]|128;let t=Array.from(e,e=>e.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}},42256:(e,t,r)=>{"use strict";r.d(t,{L:()=>o});var n=r(72914);function o(e,t){let{connectionUrl:r,...o}=t??{};(0,n.Qv)("/api/activity",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,connectionUrl:r,params:o}),keepalive:!0}).catch(()=>{})}},63307:(e,t,r)=>{"use strict";function n(e,t){if(null!==window.localStorage.getItem(t))return;let r=window.localStorage.getItem(e);null!==r&&window.localStorage.setItem(t,r)}r.d(t,{q:()=>n})},69586:(e,t,r)=>{"use strict";r.d(t,{Z:()=>u,w:()=>d});var n=r(1934),o=r(31692),l=r(42256),i=r(32538),s=r(40980),a=r(63307);let c="ytdb:connections";(0,a.q)("db-studio:connections",c);let u=(0,n.v)()((0,o.Zr)((e,t)=>({connections:[],add:r=>{let n=r.color??(0,i.XU)(t().connections.map(e=>(0,i.Mq)(e))),o={id:(0,s.z)(),...r,color:n};return e(e=>({connections:[...e.connections,o]})),(0,l.L)("connection.add",{connectionUrl:o.url,name:o.name}),o},update:(r,n)=>{let o=t().connections.find(e=>e.id===r);e(e=>({connections:e.connections.map(e=>e.id===r?{...e,...n}:e)})),(0,l.L)("connection.update",{connectionUrl:n.url??o?.url,name:n.name??o?.name,changed:Object.keys(n)})},remove:r=>{let n=t().connections.find(e=>e.id===r);e(e=>({connections:e.connections.filter(e=>e.id!==r)})),(0,l.L)("connection.remove",{connectionUrl:n?.url,name:n?.name})}}),{name:c}));function d(e){return u(t=>t.connections.find(t=>t.id===e))}},72914:(e,t,r)=>{"use strict";r.d(t,{Qv:()=>i,i:()=>o});let n="ytdb:bridge-port";function o(){var e;return"localhost"!==(e=window.location.hostname)&&"127.0.0.1"!==e&&"[::1]"!==e&&"local.ytdb"!==e&&"local.dbstudio"!==e}function l(e){let t=Number(e);return e&&Number.isInteger(t)&&t>=1024&&t<=65535?t:null}async function i(e,t={}){let r=o()?`http://127.0.0.1:${function(){let e=new URLSearchParams(window.location.hash.slice(1));if(e.has("port")){window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}`);let t=l(e.get("port"));if(t)return window.localStorage.setItem(n,String(t)),t}return l(window.localStorage.getItem(n))??4371}()}`:null;return fetch(r?new URL(e,r):e,{...t,targetAddressSpace:r?"loopback":void 0})}},96365:(e,t,r)=>{"use strict";r.d(t,{QueryView:()=>R});var n=r(95155),o=r(12115),l=r(13267),i=r(36331),s=r(17491),a=r(48861),c=r(89239),u=r(27529),d=r(96532),m=r(43262),h=r(34263),f=r(40980),x=r(55737),g=r(82228),p=r(46732),b=r(14097),v=r(27071),w=r(89561),y=r(32638);let j=[w.Lz.theme({"&":{height:"100%",backgroundColor:"var(--background)",color:"var(--foreground)",fontSize:"13px"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"var(--font-geist-mono), ui-monospace, SFMono-Regular, monospace",lineHeight:"1.6",overflow:"auto"},".cm-content":{padding:"10px 0",caretColor:"var(--foreground)"},".cm-line":{padding:"0 16px 0 8px"},".cm-gutters":{backgroundColor:"color-mix(in oklch, var(--muted) 35%, var(--background))",color:"var(--muted-foreground)",borderRight:"1px solid var(--border)"},".cm-lineNumbers .cm-gutterElement":{minWidth:"42px",padding:"0 10px 0 6px"},".cm-activeLine":{backgroundColor:"color-mix(in oklch, var(--muted) 42%, transparent)"},".cm-activeLineGutter":{backgroundColor:"color-mix(in oklch, var(--muted) 68%, var(--background))",color:"var(--foreground)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--foreground)"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground":{backgroundColor:"color-mix(in oklch, var(--primary) 18%, transparent) !important"},".cm-matchingBracket":{backgroundColor:"color-mix(in oklch, var(--primary) 16%, transparent)",outline:"1px solid color-mix(in oklch, var(--primary) 32%, transparent)"},".cm-tooltip":{border:"1px solid var(--border)",borderRadius:"var(--radius-md)",backgroundColor:"var(--popover)",color:"var(--popover-foreground)",overflow:"hidden"},".cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:"var(--accent)",color:"var(--accent-foreground)"}}),(0,p.y9)(p.cr.define([{tag:y._A.keyword,color:"var(--chart-1)",fontWeight:"600"},{tag:[y._A.string,y._A.special(y._A.string)],color:"var(--chart-2)"},{tag:[y._A.number,y._A.bool,y._A.null],color:"var(--chart-3)"},{tag:[y._A.typeName,y._A.className],color:"var(--chart-4)"},{tag:y._A.function(y._A.variableName),color:"var(--chart-4)"},{tag:y._A.comment,color:"var(--muted-foreground)",fontStyle:"italic"},{tag:[y._A.operator,y._A.punctuation],color:"var(--foreground)",opacity:"0.72"}]))],k=(0,o.forwardRef)(function({value:e,schema:t,maxLength:r,onChange:l,onRun:i,onLimitExceeded:s},a){let c=(0,o.useRef)(null),u=(0,o.useRef)(i);u.current=i;let d=(0,o.useRef)(s);d.current=s;let m=(0,o.useMemo)(()=>[(0,b.ll)({dialect:b.Rv,schema:t}),v.$t.changeFilter.of(e=>e.newDoc.length<=r||(queueMicrotask(()=>d.current()),!1)),w.Lz.contentAttributes.of({"aria-label":"SQL query editor"}),v.Nb.highest(w.w4.of([{key:"Mod-Enter",run:()=>(u.current(),!0)}])),w.w4.of([g.Yc])],[r,t]);return(0,o.useImperativeHandle)(a,()=>({focus(e=!1){let t=c.current;if(t){if(e){let e=t.state.doc.length;t.dispatch({selection:{anchor:e},scrollIntoView:!0})}t.focus()}},selectedText(){let e=c.current;if(!e)return"";let t=e.state.selection.main;return t.empty?"":e.state.sliceDoc(t.from,t.to)}})),(0,n.jsx)(x.Ay,{className:"h-full",value:e,height:"100%",theme:j,extensions:m,placeholder:"select *\nfrom public.users\nlimit 100;",basicSetup:{lineNumbers:!0,foldGutter:!1,highlightActiveLineGutter:!0,highlightSpecialChars:!0,history:!0,drawSelection:!0,dropCursor:!0,allowMultipleSelections:!0,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,rectangularSelection:!0,crosshairCursor:!1,highlightActiveLine:!0,highlightSelectionMatches:!0},onCreateEditor:e=>{c.current=e},onChange:l})});function N({statement:e}){return(0,n.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto",children:[(0,n.jsxs)("table",{className:"min-w-full border-separate border-spacing-0 font-mono text-xs",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:"sticky top-0 left-0 z-20 h-9 w-10 border-r border-b bg-muted px-2 text-right font-normal text-muted-foreground",children:"#"}),e.columns.map((e,t)=>(0,n.jsx)("th",{className:"sticky top-0 z-10 h-9 min-w-32 border-r border-b bg-muted px-3 text-left font-medium whitespace-nowrap text-foreground last:border-r-0",children:e},`${e}:${t}`))]})}),(0,n.jsx)("tbody",{children:e.rows.map((t,r)=>(0,n.jsxs)("tr",{className:"group hover:bg-muted/45",children:[(0,n.jsx)("th",{className:"sticky left-0 z-10 h-8 border-r border-b bg-background px-2 text-right font-normal text-muted-foreground group-hover:bg-muted",children:r+1}),e.columns.map((e,r)=>{let o=t[r]??null,l=null===o?"null":String(o);return(0,n.jsx)("td",{title:l,className:"h-8 max-w-96 min-w-32 border-r border-b px-3 whitespace-nowrap last:border-r-0",children:(0,n.jsx)("span",{className:null===o?"text-muted-foreground/65":"block max-w-96 truncate text-foreground/90",children:l})},`${e}:${r}`)})]},r))})]}),0===e.rows.length?(0,n.jsx)("p",{className:"p-8 text-center text-sm text-muted-foreground",children:"Query returned no rows."}):null]})}function C({result:e,loading:t}){let[r,i]=(0,o.useState)({source:null,index:0});if(!e)return(0,n.jsx)("div",{className:"flex min-h-0 flex-1 items-center justify-center p-8 text-center text-sm text-muted-foreground",children:"Run a query or migration to see its results."});let s=r.index;r.source!==e&&(s=Math.max(0,e.statements.length-1),i({source:e,index:s}));let a=e.statements[s];if(!a)return(0,n.jsx)("div",{className:"flex min-h-0 flex-1 items-center justify-center p-8 text-center text-sm text-muted-foreground",children:"Execution completed without a result."});let c=function(e){if(e.truncated)return`${e.rows.length.toLocaleString()}+ rows`;let t=e.rowCount??e.rows.length;return 0===e.columns.length&&null===e.rowCount?null:`${t.toLocaleString()} ${1===t?"row":"rows"}`}(a);return(0,n.jsxs)("div",{className:(0,f.cn)("flex min-h-0 flex-1 flex-col",t&&"opacity-55"),"data-query-results":"",children:[(0,n.jsxs)("div",{className:"flex h-9 shrink-0 items-center gap-1 overflow-x-auto border-b px-2 text-xs",children:[(0,n.jsx)("span",{className:"mr-1 shrink-0 font-medium",children:"Results"}),e.statements.length>1?e.statements.map((t,r)=>(0,n.jsxs)("button",{type:"button","aria-pressed":r===s,onClick:()=>i({source:e,index:r}),className:(0,f.cn)("h-6 shrink-0 rounded-md px-2 font-mono text-[11px] text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/60",r===s&&"bg-muted text-foreground"),children:[r+1," ",t.command]},r)):(0,n.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:a.command}),c?(0,n.jsxs)("span",{className:"ml-1 shrink-0 text-muted-foreground",children:["\xb7 ",c]}):null,a.truncated?(0,n.jsxs)("span",{className:"shrink-0 text-muted-foreground",children:["\xb7 limited to ",a.rows.length]}):null,(0,n.jsxs)("span",{className:"ml-auto shrink-0 font-mono tabular-nums text-muted-foreground",children:[e.durationMs.toLocaleString()," ms"]})]}),a.columns.length>0?(0,n.jsx)(N,{statement:a}):(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-2 p-8 text-center",children:[(0,n.jsx)(l.Ykz,{className:"size-5 text-emerald-600 dark:text-emerald-400"}),(0,n.jsxs)("p",{className:"font-medium",children:[a.command," completed"]}),c?(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:[c," affected"]}):null]})]})}var S=r(7412),$=r(19065);function A(e){return(e.split(/\r?\n/).find(e=>e.trim())?.trim()??e).replace(/\s+/g," ")}function L({connectionId:e,search:t,onSelect:r}){let i=(0,h.En)(e=>e.history),s=(0,h.En)(e=>e.remove),a=(0,o.useMemo)(()=>i.filter(t=>t.connectionId===e),[e,i]),c=(0,o.useMemo)(()=>t.trim()?(0,$.UO)(t,a,e=>[A(e.sql),e.sql]).map(e=>e.item):a,[a,t]);return 0===c.length?(0,n.jsx)("p",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:0===a.length?"Queries you run will appear here.":"No matching queries."}):(0,n.jsx)("ul",{className:"flex flex-col gap-1 p-1.5",children:c.map(e=>{var t;return(0,n.jsxs)("li",{className:"group flex items-start rounded-md hover:bg-muted/70",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>r(e.sql),title:e.sql,className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[(0,n.jsx)("span",{className:"block truncate font-mono text-xs text-foreground/90",children:A(e.sql)}),(0,n.jsx)("span",{className:"mt-1 block text-[10px] text-muted-foreground",children:(t=e.executedAt,new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(t))})]}),(0,n.jsx)("button",{type:"button",onClick:()=>s(e.id),"aria-label":"Remove query from history",title:"Remove from history",className:"mt-1.5 mr-1 flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground opacity-0 outline-none hover:bg-foreground/10 hover:text-destructive focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:opacity-100 group-hover:opacity-100",children:(0,n.jsx)(l.mYx,{className:"size-3.5"})})]},e.id)})})}function E({connectionId:e,onSelectHistory:t}){let[r,l]=(0,o.useState)("");return(0,n.jsxs)("aside",{className:"flex w-72 max-w-[35%] shrink-0 flex-col border-l bg-sidebar","aria-label":"Query history",children:[(0,n.jsx)("div",{className:"flex h-11 shrink-0 items-center border-b px-2",children:(0,n.jsx)(S.L,{value:r,onChange:e=>l(e.target.value),placeholder:"Search history","aria-label":"Search query history",className:"min-w-0 flex-1"})}),(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:(0,n.jsx)(L,{connectionId:e,search:r,onSelect:t})})]})}let q=new Set(["SELECT","SHOW","EXPLAIN","FETCH"]);function R(){let{connection:e,tables:t}=(0,i.k)(),r=(0,h.En)(t=>t.drafts[e.id]??""),x=(0,h.En)(e=>e.setDraft),g=(0,h.En)(e=>e.record),p=(0,h.En)(e=>e.editorHeight),b=(0,h.En)(e=>e.setEditorHeight),[v,w]=(0,o.useState)(null),[y,j]=(0,o.useState)(null),[N,S]=(0,o.useState)(!1),$=(0,o.useRef)(null),A=(0,o.useRef)(null),L=(0,o.useRef)(null),R=(0,a.Q)(e.id),_=R.back?.route.kind==="migration"&&R.back.route.connectionId===e.id?R.back:null,z=(0,o.useMemo)(()=>{let e={};for(let r of t.data??[])(e[r.schema]??={})[r.name]=r.columns.map(e=>e.name);return e},[t.data]);async function I(){if(N)return;let n=$.current?.selectedText().trim()||r.trim();if(!n){j("Enter a query to run."),$.current?.focus();return}let o=new AbortController;L.current=o,g(e.id,n),S(!0),j(null);try{let r=await u.F.query(e.url,n,o.signal);w(r),r.statements.some(e=>!q.has(e.command))&&t.reload()}catch(e){if(o.signal.aborted)return;j(e instanceof Error?e.message:String(e))}finally{L.current===o&&(L.current=null,S(!1))}}return(0,o.useEffect)(()=>()=>L.current?.abort(),[]),(0,o.useEffect)(()=>{let e=A.current;if(!e)return;let t=null,r=new ResizeObserver(()=>{null!==t&&window.clearTimeout(t),t=window.setTimeout(()=>b(e.offsetHeight),200)});return r.observe(e),()=>{null!==t&&window.clearTimeout(t),r.disconnect()}},[b]),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[(0,n.jsxs)("section",{className:"flex min-w-0 flex-1 flex-col",children:[(0,n.jsxs)(s.X,{children:[(0,n.jsx)(l.Uoo,{className:"size-4 shrink-0 text-muted-foreground"}),(0,n.jsx)("span",{className:"font-medium",children:"Query"}),_&&(0,n.jsxs)(c.$,{type:"button",variant:"ghost",size:"sm",className:"ml-auto text-muted-foreground",title:`Back to ${_.label} (${m.Ar.back})`,onClick:R.goBack,children:[(0,n.jsx)(l.a7N,{"data-icon":"inline-start"}),(0,n.jsx)("span",{className:"max-w-40 truncate",children:_.label})]}),(0,n.jsxs)(c.$,{type:"button",variant:"ghost",size:"sm",className:(0,f.cn)(!_&&"ml-auto"),disabled:N||!r,onClick:function(){x(e.id,""),j(null),$.current?.focus()},children:[(0,n.jsx)(l.GVO,{"data-icon":"inline-start"}),"Clear"]}),(0,n.jsxs)(c.$,{type:"button",size:"sm",disabled:N||!r.trim(),title:"Run the selection or the whole script (⌘↵)",onClick:()=>void I(),children:[N?(0,n.jsx)(l.gnh,{"data-icon":"inline-start",className:"animate-spin"}):(0,n.jsx)(l.eGB,{"data-icon":"inline-start"}),N?"Running":"Run"]})]}),(0,n.jsx)("div",{ref:A,style:{height:p,minHeight:h.jl,maxHeight:h.Pc},className:"max-h-[55vh] shrink-0 resize-y overflow-hidden border-b bg-background",children:(0,n.jsx)(k,{ref:$,value:r,schema:z,maxLength:d.H4,onChange:t=>x(e.id,t),onRun:()=>void I(),onLimitExceeded:()=>j(`Query is too long (maximum ${d.H4.toLocaleString()} characters).`)})}),y?(0,n.jsx)("div",{className:"min-h-0 flex-1 overflow-auto p-4",children:(0,n.jsx)("div",{className:"rounded-md border border-destructive/25 bg-destructive/5 px-3 py-2 font-mono text-xs whitespace-pre-wrap text-destructive",children:y})}):(0,n.jsx)(C,{result:v,loading:N})]}),(0,n.jsx)(E,{connectionId:e.id,onSelectHistory:function(t){x(e.id,t),j(null),window.requestAnimationFrame(()=>$.current?.focus(!0))}})]})}},96532:(e,t,r)=>{"use strict";r.d(t,{H4:()=>o,d6:()=>n});let n=1e4,o=5e5}},e=>{e.O(0,[4506,6079,1731,8026,9159,4097,6090,8441,3794,7358],()=>e(e.s=21281)),_N_E=e.O()}]);