mage-ai 0.8.91__py3-none-any.whl → 0.8.93__py3-none-any.whl

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.

Potentially problematic release.


This version of mage-ai might be problematic. Click here for more details.

Files changed (103) hide show
  1. mage_ai/api/policies/BlockPolicy.py +1 -0
  2. mage_ai/api/policies/PipelinePolicy.py +6 -0
  3. mage_ai/api/presenters/BlockPresenter.py +1 -0
  4. mage_ai/api/presenters/PipelinePresenter.py +2 -0
  5. mage_ai/data_preparation/decorators.py +4 -0
  6. mage_ai/data_preparation/executors/block_executor.py +68 -3
  7. mage_ai/data_preparation/models/block/__init__.py +212 -67
  8. mage_ai/data_preparation/models/block/constants.py +3 -1
  9. mage_ai/data_preparation/models/constants.py +8 -8
  10. mage_ai/data_preparation/models/pipeline.py +83 -5
  11. mage_ai/data_preparation/repo_manager.py +5 -2
  12. mage_ai/data_preparation/shared/constants.py +2 -1
  13. mage_ai/data_preparation/templates/conditionals/base.jinja +11 -0
  14. mage_ai/data_preparation/templates/constants.py +7 -0
  15. mage_ai/io/mssql.py +11 -1
  16. mage_ai/io/sql.py +8 -1
  17. mage_ai/orchestration/db/migrations/versions/dfe49d040487_add_condition_failed_status_to_block_.py +39 -0
  18. mage_ai/orchestration/db/models/schedules.py +5 -1
  19. mage_ai/orchestration/pipeline_scheduler.py +27 -17
  20. mage_ai/server/api/downloads.py +64 -0
  21. mage_ai/server/constants.py +1 -1
  22. mage_ai/server/execution_manager.py +3 -2
  23. mage_ai/server/frontend_dist/404.html +2 -2
  24. mage_ai/server/frontend_dist/404.html.html +2 -2
  25. mage_ai/server/frontend_dist/_next/static/chunks/1424-321c8c08a2b05c19.js +1 -0
  26. mage_ai/server/frontend_dist/_next/static/chunks/2786-2b3ad2cf216fae42.js +1 -0
  27. mage_ai/server/frontend_dist/_next/static/chunks/3714-3bd2a8c979d6d820.js +1 -0
  28. mage_ai/server/frontend_dist/_next/static/chunks/3752-8f15fe0ca9c23cf4.js +1 -0
  29. mage_ai/server/frontend_dist/_next/static/chunks/{4476-cdae7a65db573bb7.js → 4476-c1a62e69cd8e14d5.js} +1 -1
  30. mage_ai/server/frontend_dist/_next/static/chunks/pages/_app-8aaee96edc252aa3.js +1 -0
  31. mage_ai/server/frontend_dist/_next/static/chunks/pages/manage-88c03376d807012e.js +1 -0
  32. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipeline-runs-915825c19bf42fa1.js +1 -0
  33. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/backfills-bf2d83dabe1bd25a.js +1 -0
  34. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/edit-f0940870ff5a17f6.js +1 -0
  35. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/logs-8ee12ce8362ed576.js +1 -0
  36. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/monitors/block-runs-a64f7a0aba0f481d.js +1 -0
  37. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/monitors/block-runtime-3a3a115ab1a86e2f.js +1 -0
  38. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/runs/[run]-160881dab5ef66d8.js +1 -0
  39. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/runs-69d63c14abf8cf68.js +1 -0
  40. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/syncs-6092226e191dd720.js +1 -0
  41. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines-549f4708f2912a7a.js +1 -0
  42. mage_ai/server/frontend_dist/_next/static/zlCBBK90aKYZtPlYLj9_T/_buildManifest.js +1 -0
  43. mage_ai/server/frontend_dist/files.html +2 -2
  44. mage_ai/server/frontend_dist/index.html +2 -2
  45. mage_ai/server/frontend_dist/manage/users/[user].html +2 -2
  46. mage_ai/server/frontend_dist/manage/users.html +2 -2
  47. mage_ai/server/frontend_dist/manage.html +2 -2
  48. mage_ai/server/frontend_dist/pipeline-runs.html +2 -2
  49. mage_ai/server/frontend_dist/pipelines/[pipeline]/backfills/[...slug].html +2 -2
  50. mage_ai/server/frontend_dist/pipelines/[pipeline]/backfills.html +2 -2
  51. mage_ai/server/frontend_dist/pipelines/[pipeline]/edit.html +2 -2
  52. mage_ai/server/frontend_dist/pipelines/[pipeline]/logs.html +2 -2
  53. mage_ai/server/frontend_dist/pipelines/[pipeline]/monitors/block-runs.html +2 -2
  54. mage_ai/server/frontend_dist/pipelines/[pipeline]/monitors/block-runtime.html +2 -2
  55. mage_ai/server/frontend_dist/pipelines/[pipeline]/monitors.html +2 -2
  56. mage_ai/server/frontend_dist/pipelines/[pipeline]/runs/[run].html +2 -2
  57. mage_ai/server/frontend_dist/pipelines/[pipeline]/runs.html +2 -2
  58. mage_ai/server/frontend_dist/pipelines/[pipeline]/settings.html +2 -2
  59. mage_ai/server/frontend_dist/pipelines/[pipeline]/syncs.html +2 -2
  60. mage_ai/server/frontend_dist/pipelines/[pipeline]/triggers/[...slug].html +2 -2
  61. mage_ai/server/frontend_dist/pipelines/[pipeline]/triggers.html +2 -2
  62. mage_ai/server/frontend_dist/pipelines/[pipeline].html +2 -2
  63. mage_ai/server/frontend_dist/pipelines.html +2 -2
  64. mage_ai/server/frontend_dist/settings/account/profile.html +2 -2
  65. mage_ai/server/frontend_dist/settings/workspace/preferences.html +2 -2
  66. mage_ai/server/frontend_dist/settings/workspace/sync-data.html +2 -2
  67. mage_ai/server/frontend_dist/settings/workspace/users.html +2 -2
  68. mage_ai/server/frontend_dist/settings.html +2 -2
  69. mage_ai/server/frontend_dist/sign-in.html +2 -2
  70. mage_ai/server/frontend_dist/terminal.html +2 -2
  71. mage_ai/server/frontend_dist/test.html +2 -2
  72. mage_ai/server/frontend_dist/triggers.html +2 -2
  73. mage_ai/server/server.py +8 -0
  74. mage_ai/server/websocket_server.py +3 -2
  75. mage_ai/services/spark/config.py +8 -2
  76. mage_ai/services/spark/spark.py +64 -22
  77. mage_ai/shared/environments.py +4 -8
  78. mage_ai/tests/api/operations/test_syncs.py +1 -1
  79. mage_ai/tests/data_preparation/models/test_pipeline.py +11 -1
  80. {mage_ai-0.8.91.dist-info → mage_ai-0.8.93.dist-info}/METADATA +1 -1
  81. {mage_ai-0.8.91.dist-info → mage_ai-0.8.93.dist-info}/RECORD +87 -83
  82. mage_ai/server/frontend_dist/_next/static/chunks/1424-c6b0d89ffb4a10b9.js +0 -1
  83. mage_ai/server/frontend_dist/_next/static/chunks/3714-c70e815b08e3d9be.js +0 -1
  84. mage_ai/server/frontend_dist/_next/static/chunks/3752-bd78037feb0a755f.js +0 -1
  85. mage_ai/server/frontend_dist/_next/static/chunks/pages/_app-aa11738683e2250f.js +0 -1
  86. mage_ai/server/frontend_dist/_next/static/chunks/pages/manage-06aa8a8f1ca2e8d8.js +0 -1
  87. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipeline-runs-3260a2dac8df672e.js +0 -1
  88. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/backfills-f08b51d9dc56eab5.js +0 -1
  89. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/edit-43e71712d3fc0299.js +0 -1
  90. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/logs-264439be4f197741.js +0 -1
  91. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/monitors/block-runs-91ba61b9030eff1f.js +0 -1
  92. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/monitors/block-runtime-0bbae5456b0e6e82.js +0 -1
  93. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/runs/[run]-86d1477c6671ea30.js +0 -1
  94. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/runs-4b0c098074dd3e6d.js +0 -1
  95. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/syncs-891c3d3f7a2b634b.js +0 -1
  96. mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines-f4d470fe28b74de7.js +0 -1
  97. mage_ai/server/frontend_dist/_next/static/j-J6532RA0pcVgjHCeKSz/_buildManifest.js +0 -1
  98. /mage_ai/server/frontend_dist/_next/static/{j-J6532RA0pcVgjHCeKSz → zlCBBK90aKYZtPlYLj9_T}/_middlewareManifest.js +0 -0
  99. /mage_ai/server/frontend_dist/_next/static/{j-J6532RA0pcVgjHCeKSz → zlCBBK90aKYZtPlYLj9_T}/_ssgManifest.js +0 -0
  100. {mage_ai-0.8.91.dist-info → mage_ai-0.8.93.dist-info}/LICENSE +0 -0
  101. {mage_ai-0.8.91.dist-info → mage_ai-0.8.93.dist-info}/WHEEL +0 -0
  102. {mage_ai-0.8.91.dist-info → mage_ai-0.8.93.dist-info}/entry_points.txt +0 -0
  103. {mage_ai-0.8.91.dist-info → mage_ai-0.8.93.dist-info}/top_level.txt +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2551],{85307:function(e,n,t){"use strict";t.d(n,{$W:function(){return a},cl:function(){return s},cv:function(){return d},dE:function(){return u}});var i=t(9518),r=t(23831),o=t(73942),l=t(49125),c=t(37391),u=i.default.div.withConfig({displayName:"indexstyle__SectionStyle",componentId:"sc-7a1uhf-0"})(["border-radius:","px;padding:","px;",""],o.n_,l.cd*l.iI,(function(e){return"\n background-color: ".concat((e.theme.background||r.Z.background).popup,";\n ")})),a=i.default.div.withConfig({displayName:"indexstyle__CodeEditorStyle",componentId:"sc-7a1uhf-1"})(["padding-top:","px;",""],l.cd*l.iI,(function(e){return"\n background-color: ".concat((e.theme.background||r.Z.background).codeTextarea,";\n ")})),s=i.default.div.withConfig({displayName:"indexstyle__TableContainerStyle",componentId:"sc-7a1uhf-2"})(["overflow:auto;max-height:90vh;width:100%;"," "," "," "," ",""],c.w5,(function(e){return e.hideHorizontalScrollbar&&"\n overflow-x: hidden;\n "}),(function(e){return e.width&&"\n width: ".concat(e.width,";\n ")}),(function(e){return e.height&&"\n height: ".concat(e.height,";\n ")}),(function(e){return e.maxHeight&&"\n max-height: ".concat(e.maxHeight,";\n ")})),d=i.default.div.withConfig({displayName:"indexstyle__HeaderRowStyle",componentId:"sc-7a1uhf-3"})(["padding:","px;"," "," ",""],2*l.iI,(function(e){return"\n background-color: ".concat((e.theme||r.Z).interactive.defaultBackground,";\n border-bottom: ").concat(o.YF,"px ").concat(o.M8," ").concat((e.theme||r.Z).borders.medium,";\n ")}),(function(e){return e.padding&&"\n padding: ".concat(e.padding,"px;\n ")}),(function(e){return e.rounded&&"\n border-top-left-radius: ".concat(o.n_,"px;\n border-top-right-radius: ").concat(o.n_,"px;\n ")}))},70543:function(e,n,t){"use strict";t.d(n,{IY:function(){return o},Jf:function(){return r},NR:function(){return l},b7:function(){return i}});var i="edit",r={uuid:"All files"},o={uuid:"Files in pipeline"},l=[r,o]},59920:function(e,n,t){"use strict";var i;t.d(n,{M:function(){return i}}),function(e){e.BACKFILLS="backfills",e.BLOCK_RUNS="block_runs",e.EDIT="edit",e.MONITOR="monitor",e.PIPELINE_LOGS="pipeline_logs",e.PIPELINE_RUNS="pipeline_runs",e.RUNS="runs",e.SETTINGS="settings",e.SYNCS="syncs",e.TRIGGERS="triggers"}(i||(i={}))},36405:function(e,n,t){"use strict";t.d(n,{H:function(){return c}});var i=t(98781),r=t(10503),o=t(59920),l=t(9736);function c(e,n,t){var c=(n||{}).uuid||t,u=[{Icon:r.Bf,id:o.M.TRIGGERS,isSelected:function(){return o.M.TRIGGERS===e},label:function(){return"Triggers"},linkProps:{as:"/pipelines/".concat(c,"/triggers"),href:"/pipelines/[pipeline]/triggers"}},{Icon:r.Pf,id:o.M.RUNS,isSelected:function(){return o.M.RUNS===e},label:function(){return"Runs"},linkProps:{as:"/pipelines/".concat(c,"/runs"),href:"/pipelines/[pipeline]/runs"}},{Icon:r.dE,id:o.M.BACKFILLS,isSelected:function(){return o.M.BACKFILLS===e},label:function(){return"Backfills"},linkProps:{as:"/pipelines/".concat(c,"/backfills"),href:"/pipelines/[pipeline]/backfills"}},{Icon:r.UL,id:o.M.PIPELINE_LOGS,isSelected:function(){return o.M.PIPELINE_LOGS===e},label:function(){return"Logs"},linkProps:{as:"/pipelines/".concat(c,"/logs"),href:"/pipelines/[pipeline]/logs"}},{Icon:r.ug,id:o.M.MONITOR,isSelected:function(){return o.M.MONITOR===e},label:function(){return"Monitor"},linkProps:{as:"/pipelines/".concat(c,"/monitors"),href:"/pipelines/[pipeline]/monitors"}}];return i.qL.INTEGRATION===(null===n||void 0===n?void 0:n.type)&&u.unshift({Icon:r.Nt,id:o.M.SYNCS,isSelected:function(){return o.M.SYNCS===e},label:function(){return"Syncs"},linkProps:{as:"/pipelines/".concat(c,"/syncs"),href:"/pipelines/[pipeline]/syncs"}}),(0,l.Ct)()||(u.unshift({Icon:r.EK,disabled:!c,id:o.M.EDIT,isSelected:function(){return o.M.EDIT===e},label:function(){return"Edit pipeline"},linkProps:{as:"/pipelines/".concat(c,"/edit"),href:"/pipelines/[pipeline]/edit"}}),u.push({Icon:r.Zr,id:o.M.SETTINGS,isSelected:function(){return o.M.SETTINGS===e},label:function(){return"Pipeline settings"},linkProps:{as:"/pipelines/".concat(c,"/settings"),href:"/pipelines/[pipeline]/settings"}})),u}},64155:function(e,n,t){"use strict";t.d(n,{Eh:function(){return a},ht:function(){return d},t0:function(){return s}});var i=t(9518),r=t(82386),o=t(1286),l=t(31012),c=t(37391),u=t(49125),a=(u.iI,o.O$+3*u.iI+l.dN),s=i.default.div.withConfig({displayName:"indexstyle__SidekickContainerStyle",componentId:"sc-15ofupc-0"})([""," overflow:auto;position:absolute;width:100%;",""],c.w5,(function(e){return"\n height: calc(100vh - ".concat(r.uX,"px - ").concat(e.heightOffset,"px);\n ")})),d=i.default.div.withConfig({displayName:"indexstyle__PaddingContainerStyle",componentId:"sc-15ofupc-1"})(["padding:","px;",""],2*u.iI,(function(e){return e.noPadding&&"\n padding: 0;\n "}))},58122:function(e,n,t){"use strict";t.d(n,{CL:function(){return p},FS:function(){return h},JZ:function(){return v},e7:function(){return b},v0:function(){return f},wx:function(){return m}});var i=t(75582),r=t(82394),o=t(43313),l=t(93348),c=t(1286),u=t(90211),a=t(84779);function s(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function d(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?s(Object(t),!0).forEach((function(n){(0,r.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):s(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function f(e){var n=e.statistics,t=Object.keys(n),i=Array(o.Dy.length).fill(0);return 0===t.length?null:(t.forEach((function(e){if(o.Dy.includes(e)){var t=o.CC[e],r=n[e],l=r,c=!1,u=[2,3],s=o.Ub[e],d=o.oH[e],f=o.OD[e];if(o.y_.includes(e))c=!0,u=[2,1,2];else if(e in o.Sq){r=(0,a.Jw)(r,0);var p=o.Sq[e];l=n[p]}var h={columnFlexNumbers:u,name:t,progress:c,rate:l,successDirection:d,warning:f};o.y_.includes(e)||(h.value=r),i[s]=h}})),i)}function p(e){var n=e.columnTypes,t=void 0===n?{}:n,i=e.statistics,r=Object.keys(i);if(0===r.length)return null;var l=Object.values(t),a=l.length,s=[];s.push({name:"Column count",successDirection:o.oH.column_count,value:(0,u.x6)(a)}),r.forEach((function(e){if(o.Zu.includes(e)){var n=o.CC[e],t=i[e],r=o.OD[e];s.push({name:n,successDirection:o.oH[e],value:(0,u.x6)(t),warning:r})}}));var d=(0,c.QO)(l),f=d.countCategory,p=d.countDatetime,h=d.countNumerical;return s.push({name:"Categorical Features",rate:f/a,value:(0,u.x6)(f)},{name:"Numerical Features",rate:h/a,value:(0,u.x6)(h)},{name:"Datetime Features",rate:p/a,value:(0,u.x6)(p)}),s}function h(e){return"string"===typeof e?e:JSON.stringify(e)}function m(e,n){var t,i;return null===e||void 0===e||null===(t=e.find((function(e){var t=e.block;return n(t)})))||void 0===t||null===(i=t.variables)||void 0===i?void 0:i.map((function(e){var n=e.value;return d(d({},e),{},{value:h(n)})}))}function v(e,n){return n===l.Xm.TIME?e.push({uuid:"execution_date",value:"<run datetime>"}):n===l.Xm.EVENT&&e.push({uuid:"event",value:"<trigger event>"}),e}function b(e){return e?Object.entries(e).reduce((function(e,n){var t=(0,i.Z)(n,2),o=t[0],l=t[1],c=l;try{c=JSON.parse(l)}catch(u){}return d(d({},e),{},(0,r.Z)({},o,c))}),{}):e}},76096:function(e,n,t){"use strict";var i=t(82394),r=t(26304),o=(t(82684),t(33591)),l=t(28598),c=["children","fullHeight","gutter","style"];function u(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function a(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?u(Object(t),!0).forEach((function(n){(0,i.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):u(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}n.Z=function(e){var n=e.children,t=e.fullHeight,i=e.gutter,u=e.style,s=void 0===u?{}:u,d=(0,r.Z)(e,c),f=a({},s);return i&&(f.paddingLeft=i,f.paddingRight=f.paddingLeft),t&&(f.height="100%"),(0,l.jsx)(o.Col,a(a({},d),{},{style:f,children:n}))}},97361:function(e,n,t){"use strict";var i=t(82394),r=t(26304),o=t(82684),l=t(33591),c=t(28598),u=["children","fullHeight","gutter","justifyContent","style"];function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function s(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?a(Object(t),!0).forEach((function(n){(0,i.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}n.Z=function(e){var n=e.children,t=e.fullHeight,i=e.gutter,a=e.justifyContent,d=e.style,f=void 0===d?{}:d,p=(0,r.Z)(e,u),h=s({},f);return i&&(h.marginLeft=-1*i,h.marginRight=h.marginLeft),t&&(h.height="100%"),(0,c.jsx)(l.Row,s(s({},p),{},{justifyContent:a,style:h,children:o.Children.map(n,(function(e,n){return e&&o.cloneElement(e,{gutter:i,key:n})}))}))}},93348:function(e,n,t){"use strict";t.d(n,{TR:function(){return d},U5:function(){return u},Xm:function(){return o},Z4:function(){return s},fq:function(){return c},kJ:function(){return a}});var i,r,o,l=t(82394);!function(e){e.API="api",e.EVENT="event",e.TIME="time"}(o||(o={}));var c,u,a,s=(i={},(0,l.Z)(i,o.API,(function(){return"API"})),(0,l.Z)(i,o.EVENT,(function(){return"event"})),(0,l.Z)(i,o.TIME,(function(){return"schedule"})),i);!function(e){e.ACTIVE="active",e.INACTIVE="inactive"}(c||(c={})),function(e){e.ONCE="@once",e.HOURLY="@hourly",e.DAILY="@daily",e.WEEKLY="@weekly",e.MONTHLY="@monthly"}(u||(u={})),function(e){e.CREATED_AT="created_at",e.NAME="name",e.PIPELINE="pipeline_uuid",e.STATUS="status",e.TYPE="schedule_type"}(a||(a={}));var d=(r={},(0,l.Z)(r,a.CREATED_AT,"Created at"),(0,l.Z)(r,a.NAME,"Name"),(0,l.Z)(r,a.PIPELINE,"Pipeline"),(0,l.Z)(r,a.STATUS,"Status"),(0,l.Z)(r,a.TYPE,"Type"),r)},52769:function(e,n,t){"use strict";t.d(n,{C:function(){return i}});var i="global"},79891:function(e,n,t){"use strict";var i=t(9518),r=t(60328),o=t(67971),l=t(86673),c=t(19711),u=t(23831),a=t(10503),s=t(49125),d=t(31012),f=t(28598),p=i.default.div.withConfig({displayName:"Chip__ChipStyle",componentId:"sc-1ok73g-0"})(["display:inline-block;"," "," "," "," ",""],(function(e){return!e.primary&&"\n background-color: ".concat((e.theme.background||u.Z.background).popup,";\n ")}),(function(e){return e.primary&&"\n background-color: ".concat((e.theme.chart||u.Z.chart).primary,";\n ")}),(function(e){return!e.small&&"\n border-radius: ".concat((s.iI+d.Al)/2,"px;\n height: ").concat(1.5*s.iI+d.Al,"px;\n padding: ").concat(s.iI/1.5,"px ").concat(1.25*s.iI,"px;\n ")}),(function(e){return e.small&&"\n border-radius: ".concat((s.iI/2+d.Al)/2,"px;\n height: ").concat(d.Al+s.iI/2+2,"px;\n padding: ").concat(s.iI/4,"px ").concat(s.iI,"px;\n ")}),(function(e){return e.border&&"\n border: 1px solid ".concat((e.theme.content||u.Z.content).muted,";\n ")}));n.Z=function(e){var n=e.border,t=e.children,i=e.disabled,u=e.label,d=e.onClick,h=e.primary,m=e.small;return(0,f.jsx)(p,{border:n,primary:h,small:m,children:(0,f.jsx)(r.Z,{basic:!0,disabled:i,noBackground:!0,noPadding:!0,onClick:d,transparent:!0,children:(0,f.jsxs)(o.Z,{alignItems:"center",children:[t,u&&(0,f.jsx)(c.ZP,{small:m,children:u}),!i&&(0,f.jsx)(l.Z,{ml:1,children:(0,f.jsx)(a.x8,{default:h,muted:!h,size:m?s.iI:1.25*s.iI})})]})})})}},22673:function(e,n,t){"use strict";var i=t(82684),r=t(68792),o=t(31811),l=t(9518),c=t(65292),u=t(23831),a=t(2005),s=t(49125),d=t(28598);n.Z=function(e){var n=e.language,t=e.maxWidth,f=e.showLineNumbers,p=e.small,h=e.source,m=e.wrapLines,v=(0,i.useContext)(l.ThemeContext);function b(e){var i=e.value;return(0,d.jsx)(o.Z,{customStyle:{backgroundColor:(v.background||u.Z.background).popup,border:"none",borderRadius:"none",boxShadow:"none",fontFamily:a.Vp,fontSize:p?12:14,marginBottom:0,marginTop:0,maxWidth:t,paddingBottom:2*s.iI,paddingTop:2*s.iI},language:n,lineNumberStyle:{color:(v.content||u.Z.content).muted},showLineNumbers:f,style:c._4,useInlineStyles:!0,wrapLines:m,children:i})}return(0,d.jsx)(r.D,{components:{code:function(e){var n=e.children;return(0,d.jsx)(b,{value:n})}},children:h})}},65730:function(e,n,t){"use strict";var i,r=t(82394),o=(t(82684),t(64866)),l=t(21764),c=t(67971),u=t(10919),a=t(86673),s=t(19711),d=t(46261),f=t(10503),p=t(49125),h=t(28598);function m(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function v(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?m(Object(t),!0).forEach((function(n){(0,r.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):m(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}!function(e){e.LEFT="left",e.RIGHT="right"}(i||(i={})),n.Z=function(e){var n,t=e.children,r=e.copiedText,m=e.iconPosition,b=void 0===m?i.LEFT:m,g=e.inverted,x=e.linkProps,j=e.linkText,y=e.monospace,k=e.muted,Z=e.small,_=e.toastMessage,O=e.withCopyIcon;return t?n=(0,h.jsx)("span",{children:t}):O&&(n=(0,h.jsx)(u.Z,v(v({href:"#",inline:!0,muted:k,preventDefault:!0,sameColorAsText:!0,small:Z},x),{},{children:(0,h.jsxs)(c.Z,{alignItems:"center",children:[b===i.LEFT&&(0,h.jsx)(a.Z,{mr:j?1:0,children:(0,h.jsx)(c.Z,{alignItems:"center",children:(0,h.jsx)(f.CK,{inverted:g,muted:k,size:2*p.iI})})}),j&&(0,h.jsx)(s.ZP,{inverted:g,monospace:y,muted:k,small:Z,children:j}),b===i.RIGHT&&(0,h.jsx)(a.Z,{ml:j?1:0,children:(0,h.jsx)(c.Z,{alignItems:"center",children:(0,h.jsx)(f.CK,{inverted:g,muted:k})})})]})}))),(0,h.jsx)(d.Z,{block:!0,label:"Copy",size:null,widthFitContent:!0,children:(0,h.jsx)(o.CopyToClipboard,{onCopy:function(){return l.Am.success(_||"Successfully copied to clipboard.",{position:l.Am.POSITION.BOTTOM_RIGHT,toastId:r})},text:r,children:n})})}},30264:function(e,n,t){"use strict";var i=t(82394),r=t(26304),o=(t(82684),t(47999)),l=t(62084),c=t(28598),u=["children","items","open","onClickCallback","onClickOutside","parentRef","uuid"];function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function s(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?a(Object(t),!0).forEach((function(n){(0,i.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}n.Z=function(e){var n=e.children,t=e.items,i=e.open,a=e.onClickCallback,d=e.onClickOutside,f=e.parentRef,p=e.uuid,h=(0,r.Z)(e,u),m=(0,c.jsxs)("div",{style:{position:"relative",zIndex:d?3:2},children:[(0,c.jsx)("div",{ref:f,children:n}),(0,c.jsx)(l.Z,s(s({},h),{},{items:t,onClickCallback:a,open:i,parentRef:f,uuid:p}))]});return d?(0,c.jsx)(o.Z,{onClickOutside:d,open:!0,children:m}):m}},35533:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return Rc}});var i=t(77837),r=t(21831),o=t(82394),l=t(75582),c=t(38860),u=t.n(c),a=t(56085),s=t(82684),d=t(83455),f=t(34376),p=t(48591),h=t(35490),m=t(86422),v=t(9518),b=t(38341),g=t(16634),x=t(34744),j=t(93461),y=t(67971),k=t(10919),Z=t(86673),_=t(19711),O=t(49125),C=t(44162),S=t(28598);function E(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function P(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?E(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):E(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var w=function(e){var n=e.blockRefs,t=e.hiddenBlocks,i=e.pipeline,r=e.setHiddenBlocks,l=(0,s.useContext)(v.ThemeContext),c=(0,s.useMemo)((function(){return(null===i||void 0===i?void 0:i.blocks)||[]}),[i]),u=(0,s.useMemo)((function(){var e=[],n=[];return c.forEach((function(i){var r=i.uuid;null!==t&&void 0!==t&&t[r]?e.push(i):n.push(i)})),{blocksHidden:e,blocksVisible:n}}),[c,t]),a=u.blocksHidden,d=u.blocksVisible,f=(0,s.useMemo)((function(){return(null===c||void 0===c?void 0:c.length)>=1&&0===d.length}),[c,d]),p=(0,s.useMemo)((function(){return(null===c||void 0===c?void 0:c.length)>=1&&0===a.length}),[c,a]),h=(0,s.useCallback)((function(e){var t=e.type,i=e.uuid;if(null!==n&&void 0!==n&&n.current){var r,o=n.current["".concat(t,"s/").concat(i,".py")];null===o||void 0===o||null===(r=o.current)||void 0===r||r.scrollIntoView()}}),[n]);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Z.Z,{p:1,children:(0,S.jsxs)(y.Z,{alignItems:"center",justifyContent:"space-between",children:[(0,S.jsx)(j.Z,{flex:1,justifyContent:"center",children:(0,S.jsx)(b.Z,{checked:p,label:"Show all",onClick:function(){return r((function(){return{}}))}})}),(0,S.jsx)(j.Z,{flex:1,justifyContent:"center",children:(0,S.jsx)(b.Z,{checked:f,label:"Hide all",onClick:function(){return r((function(){return c.reduce((function(e,n){var t=n.uuid;return P(P({},e),{},(0,o.Z)({},t,!0))}),{})}))}})})]})}),(0,S.jsx)(x.Z,{medium:!0}),null===c||void 0===c?void 0:c.map((function(e){var n=e.uuid,i=(0,C.qn)(e.type,{blockColor:e.color,theme:l}).accent,c=!(null!==t&&void 0!==t&&t[n]);return(0,S.jsx)(k.Z,{block:!0,noHoverUnderline:!0,noOutline:!0,onClick:function(){r((function(e){return P(P({},e),{},(0,o.Z)({},n,c))})),c||setTimeout((function(){return h(e)}),1)},preventDefault:!0,children:(0,S.jsx)(Z.Z,{mt:1,px:1,children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(Z.Z,{pr:1,children:(0,S.jsx)(b.Z,{checked:c})}),(0,S.jsxs)(j.Z,{alignItems:"center",children:[(0,S.jsx)(g.Z,{color:i,size:1.5*O.iI,square:!0}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(_.ZP,{default:!0,monospace:!0,noWrapping:!0,small:!0,children:n})]})]})})},n)}))]})},I=t(60328),T=t(32316),A=t(11135),R=t(29237),D=t(98781),M=t(82944),B=t(16115),N=t(11366),L=t(91427),F=t(51504);var U=function(e){var n=e.block,t=e.defaultName,i=e.onClose,r=e.onSave,o=e.pipeline,l=(0,s.useRef)(null),c=(0,s.useState)(t),u=c[0],a=c[1],d=(0,s.useState)(!!(0,L.U2)(N.kY)),f=d[0],p=d[1];(0,s.useEffect)((function(){var e;null===l||void 0===l||null===(e=l.current)||void 0===e||e.focus()}),[]);var h=(0,s.useMemo)((function(){return D.qL.INTEGRATION===(null===o||void 0===o?void 0:o.type)}),[o]),v=(0,s.useMemo)((function(){var e=null===n||void 0===n?void 0:n.type;if(h){if(m.tf.DATA_LOADER===e)return"Source";if(m.tf.DATA_EXPORTER===e)return"Destination"}return m.V4[e]}),[n,h]);return(0,S.jsxs)(R.Z,{children:[(0,S.jsxs)(_.ZP,{bold:!0,children:[v," block name"]}),(0,S.jsx)(Z.Z,{mt:1,children:(0,S.jsx)(M.Z,{monospace:!0,onChange:function(e){return a(e.target.value)},ref:l,value:u})}),(0,S.jsx)(Z.Z,{mt:2,children:(0,S.jsx)(y.Z,{alignItems:"center",children:(0,S.jsx)(b.Z,{checked:f,label:(0,S.jsxs)(_.ZP,{muted:!0,small:!0,children:["Automatically use randomly generated name",(0,S.jsx)("br",{}),"for blocks created in the future"]}),onClick:function(){p(!f),(0,L.t8)(N.kY,!f)}})})}),(0,S.jsx)(Z.Z,{mt:3,children:(0,S.jsxs)(y.Z,{children:[(0,S.jsx)(A.ZP,{bold:!0,inline:!0,keyboardShortcutValidation:function(e){var n=e.keyMapping;return(0,F.y)([B.Uq],n)},onClick:function(){return r({name:u||t})},primary:!0,tabIndex:0,uuid:"ConfigureBlock/SaveAndAddBlock",children:"Save and add block"}),(0,S.jsx)(Z.Z,{ml:1,children:(0,S.jsx)(I.Z,{onClick:i,tabIndex:0,children:"Cancel"})})]})})]})},H=t(46299),G=t(91207),z=t(47999),q=t(62084),K=t(64318),W=t(54405),Q=t(90211),V=t(41150);function Y(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function X(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Y(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Y(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var J,$,ee=function(e){var n=e.cancelPipeline,t=e.children,i=e.createPipeline,r=e.executePipeline,l=e.interruptKernel,c=e.isPipelineExecuting,u=e.pipeline,a=e.restartKernel,d=e.savePipelineContent,f=(e.setActiveSidekickView,e.setMessages),p=(0,s.useState)(null),h=p[0],m=p[1],v=(0,s.useRef)(null),b=(0,s.useRef)(null),g=(0,s.useRef)(null),x=[{label:function(){return"New standard pipeline"},onClick:function(){return i({pipeline:{name:(0,Q.Y6)()}})},uuid:"new_standard_pipeline"},{label:function(){return"New streaming pipeline"},onClick:function(){return i({pipeline:{name:(0,Q.Y6)(),type:D.qL.STREAMING}})},uuid:"new_streaming_pipeline"},{keyTextGroups:[[(0,W.V5)()?B.RJ:B.hE,B.SS]],label:function(){return"Save pipeline"},onClick:function(){return d()},uuid:"save_pipeline"}],j=(0,s.useMemo)((function(){var e=[{label:function(){return"Interrupt kernel"},keyTextGroups:[[B.kA],[B.kA]],onClick:function(){return l()},uuid:"Interrupt kernel"},{label:function(){return"Restart kernel"},keyTextGroups:[[B.t_[B.OC]],[B.t_[B.OC]]],onClick:function(){return a()},uuid:"Restart kernel"},{label:function(){return"Clear all outputs"},onClick:function(){return f((function(e){return Object.keys(e).reduce((function(e,n){return X(X({},e),{},(0,o.Z)({},n,[]))}),{})}))},uuid:"Clear all outputs"}];return c?e.push({label:function(){return"Cancel pipeline"},onClick:function(){return n()},uuid:"Cancel pipeline"}):e.push({label:function(){return"Execute pipeline"},onClick:function(){return r()},uuid:"Execute pipeline"}),e}),[n,r,l,c,a,f]),k=(0,s.useMemo)((function(){return[{label:function(){return"Pipeline settings"},linkProps:{as:"/pipelines/".concat(null===u||void 0===u?void 0:u.uuid,"/settings"),href:"/pipelines/[pipeline]/settings"},uuid:"Pipeline settings"}]}),[u]),Z="FileHeaderMenu/index",O=(0,V.y)(),C=O.registerOnKeyDown,E=O.unregisterOnKeyDown;return(0,s.useEffect)((function(){return function(){E(Z)}}),[E,Z]),C(Z,(function(e,n,t){null!==h&&(n[B.QK]?m((function(e){return 0===e?2:e-1})):n[B.DY]&&m((function(e){return 2===e?0:e+1})))}),[h,m]),(0,S.jsx)(z.Z,{onClickOutside:function(){return m(null)},open:!0,style:{position:"relative"},children:(0,S.jsxs)(y.Z,{children:[(0,S.jsxs)("div",{style:{position:"relative"},children:[(0,S.jsx)(K.u,{highlighted:0===h,onClick:function(){return m((function(e){return 0===e?null:0}))},onMouseEnter:function(){return m((function(e){return null!==e?0:null}))},ref:v,children:(0,S.jsx)(_.ZP,{children:"File"})}),(0,S.jsx)(q.Z,{items:x,onClickCallback:function(){return m(null)},open:0===h,parentRef:v,uuid:"FileHeaderMenu/file_items"})]}),(0,S.jsxs)("div",{style:{position:"relative"},children:[(0,S.jsx)(K.u,{highlighted:1===h,onClick:function(){return m((function(e){return 1===e?null:1}))},onMouseEnter:function(){return m((function(e){return null!==e?1:null}))},ref:b,children:(0,S.jsx)(_.ZP,{children:"Run"})}),(0,S.jsx)(q.Z,{items:j,onClickCallback:function(){return m(null)},open:1===h,parentRef:b,uuid:"FileHeaderMenu/run_items"})]}),(0,S.jsxs)("div",{style:{position:"relative"},children:[(0,S.jsx)(K.u,{highlighted:2===h,onClick:function(){return m((function(e){return 2===e?null:2}))},onMouseEnter:function(){return m((function(e){return null!==e?2:null}))},ref:g,children:(0,S.jsx)(_.ZP,{children:"Edit"})}),(0,S.jsx)(q.Z,{items:k,onClickCallback:function(){return m(null)},open:2===h,parentRef:g,uuid:"FileHeaderMenu/edit_items"})]}),t]})})},ne=t(38488),te=t(57384);!function(e){e.CREATE_NEW_CLUSTER="create_new_cluster",e.SET_ACTIVE_CLUSTER="set_active_cluster"}(J||(J={})),function(e){e.BOOTSTRAPPING="BOOTSTRAPPING",e.STARTING="STARTING",e.WAITING="WAITING"}($||($={}));var ie,re=t(90686),oe=t(62609),le=t(46261),ce=t(82531),ue=t(23831),ae=t(66166),se=t(10503);!function(e){e.EMR="emr"}(ie||(ie={}));var de=t(28347),fe=t(42305),pe=t(24224),he=t(33766),me=t(96510),ve=t(99497);var be=function(e){var n,t=e.children,i=(e.filePaths,e.filesTouched,e.isBusy),o=e.isPipelineUpdating,c=e.kernel,u=e.pipeline,a=e.pipelineContentTouched,f=e.pipelineLastSaved,p=(e.restartKernel,e.savePipelineContent,e.selectedFilePath),h=e.setErrors,m=e.setRunningBlocks,b=e.updatePipelineMetadata,x=(0,s.useContext)(v.ThemeContext),C=c||{},E=C.alive,P=C.usage,w=(0,s.useState)(!1),I=w[0],T=w[1],R=(0,s.useState)(""),M=R[0],N=R[1],F=(0,s.useState)(ie.EMR),U=F[0],H=(F[1],(0,s.useState)(!1)),G=H[0],K=H[1],Q=(0,s.useState)(!1),Y=Q[0],X=Q[1],J=(0,s.useRef)(null),ee=ce.ZP.clusters.detail(U,{},{revalidateOnFocus:!1}),ne=ee.data,te=ee.mutate,be=(0,s.useMemo)((function(){var e;return(null===ne||void 0===ne||null===(e=ne.cluster)||void 0===e?void 0:e.clusters)||[]}),[ne]),ge=(0,s.useMemo)((function(){return(0,pe.sE)(be,(function(e){return e.is_active}))}),[be]),xe=(0,d.Db)(ce.ZP.clusters.useUpdate(U),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(){te()},onErrorCallback:function(e,n){return h({errors:n,response:e})}})}}),je=(0,l.Z)(xe,1)[0];(0,s.useEffect)((function(){null!==u&&void 0!==u&&u.uuid&&N(u.uuid)}),[null===u||void 0===u?void 0:u.uuid]),n=a?"Unsaved changes":o?"Saving changes...":f?"Last saved ".concat((0,fe.JX)(Number(f)/1e3)):"All changes saved";var ye="KernelStatus",ke=(0,V.y)(),Ze=ke.registerOnKeyDown,_e=ke.unregisterOnKeyDown;(0,s.useEffect)((function(){return function(){_e(ye)}}),[_e,ye]),Ze(ye,(function(e,n,t){I&&String(t[0])===String(B.Uq)&&String(t[1])!==String(B.zX)&&((null===u||void 0===u?void 0:u.uuid)===M?e.target.blur():(b(M),T(!1)))}),[I,M,T,b]);var Oe=(0,s.useMemo)((function(){return null===P||void 0===P?void 0:P.pid}),[null===P||void 0===P?void 0:P.pid]),Ce=(0,ae.Z)(Oe),Se=(0,s.useMemo)((function(){if(null!==P&&void 0!==P&&P.kernel_memory){var e=P.kernel_memory,n=Math.floor(Math.log(e)/Math.log(1024));return"".concat(parseFloat((e/Math.pow(1024,n)).toFixed(2))).concat(["B","KB","MB","GB","TB","PB","EB","ZB","YB"][n])}}),[null===P||void 0===P?void 0:P.kernel_memory]),Ee=(0,ve.dd)((function(){return(0,S.jsx)(oe.Z,{cancelText:"Close",centerOnScreen:!0,confirmText:"Don't show again",neutral:!0,onCancel:Ie,onClick:function(){(0,L.t8)(L.DU,1),Ie()},subtitle:"You may need to refresh your page to continue using the notebook. Unexpected kernel restarts may be caused by your kernel running out of memory.",title:"The kernel has restarted",width:34*O.iI})}),{},[],{background:!0,uuid:"restart_kernel_warning"}),Pe=(0,l.Z)(Ee,2),we=Pe[0],Ie=Pe[1];(0,s.useEffect)((function(){var e=(0,L.U2)(L.DU,0);Oe!==Ce&&i&&!e&&(we(),m([]))}),[i,Oe,Ce,m]);var Te=(0,s.useMemo)((function(){return(0,S.jsx)("div",{ref:J,style:{position:"relative"},children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[(null===u||void 0===u?void 0:u.type)===D.qL.PYSPARK&&(0,S.jsxs)(Z.Z,{mr:1,children:[(0,S.jsxs)(k.Z,{muted:!!ge,onClick:function(){return K(!0)},preventDefault:!0,sameColorAsText:!ge,underline:!ge,children:[ge&&ge.id,!ge&&"Select cluster"]}),(0,S.jsx)(z.Z,{disableEscape:!0,onClickOutside:function(){return K(!1)},open:G,children:(0,S.jsx)(q.Z,{items:[{isGroupingTitle:!0,label:function(){return"Select cluster"},uuid:"select_cluster"}].concat((0,r.Z)(be.map((function(e){var n=e.id,t=e.is_active,i=e.status;return{label:function(){return(0,S.jsxs)(y.Z,{alignItems:"center",fullWidth:!0,justifyContent:"space-between",children:[(0,S.jsx)(j.Z,{flex:1,children:(0,S.jsx)(_.ZP,{muted:!t&&$.WAITING!==i,children:n})}),t&&(0,S.jsx)(se.Jr,{size:2*O.iI,success:!0}),!t&&(0,S.jsx)(_.ZP,{monospace:!0,muted:!0,children:i})]})},onClick:t||$.WAITING!==i?null:function(){return je({cluster:{id:n,is_active:!0}})},uuid:n}})))),onClickCallback:function(){return K(!1)},open:G,parentRef:J,uuid:"KernelStatus/select_cluster",width:40*O.iI})})]}),(0,S.jsx)(A.ZP,{beforeElement:(0,S.jsx)(g.Z,{color:i?(x||ue.Z).borders.info:E?(x||ue.Z).borders.success:(x||ue.Z).borders.danger,size:O.iI}),blackBorder:!0,compact:!0,inline:!0,onClick:function(){return X(!0)},uuid:"Pipeline/KernelStatus/kernel",children:(null===u||void 0===u?void 0:u.type)||D.qL.PYTHON}),(0,S.jsx)(z.Z,{disableEscape:!0,onClickOutside:function(){return X(!1)},open:Y,children:(0,S.jsx)(q.Z,{items:[{isGroupingTitle:!0,label:function(){return"Select kernel"},uuid:"select_kernel"}].concat((0,r.Z)(Object.keys(D.a_).filter((function(e){return(null===u||void 0===u?void 0:u.type)!=e})).map((function(e){return{label:function(){return e},onClick:function(){return b(null===u||void 0===u?void 0:u.name,e)},uuid:e}})))),onClickCallback:function(){return X(!1)},open:Y,parentRef:J,uuid:"KernelStatus/select_kernel",width:25*O.iI})})]})})}),[E,be,i,u,ge,K,X,G,Y,x,je]);return(0,S.jsx)(de.rK,{relativePosition:!0,children:(0,S.jsxs)(y.Z,{alignItems:"center",fullHeight:!0,justifyContent:"space-between",children:[(0,S.jsxs)(y.Z,{alignItems:"center",fullHeight:!0,justifyContent:"flex-start",children:[(0,S.jsxs)(Z.Z,{px:O.cd,children:[p&&(0,S.jsx)(k.Z,{noHoverUnderline:!0,noOutline:!0,onClick:p?function(){return(0,he.u7)({file_path:null})}:null,preventDefault:!0,children:t}),!p&&(0,S.jsxs)(y.Z,{alignItems:"center",children:[t,I&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Z.Z,{ml:1}),(0,S.jsx)(k.Z,{onClick:function(){b(M),T(!1)},preventDefault:!0,sameColorAsText:!0,small:!0,children:"Update name"})]})]})]}),P&&(0,S.jsx)(Z.Z,{mr:O.cd,children:(0,S.jsxs)(j.Z,{flexDirection:"column",children:[(0,S.jsxs)(_.ZP,{monospace:!0,muted:!0,xsmall:!0,children:["CPU: ",null===P||void 0===P?void 0:P.kernel_cpu,"undefined"!==typeof(null===P||void 0===P?void 0:P.kernel_cpu)&&"%"]}),(0,S.jsxs)(_.ZP,{monospace:!0,muted:!0,xsmall:!0,children:["Memory: ",Se]})]})})]}),(0,S.jsx)(Z.Z,{px:O.cd,children:(0,S.jsxs)(j.Z,{alignItems:"center",children:[(0,S.jsx)(le.Z,{appearBefore:!0,block:!0,description:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(_.ZP,{default:!0,inline:!0,children:"Press"}),"\xa0",(0,S.jsx)(re.Z,{inline:!0,keyText:(0,W.V5)()?B.RJ:B.hE}),"\xa0",(0,S.jsx)(_.ZP,{default:!0,inline:!0,children:"+"}),"\xa0",(0,S.jsx)(re.Z,{inline:!0,keyText:B.SS}),"\xa0",(0,S.jsx)(_.ZP,{default:!0,inline:!0,children:"to save changes."}),(0,S.jsx)("br",{})]}),(0,S.jsx)(Z.Z,{mt:1,children:(0,S.jsxs)(_.ZP,{default:!0,children:["Or, go to ",(0,S.jsx)(_.ZP,{inline:!0,monospace:!0,children:"File"})," \u203a ",(0,S.jsx)(_.ZP,{inline:!0,monospace:!0,children:"Save pipeline"}),"."]})})]}),size:null,widthFitContent:!0,children:(0,S.jsx)(_.ZP,{muted:!0,children:n})}),(0,S.jsx)(Z.Z,{ml:2}),Te]})})]})})},ge=t(82635),xe=t(17717),je=t(16910),ye=t(65701),ke=t(1254);var Ze,_e,Oe,Ce,Se,Ee,Pe=function(e){var n=e.size;return(0,S.jsx)("svg",{fill:"none",height:n,preserveAspectRatio:"xMidYMid",viewBox:"0 0 256 256",width:n,xmlns:"http://www.w3.org/2000/svg",children:(0,S.jsx)("path",{d:"M245.121138,10.6473813 C251.139129,16.4340053 255.074133,24.0723342 256,32.4050489 C256,35.8769778 255.074133,38.1917867 252.990862,42.5895822 C250.907876,46.9873778 225.215147,91.4286933 217.57696,103.696213 C213.179164,110.871609 210.864356,119.435947 210.864356,127.768462 C210.864356,136.3328 213.179164,144.6656 217.57696,151.840996 C225.215147,164.108516 250.907876,208.781084 252.990862,213.179164 C255.074133,217.57696 256,219.659947 256,223.131876 C255.074133,231.464676 251.370667,239.103147 245.352676,244.658347 C239.565938,250.676338 231.927751,254.611342 223.826489,255.305671 C220.35456,255.305671 218.039751,254.379804 213.873493,252.296533 C209.706951,250.213262 164.340053,225.215147 152.072249,217.57696 C151.146382,217.113884 150.220516,216.419556 149.063396,215.95648 L88.4195556,180.079502 C89.8082133,191.652693 94.9006222,202.763093 103.233138,210.864356 C104.853618,212.484551 106.473813,213.873493 108.325547,215.262151 C106.936604,215.95648 105.316409,216.651093 103.927751,217.57696 C91.6599467,225.215147 46.9873778,250.907876 42.5895822,252.990862 C38.1917867,255.074133 36.1085156,256 32.4050489,256 C24.0723342,255.074133 16.4340053,251.370667 10.8788338,245.352676 C4.86075733,239.565938 0.925858133,231.927751 0,223.594951 C0.231464676,220.123022 1.1573248,216.651093 3.00905244,213.641956 C5.09223822,209.24416 30.7848533,164.571307 38.42304,152.303787 C42.82112,145.128391 45.1356444,136.795591 45.1356444,128.231538 C45.1356444,119.6672 42.82112,111.3344 38.42304,104.159004 C30.7848533,91.4286933 4.86075733,46.75584 3.00905244,42.3580444 C1.1573248,39.3489067 0.231464676,35.8769778 0,32.4050489 C0.925858133,24.0723342 4.62930489,16.4340053 10.6473813,10.6473813 C16.4340053,4.62930489 24.0723342,0.925858133 32.4050489,0 C35.8769778,0.231464676 39.3489067,1.1573248 42.5895822,3.00905244 C46.2930489,4.62930489 78.9293511,23.6094009 96.28928,33.7939911 L100.224284,36.1085156 C101.612942,37.0343822 102.770347,37.7287111 103.696213,38.1917867 L105.547947,39.3489067 L167.348907,75.9204978 C165.960249,62.0324978 158.784853,49.3019022 147.674453,40.7378489 C149.063396,40.04352 150.683591,39.3489067 152.072249,38.42304 C164.340053,30.7848533 209.012622,4.86075733 213.410418,3.00905244 C216.419556,1.1573248 219.891484,0.231464676 223.594951,0 C231.696213,0.925858133 239.334684,4.62930489 245.121138,10.6473813 Z M131.240391,144.434062 L144.434062,131.240391 C146.285796,129.388658 146.285796,126.611342 144.434062,124.759609 L131.240391,111.565938 C129.388658,109.714204 126.611342,109.714204 124.759609,111.565938 L111.565938,124.759609 C109.714204,126.611342 109.714204,129.388658 111.565938,131.240391 L124.759609,144.434062 C126.379804,146.054258 129.388658,146.054258 131.240391,144.434062 Z",fill:"#FF694A"})})},we=t(30264),Ie=t(80906),Te=t(73942),Ae=O.cd*O.iI,Re=v.default.div.withConfig({displayName:"indexstyle__IconContainerStyle",componentId:"sc-oyfjzc-0"})(["align-items:center;border-radius:","px;border:1px solid transparent;display:flex;justify-content:center;"," "," "," "," "," "," "," "," "," ",""],Te.BG,(function(e){return e.border&&"\n border: 1px dotted ".concat((e.theme.content||ue.Z.content).active,";\n ")}),(function(e){return e.grey&&"\n background-color: ".concat((0,C.qn)(m.tf.SCRATCHPAD,e).accent,";\n ")}),(function(e){return e.blue&&"\n background-color: ".concat((0,C.qn)(m.tf.DATA_LOADER,e).accent,";\n ")}),(function(e){return e.purple&&"\n background-color: ".concat((0,C.qn)(m.tf.TRANSFORMER,e).accent,";\n ")}),(function(e){return e.sky&&"\n background-color: ".concat((0,C.qn)(m.tf.MARKDOWN,e).accent,";\n ")}),(function(e){return e.teal&&"\n background-color: ".concat((0,C.qn)(m.tf.EXTENSION,e).accent,";\n ")}),(function(e){return e.rose&&"\n background-color: ".concat((0,C.qn)(m.tf.CALLBACK,e).accent,";\n ")}),(function(e){return e.yellow&&"\n background-color: ".concat((0,C.qn)(m.tf.DATA_EXPORTER,e).accent,";\n ")}),(function(e){return!e.compact&&"\n height: ".concat(Ae+O.iI/2,"px;\n width: ").concat(Ae+O.iI/2,"px;\n ")}),(function(e){return e.compact&&"\n height: ".concat(Ae/2+O.iI,"px;\n width: ").concat(Ae/2+O.iI,"px;\n ")})),De=v.default.div.withConfig({displayName:"indexstyle__ButtonWrapper",componentId:"sc-oyfjzc-1"})(["position:relative;margin-bottom:","px;margin-right:","px;",""],O.iI,O.iI,(function(e){return e.increasedZIndex&&"\n z-index: 3;\n "})),Me=(Ie.Q0.AVERAGE,Ie.Q0.CLEAN_COLUMN_NAME,Ie.Q0.COUNT,Ie.Q0.COUNT_DISTINCT,Ie.Q0.CUSTOM,Ie.Q0.DIFF,Ie.Q0.FIRST,Ie.Q0.FIX_SYNTAX_ERRORS,Ie.Q0.IMPUTE,Ie.Q0.LAST,Ie.Q0.MAX,Ie.Q0.MEDIAN,Ie.Q0.MIN,Ie.Q0.NORMALIZE,Ie.Q0.REFORMAT,Ie.Q0.REMOVE,Ie.Q0.REMOVE_OUTLIERS,Ie.Q0.SELECT,Ie.Q0.SHIFT_DOWN,Ie.Q0.SHIFT_UP,Ie.Q0.STANDARDIZE,Ie.Q0.SUM,[Ie.Q0.DROP_DUPLICATE,Ie.Q0.FILTER,Ie.Q0.SORT,Ie.Q0.REMOVE]);!function(e){e.AGGREGATE="Aggregate",e.FORMATTING="Formatting",e.COLUMN_REMOVAL="Column removal",e.SHIFT_ROWS="Shift rows in a column",e.MISC="Miscellaneous",e.FEATURE_SCALING="Feature Scaling"}(Ee||(Ee={}));var Be,Ne,Le,Fe=(_e={},(0,o.Z)(_e,Ie.qs.COLUMN,(Ze={},(0,o.Z)(Ze,Ee.AGGREGATE,[Ie.Q0.AVERAGE,Ie.Q0.COUNT,Ie.Q0.COUNT_DISTINCT,Ie.Q0.FIRST,Ie.Q0.LAST,Ie.Q0.MAX,Ie.Q0.MEDIAN,Ie.Q0.MIN,Ie.Q0.SUM]),(0,o.Z)(Ze,Ee.FORMATTING,[Ie.Q0.CLEAN_COLUMN_NAME,Ie.Q0.FIX_SYNTAX_ERRORS,Ie.Q0.REFORMAT]),(0,o.Z)(Ze,Ee.COLUMN_REMOVAL,[Ie.Q0.REMOVE,Ie.Q0.SELECT]),(0,o.Z)(Ze,Ee.SHIFT_ROWS,[Ie.Q0.SHIFT_DOWN,Ie.Q0.SHIFT_UP]),(0,o.Z)(Ze,Ee.MISC,[Ie.Q0.DIFF,Ie.Q0.IMPUTE,Ie.Q0.REMOVE_OUTLIERS]),(0,o.Z)(Ze,Ee.FEATURE_SCALING,[Ie.Q0.NORMALIZE,Ie.Q0.STANDARDIZE]),Ze)),(0,o.Z)(_e,Ie.qs.ROW,(0,o.Z)({},Ee.MISC,[].concat(Me))),_e),Ue=Object.keys(Fe[Ie.qs.COLUMN]),He=[Ee.MISC],Ge=(Se={},(0,o.Z)(Se,Ie.qs.COLUMN,(Oe={},(0,o.Z)(Oe,Ie.Q0.ADD,"Add column"),(0,o.Z)(Oe,Ie.Q0.AVERAGE,"Aggregate by average value"),(0,o.Z)(Oe,Ie.Q0.CLEAN_COLUMN_NAME,"Clean column name"),(0,o.Z)(Oe,Ie.Q0.COUNT_DISTINCT,"Aggregate by distinct count"),(0,o.Z)(Oe,Ie.Q0.COUNT,"Aggregate by total count"),(0,o.Z)(Oe,Ie.Q0.DIFF,"Difference"),(0,o.Z)(Oe,Ie.Q0.FIRST,"Aggregate by first value"),(0,o.Z)(Oe,Ie.Q0.FIX_SYNTAX_ERRORS,"Fix syntax errors"),(0,o.Z)(Oe,Ie.Q0.IMPUTE,"Fill in missing values"),(0,o.Z)(Oe,Ie.Q0.NORMALIZE,"Normalize Data"),(0,o.Z)(Oe,Ie.Q0.STANDARDIZE,"Standardize Data"),(0,o.Z)(Oe,Ie.Q0.LAST,"Aggregate by last value"),(0,o.Z)(Oe,Ie.Q0.MAX,"Aggregate by maximum value"),(0,o.Z)(Oe,Ie.Q0.MEDIAN,"Aggregate by median value"),(0,o.Z)(Oe,Ie.Q0.MIN,"Aggregate by mininum value"),(0,o.Z)(Oe,Ie.Q0.REFORMAT,"Reformat"),(0,o.Z)(Oe,Ie.Q0.REMOVE_OUTLIERS,"Remove outliers"),(0,o.Z)(Oe,Ie.Q0.REMOVE,"Remove column(s)"),(0,o.Z)(Oe,Ie.Q0.SELECT,"Keep columns"),(0,o.Z)(Oe,Ie.Q0.SHIFT_DOWN,"Shift rows down in a column"),(0,o.Z)(Oe,Ie.Q0.SHIFT_UP,"Shift rows up in a column"),(0,o.Z)(Oe,Ie.Q0.SUM,"Aggregate by sum of values"),Oe)),(0,o.Z)(Se,Ie.qs.ROW,(Ce={},(0,o.Z)(Ce,Ie.Q0.DROP_DUPLICATE,"Drop duplicates"),(0,o.Z)(Ce,Ie.Q0.FILTER,"Filter"),(0,o.Z)(Ce,Ie.Q0.SORT,"Sort"),(0,o.Z)(Ce,Ie.Q0.REMOVE,"Remove rows"),Ce)),Se);!function(e){e.AMAZON_SQS="amazon_sqs",e.API="api",e.AZURE_BLOB_STORAGE="azure_blob_storage",e.AZURE_EVENT_HUB="azure_event_hub",e.BIGQUERY="bigquery",e.DRUID="druid",e.DUMMY="dummy",e.FILE="file",e.GENERIC="generic",e.GOOGLE_CLOUD_PUBSUB="google_cloud_pubsub",e.GOOGLE_CLOUD_STORAGE="google_cloud_storage",e.KAFKA="kafka",e.KINESIS="kinesis",e.MONGODB="mongodb",e.MYSQL="mysql",e.OPENSEARCH="opensearch",e.POSTGRES="postgres",e.RABBITMQ="rabbitmq",e.REDSHIFT="redshift",e.S3="s3",e.SNOWFLAKE="snowflake"}(Le||(Le={}));var ze=(Be={},(0,o.Z)(Be,Le.AMAZON_SQS,"Amazon SQS"),(0,o.Z)(Be,Le.API,"API"),(0,o.Z)(Be,Le.AZURE_BLOB_STORAGE,"Azure Blob Storage"),(0,o.Z)(Be,Le.AZURE_EVENT_HUB,"Azure Event Hub"),(0,o.Z)(Be,Le.BIGQUERY,"Google BigQuery"),(0,o.Z)(Be,Le.DRUID,"Druid"),(0,o.Z)(Be,Le.DUMMY,"Dummy"),(0,o.Z)(Be,Le.FILE,"Local file"),(0,o.Z)(Be,Le.GENERIC,"Generic (no template)"),(0,o.Z)(Be,Le.GOOGLE_CLOUD_PUBSUB,"Google Cloud PubSub"),(0,o.Z)(Be,Le.GOOGLE_CLOUD_STORAGE,"Google Cloud Storage"),(0,o.Z)(Be,Le.KAFKA,"Kafka"),(0,o.Z)(Be,Le.KINESIS,"Kinesis"),(0,o.Z)(Be,Le.MONGODB,"MongoDB"),(0,o.Z)(Be,Le.MYSQL,"MySQL"),(0,o.Z)(Be,Le.OPENSEARCH,"OpenSearch"),(0,o.Z)(Be,Le.POSTGRES,"PostgreSQL"),(0,o.Z)(Be,Le.RABBITMQ,"RabbitMQ"),(0,o.Z)(Be,Le.REDSHIFT,"Amazon Redshift"),(0,o.Z)(Be,Le.S3,"Amazon S3"),(0,o.Z)(Be,Le.SNOWFLAKE,"Snowflake"),Be),qe=(Ne={},(0,o.Z)(Ne,m.tf.DATA_LOADER,[Le.GENERIC,Le.FILE,Le.API,Le.AZURE_BLOB_STORAGE,Le.BIGQUERY,Le.DRUID,Le.GOOGLE_CLOUD_STORAGE,Le.MYSQL,Le.POSTGRES,Le.REDSHIFT,Le.S3,Le.SNOWFLAKE]),(0,o.Z)(Ne,m.tf.DATA_EXPORTER,[Le.GENERIC,Le.FILE,Le.AZURE_BLOB_STORAGE,Le.BIGQUERY,Le.GOOGLE_CLOUD_STORAGE,Le.MYSQL,Le.POSTGRES,Le.REDSHIFT,Le.S3,Le.SNOWFLAKE]),(0,o.Z)(Ne,m.tf.TRANSFORMER,[Le.BIGQUERY,Le.POSTGRES,Le.REDSHIFT,Le.SNOWFLAKE]),(0,o.Z)(Ne,m.tf.SENSOR,[Le.GENERIC,Le.BIGQUERY,Le.MYSQL,Le.POSTGRES,Le.REDSHIFT,Le.S3,Le.SNOWFLAKE]),Ne),Ke=Le;function We(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}var Qe=function(e,n,t){var i=t===D.qL.STREAMING&&(e===m.tf.DATA_LOADER||e===m.tf.DATA_EXPORTER);return(function(e){var n;return e===D.qL.STREAMING?(n={},(0,o.Z)(n,m.tf.DATA_LOADER,[Ke.AMAZON_SQS,Ke.AZURE_EVENT_HUB,Ke.GOOGLE_CLOUD_PUBSUB,Ke.KAFKA,Ke.KINESIS,Ke.RABBITMQ]),(0,o.Z)(n,m.tf.DATA_EXPORTER,[Ke.DUMMY,Ke.S3,Ke.KAFKA,Ke.KINESIS,Ke.MONGODB,Ke.OPENSEARCH]),(0,o.Z)(n,m.tf.TRANSFORMER,[Ke.GENERIC]),n):qe}(t)[e]||[]).map((function(t){return{indent:e===m.tf.TRANSFORMER,label:function(){return ze[t]},onClick:function(){n({config:{data_source:t===Ke.GENERIC?null:t},language:i?m.t6.YAML:m.t6.PYTHON,type:e})},uuid:"".concat(e,"/").concat(t)}}))};function Ve(e,n){return{label:function(){return"SQL"},onClick:function(){return e({language:m.t6.SQL,type:n})},uuid:"".concat(n,"/sql")}}function Ye(e,n){return{label:function(){return"R"},onClick:function(){return e({language:m.t6.R,type:n})},uuid:"".concat(n,"/r")}}var Xe=function(e,n){return[Ve(e,n),Ye(e,n)]};function Je(e,n){var t={};return null===e||void 0===e||e.forEach((function(e){var i=e.block_type,r=e.description,l=e.groups,c=e.language,u=e.name,a=e.path;t[i]||(t[i]={}),t[i][c]||(t[i][c]={items:[],label:function(){return c},uuid:"".concat(i,"/").concat(c)});var s={label:function(){return u},onClick:function(){return n({config:{template_path:a},language:c,type:i})},tooltip:function(){return r},uuid:a};if((null===l||void 0===l?void 0:l.length)>=1){var d=function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?We(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):We(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}({},t[i][c]),f=[null],p=[d];l.forEach((function(e,n){var t="".concat(i,"/").concat(c,"/").concat(l.slice(0,n+1).join("/")),r=p[n],o=r.items.findIndex((function(e){var n=e.uuid;return t===n})),u=o>=0?r.items[o]:null;u||(u={items:[],label:function(){return e},uuid:t}),f.push(o),p.push(u)})),f.push(-1),p.push(s);var h=p.length;t[i][c]=p.reduce((function(e,n,t){var i=h-t,r=p[i-2],o=p[i-1],l=f[i-1];return r?(l>=0?r.items[l]=o:r.items.push(o),r):o}),{})}else t[i][c].items.push(s)})),t}var $e=function(e,n,t,i){var r=i||{},o=r.blockTemplatesByBlockType,l=r.languages,c=Object.fromEntries(m.Ut.map((function(n){return[n,Qe(n,e,t)]})));if(t===D.qL.PYSPARK||t===D.qL.PYTHON&&n===m.tf.TRANSFORMER||t===D.qL.STREAMING||n===m.tf.SENSOR)return c[n];var u,a,s=(null===o||void 0===o||null===(u=o[n])||void 0===u||null===(a=u[m.t6.PYTHON])||void 0===a?void 0:a.items)||[],d=[{items:(c[n]||[]).concat(s),label:function(){return"Python"},uuid:"".concat(n,"/").concat(m.t6.PYTHON)}];return(!l||null!==l&&void 0!==l&&l.includes(m.t6.SQL))&&d.push(Ve(e,n)),(!l||null!==l&&void 0!==l&&l.includes(m.t6.R))&&d.push(Ye(e,n)),d};function en(e,n,t){return e.map((function(e){return{indent:!0,label:function(){return Ge[n][e]},onClick:function(){t({config:{action_type:e,axis:n},language:m.t6.PYTHON,type:m.tf.TRANSFORMER})},uuid:"".concat(n,"_").concat(e)}})).sort((function(e,n){return e.label().localeCompare(n.label())}))}function nn(e,n,t){var i=[];return e.forEach((function(e){if(e!==Ee.MISC)i.push({indent:!0,items:en(Fe[n][e],n,t),label:function(){return e},uuid:"".concat(n,"_grouping_").concat((0,Q.RA)(e))});else{var o=en(Fe[n][e],n,t);i.push.apply(i,(0,r.Z)(o))}})),i}var tn=function(e,n,t){return Object.values(m.Lq).map((function(i){return{label:function(){return(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(se.mm,{fill:(0,C.qn)(m.tf.CUSTOM,{blockColor:i}).accent,size:16}),"\xa0",(0,S.jsx)(_.ZP,{children:(0,Q.kC)(i)})]})},leftAligned:!0,onClick:function(){e({color:i,language:t,type:n})},uuid:"".concat(t,"_").concat(i)}}))},rn=function(e){return"-- Docs: https://docs.mage.ai/guides/sql-blocks\n"+(e||"")};function on(e,n){var t=n;return m.tf.SCRATCHPAD===e.type&&(t='"""\nNOTE: Scratchpad blocks are used only for experimentation and testing out code.\nThe code written here will not be executed as part of the pipeline.\n"""\n'+(n||"")),t}function ln(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function cn(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?ln(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ln(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var un=function(e){var n=e.addNewBlock,t=e.blockIdx,i=e.blockTemplates,o=e.compact,l=e.hideCustom,c=e.hideDataExporter,u=(e.hideDataLoader,e.hideDbt),a=e.hideMarkdown,d=e.hideScratchpad,f=e.hideSensor,p=e.hideTransformer,h=e.hideTransformerDataSources,v=e.onClickAddSingleDBTModel,b=e.pipeline,g=e.setAddNewBlockMenuOpenIdx,x=e.setCreatingNewDBTModel,j=(0,s.useState)(null),k=j[0],Z=j[1],_=(0,s.useRef)(null),C=(0,s.useRef)(null),E=(0,s.useRef)(null),P=(0,s.useRef)(null),w=(0,s.useRef)(null),I=(0,s.useRef)(null),T={compact:o,inline:!0},R=null===b||void 0===b?void 0:b.type,M=R===D.qL.STREAMING,B=o?Ae/2:Ae,N=25*O.iI,L=nn(Ue,Ie.qs.COLUMN,n),F=[{label:function(){return"Generic (no template)"},onClick:function(){n({language:m.t6.PYTHON,type:m.tf.TRANSFORMER})},uuid:"generic_transformer_action"},{bold:!0,items:nn(He,Ie.qs.ROW,n),label:function(){return"Row actions"},uuid:"row_actions_grouping"},{isGroupingTitle:!0,label:function(){return"Column actions"},uuid:"column_actions_grouping"}].concat((0,r.Z)(L));h||F.splice(1,0,{bold:!0,items:$e(n,m.tf.TRANSFORMER,R),label:function(){return"Data sources"},uuid:"data_sources_grouping"});var U=(0,s.useCallback)((function(){return Z(null)}),[]),H=(0,s.useCallback)((function(e){return null===g||void 0===g?void 0:g((function(n){return null===n||k!==e?t:null}))}),[t,k,g]),G=D.qL.PYSPARK===R,q=(0,s.useMemo)((function(){return Je(i,n)}),[n,i]),K=(0,s.useMemo)((function(){return $e(n,m.tf.DATA_LOADER,R,{blockTemplatesByBlockType:q})}),[n,q,R]),W=(0,s.useMemo)((function(){return $e(n,m.tf.DATA_EXPORTER,R,{blockTemplatesByBlockType:q})}),[n,q,R]);return(0,S.jsx)(y.Z,{flexWrap:"wrap",inline:!0,children:(0,S.jsx)(z.Z,{onClickOutside:U,open:!0,children:(0,S.jsxs)(y.Z,{flexWrap:"wrap",children:[!c&&(0,S.jsx)(De,{increasedZIndex:0===k,children:(0,S.jsx)(we.Z,{disableKeyboardShortcuts:!0,items:K,onClickCallback:U,open:0===k,parentRef:_,uuid:"data_loader_button",children:(0,S.jsx)(A.ZP,cn(cn({},T),{},{beforeElement:(0,S.jsx)(Re,{blue:!0,compact:o,children:(0,S.jsx)(se.mm,{size:B})}),onClick:function(e){e.preventDefault(),Z((function(e){return 0===e?null:0})),H(0)},uuid:"AddNewBlocks/Data_loader",children:"Data loader"}))})}),!p&&(0,S.jsx)(De,{increasedZIndex:1===k,children:(0,S.jsx)(we.Z,{disableKeyboardShortcuts:!0,items:G||D.qL.INTEGRATION===R?F:M?[{items:$e(n,m.tf.TRANSFORMER,R),label:function(){return"Python"},uuid:"transformers/python"}]:[{items:F,label:function(){return"Python"},uuid:"transformers/python_all"}].concat((0,r.Z)(Xe(n,m.tf.TRANSFORMER))),onClickCallback:U,open:1===k,parentRef:C,uuid:"transformer_button",children:(0,S.jsx)(A.ZP,cn(cn({},T),{},{beforeElement:(0,S.jsx)(Re,{compact:o,purple:!0,children:(0,S.jsx)(se.mm,{size:B})}),onClick:function(e){e.preventDefault(),Z((function(e){return 1===e?null:1})),H(1)},uuid:"AddNewBlocks/Transformer",children:"Transformer"}))})}),!c&&(0,S.jsx)(De,{increasedZIndex:2===k,children:(0,S.jsx)(we.Z,{disableKeyboardShortcuts:!0,items:W,onClickCallback:U,open:2===k,parentRef:E,uuid:"data_exporter_button",children:(0,S.jsx)(A.ZP,cn(cn({},T),{},{beforeElement:(0,S.jsx)(Re,{compact:o,yellow:!0,children:(0,S.jsx)(se.mm,{inverted:!0,size:B})}),onClick:function(e){e.preventDefault(),Z((function(e){return 2===e?null:2})),H(2)},uuid:"AddNewBlocks/Data_exporter",children:"Data exporter"}))})}),!u&&(0,S.jsx)(De,{increasedZIndex:3===k,children:(0,S.jsx)(we.Z,{disableKeyboardShortcuts:!0,items:[{label:function(){return"New model"},onClick:function(){null===x||void 0===x||x(!0),null===v||void 0===v||v(t)},uuid:"dbt/new_model"},{label:function(){return"Single model or snapshot (from file)"},onClick:function(){return null===v||void 0===v?void 0:v(t)},uuid:"dbt/single_model"},{label:function(){return"All models (w/ optional exclusion)"},onClick:function(){return n({language:m.t6.YAML,type:m.tf.DBT})},uuid:"dbt/all_models"}],onClickCallback:U,open:3===k,parentRef:P,uuid:"dbt_button",children:(0,S.jsx)(A.ZP,cn(cn({},T),{},{beforeElement:(0,S.jsx)(Pe,{size:Ae*(o?.75:1.25)}),onClick:function(e){e.preventDefault(),Z((function(e){return 3===e?null:3})),H(3)},uuid:"AddNewBlocks/DBT",children:"DBT model"}))})}),!l&&(0,S.jsx)(De,{increasedZIndex:4===k,children:(0,S.jsx)(we.Z,{disableKeyboardShortcuts:!0,items:[{items:tn(n,m.tf.CUSTOM,m.t6.PYTHON),label:function(){return"Python"},uuid:"custom_block_python"},{items:tn(n,m.tf.CUSTOM,m.t6.SQL),label:function(){return"SQL"},uuid:"custom_block_sql"}],onClickCallback:U,open:4===k,parentRef:w,uuid:"custom_block_button",children:(0,S.jsx)(le.Z,{block:!0,label:"Add a custom code block with a designated color.",maxWidth:N,size:null,children:(0,S.jsx)(A.ZP,cn(cn({},T),{},{beforeElement:(0,S.jsx)(Re,{compact:o,grey:!0,children:(0,S.jsx)(se.mm,{inverted:!0,size:B})}),onClick:function(e){e.preventDefault(),Z((function(e){return 4===e?null:4})),H(4)},uuid:"AddNewBlocks/Scratchpad",children:"Custom"}))})})}),!d&&(0,S.jsx)(De,{children:(0,S.jsx)(le.Z,{block:!0,label:"Write experimental code that doesn\u2019t get executed when you run your pipeline.",maxWidth:N,size:null,children:(0,S.jsx)(A.ZP,cn(cn({},T),{},{beforeElement:(0,S.jsx)(Re,{border:!0,compact:o,children:(0,S.jsx)(se.mm,{size:B})}),onClick:function(e){e.preventDefault(),n({type:m.tf.SCRATCHPAD})},uuid:"AddNewBlocks/Scratchpad",children:"Scratchpad"}))})}),!M&&!f&&(0,S.jsx)(De,{increasedZIndex:6===k,children:(0,S.jsx)(we.Z,{disableKeyboardShortcuts:!0,items:$e(n,m.tf.SENSOR,R),onClickCallback:U,open:6===k,parentRef:I,uuid:"sensor_button",children:(0,S.jsx)(A.ZP,cn(cn({},T),{},{beforeElement:(0,S.jsx)(Re,{compact:o,children:(0,S.jsx)(se.LM,{pink:!0,size:Ae*(o?.75:1.25)})}),onClick:function(e){e.preventDefault(),Z((function(e){return 6===e?null:6})),H(6)},uuid:"AddNewBlocks/Sensor",children:"Sensor"}))})}),!a&&(0,S.jsx)(De,{children:(0,S.jsx)(A.ZP,cn(cn({},T),{},{beforeElement:(0,S.jsx)(Re,{compact:o,sky:!0,children:(0,S.jsx)(se.mm,{inverted:!0,size:B})}),onClick:function(e){e.preventDefault(),n({language:m.t6.MARKDOWN,type:m.tf.MARKDOWN})},uuid:"AddNewBlocks/Markdown",children:"Markdown"}))})]})})})},an=t(10975),sn=t(14567),dn=t(18283),fn=t(60701);var pn=function(e){var n=e.block,t=e.blocks,i=e.openSidekickView,r=(0,s.useContext)(v.ThemeContext),o=(0,s.useMemo)((function(){return(0,pe.HK)(t,(function(e){return e.uuid}))}),[t]),l=(0,s.useMemo)((function(){var e;return null===n||void 0===n||null===(e=n.callback_blocks)||void 0===e?void 0:e.reduce((function(e,n){var t=null===o||void 0===o?void 0:o[n];return t?e.concat(t):e}),[])}),[n,o]);return(0,S.jsx)(S.Fragment,{children:(null===l||void 0===l?void 0:l.length)>=1&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Z.Z,{px:1,children:(0,S.jsx)(_.ZP,{bold:!0,muted:!0,children:"Callbacks"})}),(0,S.jsx)(y.Z,{alignItems:"center",children:null===l||void 0===l?void 0:l.map((function(e){var n=e.color,t=e.type,o=e.uuid,l=(0,C.qn)(t,{blockColor:n,theme:r}).accentLight;return(0,S.jsx)(Z.Z,{ml:1,mt:1,children:(0,S.jsx)(I.Z,{backgroundColor:l,compact:!0,onClick:function(){i(fn.cH.CALLBACKS,!0,{blockUUID:o})},small:!0,children:(0,S.jsx)(_.ZP,{monospace:!0,small:!0,children:o})})},o)}))})]})})},hn=t(57722),mn=t(89565),vn=t.n(mn),bn=t(62976),gn=t(73752),xn=t(66176),jn=v.default.div.withConfig({displayName:"indexstyle__ContainerStyle",componentId:"sc-n38rkq-0"})([""," border-left-style:solid;border-left-width:2px;border-right-style:solid;border-right-width:2px;overflow:hidden;"," "," ",""],C.Kf,(function(e){return e.addBottomPadding&&"\n padding-bottom: ".concat(2*O.tr,"px;\n ")}),(function(e){return"\n background-color: ".concat((e.theme.background||ue.Z.background).table,";\n ")}),(function(e){return!e.executedAndIdle&&"\n border-bottom-left-radius: ".concat(Te.n_,"px;\n border-bottom-right-radius: ").concat(Te.n_,"px;\n border-bottom-style: solid;\n border-bottom-width: 2px;\n ")})),yn=v.default.div.withConfig({displayName:"indexstyle__OutputRowStyle",componentId:"sc-n38rkq-1"})([""," "," ",""],(function(e){return e.first&&"\n padding-top: ".concat(O.iI*O.cd,"px;\n ")}),(function(e){return e.last&&"\n padding-bottom: ".concat(O.iI*O.cd,"px;\n ")}),(function(e){return e.contained&&"\n padding-left: ".concat(C.oh,"px;\n padding-right: ").concat(O.iI*O.cd,"px;\n ")})),kn=v.default.div.withConfig({displayName:"indexstyle__HTMLOutputStyle",componentId:"sc-n38rkq-2"})(["table{"," border-left-style:solid;border-left-width:2px;border-right-style:solid;border-right-width:2px;}td,th{padding:0 8px;}a{","}"],C.Kf,(function(e){return"\n color: ".concat((e.theme.interactive||ue.Z.interactive).linkPrimary,";\n ")})),Zn=v.default.div.withConfig({displayName:"indexstyle__ExtraInfoStyle",componentId:"sc-n38rkq-3"})([""," border-bottom-style:solid;border-bottom-width:2px;border-left-style:solid;border-left-width:2px;border-right-style:solid;border-right-width:2px;",""],C.Kf,(function(e){return"\n background-color: ".concat((e.theme.borders||ue.Z.borders).light,";\n border-bottom-left-radius: ").concat(Te.n_,"px;\n border-bottom-right-radius: ").concat(Te.n_,"px;\n ")})),_n=v.default.div.withConfig({displayName:"indexstyle__ExtraInfoContentStyle",componentId:"sc-n38rkq-4"})(["padding-bottom:","px;padding-left:","px;padding-right:","px;padding-top:","px;"],O.iI,C.oh,O.iI*O.cd,O.iI),On=v.default.div.withConfig({displayName:"indexstyle__ExtraInfoBorderStyle",componentId:"sc-n38rkq-5"})(["height:1px;width:100%;",""],(function(e){return"\n border-top: 1px solid ".concat((e.theme.borders||ue.Z.borders).medium,";\n ")})),Cn=t(73828),Sn=/\[__internal_output__\]/,En=/\[__internal_test__\]/,Pn=t(37391),wn={uuid:"Preview results"},In={uuid:"Logs"},Tn={uuid:"SQL"},An={uuid:"Lineage"},Rn=function(e){var n,t,i=e.metadata,r=[In,Tn];return(null===i||void 0===i||null===(n=i.dbt)||void 0===n||null===(t=n.block)||void 0===t?void 0:t.snapshot)||(r.unshift(wn),r.push(An)),r},Dn=2.5*O.iI,Mn="CodeBlock_HiddenBlock";function Bn(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Nn(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Bn(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Bn(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function Ln(e){var n={},t={};return null===e||void 0===e||e.forEach((function(e){var i=e.content,r=e.outputs,o=e.type,l=e.uuid;(null===r||void 0===r?void 0:r.length)>=1&&(n[l]=r.map((function(e){var n=e||{},t=n.sample_data,i=n.shape,r=n.text_data,o=n.type;return t?{data:Nn({shape:i},t),type:o}:r&&(0,Q.Pb)(r)?JSON.parse(r):r}))),t[o]||(t[o]={}),t[o][l]=i})),{content:t,messages:n}}function Fn(e,n,t){e.forEach((function(e){(0,L.t8)("".concat(t,"/").concat(e.uuid,"/codeCollapsed"),(0,L.Od)("".concat(n,"/").concat(e.uuid,"/codeCollapsed"))),(0,L.t8)("".concat(t,"/").concat(e.uuid,"/outputCollapsed"),(0,L.Od)("".concat(n,"/").concat(e.uuid,"/outputCollapsed")))}))}function Un(e){return"".concat(e,"/").concat(L.kP)}function Hn(e){return(0,L.U2)(Un(e),[])}function Gn(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function zn(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Gn(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Gn(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var qn,Kn=function(e){var n=e.block,t=e.blockMetadata,i=e.buttonTabs,o=e.collapsed,l=e.contained,c=void 0===l||l,u=e.dynamicBlock,a=e.dynamicChildBlock,d=e.hasError,f=e.hasOutput,p=e.hideExtraInfo,h=e.isInProgress,v=e.mainContainerWidth,b=e.messages,k=e.openSidekickView,C=e.pipeline,E=e.runCount,P=e.runEndTime,w=e.runStartTime,T=e.selected,A=e.selectedTab,R=e.setCollapsed,M=e.setOutputBlocks,B=e.setSelectedOutputBlock,N=e.setSelectedTab,F=n.status,U=n.type,H=(0,s.useMemo)((function(){return(null===b||void 0===b?void 0:b.length)||0}),[b]),G=m.DA.EXECUTED===F||!h&&0===E&&H>=1||!h&&E>=1&&P>=w,z=(0,s.useState)(),q=z[0],K=z[1],W=(0,s.useState)(),V=W[0],Y=W[1];(0,s.useEffect)((function(){h||Y(100)}),[h]);var X=function(e){return Array.isArray(e)?e.join("\n"):e},J=(0,s.useMemo)((function(){return b.reduce((function(e,n){var t=e.at(-1);if(ge.jU.includes(null===t||void 0===t?void 0:t.type)&&(null===t||void 0===t?void 0:t.type)===n.type&&!X(null===n||void 0===n?void 0:n.data).match(Sn)){if(Array.isArray(t.data))t.data.concat(n.data);else if("string"===typeof t.data){var i=X(n.data)||"";t.data=[t.data,i].join("\n")}}else ge.jU.includes(null===n||void 0===n?void 0:n.type)&&!X(null===n||void 0===n?void 0:n.data).match(Sn)?e.push(zn(zn({},n),{},{data:X(n.data)})):e.push(zn({},n));return e}),[])}),[b]),$=(0,s.useMemo)((function(){return(0,S.jsx)(xn.Z,{progress:V})}),[V]),ee=m.tf.DBT===(null===n||void 0===n?void 0:n.type),ne=(0,ae.Z)(d);(0,s.useEffect)((function(){ee&&!ne&&d&&N(In)}),[d,ne,ee,N]);var te=(0,s.useMemo)((function(){var e=function(e,n){var t=e.columns,i=e.index,r=e.rows,o=e.shape,l=n.borderTop,c=n.selected;return o&&K(o),r.length>=1&&(0,S.jsx)(bn.Z,{columns:t,disableScrolling:!c,index:i,maxHeight:60*O.iI,noBorderBottom:!0,noBorderLeft:!0,noBorderRight:!0,noBorderTop:!l,rows:r,width:v-(2+O.cd*O.iI*2+2+Pn.nn)},"data-table-".concat(i))},n=[],t=[],i=[];return null===J||void 0===J||J.forEach((function(o,l){var u=o.data,a=o.type;if(u&&0!==(null===u||void 0===u?void 0:u.length)){var s=[];s=(s=Array.isArray(u)?u:[u]).filter((function(e){return e}));var d=[];s.forEach((function(e){if(e&&"string"===typeof e){var n=e.split("\n");d.push.apply(d,(0,r.Z)(n))}else"object"===typeof d&&d.push(e)}));var f=d.length,p=[];d.forEach((function(n,r){var o,u={contained:c,first:0===l&&0===r,last:l===J.length-1&&r===f-1},s=l>=1;if("string"===typeof n&&n.match(En)){var d=n.split("\n"),h=[];d.forEach((function(e){if(e.match(En)){var t=e.split("[__internal_test__]"),r=t[t.length-1];(0,Q.Pb)(r)&&i.push(JSON.parse(r))}else h.push(e);n=h.length>=1?h.join("\n"):null}))}if(null!==n){if("string"===typeof n&&n.match(Sn)){var m=n.split("[__internal_output__]"),v=m[m.length-1],b=v.split("FloatProgress");if(m.length>=2&&(v=b[0]),(0,Q.Pb)(v)){var g=JSON.parse(v),x=g.data,j=g.type;if(ge.Gi.TABLE===j){!0;var y=e(x,{borderTop:s,selected:T});t.push(y),ee||(o=y)}}}else if(a===ge.Gi.TABLE){!0;var k=e((0,Q.Pb)(n)?JSON.parse(n):n,{borderTop:s,selected:T});t.push(k),ee||(o=k)}else if(ge.jU.includes(a)){var Z,O=null===(Z=n)||void 0===Z?void 0:Z.split("\\n");o=(0,S.jsx)(yn,zn(zn({},u),{},{children:O.map((function(e){return(0,S.jsx)(_.ZP,{monospace:!0,preWrap:!0,children:(0,S.jsx)(vn(),{children:e})},e)}))}))}else if(a===ge.Gi.TEXT_HTML)o=(0,S.jsx)(yn,zn(zn({},u),{},{children:(0,S.jsx)(kn,{children:(0,S.jsx)(_.ZP,{dangerouslySetInnerHTML:{__html:n},monospace:!0})})}));else if(a===ge.Gi.IMAGE_PNG)o=(0,S.jsx)("div",{style:{backgroundColor:"white"},children:(0,S.jsx)("img",{alt:"Image ".concat(l," from code output"),src:"data:image/png;base64, ".concat(n)})});else if(a===ge.Gi.PROGRESS){var C=parseInt(n);Y(C>90?90:C)}o&&p.push((0,S.jsx)("div",{children:o},"code-output-".concat(l,"-").concat(r)))}})),p.length>=1&&n.push(p)}})),h&&(null===C||void 0===C?void 0:C.type)===D.qL.PYSPARK&&n.unshift([(0,S.jsx)(yn,{contained:!0,children:(0,S.jsx)(Z.Z,{mt:1,children:$})},"progress_bar")]),{content:n,tableContent:t,testContent:i}}),[J,c,ee,h,v,C,$,T]),ie=te.content,re=te.tableContent,oe=te.testContent,ce=(null===q||void 0===q?void 0:q[1])||0,ue=ce>30?" (30 out of ".concat(ce," columns displayed)"):"",de=(0,s.useMemo)((function(){var e;if(ee&&A){var n=A.uuid;if(wn.uuid===n)(null===re||void 0===re?void 0:re.length)>=1?e=re:h||(e=(0,S.jsx)(Z.Z,{px:2,py:1,children:(0,S.jsx)(_.ZP,{muted:!0,children:d?"Error, check logs.":"No preview to display yet, try running the block."})}));else if(In.uuid===n)(null===ie||void 0===ie?void 0:ie.length)>=1?e=ie:h||(e=(0,S.jsx)(Z.Z,{px:2,py:1,children:(0,S.jsx)(_.ZP,{muted:!0,children:d?"Error, check logs.":"No logs to display yet, try running the block."})}));else if(Tn.uuid===n){var r,o=null===t||void 0===t||null===(r=t.dbt)||void 0===r?void 0:r.sql;e=o?(0,S.jsx)(hn.Z,{autoHeight:!0,language:Cn.Lu.SQL,padding:!0,readOnly:!0,value:o,width:"100%"}):null}else if(An.uuid===n){var l,c=null===t||void 0===t||null===(l=t.dbt)||void 0===l?void 0:l.lineage;e=c?(0,S.jsx)(gn.Z,{disabled:!0,enablePorts:!1,height:55*O.iI,pannable:T,pipeline:zn(zn({},C),{},{blocks:c}),zoomable:T}):null}}else e=ie;return(0,S.jsxs)(S.Fragment,{children:[i,e]})}),[t,i,ie,d,ee,h,C,T,A,re]);return i||d||f?(0,S.jsxs)(S.Fragment,{children:[c&&(0,S.jsxs)(jn,{addBottomPadding:h&&(null===C||void 0===C?void 0:C.type)===D.qL.PYSPARK,blockType:U,dynamicBlock:u,dynamicChildBlock:a,executedAndIdle:G,hasError:d,selected:T,children:[!o&&(null===oe||void 0===oe?void 0:oe.length)>=1&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Z.Z,{py:2,children:(0,S.jsx)(yn,{contained:!0,children:oe.map((function(e,n){var t=e.error,i=e.message,r=e.stacktrace;return(0,S.jsxs)(Z.Z,{mt:n>=1?3:0,children:[(0,S.jsx)(_.ZP,{monospace:!0,preWrap:!0,children:(0,S.jsx)(vn(),{children:"".concat(i).concat(t?" "+t:"")})}),null===r||void 0===r?void 0:r.map((function(e){return(0,S.jsx)(_.ZP,{default:!0,monospace:!0,preWrap:!0,small:!0,children:(0,S.jsx)(vn(),{children:e})},e)}))]},i)}))})}),(0,S.jsx)(Z.Z,{mb:d?2:0,children:(0,S.jsx)(x.Z,{medium:!0})})]}),!o&&de]}),!c&&de,G&&!p&&(0,S.jsxs)(Zn,{blockType:U,dynamicBlock:u,dynamicChildBlock:a,hasError:d,selected:T,children:[(0,S.jsx)(On,{}),(0,S.jsxs)(y.Z,{justifyContent:"space-between",children:[R&&(0,S.jsx)(j.Z,{alignItems:"center",px:1,children:(0,S.jsx)(I.Z,{basic:!0,iconOnly:!0,noPadding:!0,onClick:function(){return R(!o)},transparent:!0,children:o?(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(se._M,{muted:!0,size:2*O.iI}),"\xa0",(0,S.jsx)(_.ZP,{default:!0,children:"Expand output"})]}):(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(se.Kh,{muted:!0,size:2*O.iI}),q&&(0,S.jsx)(Z.Z,{ml:2,children:(0,S.jsx)(_.ZP,{children:"".concat(q[0]," rows x ").concat(q[1]," columns").concat(ue)})})]})})}),(0,S.jsx)(_n,{children:(0,S.jsxs)(y.Z,{alignItems:"center",fullWidth:!0,justifyContent:"flex-end",children:[(0,S.jsx)(le.Z,{appearAbove:!0,appearBefore:!0,block:!0,label:E>=1&&w?"Last run at ".concat(new Date(w.valueOf()).toLocaleString()):d?"Block executed with errors":"Block executed successfully",size:null,widthFitContent:!0,children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[E>=1&&Number(P)>Number(w)&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(_.ZP,{small:!0,children:[(Number(P)-Number(w))/1e3,"s"]}),(0,S.jsx)(Z.Z,{mr:1})]}),!d&&(0,S.jsx)(se.Jr,{size:2*O.iI,success:!0}),d&&(0,S.jsx)(g.Z,{danger:!0,size:2*O.iI,children:(0,S.jsx)(_.ZP,{bold:!0,monospace:!0,small:!0,children:"!"})})]})}),!d&&!m.Qj.includes(U)&&(0,S.jsx)(Z.Z,{pl:1,children:(0,S.jsx)(I.Z,{afterIcon:(0,S.jsx)(se.M0,{muted:!0,size:1.75*O.iI}),basic:!0,noPadding:!0,onClick:function(){!function(e,n){var t=Hn(e);t.includes(n)||(0,L.t8)(Un(e),[].concat((0,r.Z)(t),[n]))}(null===C||void 0===C?void 0:C.uuid,n.uuid),null===k||void 0===k||k(fn.cH.DATA),null===M||void 0===M||M((function(e){return e.find((function(e){return e.uuid===n.uuid}))?e:(null===B||void 0===B||B(n),e.concat(n))}))},transparent:!0,children:(0,S.jsx)(_.ZP,{default:!0,children:"Expand table"})})})]})})]})]})]}):null},Wn="buckets",Qn="chart_style",Vn="group_by",Yn="height",Xn="index",Jn="legend_labels",$n="limit",et="metrics",nt="time_interval",tt="width_percentage",it="x",rt="y",ot="y_sort_order",lt="data_provider",ct="data_provider_database",ut="data_provider_profile",at="data_provider_schema",st="data_provider_table",dt="dbt_profile_target",ft="dbt_project_name",pt="export_write_policy",ht="limit",mt="unique_upstream_table_name",vt="upstream_block_configuration",bt="table_name",gt="use_raw_sql",xt=[it,rt];!function(e){e.BAR_CHART="bar chart",e.HISTOGRAM="histogram",e.LINE_CHART="line chart",e.PIE_CHART="pie chart",e.TABLE="table",e.TIME_SERIES_BAR_CHART="time series bar chart",e.TIME_SERIES_LINE_CHART="time series line chart"}(qn||(qn={}));var jt,yt,kt=[qn.BAR_CHART,qn.HISTOGRAM,qn.LINE_CHART,qn.PIE_CHART,qn.TABLE,qn.TIME_SERIES_BAR_CHART,qn.TIME_SERIES_LINE_CHART];!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(jt||(jt={})),function(e){e.AVERAGE="average",e.COUNT="count",e.COUNT_DISTINCT="count_distinct",e.MAX="max",e.MEDIAN="median",e.MIN="min",e.MODE="mode",e.SUM="sum"}(yt||(yt={}));var Zt,_t,Ot,Ct,St,Et,Pt,wt,It,Tt=[yt.AVERAGE,yt.COUNT,yt.COUNT_DISTINCT,yt.MAX,yt.MEDIAN,yt.MIN,yt.MODE,yt.SUM];!function(e){e.ASCENDING="ascending",e.DESCENDING="descending"}(Zt||(Zt={})),function(e){e.DAY="day",e.HOUR="hour",e.MINUTE="minute",e.MONTH="month",e.ORIGINAL="original",e.SECOND="second",e.WEEK="week",e.YEAR="year"}(_t||(_t={})),function(e){e.COLUMNS="columns",e.METRICS="metrics",e.NUMBER="number"}(It||(It={}));var At={noCode:[{label:function(){return"time column"},settings:{maxValues:1},type:It.COLUMNS,uuid:Vn},{label:function(){return"time interval"},options:[_t.ORIGINAL,_t.SECOND,_t.MINUTE,_t.HOUR,_t.DAY,_t.WEEK,_t.MONTH,_t.YEAR],uuid:nt},{label:function(){return"metrics"},type:It.METRICS,uuid:et}]},Rt=(Ot={},(0,o.Z)(Ot,qn.BAR_CHART,{noCode:[{label:function(){return"group by columns"},type:It.COLUMNS,uuid:Vn},{label:function(){return"metrics"},type:It.METRICS,uuid:et},{autoRun:!0,label:function(){return"chart style"},options:[jt.HORIZONTAL,jt.VERTICAL],uuid:Qn},{autoRun:!0,label:function(){return"sort direction"},options:[null,Zt.ASCENDING,Zt.DESCENDING],uuid:ot}],code:[{label:function(){return"variable name of x-axis values"},monospace:!0,uuid:it},{label:function(){return"variable name of y-axis values"},monospace:!0,uuid:rt}]}),(0,o.Z)(Ot,qn.HISTOGRAM,{noCode:[{label:function(){return"number column for chart"},settings:{maxValues:1},type:It.COLUMNS,uuid:Vn},{autoRun:!0,label:function(){return"Number of buckets"},type:It.NUMBER,uuid:Wn}],code:[{label:function(){return"variable name of values"},monospace:!0,uuid:it}]}),(0,o.Z)(Ot,qn.LINE_CHART,{noCode:[{label:function(){return"group by columns"},settings:{maxValues:1},type:It.COLUMNS,uuid:Vn},{label:function(){return"metrics"},type:It.METRICS,uuid:et}],code:[{label:function(){return"variable name of x-axis values"},monospace:!0,uuid:it},{label:function(){return"variable name of y-axis values"},monospace:!0,uuid:rt},{label:function(){return"labels of lines in chart (comma separated)"},uuid:Jn}]}),(0,o.Z)(Ot,qn.PIE_CHART,{noCode:[{label:function(){return"column for chart"},settings:{maxValues:1},type:It.COLUMNS,uuid:Vn},{autoRun:!0,label:function(){return"Number of slices"},type:It.NUMBER,uuid:Wn}],code:[{label:function(){return"variable name of values"},monospace:!0,uuid:it}]}),(0,o.Z)(Ot,qn.TABLE,{noCode:[{label:function(){return"columns"},type:It.COLUMNS,uuid:Vn},{label:function(){return"max number of rows"},type:It.NUMBER,uuid:$n}],code:[{label:function(){return"variable name of columns"},monospace:!0,uuid:it},{label:function(){return"variable name of rows"},monospace:!0,uuid:rt}]}),(0,o.Z)(Ot,qn.TIME_SERIES_BAR_CHART,At),(0,o.Z)(Ot,qn.TIME_SERIES_LINE_CHART,At),Ot),Dt=(Ct={},(0,o.Z)(Ct,qn.BAR_CHART,{configuration:function(e){var n;return n={},(0,o.Z)(n,it,"x"),(0,o.Z)(n,rt,"y"),(0,o.Z)(n,Qn,jt.VERTICAL),n},content:function(e){return"columns = df_1.columns\nx = df_1.columns[:7]\ny = [[v] for v in [len(df_1[col].unique()) for col in x]]\n"}}),(0,o.Z)(Ct,qn.HISTOGRAM,{configuration:function(e){var n;return n={},(0,o.Z)(n,Wn,10),(0,o.Z)(n,it,"x"),n},content:function(e){return"columns = df_1.columns\ncol = list(filter(lambda x: df_1[x].dtype == float or df_1[x].dtype == int, columns))[0]\nx = df_1[col]\n"}}),(0,o.Z)(Ct,qn.LINE_CHART,{configuration:function(e){var n;return n={},(0,o.Z)(n,it,"x"),(0,o.Z)(n,rt,"y"),n},content:function(e){return"columns = df_1.columns\ncols = list(filter(lambda x: df_1[x].dtype == float or df_1[x].dtype == int, columns))\nx = df_1[cols[0]]\ny = [df_1[cols[1]]]\n"}}),(0,o.Z)(Ct,qn.PIE_CHART,{configuration:function(e){var n;return n={},(0,o.Z)(n,Wn,7),(0,o.Z)(n,it,"x"),n},content:function(e){return"x = df_1[df_1.columns[0]]"}}),(0,o.Z)(Ct,qn.TABLE,{configuration:function(e){var n;return n={},(0,o.Z)(n,$n,10),(0,o.Z)(n,it,"x"),(0,o.Z)(n,rt,"y"),n},content:function(e){return"x = df_1.columns\ny = df_1.to_numpy()"}}),(0,o.Z)(Ct,qn.TIME_SERIES_BAR_CHART,{configuration:function(e){return(0,o.Z)({},nt,_t.ORIGINAL)}}),(0,o.Z)(Ct,qn.TIME_SERIES_LINE_CHART,{configuration:function(e){return(0,o.Z)({},nt,_t.ORIGINAL)}}),Ct),Mt=(wt={},(0,o.Z)(wt,qn.BAR_CHART,(St={},(0,o.Z)(St,it,(function(){return"must be a list of booleans, dates, integers, floats, or strings."})),(0,o.Z)(St,rt,(function(){return"must be a list of lists containing integers or floats."})),St)),(0,o.Z)(wt,qn.HISTOGRAM,(0,o.Z)({},it,(function(){return"must be a list of integers or floats."}))),(0,o.Z)(wt,qn.LINE_CHART,(Et={},(0,o.Z)(Et,it,(function(){return"must be a list of integers or floats."})),(0,o.Z)(Et,rt,(function(){return"must be a list of lists containing integers or floats. Each list is a single line in the chart."})),Et)),(0,o.Z)(wt,qn.PIE_CHART,(0,o.Z)({},it,(function(){return"must be a list of booleans, dates, integers, floats, or strings."}))),(0,o.Z)(wt,qn.TABLE,(Pt={},(0,o.Z)(Pt,it,(function(){return"must be a list of strings."})),(0,o.Z)(Pt,rt,(function(){return"must be a list of lists containing booleans, dates, integers, floats, or strings."})),Pt)),wt),Bt=[{label:function(){return"% of missing values"},widgetTemplate:function(e){var n,t=e.block;return{name:"missing values for ".concat(null===t||void 0===t?void 0:t.uuid),configuration:(n={},(0,o.Z)(n,it,"columns_with_mising_values"),(0,o.Z)(n,rt,"percentage_of_missing_values"),(0,o.Z)(n,Qn,jt.HORIZONTAL),(0,o.Z)(n,ot,Zt.DESCENDING),(0,o.Z)(n,"chart_type",qn.BAR_CHART),n),content:"number_of_rows = len(df_1.index)\ncolumns_with_mising_values = []\npercentage_of_missing_values = []\nfor col in df_1.columns:\n missing = df_1[col].isna().sum()\n if missing > 0:\n columns_with_mising_values.append(col)\n percentage_of_missing_values.append(100 * missing / number_of_rows)\n"}}},{label:function(){return"Unique values"},widgetTemplate:function(e){var n,t=e.block;return{name:"unique values for ".concat(null===t||void 0===t?void 0:t.uuid),configuration:(n={},(0,o.Z)(n,it,"columns"),(0,o.Z)(n,rt,"number_of_unique_values"),(0,o.Z)(n,Qn,jt.HORIZONTAL),(0,o.Z)(n,ot,Zt.DESCENDING),(0,o.Z)(n,"chart_type",qn.BAR_CHART),n),content:"columns = df_1.columns\nnumber_of_unique_values = [df_1[col].nunique() for col in columns]\n"}}},{label:function(){return"Most frequent values"},widgetTemplate:function(e){var n,t=e.block;return{name:"most frequent values for ".concat(null===t||void 0===t?void 0:t.uuid),configuration:(n={},(0,o.Z)(n,Yn,3e3),(0,o.Z)(n,Xn,"column_index"),(0,o.Z)(n,it,"columns"),(0,o.Z)(n,rt,"rows"),(0,o.Z)(n,"chart_type",qn.TABLE),n),content:"columns = ['mode value', 'frequency', '% of values']\n\ncolumn_index = []\nrows = []\nfor col in df_1.columns:\n value_counts = df_1[col].value_counts()\n if len(value_counts.index) == 0:\n continue\n column_value = value_counts.index[0]\n value = value_counts[column_value]\n number_of_rows = df_1[col].count()\n column_index.append(col)\n rows.append([\n column_value,\n f'{round(100 * value / number_of_rows, 2)}%',\n value,\n ])\n"}}},{label:function(){return"Summary overview"},widgetTemplate:function(e){var n,t=e.block;return{name:"summary overview for ".concat(null===t||void 0===t?void 0:t.uuid),configuration:(n={},(0,o.Z)(n,Yn,3e3),(0,o.Z)(n,Xn,"stats"),(0,o.Z)(n,it,"headers"),(0,o.Z)(n,rt,"rows"),(0,o.Z)(n,"chart_type",qn.TABLE),n),content:"from mage_ai.data_cleaner.column_types.column_type_detector import infer_column_types\n\n\nheaders = ['value']\nstats = ['Columns', 'Rows']\nrows = [[len(df_1.columns)], [len(df_1.index)]]\n\ncol_counts = {}\nfor col, col_type in infer_column_types(df_1).items():\n col_type_name = col_type.value\n if not col_counts.get(col_type_name):\n col_counts[col_type_name] = 0\n col_counts[col_type_name] += 1\n\nfor col_type, count in sorted(col_counts.items()):\n stats.append(f'# of {col_type}')\n rows.append([count])\n"}}},{label:function(){return"Feature profiles"},widgetTemplate:function(e){var n,t=e.block;return{name:"feature profiles for ".concat(null===t||void 0===t?void 0:t.uuid),configuration:(n={},(0,o.Z)(n,Yn,3e3),(0,o.Z)(n,Xn,"stats"),(0,o.Z)(n,it,"columns"),(0,o.Z)(n,rt,"rows"),(0,o.Z)(n,"chart_type",qn.TABLE),n),content:"from mage_ai.data_cleaner.column_types.column_type_detector import infer_column_types\nimport statistics\n\n\ncolumns_and_types = infer_column_types(df_1).items()\ncolumns = [t[0] for t in columns_and_types]\nstats = ['Type', 'Missing values', 'Unique values', 'Min', 'Max', 'Mean', 'Median', 'Mode']\nrows = [[] for _ in stats]\n\nfor col, col_type in columns_and_types:\n series = df_1[col]\n min_value = None\n max_value = None\n mean = None\n median = None\n\n not_null = series[series.notnull()]\n\n if col_type.value in ['number', 'number_with_decimals']:\n count = len(not_null.index)\n if count >= 1:\n mean = round(not_null.sum() / count, 2)\n median = sorted(not_null)[int(count / 2)]\n min_value = round(series.min(), 2)\n max_value = round(series.max(), 2)\n else:\n min_value = not_null.astype(str).min()\n max_value = not_null.astype(str).max()\n\n _, mode = sorted(\n [(v, k) for k, v in not_null.value_counts().items()],\n reverse=True,\n )[0]\n\n for idx, value in enumerate([\n col_type.value,\n len(series[series.isna()].index),\n len(series.unique()),\n min_value,\n max_value,\n mean,\n median,\n mode,\n ]):\n rows[idx].append(value)\n"}}}];function Nt(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Lt(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Nt(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Nt(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var Ft=function(e){var n=e.addWidget,t=e.block,i=e.left,o=e.rightOffset,l=e.onClickCallback,c=e.open,u=e.parentRef,a=e.runBlock,d=e.topOffset,f=(0,s.useMemo)((function(){return kt.map((function(e){var i,r,o={configuration:{chart_type:e},language:t.language,type:m.tf.CHART,upstream_blocks:t?[t.uuid]:null},l=Dt[e],c=(null===l||void 0===l||null===(i=l.configuration)||void 0===i?void 0:i.call(l,o))||{},u=m.t6.SQL===(null===t||void 0===t?void 0:t.language)?null:(null===l||void 0===l||null===(r=l.content)||void 0===r?void 0:r.call(l,o))||null,s=e;return t&&(s="".concat(s," for ").concat(t.uuid)),{label:function(){return(0,Q.vg)(e)},onClick:function(){return n(Lt(Lt({},o),{},{name:"".concat(s," ").concat((0,Q.Mp)()),configuration:Lt(Lt({},o.configuration),c),content:u}),{onCreateCallback:function(e){t&&m.t6.SQL!==t.language&&([m.DA.EXECUTED,m.DA.UPDATED].includes(t.status)?null===a||void 0===a||a({block:e,code:u,disableReset:!0}):null===a||void 0===a||a({block:t,runDownstream:!0}))}})},uuid:e}}))}),[kt,t,a]),p=(0,s.useMemo)((function(){return Bt.map((function(e){var i=e.label,r=Lt(Lt({},(0,e.widgetTemplate)({block:t})),{},{language:t.language,type:m.tf.CHART,upstream_blocks:t?[t.uuid]:null});return{label:i,onClick:function(){return n(r,{onCreateCallback:function(e){t&&m.t6.SQL!==t.language&&([m.DA.EXECUTED,m.DA.UPDATED].includes(t.status)?null===a||void 0===a||a({block:e,code:e.content,disableReset:!0}):null===a||void 0===a||a({block:t,runDownstream:!0}))}})},uuid:i()}}))}),[Bt,n,t,a]),h=[{isGroupingTitle:!0,label:function(){return"Custom charts"},uuid:"custom_charts"}].concat((0,r.Z)(f));return m.t6.SQL!==t.language&&h.push.apply(h,[{isGroupingTitle:!0,label:function(){return"Templates"},uuid:"chart_templates"}].concat((0,r.Z)(p))),(0,S.jsx)(q.Z,{items:h,left:i,onClickCallback:l,open:c,parentRef:u,rightOffset:o,topOffset:d,uuid:"CommandButtons/add_charts",width:25*O.iI})},Ut=t(40656),Ht=v.default.svg.withConfig({displayName:"Convert__SVGStyle",componentId:"sc-fmw0vr-0"})([""]),Gt=function(e){var n=e.fill,t=e.opacity,i=e.size,r=void 0===i?Ut.C:i,o=e.style,l=e.viewBox,c=void 0===l?"0 0 12 12":l;return(0,S.jsxs)(Ht,{fill:n,height:r,opacity:t,style:o,viewBox:c,width:r,children:[(0,S.jsx)("path",{clipRule:"evenodd",d:"M2.5 1C1.67157 1 1 1.67157 1 2.5v.0625c0 .27614-.223858.5-.5.5s-.5-.22386-.5-.5V2.5C0 1.11929 1.11929 0 2.5 0h7C10.8807 0 12 1.11929 12 2.5v7c0 1.3807-1.1193 2.5-2.5 2.5h-7C1.11929 12 0 10.8807 0 9.5v-.0625c0-.27614.223858-.5.5-.5s.5.22386.5.5V9.5c0 .8284.67157 1.5 1.5 1.5h7c.8284 0 1.5-.6716 1.5-1.5v-7c0-.82843-.6716-1.5-1.5-1.5h-7z",fill:"url(#paint0_linear_1332_60037)",fillRule:"evenodd"}),(0,S.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.05806 3.55806c.24408-.24408.6398-.24408.88388 0l2 2c.24408.24408.24408.6398 0 .88388l-2 2c-.24408.24408-.6398.24408-.88388 0-.24408-.24408-.24408-.6398 0-.88388l.93306-.93306H1C.654822 6.625.375 6.34518.375 6s.279822-.625.625-.625h5.99112l-.93306-.93306c-.24408-.24408-.24408-.6398 0-.88388z",fill:"#fff"}),(0,S.jsx)("defs",{children:(0,S.jsxs)("linearGradient",{id:"paint0_linear_1332_60037",x1:"-.618557",y1:"-.000001",x2:"10.5709",y2:".83113",gradientUnits:"userSpaceOnUse",children:[(0,S.jsx)("stop",{stopColor:"#FFCC19"}),(0,S.jsx)("stop",{offset:".585938",stopColor:"#2ECDF7"}),(0,S.jsx)("stop",{offset:"1",stopColor:"#9E7BFF"})]})})]})},zt=t(79749),qt=t(54283),Kt=t(75968);function Wt(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Qt(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Wt(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Wt(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var Vt,Yt=function(e){var n,t,i=e.addNewBlock,r=e.addWidget,o=e.block,c=e.blocks,u=e.deleteBlock,a=e.executionState,f=e.fetchFileTree,p=e.fetchPipeline,h=e.interruptKernel,b=e.isEditingBlock,x=e.pipeline,j=e.runBlock,k=e.setIsEditingBlock,E=e.savePipelineContent,P=e.setErrors,w=e.setOutputCollapsed,T=o.all_upstream_blocks_executed,A=void 0===T||T,R=o.color,M=o.metadata,N=o.type,L=o.uuid,F=(0,s.useRef)(null),U=(0,s.useRef)(null),H=(0,s.useRef)(null),G=(0,s.useRef)(null),K=null===x||void 0===x?void 0:x.type,Q=(0,s.useState)(!1),V=Q[0],Y=Q[1],X=(0,s.useState)(!1),J=X[0],$=X[1],ee=(0,s.useState)(!1),ne=ee[0],te=ee[1],ie=(0,s.useState)(!1),re=ie[0],oe=ie[1],ae=(0,s.useContext)(v.ThemeContext),de=ge.uF.IDLE!==a,fe=(0,C.qn)(N,{blockColor:R,theme:ae}).accent,he=(0,s.useMemo)((function(){return K===D.qL.STREAMING}),[K]),ve=(0,s.useMemo)((function(){return K===D.qL.INTEGRATION}),[K]),be=(0,s.useMemo)((function(){return(0,Kt.Ts)(o,c,"CommandButtons",i).map((function(e){return Qt(Qt({},e),{},{onClick:function(){return E().then((function(){return e.onClick()}))}})}))}),[i,o,c,E]),xe=(0,s.useMemo)((function(){return(0,pe.HK)(c,(function(e){return e.uuid}))}),[c]),je=(0,s.useMemo)((function(){return m.tf.DBT===(null===o||void 0===o?void 0:o.type)}),[o]),ye=(0,s.useMemo)((function(){return m.tf.MARKDOWN===(null===o||void 0===o?void 0:o.type)}),[o]),ke=(0,d.Db)(ce.ZP.pipelines.useUpdate(null===x||void 0===x?void 0:x.uuid),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(){p()},onErrorCallback:function(e,n){return P({errors:n,response:e})}})}}),Ze=(0,l.Z)(ke,2),_e=Ze[0];return Ze[1].isLoading,(0,S.jsxs)(y.Z,{alignItems:"center",children:[ge.uF.QUEUED===a&&(0,S.jsx)(qt.Z,{color:(ae||ue.Z).content.active,type:"cylon"}),ge.uF.BUSY===a&&(0,S.jsx)(qt.Z,{color:(ae||ue.Z).content.active}),j&&!de&&!he&&(0,S.jsxs)(S.Fragment,{children:[!je&&(0,S.jsx)(le.Z,{appearBefore:!0,default:!0,label:(0,S.jsxs)(_.ZP,{children:["Run block \xa0 \xa0",(0,S.jsx)(zt.Z,{inline:!0,keyTextGroups:[[(0,W.V5)()?B.RJ:B.hE,B.Lz]],monospace:!0,uuidForKey:L})]}),size:3*O.iI,widthFitContent:!0,children:(0,S.jsx)(I.Z,{noBackground:!0,noBorder:!0,noPadding:!0,onClick:function(){A?j({block:o}):te(!0)},children:(0,S.jsx)(g.Z,{color:fe,size:3*O.iI,children:(0,S.jsx)(se.Py,{black:!0,size:1.5*O.iI})})})}),je&&(0,S.jsx)(I.Z,{backgroundColor:fe,beforeIcon:(0,S.jsx)(se.Py,{size:1.5*O.iI}),compact:!0,onClick:function(){A?j({block:o}):te(!0)},small:!0,children:null!==M&&void 0!==M&&null!==(n=M.dbt)&&void 0!==n&&null!==(t=n.block)&&void 0!==t&&t.snapshot?"Run snapshot":"Compile & preview"}),(0,S.jsx)(z.Z,{disableEscape:!0,onClickOutside:function(){return te(!1)},open:ne,children:(0,S.jsx)(q.Z,{items:[{label:function(){return"Execute block"},onClick:function(){return j({block:o})},uuid:"execute_block"},{label:function(){return"Execute with upstream blocks"},onClick:function(){return j({block:o,runUpstream:!0})},uuid:"execute_upstream"}],onClickCallback:function(){return te(!1)},open:ne,parentRef:H,rightOffset:13.25*O.iI,topOffset:4.5*O.iI,uuid:"execute_actions",width:25*O.iI})})]}),de&&(0,S.jsx)(Z.Z,{ml:O.cd,children:(0,S.jsx)(le.Z,{appearBefore:!0,default:!0,label:(0,S.jsxs)(_.ZP,{children:["Interrupt kernel \xa0 \xa0",(0,S.jsx)(zt.Z,{inline:!0,keyTextGroups:[[B.kA],[B.kA]],monospace:!0,uuidForKey:L})]}),size:Dn,widthFitContent:!0,children:(0,S.jsx)(I.Z,{noBackground:!0,noBorder:!0,noPadding:!0,onClick:function(){return h()},children:(0,S.jsx)(g.Z,{borderSize:1.5,size:Dn,children:(0,S.jsx)(se.x8,{size:1*O.iI})})})})}),m.tf.SCRATCHPAD===o.type&&!he&&(0,S.jsx)(Z.Z,{ml:O.cd,children:(0,S.jsx)(we.Z,{items:be,onClickCallback:function(){return $(!1)},onClickOutside:function(){return $(!1)},open:J,parentRef:U,rightOffset:0,topOffset:4,uuid:"CommandButtons/convert_block",children:(0,S.jsx)(le.Z,{appearBefore:!0,default:!0,label:(0,S.jsx)(_.ZP,{children:"Convert block"}),size:Dn,widthFitContent:!0,children:(0,S.jsx)(I.Z,{noBackground:!0,noBorder:!0,noPadding:!0,onClick:function(){return $(!J)},ref:U,children:(0,S.jsx)(Gt,{size:Dn})})})})}),[m.tf.DATA_LOADER,m.tf.TRANSFORMER].includes(o.type)&&!he&&!ve&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Z.Z,{ml:O.cd,ref:F,children:(0,S.jsx)(le.Z,{appearBefore:!0,default:!0,label:"Add chart",size:2.25*O.iI,widthFitContent:!0,children:(0,S.jsx)(I.Z,{noBackground:!0,noBorder:!0,noPadding:!0,onClick:function(){return Y((function(e){return!e}))},children:(0,S.jsx)(se.GQ,{size:2.25*O.iI})})})}),r&&(0,S.jsx)(z.Z,{disableEscape:!0,onClickOutside:function(){return Y(!1)},open:V,children:(0,S.jsx)(Ft,{addWidget:r,block:o,onClickCallback:function(){return Y(!1)},open:V,parentRef:F,rightOffset:9*O.iI,runBlock:j,topOffset:2*O.iI})})]}),ye&&(0,S.jsx)(Z.Z,{ml:O.cd,children:(0,S.jsx)(le.Z,{appearBefore:!0,default:!0,label:b?"Close editor":"Edit",size:Dn,widthFitContent:!0,children:(0,S.jsx)(I.Z,{noBackground:!0,noBorder:!0,noPadding:!0,onClick:function(){return k((function(e){return!e}))},children:b?(0,S.jsx)(se.Jr,{size:Dn,success:!0}):(0,S.jsx)(se.I8,{size:Dn})})})}),(0,S.jsx)("div",{ref:G,children:(0,S.jsx)(Z.Z,{ml:O.cd,children:(0,S.jsx)(le.Z,{appearBefore:!0,default:!0,label:(0,S.jsx)(_.ZP,{children:"More actions"}),size:Dn,widthFitContent:!0,children:(0,S.jsx)(I.Z,{noBackground:!0,noBorder:!0,noPadding:!0,onClick:function(){return oe((function(e){return!e}))},children:(0,S.jsx)(g.Z,{borderSize:1.5,size:Dn,children:(0,S.jsx)(se.mH,{size:O.iI})})})})})}),(0,S.jsx)(z.Z,{disableEscape:!0,onClickOutside:function(){return oe(!1)},open:re,children:(0,S.jsx)(q.Z,{items:(0,Kt.J8)(o,j,u,w,he||ve,{addNewBlock:i,blocksMapping:xe,fetchFileTree:f,fetchPipeline:p,savePipelineContent:E,updatePipeline:_e}),onClickCallback:function(){return oe(!1)},open:re,parentRef:G,rightOffset:4.75*O.iI,topOffset:2*O.iI,uuid:"FileHeaderMenu/file_items"})})]})};!function(e){e.APPEND="append",e.FAIL="fail",e.REPLACE="replace"}(Vt||(Vt={}));var Xt,Jt=[Vt.APPEND,Vt.FAIL,Vt.REPLACE];!function(e){e.BIGQUERY="bigquery",e.CLICKHOUSE="clickhouse",e.DRUID="druid",e.MYSQL="mysql",e.POSTGRES="postgres",e.REDSHIFT="redshift",e.SNOWFLAKE="snowflake",e.TRINO="trino"}(Xt||(Xt={}));var $t=t(26304),ei=["bold","defaultColor","description","disableWordBreak","fullWidth","inputValue","inputWidth","invertedTheme","label","labelColor","menuOpen","monospace","muted","onClick","notRequired","selectedTextProps","small","stacked","suffixValue","tooltipProps","value"];function ni(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function ti(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?ni(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ni(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var ii=v.default.div.withConfig({displayName:"LabelWithValueClicker__LabelStyle",componentId:"sc-1hzpn4h-0"})(["margin-bottom:","px;"],.25*O.iI),ri=v.default.div.withConfig({displayName:"LabelWithValueClicker__DescriptionStyle",componentId:"sc-1hzpn4h-1"})([""]);var oi=function(e){var n=e.bold,t=void 0===n||n,i=e.defaultColor,r=e.description,o=e.disableWordBreak,l=e.fullWidth,c=e.inputValue,u=e.inputWidth,a=e.invertedTheme,d=e.label,f=e.labelColor,p=e.menuOpen,h=void 0!==p&&p,m=e.monospace,v=e.muted,b=e.onClick,g=e.notRequired,x=e.selectedTextProps,O=e.small,C=e.stacked,E=e.suffixValue,P=e.tooltipProps,w=e.value,I=(0,$t.Z)(e,ei),T=(0,s.useRef)(null),A=(0,s.useState)(!1),R=A[0],D=A[1],B=(0,s.useState)(!1),N=B[0],L=B[1],F=d&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(_.ZP,{bold:t,color:f,inverted:a,lineHeight:20,monospace:m,muted:v,small:O,children:d}),P&&(0,S.jsx)(Z.Z,{ml:1,children:(0,S.jsx)(le.Z,ti({muted:!0},P))})]}),U=(0,S.jsxs)(j.Z,{flex:l?"1":"none",children:[w&&(0,S.jsx)(k.Z,{block:!0,danger:null===x||void 0===x?void 0:x.danger,fullWidth:!0,muted:v,onClick:function(){b(),T.current&&T.current.focus(),D(!0)},preventDefault:!0,sameColorAsText:v||!(null!==x&&void 0!==x&&x.primary)&&!(null!==x&&void 0!==x&&x.danger)&&!(null!==x&&void 0!==x&&x.warning),underline:null===x||void 0===x?void 0:x.underline,warning:null===x||void 0===x?void 0:x.warning,children:(0,S.jsx)(_.ZP,ti(ti({inverted:a,muted:v},x),{},{disableWordBreak:o,monospace:m,small:O,width:u,children:w}))}),(0,S.jsx)(M.Z,ti(ti({},I),{},{basic:!0,defaultColor:i,fullWidth:l,invertedTheme:a,monospace:m,onBlur:function(e){D(!1),I.onBlur&&I.onBlur(e),N||L(!0)},onFocus:function(e){D(!0),I.onFocus&&I.onFocus(e)},ref:T,small:O,value:c,visible:!w}))]}),H=r&&(0,S.jsx)(ri,{children:(0,S.jsx)(_.ZP,{dangerouslySetInnerHTML:{__html:r},monospace:m,muted:!0,small:O})}),G=(0,s.useMemo)((function(){return(0,S.jsx)(_.ZP,{default:!0,small:O,children:E})}),[O,E]);return(0,S.jsxs)(S.Fragment,{children:[C&&(0,S.jsxs)(S.Fragment,{children:[F&&(0,S.jsxs)(ii,{children:[(0,S.jsx)(y.Z,{alignItems:"center",fullHeight:!1,fullWidth:!0,children:F}),H]}),(0,S.jsxs)(y.Z,{fullWidth:l,children:[U,E&&G]})]}),!C&&(0,S.jsxs)(y.Z,{alignItems:"center",fullWidth:!0,children:[F&&(0,S.jsxs)(S.Fragment,{children:[F,(0,S.jsx)(Z.Z,{ml:1})]}),U,E&&G]}),N&&!R&&!w&&!h&&!g&&(0,S.jsx)(_.ZP,{danger:!0,small:O,children:"This field is required."})]})},li=t(68792),ci=t(5882),ui=t(87372),ai=t(2005),si=t(31012),di="0.75em",fi=v.default.div.withConfig({displayName:"indexstyle__MarkdownContainer",componentId:"sc-j72mol-0"})(["font-family:",";margin:0 ","px;overflow:auto;"," "," p{margin:0.5em 0;}blockquote{margin:"," 0;padding:","px 0;","}blockquote:before{content:'';font-size:","px;line-height:0.1em;margin-right:0.25em;vertical-align:-0.4em;}blockquote p{display:inline;}pre{border-radius:","px;white-space:pre;margin:"," 0;padding:","px;overflow-x:auto;"," "," span{padding:0;}}ul,ol{margin-bottom:",";padding-left:","px;}li{","}li > input[type='checkbox']{pointer-events:none;}table{"," margin:",";thead{font-family:",";","}th,td{padding:","px ","px;","}}"],ai.ry,O.iI,Pn.w5,(function(e){return"\n color: ".concat((e.theme||ue.Z).content.active,";\n ")}),di,O.iI,(function(e){return"\n border-left: ".concat(.5*O.iI,"px solid ").concat((e.theme||ue.Z).content.active,";\n ")}),3*O.l4,Te.BG,di,O.iI,Pn.w5,(function(e){return"\n background-color: ".concat((e.theme||ue.Z).interactive.defaultBorder,";\n ")}),di,3*O.iI,si.iD,si.iD,di,ai.nF,(function(e){return"\n border-bottom: ".concat(Te.YF,"px solid ").concat((e.theme||ue.Z).content.active,";\n ")}),.5*O.iI,.75*O.iI,(function(e){return"\n border: ".concat(Te.YF,"px solid ").concat((e.theme||ue.Z).content.muted,";\n ")}));var pi=function(e){var n=e.children;return(0,S.jsx)(fi,{children:(0,S.jsx)(li.D,{components:{a:function(e){var n=e.children,t=e.href;return(0,S.jsx)(k.Z,{href:t,inline:!0,openNewWindow:!0,primary:!0,children:n})},code:function(e){var n=e.children;return(0,S.jsx)(_.ZP,{backgroundColor:ue.Z.interactive.defaultBorder,inline:!0,monospace:!0,pre:!0,style:{fontSize:"13px"},children:n})},em:function(e){var n=e.children;return(0,S.jsx)(_.ZP,{inline:!0,italic:!0,children:n})},h1:function(e){var n=e.children;return(0,S.jsx)(ui.Z,{level:1,children:n})},h2:function(e){var n=e.children;return(0,S.jsx)(ui.Z,{level:2,children:n})},h3:function(e){var n=e.children;return(0,S.jsx)(ui.Z,{level:3,children:n})},h4:function(e){var n=e.children;return(0,S.jsx)(ui.Z,{level:4,children:n})},h5:function(e){var n=e.children;return(0,S.jsx)(ui.Z,{level:5,children:n})},p:function(e){var n=e.children;return(0,S.jsx)(_.ZP,{children:n})},strong:function(e){var n=e.children;return(0,S.jsx)(_.ZP,{bold:!0,inline:!0,children:n})}},remarkPlugins:[ci.Z],children:n})})},hi=t(55378),mi=t(58180),vi=t(66653);function bi(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function gi(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?bi(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):bi(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var xi,ji=function(e){var n=e.block,t=e.blockConfiguration,i=e.blockRefs,r=e.blocks,l=e.updateBlockConfiguration,c=(0,s.useContext)(v.ThemeContext),u=m.t6.R===(null===n||void 0===n?void 0:n.language),a=m.t6.SQL===(null===n||void 0===n?void 0:n.language),d=null===r||void 0===r?void 0:r.find((function(e){var n=e.language;return m.t6.PYTHON===n})),f=(0,s.useMemo)((function(){var e=[null];return a&&d?e.push.apply(e,[null,1]):e.push(1),e}),[d,a]),p=(0,s.useMemo)((function(){var e=[{tooltipMessage:null,uuid:"Variable"},{tooltipMessage:null,uuid:"Block"}];return a&&d&&e.push({tooltipMessage:"Customize the full table name that this block gets created in. Include database, schema, and table name where applicable.",uuid:"Table name"}),e}),[d,a]),h=(0,s.useMemo)((function(){return null===r||void 0===r?void 0:r.map((function(e,n){var r,s=e.color,f=e.language,p=e.type,h=e.uuid,v=(0,C.qn)(p,{blockColor:s,theme:c}).accent,b=m.t6.PYTHON===f;r=a?"{{ df_".concat(n+1," }}"):u?"df".concat(n+1):"data".concat(n>=1?"_".concat(n+1):null);var g=[(0,S.jsx)(_.ZP,{default:!0,monospace:!0,small:!0,children:r},"variable-".concat(h)),(0,S.jsx)(k.Z,{color:v,onClick:function(){var e,n,t=null===i||void 0===i||null===(e=i.current)||void 0===e?void 0:e["".concat(p,"s/").concat(h,".py")];null===t||void 0===t||null===(n=t.current)||void 0===n||n.scrollIntoView()},preventDefault:!0,small:!0,children:(0,S.jsx)(_.ZP,{color:v,monospace:!0,small:!0,children:h})},"block-".concat(h))];if(a){var x="table-name-input-".concat(h),j=(null===t||void 0===t?void 0:t.upstream_block_configuration)||{},y=(null===j||void 0===j?void 0:j[h])||{};b?g.push((0,S.jsx)(M.Z,{borderless:!0,compact:!0,monospace:!0,onChange:function(e){var n=e.target.value;l((0,o.Z)({},vt,gi(gi({},j),{},(0,o.Z)({},h,gi(gi({},y),{},(0,o.Z)({},bt,n))))))},onClick:vi.j,placeholder:"[database_optional].[schema_optional].[table]",small:!0,value:(null===y||void 0===y?void 0:y.table_name)||""},x)):d&&g.push((0,S.jsx)(_.ZP,{italic:!0,muted:!0,small:!0,children:"Table name is defined in upstream block."},x))}return g}))}),[d,t,i,r,u,a,c,l]);return(0,S.jsx)(S.Fragment,{children:(0,S.jsx)(mi.Z,{columnFlex:f,columns:p,compact:!0,noBorder:!0,rows:h,uuid:"CodeBlock/UpstreamBlockSettings/".concat(null===n||void 0===n?void 0:n.uuid)})})};!function(e){e.DATA_EXPORTER="data_exporter",e.DATA_LOADER="data_loader",e.MAGE_LIBRARY="mage_library",e.TRANSFORMER="transformer",e.USER_LIBRARY="user_library"}(xi||(xi={}));var yi=t(5677);function ki(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Zi(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?ki(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ki(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function _i(e,n){var t=e;t.includes("__init__")||t.push("__init__");var i,r=t.length;return(0,pe.w6)(r).forEach((function(e,o){if(i)return i;var l=t.slice(0,r-o).join(xe.sep);i=n["".concat(l,".py")]})),i}function Oi(e,n,t){var i,r,o;return((null===(i=t.outputs)||void 0===i||null===(r=i[0])||void 0===r||null===(o=r.sample_data)||void 0===o?void 0:o.columns)||[]).map((function(t){return{label:"".concat(t," column"),kind:e.languages.CompletionItemKind.Variable,insertText:"'".concat(t,"'"),range:n}}))}function Ci(e,n){var t=e.word.split(""),i=new RegExp(t.reduce((function(e,n,i){var r=t[i+1],o=r?"^".concat(r):"";return e+"".concat(n,"[w ").concat(o,"]*")}),""));return n.reduce((function(e,n){return n.label.match(i)?e.concat(n):e}),[])}function Si(e){var n=e.autocompleteItems,t=e.block,i=e.blocks,o=e.pipeline,c=t.type,u=t.upstream_blocks,a=(0,pe.HK)(n,(function(e){return e.id}));return function(t){return function(s,d){var f=[],p=s.getValueInRange({endColumn:d.column,endLineNumber:d.lineNumber,startColumn:1,startLineNumber:1}),h=s.getWordUntilPosition(d),v=h.endColumn,b=h.startColumn,g={endColumn:v,endLineNumber:d.lineNumber,startColumn:b,startLineNumber:d.lineNumber},x=function(e,n,t){var i=(0,yi.Yn)(e),r=(0,yi.M4)(e,n),o=i.find((function(e){var n=e.variableName;return r.match(new RegExp(n))}));if(o){var l=o.assignmentValue,c=(0,yi.S0)(e)[l];if(c){var u,a=_i(c.split(" as ")[0].replace("from ","").replace("import ","").split(" ").reduce((function(e,n){return n.trim()?e.concat(n):e}),[]).join(".").split("."),t),s=(0,yi.rW)(c,l);return null===a||void 0===a||null===(u=a.methods_for_class)||void 0===u?void 0:u[s]}}return[]}(p,g,a);if((null===x||void 0===x?void 0:x.length)>=1){var j=Ci(h,x.map((function(e){return{filterText:e,insertText:e,kind:t.languages.CompletionItemKind.Method,label:e,range:g}})));if(j.length>=1)return{suggestions:j}}var y=function(e,n,t){var i=(0,yi.M4)(e,n);if(i=i.match(/([\w_]+)./)){var r=(0,yi.S0)(e)[i[1]];if(r){var o=_i(r.split(" as ")[0].replace("from ","").replace("import ","").split(" ").reduce((function(e,n){return n.trim()?e.concat(n):e}),[]).join(".").split("."),t);if(null!==o&&void 0!==o&&o.functions)return null===o||void 0===o?void 0:o.functions}}return[]}(p,g,a);if((null===y||void 0===y?void 0:y.length)>=1){var k=Ci(h,y.map((function(e){return{filterText:e,insertText:e,kind:t.languages.CompletionItemKind.Function,label:e,range:g}})));if(k.length>=1)return{suggestions:k}}if((null===u||void 0===u?void 0:u.length)>=1){var Z=new RegExp("\n@".concat(c));p.match(Z)&&f.push.apply(f,(0,r.Z)(Ci(h,function(e,n,t){var i=t.block,r=t.blocks,o=i.upstream_blocks,l=(0,pe.HK)(r,(function(e){return e.uuid}));return o.map((function(t,i){var r=l[t].type,o=0===i?"output_0":"args[".concat(i-1,"]");return{label:"df ".concat(t," ").concat(r," block"),kind:e.languages.CompletionItemKind.Variable,documentation:"Variable for ".concat(r," ").concat(t," data."),insertText:o,range:n}}))}(t,g,e))))}if(h.word.match(/i|f/)){var _=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0,t=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,o=(arguments.length>2?arguments[2]:void 0).word,c=new Set,u={};e.forEach((function(e){var n=e.group,t=e.id,i=e.imports;if([xi.MAGE_LIBRARY,xi.USER_LIBRARY].includes(n)){var r=t;r.match(/__init__.py/)&&(r=r.replace(/\/__init__.py/,"")),r=r.split(".py")[0].replaceAll(xe.sep,"."),u[r]=e}var o=t.replace(".py","").replace("/__init__","").split(xe.sep);if(1===o.length)c.add("import ".concat(o[0]));else if(o.length>=2){var l=o.slice(0,o.length-1).join(".");c.add("from ".concat(l," import ").concat(o[o.length-1]))}i.forEach((function(e){return c.add(e)}))}));var a,s="i"===o,d="f"===o,f=s?"import":d?"from":"",p=(0,yi.M4)(n,i);if(s&&p.match(/from/)&&(a=p.match(/from ([A-Za-z0-9_.]+) /)[1]),a&&u[a]){var h=u[a],m=h.classes,v=h.constants,b=h.files,g=h.functions,x=[];return[[v,t.languages.CompletionItemKind.Constant],[m,t.languages.CompletionItemKind.Class],[g,t.languages.CompletionItemKind.Function]].forEach((function(e){var n=(0,l.Z)(e,2),t=n[0],r=n[1];t.forEach((function(e){x.push({filterText:"import ".concat(e),insertText:"import ".concat(e),kind:r,label:e,range:i})}))})),b.forEach((function(e){var n=e.split(xe.sep),r=n[n.length-1].split(".py")[0];x.push({filterText:"import ".concat(r),insertText:"import ".concat(r),kind:t.languages.CompletionItemKind.Variable,label:r,range:i})})),x}return(0,r.Z)(c).map((function(e){return{filterText:e,insertText:e,kind:t.languages.CompletionItemKind.File,label:e,range:i}})).concat(Object.entries(u).map((function(e){var n=(0,l.Z)(e,2),r=n[0];return n[1],{filterText:"".concat(f," ").concat(r),insertText:"".concat(f," ").concat(r," "),kind:t.languages.CompletionItemKind.File,label:"".concat(r),range:Zi({},i)}})))}(n,p,h,t,g,e);f.push.apply(f,(0,r.Z)(_))}if(m.tf.CHART===c||m.tf.SCRATCHPAD===c){var O=[];if(m.tf.CHART===c?u.forEach((function(e,n){O.push({block:i.find((function(n){var t=n.uuid;return e===t})),matchIndex:0,variableName:"df_".concat(n+1)})})):m.tf.SCRATCHPAD===c&&function(e,n){return e.map((function(e){return{block:e,regex:new RegExp("([\\w_]+)[ ]*=[ ]*get_variable\\('".concat(n.uuid,"', '").concat(e.uuid,"', 'output_0'\\)"),"g")}}))}(i,o).forEach((function(e){var n=e.block,t=e.regex,i=p.matchAll(t);(0,r.Z)(i).forEach((function(e){var t=null===e||void 0===e?void 0:e.index,i=null===e||void 0===e?void 0:e[1];i&&O.push({block:n,matchIndex:t,variableName:i})}))})),O.length>=1){var C,S=null===(C=p.split("\n")[d.lineNumber-1])||void 0===C?void 0:C.slice(0,h.startColumn-1);if(S){var E=[];if(O.forEach((function(e){var n=e.block,i=e.matchIndex,r=e.variableName,o=new RegExp("".concat(r,"\\["));S.match(o)&&E.push({items:Oi(t,g,n),matchIndex:i})})),E.length>=1)return{suggestions:Ci(h,(0,pe.YC)(E,"matchIndex",{ascending:!1})[0].items)}}}1===b&&(m.tf.CHART===c?f.push.apply(f,(0,r.Z)(Ci(h,u.map((function(e,n){var i="df_".concat(n+1);return{label:"".concat(i," ").concat(e," block"),kind:t.languages.CompletionItemKind.Snippet,insertText:i,range:g}}))))):m.tf.SCRATCHPAD===c&&f.push.apply(f,(0,r.Z)(Ci(h,function(e,n,t){var i=t.block,r=t.blocks,o=t.pipeline;return r.reduce((function(t,r){var l=r.type,c=r.uuid;return i.uuid!==c&&[m.tf.DATA_LOADER,m.tf.TRANSFORMER].includes(l)?t.concat({label:"df ".concat(c," ").concat(l," block"),kind:e.languages.CompletionItemKind.Snippet,documentation:"Get the data from ".concat(l," block ").concat(c,"."),insertText:"from mage_ai.data_preparation.variable_manager import get_variable\n\n\ndf = get_variable('".concat(o.uuid,"', '").concat(c,"', 'output_0')\n"),range:n}):t}),[])}(t,g,e)))))}var P=new Set;i.concat({content:p}).forEach((function(e){var n=e.content;(0,r.Z)(n.matchAll("([A-Za-z_0-9]+)","g")).forEach((function(e){return P.add(e[1])}))}));var w=(0,r.Z)(P);if(w.length){var I=w.map((function(e){return{filterText:e,insertText:e,kind:t.languages.CompletionItemKind.Variable,label:e,range:g}}));f.push.apply(f,(0,r.Z)(Ci(h,I)))}return{suggestions:f}}}}var Ei=t(32365),Pi=t(80636),wi=t(25958),Ii=t(7715),Ti=t(87323);function Ai(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Ri(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Ai(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Ai(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function Di(e,n){var t,i,c,u=e.addNewBlock,a=e.addNewBlockMenuOpenIdx,f=e.addWidget,p=e.allBlocks,h=e.allowCodeBlockShortcuts,E=e.autocompleteItems,P=e.block,w=e.blockIdx,A=e.blockRefs,R=e.blockTemplates,N=e.blocks,U=e.dataProviders,H=e.defaultValue,G=void 0===H?"":H,z=e.deleteBlock,q=e.disableShortcuts,K=e.executionState,W=e.extraContent,Y=e.fetchFileTree,X=e.fetchPipeline,J=e.height,$=e.hideRunButton,ee=e.interruptKernel,ne=e.mainContainerRef,te=e.mainContainerWidth,ie=e.messages,re=void 0===ie?[]:ie,oe=e.noDivider,ue=e.onCallbackChange,de=e.onChange,fe=e.onClickAddSingleDBTModel,he=e.onDrop,ve=e.openSidekickView,be=e.pipeline,xe=e.runBlock,je=e.runningBlocks,ye=e.savePipelineContent,ke=e.selected,Ze=e.setAddNewBlockMenuOpenIdx,_e=e.setAnyInputFocused,Oe=e.setCreatingNewDBTModel,Ce=e.setEditingBlock,Se=e.setErrors,Ee=e.setOutputBlocks,Pe=e.setSelected,Ie=e.setSelectedOutputBlock,Te=e.setTextareaFocused,Ae=e.textareaFocused,Re=e.widgets,De=(0,s.useContext)(v.ThemeContext),Me=P||{},Be=Me.callback_content,Ne=Me.configuration,Fe=void 0===Ne?{}:Ne,Ue=Me.color,He=Me.error,Ge=Me.has_callback,ze=Me.language,qe=Me.replicated_block,Ke=Me.type,We=Me.upstream_blocks,Qe=void 0===We?[]:We,Ve=Me.uuid,Ye=(0,s.useMemo)((function(){return Fe}),[Fe]),Xe=(0,s.useState)(!1),Je=Xe[0],$e=Xe[1],en=(0,s.useState)(null),nn=en[0],tn=en[1],ln=(0,s.useState)(!1),cn=ln[0],fn=ln[1],mn=(0,s.useState)(!1),vn=mn[0],bn=mn[1],gn=(0,s.useState)(G),xn=gn[0],jn=gn[1],yn=(0,s.useState)(null),kn=yn[0],Zn=yn[1],_n=be||{},On=_n.type,Cn=_n.uuid,Sn=(0,s.useMemo)((function(){return D.qL.STREAMING===On}),[On]),En=m.tf.DBT===Ke,Pn=m.t6.SQL===ze,wn=m.t6.R===ze,Dn=m.tf.MARKDOWN===Ke,Bn=Ye.limit;Pn&&void 0===Bn&&(Bn=1e3);var Nn=(0,s.useState)(Ri(Ri({},Ye),{},(t={},(0,o.Z)(t,lt,Ye.data_provider),(0,o.Z)(t,ct,Ye.data_provider_database),(0,o.Z)(t,ut,Ye.data_provider_profile),(0,o.Z)(t,at,Ye.data_provider_schema),(0,o.Z)(t,st,Ye.data_provider_table),(0,o.Z)(t,dt,Ye.dbt_profile_target),(0,o.Z)(t,ft,Ye.dbt_project_name),(0,o.Z)(t,pt,Ye.export_write_policy||Vt.APPEND),(0,o.Z)(t,ht,Bn),(0,o.Z)(t,mt,Ye.unique_upstream_table_name),(0,o.Z)(t,gt,!!Ye.use_raw_sql),t))),Fn=Nn[0],Un=Nn[1],Hn=(0,s.useState)(null),Gn=Hn[0],zn=Hn[1],qn=(0,s.useState)(Dn),Wn=qn[0],Qn=qn[1],Vn=(0,s.useState)(!1),Yn=Vn[0],Xn=Vn[1],Jn=(0,s.useState)(Ve),$n=Jn[0],et=Jn[1],nt=(0,s.useState)(!1),tt=nt[0],it=nt[1],rt=(0,s.useState)(0),ot=rt[0],vt=rt[1],bt=(0,s.useState)(null),xt=bt[0],jt=bt[1],yt=(0,s.useState)(null),kt=yt[0],Zt=yt[1],_t=(0,s.useState)(re),Ot=_t[0],Ct=_t[1],St=(0,s.useState)(Rn(P)[0]),Et=St[0],Pt=St[1],wt=(0,an.c)((function(){return{collect:function(e){return{isDragging:!!e.isDragging()}},item:P,type:Mn}}),[P]),It=(0,l.Z)(wt,2),Tt=It[0],At=It[1],Rt=(0,sn.L)((function(){return{accept:Mn,drop:function(e){return null===he||void 0===he?void 0:he(P,e)}}}),[P]),Dt=(0,l.Z)(Rt,2)[1],Mt=(0,s.useMemo)((function(){var e;return(null===P||void 0===P||null===(e=P.metadata)||void 0===e?void 0:e.dbt)||{project:null,projects:{}}}),[P]),Bt=(0,s.useMemo)((function(){return Mt.projects||{}}),[Mt]),Nt=(0,s.useMemo)((function(){return Mt.project||Fn.dbt_project_name}),[Fn,Mt]),Lt=(0,s.useMemo)((function(){return Bt[Nt]||{target:null,targets:[]}}),[Nt,Bt]),Ft=(0,s.useMemo)((function(){return Lt.targets||[]}),[Lt]),Ut=(0,s.useMemo)((function(){return Fn.dbt_profile_target}),[Fn]),Ht=(0,s.useState)(Ut&&!(null!==Ft&&void 0!==Ft&&Ft.includes(Ut))),Gt=Ht[0],zt=Ht[1],qt=(0,s.useState)(null),Wt=qt[0],Qt=qt[1];(0,s.useEffect)((function(){Be!==Wt&&Qt(Be)}),[Wt,Be]);var $t=(0,ae.Z)(P);(0,s.useEffect)((function(){if(JSON.stringify(P)!=JSON.stringify($t)){var e,n=Ln([P]).messages,t=null===n||void 0===n||null===(e=n[Ke])||void 0===e?void 0:e[Ve];(null===t||void 0===t?void 0:t.length)>=1&&Ct(t)}}),[P,Ke,Ve,$t,Ct]);var ei=(0,ae.Z)(re);(0,s.useEffect)((function(){"undefined"!==typeof re&&re.length!==(null===ei||void 0===ei?void 0:ei.length)&&Ct(re)}),[re,ei,Ct]);var ni=(0,s.useMemo)((function(){var e=new Set;return null===U||void 0===U||U.forEach((function(n){var t=n.profiles;e=new Set([].concat((0,r.Z)(e),(0,r.Z)(t)))})),(0,r.Z)(e)}),[U]),ti=(0,s.useMemo)((function(){return"".concat(Cn,"/").concat(Ve,"/codeCollapsed")}),[Cn,Ve]),ii=(0,s.useMemo)((function(){return"".concat(Cn,"/").concat(Ve,"/outputCollapsed")}),[Cn,Ve]);(0,s.useEffect)((function(){bn((0,L.U2)(ti,!1)),it((0,L.U2)(ii,!1))}),[ti,ii]);var ri=(0,s.useRef)(null),li=(0,s.useMemo)((function(){return(0,pe.HK)(N,(function(e){return e.uuid}))}),[N]),ci=(0,s.useMemo)((function(){return!(null===Re||void 0===Re||!Re.find((function(e){return e.upstream_blocks.includes(Ve)})))}),[Ve,Re]),ui=(0,s.useCallback)((function(e){var n=e||{},t=n.block,i=n.code,r=n.disableReset,o=n.runDownstream,l=n.runSettings,c=n.runUpstream,u=n.runTests;if(null===u||"undefined"===typeof u){var a=(t||{}).type;u=[m.tf.DATA_LOADER,m.tf.DATA_EXPORTER,m.tf.TRANSFORMER].includes(a)}En&&In!==Et&&Pt(In),xe({block:t,code:i||xn,runDownstream:o||ci,runSettings:l,runTests:u||!1,runUpstream:c||!1}),r||(vt(1+Number(ot)),jt(null),it(!1))}),[xn,ci,En,xe,ot,Et,vt,jt,Pt]),ai=!(null===je||void 0===je||!je.find((function(e){return e.uuid===Ve})))||(null===Ot||void 0===Ot?void 0:Ot.length)>=1&&K!==ge.uF.IDLE;(0,s.useEffect)((function(){ai&&Zt(Number(new Date))}),[ai,Zt]);var si=(0,ae.Z)(K);(0,s.useEffect)((function(){K===ge.uF.IDLE&&K!==si&&jt(Number(new Date))}),[K,si,jt]);var di=(0,s.useCallback)((function(e){var n=e.editorRect.top,t=e.position.lineNumberTop;if(null!==ne&&void 0!==ne&&ne.current){var i=ne.current.getBoundingClientRect().height;if(n+t>i){var r=ne.current.scrollTop+(t-i+n);ne.current.scrollTo(0,r)}else if(t+n<Ei.aU){var o=ne.current.scrollTop+(t+n-Ei.aU);ne.current.scrollTo(0,o)}}}),[ne]),fi=(0,s.useMemo)((function(){return(null===Gn||void 0===Gn?void 0:Gn.length)>=0?Gn.map((function(e){return{data:e,execution_state:ge.uF.IDLE,type:ge.Gi.TEXT_PLAIN}})):Ot.filter((function(e){return null===e||void 0===e?void 0:e.type}))}),[Gn,Ot]),mi=!!fi.find((function(e){return e.error})),bi=(0,C.qn)(Ke,{blockColor:Ue,theme:De}).accent,gi=(null===Qe||void 0===Qe?void 0:Qe.length)||0,xi=(0,Ti.cU)([P],N)[0],yi=xi.dynamic,ki=xi.dynamicUpstreamBlock,Zi=xi.reduceOutput,_i=xi.reduceOutputUpstreamBlock,Oi=(0,s.useMemo)((function(){return(0,Kt._o)({block:P,dynamic:yi,dynamicUpstreamBlock:ki,hasError:mi,reduceOutput:Zi,reduceOutputUpstreamBlock:_i,selected:ke})}),[P,yi,ki,mi,Zi,_i,ke]),Ci=Oi.borderColorShareProps,Ai=Oi.tags,Di=fi.length>=1,Mi=(0,s.useCallback)((function(){ke||(null===_e||void 0===_e||_e(!1),null===Pe||void 0===Pe||Pe(!0))}),[ke,_e,Pe]),Bi=ce.ZP.blocks.pipelines.detail(Cn,An.uuid===(null===Et||void 0===Et?void 0:Et.uuid)||Tn.uuid===(null===Et||void 0===Et?void 0:Et.uuid)?encodeURIComponent(Ve):null,{_format:"dbt"},{revalidateOnFocus:!0}),Ni=Bi.data,Li=Bi.mutate,Fi=(0,s.useMemo)((function(){var e;return(null===Ni||void 0===Ni||null===(e=Ni.block)||void 0===e?void 0:e.metadata)||{}}),[Ni]),Ui=(0,d.Db)(ce.ZP.blocks.pipelines.useUpdate(Cn,Ve),{onError:function(e){var n=(0,me.qQ)(e).messages;zn(n)},onSuccess:function(e){return(0,me.wD)(e,{callback:function(){Xn(!1),X(),Y(),jn(xn)},onErrorCallback:function(e,n){return Se({errors:n,response:e})}})}}),Hi=(0,l.Z)(Ui,1)[0],Gi="CodeBlock/".concat(Ve),zi=(0,V.y)(),qi=zi.registerOnKeyDown,Ki=zi.unregisterOnKeyDown;(0,s.useEffect)((function(){return function(){Ki(Gi)}}),[Ki,Gi]),qi(Gi,(function(e,n,t){q&&!h||(Yn&&String(t[0])===String(B.Uq)&&String(t[1])!==String(B.zX)?Ve===$n?e.target.blur():Hi({block:Ri(Ri({},P),{},{name:$n})}):ke&&!$&&((0,F.y)([B.zX,B.Uq],n)||(0,F.y)([B.PQ,B.Uq],n)?ui({block:P}):(0,F.y)([B.XR,B.Uq],n)&&u&&(e.preventDefault(),u({language:ze,type:Ke,upstream_blocks:[Ve]}),ui({block:P}))))}),[u,P,$,Yn,$n,ui,ke,Hi]),(0,s.useEffect)((function(){var e;return kt&&(e=setInterval((function(){return Zn(Number(new Date))}),1e3)),kn&&!ai&&clearInterval(e),function(){return clearInterval(e)}}),[kn,ai,kt]);var Wi=(0,s.useCallback)((function(e){return(0,o.Z)({},m.tf.SCRATCHPAD,(0,r.Z)((0,Kt.Ts)(e,N,"block_menu/scratchpad",u)).map((function(e){return Ri(Ri({},e),{},{onClick:function(){return ye().then((function(){return e.onClick()}))}})})))[e.type]}),[u,N,ye]),Qi=(0,s.useMemo)((function(){return qe&&(null===li||void 0===li?void 0:li[qe])}),[li,qe]),Vi=(0,s.useMemo)((function(){return!qe&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(hn.Z,{autoHeight:!0,autocompleteProviders:nn,block:P,height:J,language:ze,onChange:function(e){jn(e),null===de||void 0===de||de(e)},onDidChangeCursorPosition:di,placeholder:m.tf.DBT===Ke&&m.t6.YAML===ze?"e.g. --select ".concat(Nt||"project","/models --exclude ").concat(Nt||"project","/models/some_dir"):"Start typing here...",selected:ke,setSelected:Pe,setTextareaFocused:Te,shortcuts:[function(e,n){return(0,Pi.Q)(e,(function(){$||ui({block:P,code:n.getValue()})}))}],textareaFocused:Ae,value:xn,width:"100%"}),Ge&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(x.Z,{}),(0,S.jsxs)(Z.Z,{mt:1,children:[(0,S.jsxs)(C.y9,{normalPadding:!0,children:[(0,S.jsx)(_.ZP,{small:!0,children:"Callback block: define @on_success or @on_failure callbacks for this block."}),(0,S.jsxs)(_.ZP,{monospace:!0,muted:!0,small:!0,children:["kwargs",(0,S.jsx)(_.ZP,{inline:!0,monospace:!0,muted:!0,small:!0,children:" \u2192 "}),"global variables"]})]}),(0,S.jsx)(hn.Z,{autoHeight:!0,autocompleteProviders:nn,language:"python",onChange:function(e){Qt(e),null===ue||void 0===ue||ue(e)},onDidChangeCursorPosition:di,placeholder:"Start typing here...",selected:ke,setSelected:Pe,setTextareaFocused:Te,textareaFocused:Ae,value:Wt,width:"100%"})]})]})]})}),[nn,P,ze,Ke,Wt,xn,Nt,Ge,J,$,ue,de,di,qe,ui,ke,jn,Pe,Te,Ae]);(0,s.useEffect)((function(){tn({python:Si({autocompleteItems:E,block:P,blocks:N,pipeline:be})})}),[E,P,N,be]);var Yi=(0,s.useMemo)((function(){return En?(0,S.jsx)(Z.Z,{py:1,children:(0,S.jsx)(T.Z,{onClickTab:function(e){Pt(e),An.uuid!==e.uuid&&Tn.uuid!==e.uuid||Li()},selectedTabUUID:null===Et||void 0===Et?void 0:Et.uuid,small:!0,tabs:Rn(P)})}):null}),[Li,En,Et]),Xi=(0,s.useMemo)((function(){return(0,S.jsx)(Kn,Ri(Ri({},Ci),{},{block:P,blockMetadata:Fi,buttonTabs:Yi,collapsed:tt,hasOutput:Di,isInProgress:ai,mainContainerWidth:te,messages:fi,openSidekickView:ve,pipeline:be,runCount:ot,runEndTime:xt,runStartTime:kt,selected:ke,selectedTab:Et,setCollapsed:function(e){it((function(){return(0,L.t8)(ii,e),e}))},setOutputBlocks:Ee,setSelectedOutputBlock:Ie,setSelectedTab:Pt}))}),[P,Fi,Ci,Yi,Di,ai,te,fi,ve,tt,ii,be,ot,xt,kt,ke,Et,Ee,it,Ie]),Ji=(0,s.useCallback)((function(){return fn(!1)}),[]),$i=(0,s.useRef)(null),er=(0,s.useCallback)((function(e){clearTimeout($i.current),Un((function(n){return Ri(Ri({},n),e)})),$i.current=setTimeout((function(){var n=Ri(Ri({},Fn),e);("undefined"!==typeof n.data_provider&&"undefined"!==n.data_provider_profile||"undefined"!==typeof n.dbt_profile_target||"undefined"!==typeof n.dbt_project_name||"undefined"!==typeof n.limit)&&ye({block:{configuration:n,uuid:Ve}})}),1e3)}),[Ve,Fn,ye]),nr=Le.BIGQUERY===Fn.data_provider||Le.SNOWFLAKE===Fn.data_provider,tr=(0,s.useMemo)((function(){return(null===N||void 0===N?void 0:N.length)||0}),[N]),ir=(0,s.useMemo)((function(){return xn?(0,S.jsx)(pi,{children:xn}):(0,S.jsx)(Z.Z,{px:1,children:(0,S.jsx)(_.ZP,{monospace:!0,muted:!0,children:"Double-click to edit"})})}),[xn]);(0,s.useEffect)((function(){Dn&&Wn&&!ke&&Qn(!1)}),[Wn,Dn,ke]);var rr=(0,s.useMemo)((function(){return(0,S.jsx)(M.Z,{compact:!0,monospace:!0,onBlur:function(){return setTimeout((function(){_e(!1)}),300)},onChange:function(e){_e(!0),er((0,o.Z)({},ht,e.target.value)),e.preventDefault()},onClick:vi.j,onFocus:function(){_e(!0)},small:!0,type:"number",value:Fn.limit||"",width:11*O.iI})}),[Fn,_e,er]);return(0,S.jsx)("div",{ref:Dt,children:(0,S.jsxs)("div",{ref:n,style:{position:"relative",zIndex:w===a?tr+9:null},children:[(0,S.jsxs)("div",{style:{position:"relative"},children:[(0,S.jsx)(C.nz,Ri(Ri({},Ri(Ri({},Ci),Tt)),{},{bottomBorder:Dn,onClick:function(){return Mi()},ref:At,zIndex:tr+1-(w||0),children:(0,S.jsxs)(y.Z,{alignItems:"center",justifyContent:"space-between",children:[(0,S.jsxs)(j.Z,{alignItems:"center",flex:1,children:[(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(dn.Z,{monospace:!0,children:m.dO[ze]}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(g.Z,{color:bi,size:1.5*O.iI,square:!0}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(we.Z,{items:Wi(P),onClickCallback:Ji,onClickOutside:Ji,open:cn,parentRef:ri,uuid:"CodeBlock/block_menu",children:(0,S.jsx)(_.ZP,{color:bi,monospace:!0,children:null===(i=En?m.tf.DBT:m.V4[Ke])||void 0===i?void 0:i.toUpperCase()})}),m.tf.SCRATCHPAD===Ke&&(0,S.jsxs)(S.Fragment,{children:["\xa0",(0,S.jsx)(I.Z,{basic:!0,iconOnly:!0,noPadding:!0,onClick:function(){return fn(!0)},transparent:!0,children:(0,S.jsx)(se.K5,{muted:!0})})]})]}),(0,S.jsx)(Z.Z,{mr:O.cd}),(0,S.jsx)(se.iU,{size:1.5*O.iI}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsxs)(y.Z,{alignItems:"center",children:[En&&m.t6.YAML!==ze&&(0,S.jsx)(le.Z,{block:!0,label:(0,wi.$1)(P,{fullPath:!0}),size:null,children:(0,S.jsx)(_.ZP,{monospace:!0,muted:!0,children:(0,wi.$1)(P)})}),(!En||m.t6.YAML===ze)&&(0,S.jsx)(oi,{bold:!1,inputValue:$n,monospace:!0,muted:!0,notRequired:!0,onBlur:function(){return setTimeout((function(){_e(!1),Xn(!1)}),300)},onChange:function(e){et(e.target.value),e.preventDefault()},onClick:function(){_e(!0),Xn(!0)},onFocus:function(){_e(!0),Xn(!0)},stacked:!0,value:!Yn&&Ve}),Yn&&!En&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Z.Z,{ml:1}),(0,S.jsx)(k.Z,{onClick:function(){return ye({block:{name:$n,uuid:Ve}}).then((function(){Xn(!1),X(),Y()}))},preventDefault:!0,sameColorAsText:!0,small:!0,children:"Update name"})]})]}),(0,S.jsx)(Z.Z,{mr:2}),!m.iZ.includes(Ke)&&te>700&&(0,S.jsx)(le.Z,{appearBefore:!0,block:!0,label:"\n ".concat((0,Q._6)("parent block",gi),". ").concat(0===gi?"Click to select 1 or more blocks to depend on.":"Edit parent blocks.","\n "),size:null,widthFitContent:gi>=1,children:(0,S.jsx)(I.Z,{noBackground:!0,noBorder:!0,noPadding:!0,onClick:function(){Pe(!0),Ce({upstreamBlocks:{block:P,values:null===Qe||void 0===Qe?void 0:Qe.map((function(e){return{uuid:e}}))}})},children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsxs)(_.ZP,{monospace:gi>=1,small:gi>=1,underline:0===gi,children:[0===gi&&"Edit parent blocks",gi>=1&&(0,Q._6)("parent block",gi)]}),(0,S.jsx)(Z.Z,{mr:1}),0===gi&&(0,S.jsx)(se.Jj,{size:3*O.iI}),gi>=1&&(0,S.jsx)(se.eV,{size:3*O.iI})]})})})]}),(0,S.jsx)(Yt,{addNewBlock:u,addWidget:f,block:P,blocks:N,deleteBlock:z,executionState:K,fetchFileTree:Y,fetchPipeline:X,interruptKernel:ee,isEditingBlock:Wn,pipeline:be,runBlock:$?null:ui,savePipelineContent:ye,setErrors:Se,setIsEditingBlock:Qn,setOutputCollapsed:it}),(0,S.jsx)(Z.Z,{px:1,children:(0,S.jsx)(I.Z,{basic:!0,iconOnly:!0,noPadding:!0,onClick:function(){bn((function(e){return(0,L.t8)(ti,!e),!e})),vn||it((function(){return(0,L.t8)(ii,!0),!0}))},transparent:!0,children:vn?(0,S.jsx)(se._M,{muted:!0,size:2*O.iI}):(0,S.jsx)(se.Kh,{muted:!0,size:2*O.iI})})})]})})),(0,S.jsxs)(C.Nk,{onClick:function(){return Mi()},children:[(0,S.jsxs)(C.jv,Ri(Ri({},Ci),{},{className:ke&&Ae?"selected":null,hasOutput:!!Yi||Di,lightBackground:Dn&&!Wn,onDoubleClick:function(){Dn&&!Wn&&Qn(!0)},children:[m.tf.DBT===Ke&&!vn&&(0,S.jsxs)(C.y9,{normalPadding:!0,children:[(0,S.jsxs)(y.Z,{alignItems:"center",justifyContent:"space-between",children:[(0,S.jsxs)(j.Z,{alignItems:"center",children:[m.t6.YAML===ze&&(0,S.jsx)(hi.Z,{compact:!0,monospace:!0,onBlur:function(){return setTimeout((function(){_e(!1)}),300)},onChange:function(e){var n;er((n={},(0,o.Z)(n,dt,""),(0,o.Z)(n,ft,e.target.value),n)),e.preventDefault()},onClick:vi.j,onFocus:function(){_e(!0)},placeholder:"Project",small:!0,value:Fn.dbt_project_name||"",children:Object.keys(Bt||{}).map((function(e){return(0,S.jsx)("option",{value:e,children:e},e)}))}),m.t6.YAML!==ze&&(0,S.jsx)(_.ZP,{monospace:!0,small:!0,children:Nt}),(0,S.jsx)(Z.Z,{mr:2}),(0,S.jsx)(_.ZP,{monospace:!0,muted:!0,small:!0,children:"Target"}),(0,S.jsx)("span",{children:"\xa0"}),!Gt&&(0,S.jsx)(hi.Z,{compact:!0,disabled:!Nt,monospace:!0,onBlur:function(){return setTimeout((function(){_e(!1)}),300)},onChange:function(e){er((0,o.Z)({},dt,e.target.value)),e.preventDefault()},onClick:vi.j,onFocus:function(){_e(!0)},placeholder:Nt?Pn?null===Lt||void 0===Lt?void 0:Lt.target:null:"Select project first",small:!0,value:Ut||"",children:null===Ft||void 0===Ft?void 0:Ft.map((function(e){return(0,S.jsx)("option",{value:e,children:e},e)}))}),Gt&&(0,S.jsx)(M.Z,{compact:!0,monospace:!0,onBlur:function(){return setTimeout((function(){_e(!1)}),300)},onChange:function(e){er((0,o.Z)({},dt,e.target.value)),e.preventDefault()},onClick:vi.j,onFocus:function(){_e(!0)},placeholder:Nt?Pn?null===Lt||void 0===Lt?void 0:Lt.target:null:"Select project first",small:!0,value:Ut||"",width:21*O.iI}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(y.Z,{alignItems:"center",children:(0,S.jsx)(le.Z,{block:!0,description:(0,S.jsxs)(_.ZP,{default:!0,inline:!0,children:["Manually type the name of the target you want to use in the profile.",(0,S.jsx)("br",{}),"Interpolate environment variables and global variables using the following syntax:",(0,S.jsx)("br",{}),(0,S.jsx)(_.ZP,{default:!0,inline:!0,monospace:!0,children:"{{ env_var('NAME') }}"})," or ",(0,S.jsx)(_.ZP,{default:!0,inline:!0,monospace:!0,children:"{{ variables('NAME') }}"})]}),size:null,widthFitContent:!0,children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(b.Z,{checked:Gt,label:(0,S.jsx)(_.ZP,{muted:!0,small:!0,children:"Manually enter target"}),onClick:function(e){(0,vi.j)(e),zt(!Gt)}}),(0,S.jsx)("span",{children:"\xa0"}),(0,S.jsx)(se.kI,{muted:!0})]})})})]}),m.t6.YAML!==ze&&!(null!==Mt&&void 0!==Mt&&null!==(c=Mt.block)&&void 0!==c&&c.snapshot)&&(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(le.Z,{appearBefore:!0,block:!0,description:(0,S.jsxs)(_.ZP,{default:!0,inline:!0,children:["Limit the number of results that are returned",(0,S.jsx)("br",{}),"when running this block in the notebook.",(0,S.jsx)("br",{}),"This limit won\u2019t affect the number of results",(0,S.jsx)("br",{}),"returned when running the pipeline end-to-end."]}),size:null,widthFitContent:!0,children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(se.kI,{muted:!0}),(0,S.jsx)("span",{children:"\xa0"}),(0,S.jsx)(_.ZP,{monospace:!0,muted:!0,small:!0,children:"Sample limit"}),(0,S.jsx)("span",{children:"\xa0"})]})}),rr,(0,S.jsx)(Z.Z,{mr:1})]})]}),m.t6.YAML===ze&&(0,S.jsx)(Z.Z,{mt:1,children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsxs)(j.Z,{flex:1,children:[(0,S.jsxs)(_.ZP,{default:!0,monospace:!0,small:!0,children:["dbt run ",(0,S.jsx)(_.ZP,{inline:!0,monospace:!0,small:!0,children:"[type your --select and --exclude syntax below]"})]}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsxs)(_.ZP,{monospace:!0,muted:!0,small:!0,children:["(paths start from ",(null===Fn||void 0===Fn?void 0:Fn.dbt_project_name)||"project"," folder)"]})]}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(_.ZP,{muted:!0,small:!0,children:(0,S.jsx)(k.Z,{href:"https://docs.getdbt.com/reference/node-selection/syntax#examples",openNewWindow:!0,small:!0,children:"Examples"})}),(0,S.jsx)(Z.Z,{mr:1})]})})]}),Pn&&!vn&&m.tf.DBT!==Ke&&(0,S.jsx)(C.y9,{normalPadding:!0,children:(0,S.jsxs)(y.Z,{flexWrap:"wrap",style:{marginTop:"-8px"},children:[(0,S.jsxs)(y.Z,{style:{marginTop:"8px"},children:[(0,S.jsx)(hi.Z,{compact:!0,label:"Connection",onChange:function(e){return er((0,o.Z)({},lt,e.target.value))},onClick:vi.j,small:!0,value:Fn.data_provider,children:null===U||void 0===U?void 0:U.map((function(e){var n=e.id,t=e.value;return(0,S.jsx)("option",{value:t,children:n},n)}))}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(hi.Z,{compact:!0,label:"Profile",onChange:function(e){return er((0,o.Z)({},ut,e.target.value))},onClick:vi.j,small:!0,value:Fn.data_provider_profile,children:null===ni||void 0===ni?void 0:ni.map((function(e){return(0,S.jsx)("option",{value:e,children:e},e)}))}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(y.Z,{alignItems:"center",children:(0,S.jsx)(le.Z,{block:!0,description:(0,S.jsxs)(_.ZP,{default:!0,inline:!0,children:["If checked, you\u2019ll have to write your own custom",(0,S.jsx)("br",{}),"CREATE TABLE commands and INSERT commands.",(0,S.jsx)("br",{}),"Separate your commands using a semi-colon: ",(0,S.jsx)(_.ZP,{default:!0,inline:!0,monospace:!0,children:";"})]}),size:null,widthFitContent:!0,children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(b.Z,{checked:Fn.use_raw_sql,label:(0,S.jsx)(_.ZP,{muted:!0,small:!0,children:"Use raw SQL"}),onClick:function(e){(0,vi.j)(e),er((0,o.Z)({},gt,!Fn.use_raw_sql))}}),(0,S.jsx)("span",{children:"\xa0"}),(0,S.jsx)(se.kI,{muted:!0})]})})}),!Fn.use_raw_sql&&(0,S.jsxs)(S.Fragment,{children:[nr&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(y.Z,{alignItems:"center",children:(0,S.jsx)(M.Z,{compact:!0,label:"Database",monospace:!0,onBlur:function(){return setTimeout((function(){_e(!1)}),300)},onChange:function(e){er((0,o.Z)({},ct,e.target.value)),e.preventDefault()},onClick:vi.j,onFocus:function(){_e(!0)},small:!0,value:Fn.data_provider_database,width:10*O.iI})})]}),(0,S.jsx)(Z.Z,{mr:1}),![Xt.CLICKHOUSE,Xt.MYSQL].includes(Fn.data_provider)&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(le.Z,{block:!0,description:(0,S.jsxs)(_.ZP,{default:!0,inline:!0,children:["Schema that is used when creating a table and inserting values.",(0,S.jsx)("br",{}),"This field is required."]}),size:null,widthFitContent:!0,children:(0,S.jsx)(y.Z,{alignItems:"center",children:(0,S.jsx)(M.Z,{compact:!0,label:"Schema",monospace:!0,onBlur:function(){return setTimeout((function(){_e(!1)}),300)},onChange:function(e){er((0,o.Z)({},at,e.target.value)),e.preventDefault()},onClick:vi.j,onFocus:function(){_e(!0)},small:!0,value:Fn.data_provider_schema,width:10*O.iI})})}),(0,S.jsx)(Z.Z,{mr:1})]}),(0,S.jsx)(le.Z,{block:!0,description:(0,S.jsxs)(_.ZP,{default:!0,inline:!0,children:["This value will be used as the table name.",(0,S.jsx)("br",{}),"If blank, the default table name will be:",(0,S.jsx)("br",{}),(0,S.jsxs)(_.ZP,{inline:!0,monospace:!0,children:[Cn,"_",Ve]}),(0,S.jsx)("br",{}),"This field is optional."]}),size:null,widthFitContent:!0,children:(0,S.jsx)(y.Z,{alignItems:"center",children:(0,S.jsx)(M.Z,{compact:!0,label:"Table (optional)",monospace:!0,onBlur:function(){return setTimeout((function(){_e(!1)}),300)},onChange:function(e){er((0,o.Z)({},st,e.target.value)),e.preventDefault()},onClick:vi.j,onFocus:function(){_e(!0)},small:!0,value:Fn.data_provider_table,width:20*O.iI})})})]}),(0,S.jsx)(Z.Z,{mr:1})]}),!Fn.use_raw_sql&&(0,S.jsxs)(y.Z,{alignItems:"center",style:{marginTop:"8px"},children:[(0,S.jsx)(le.Z,{block:!0,description:(0,S.jsxs)(_.ZP,{default:!0,inline:!0,children:["Limit the number of results that are returned",(0,S.jsx)("br",{}),"when running this block in the notebook.",(0,S.jsx)("br",{}),"This limit won\u2019t affect the number of results",(0,S.jsx)("br",{}),"returned when running the pipeline end-to-end."]}),size:null,widthFitContent:!0,children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(se.kI,{muted:!0}),(0,S.jsx)("span",{children:"\xa0"}),(0,S.jsx)(_.ZP,{monospace:!0,muted:!0,small:!0,children:"Limit"}),(0,S.jsx)("span",{children:"\xa0"})]})}),rr,(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(le.Z,{autoWidth:!0,block:!0,description:(0,S.jsxs)(_.ZP,{default:!0,inline:!0,children:["How do you want to handle existing data with the same",nr?" database,":""," schema, and table name?",(0,S.jsx)("br",{}),(0,S.jsx)(_.ZP,{bold:!0,inline:!0,monospace:!0,children:"Append"}),": add rows to the existing table.",(0,S.jsx)("br",{}),(0,S.jsx)(_.ZP,{bold:!0,inline:!0,monospace:!0,children:"Replace"}),": delete the existing data.",(0,S.jsx)("br",{}),(0,S.jsx)(_.ZP,{bold:!0,inline:!0,monospace:!0,children:"Fail"}),": raise an error during execution."]}),size:null,widthFitContent:!0,children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(se.kI,{muted:!0}),(0,S.jsx)("span",{children:"\xa0"}),(0,S.jsx)(_.ZP,{monospace:!0,muted:!0,small:!0,children:"Write policy:"}),(0,S.jsx)("span",{children:"\xa0"}),(0,S.jsx)(hi.Z,{compact:!0,label:"strategy",onChange:function(e){return er((0,o.Z)({},pt,e.target.value))},onClick:vi.j,small:!0,value:Fn.export_write_policy,children:null===Jt||void 0===Jt?void 0:Jt.map((function(e){return(0,S.jsx)("option",{value:e,children:(0,Q.kC)(e)},e)}))})]})}),(0,S.jsx)(Z.Z,{mr:1})]}),(null===Fn||void 0===Fn?void 0:Fn.data_provider)===Xt.TRINO&&Qe.length>=1&&(0,S.jsxs)(y.Z,{alignItems:"center",style:{marginTop:"8px"},children:[(0,S.jsx)(le.Z,{appearBefore:!0,block:!0,description:(0,S.jsxs)(_.ZP,{default:!0,inline:!0,children:["If checked, upstream blocks that aren\u2019t SQL blocks",(0,S.jsx)("br",{}),"will have their data exported into a table that is",(0,S.jsx)("br",{}),"uniquely named upon each block run. For example,",(0,S.jsx)("br",{}),(0,S.jsx)(_.ZP,{default:!0,inline:!0,monospace:!0,children:"[pipeline_uuid]_[block_uuid]_[unique_timestamp]"}),"."]}),size:null,widthFitContent:!0,children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(b.Z,{checked:Fn.unique_upstream_table_name,label:(0,S.jsx)(_.ZP,{muted:!0,small:!0,children:"Unique upstream table names"}),onClick:function(e){(0,vi.j)(e),er((0,o.Z)({},mt,!Fn.unique_upstream_table_name))}}),(0,S.jsx)("span",{children:"\xa0"}),(0,S.jsx)(se.kI,{muted:!0})]})}),(0,S.jsx)(Z.Z,{mr:1})]})]})}),Ai.length>=1&&(0,S.jsx)(C.y9,{normalPadding:!0,children:(0,S.jsx)(y.Z,{children:Ai.map((function(e,n){var t=e.description,i=e.title;return(0,S.jsx)(Z.Z,{ml:n>=1?1:0,children:(0,S.jsx)(le.Z,{block:!0,description:t,size:null,widthFitContent:!0,children:(0,S.jsx)(dn.Z,{children:i})})},i)}))})}),Qe.length>=1&&!vn&&m.f2.includes(Ke)&&!Sn&&!qe&&(0,S.jsxs)(C.y9,{normalPadding:!0,children:[(0,S.jsx)(Z.Z,{mr:1,children:(0,S.jsxs)(_.ZP,{muted:!0,small:!0,children:[!Pn&&"Positional arguments for ".concat(wn?"":"decorated ","function:"),Pn&&(0,S.jsxs)(S.Fragment,{children:["The interpolated tables below are available in queries from upstream blocks.",(0,S.jsx)("br",{}),"Example: ",(0,S.jsx)(_.ZP,{inline:!0,monospace:!0,small:!0,children:"SELECT * FROM {{ df_1 }}"})," to insert all rows from ",(0,S.jsx)(_.ZP,{inline:!0,monospace:!0,small:!0,children:null===Qe||void 0===Qe?void 0:Qe[0]})," into a table."]})]})}),(0,S.jsxs)(Z.Z,{mt:1,children:[!Pn&&!wn&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(_.ZP,{monospace:!0,muted:!0,small:!0,children:[m.tf.DATA_EXPORTER===Ke&&"@data_exporter",m.tf.DATA_LOADER===Ke&&"@data_loader",m.tf.TRANSFORMER===Ke&&"@transformer",m.tf.CUSTOM===Ke&&"@custom"]}),(0,S.jsxs)(_.ZP,{monospace:!0,muted:!0,small:!0,children:["def ",(m.tf.DATA_EXPORTER===Ke?"export_data":m.tf.DATA_LOADER===Ke&&"load_data")||m.tf.TRANSFORMER===Ke&&"transform"||m.tf.CUSTOM===Ke&&"transform_custom","(",Qe.map((function(e,n){return n>=1?"data_".concat(n+1):"data"})).join(", "),"):"]})]}),wn&&(0,S.jsx)(S.Fragment,{children:(0,S.jsxs)(_.ZP,{monospace:!0,muted:!0,small:!0,children:[m.tf.DATA_EXPORTER===Ke?"export_data":m.tf.TRANSFORMER===Ke&&"transform","\xa0\u2190 function(",Qe.map((function(e,n){return"df_".concat(n+1)})).join(", "),"):"]})}),Pn&&(null===Qe||void 0===Qe?void 0:Qe.length)>=1&&(0,S.jsx)(ji,{block:P,blockConfiguration:Fn,blockRefs:A,blocks:null===Qe||void 0===Qe?void 0:Qe.map((function(e){return null===li||void 0===li?void 0:li[e]})),updateBlockConfiguration:er}),!Pn&&Qe.map((function(e,n){var t=li[e],i=(0,C.qn)(null===t||void 0===t?void 0:t.type,{blockColor:null===t||void 0===t?void 0:t.color,theme:De}).accent,r="{{ df_".concat(n+1," }}");return(0,S.jsxs)("div",{children:[!Pn&&!wn&&(0,S.jsxs)(_.ZP,{inline:!0,monospace:!0,muted:!0,small:!0,children:["\xa0\xa0\xa0\xa0data",n>=1?"_".concat(n+1):null]}),Pn&&(0,S.jsx)(_.ZP,{inline:!0,monospace:!0,muted:!0,small:!0,children:r}),wn&&(0,S.jsxs)(_.ZP,{inline:!0,monospace:!0,muted:!0,small:!0,children:["\xa0\xa0\xa0\xa0","df".concat(n+1)]})," ",(0,S.jsx)(_.ZP,{inline:!0,monospace:!0,muted:!0,small:!0,children:"\u2192"})," ",(0,S.jsx)(k.Z,{color:i,onClick:function(){var e,n,i=null===A||void 0===A||null===(e=A.current)||void 0===e?void 0:e["".concat(null===t||void 0===t?void 0:t.type,"s/").concat(null===t||void 0===t?void 0:t.uuid,".py")];null===i||void 0===i||null===(n=i.current)||void 0===n||n.scrollIntoView()},preventDefault:!0,small:!0,children:(0,S.jsx)(_.ZP,{color:i,inline:!0,monospace:!0,small:!0,children:e})})]},e)}))]})]}),!He&&(0,S.jsx)(S.Fragment,{children:vn?(0,S.jsx)(Z.Z,{px:1,children:(0,S.jsxs)(_.ZP,{monospace:!0,muted:!0,children:["(",(0,Q._6)("line",null===xn||void 0===xn?void 0:xn.split(/\r\n|\r|\n/).length)," collapsed)"]})}):!Dn||Wn?Qi?(0,S.jsx)(Z.Z,{px:1,children:(0,S.jsxs)(_.ZP,{monospace:!0,muted:!0,children:["Replicated from block ",(0,S.jsx)(k.Z,{color:(0,C.qn)(null===Qi||void 0===Qi?void 0:Qi.type,{blockColor:null===Qi||void 0===Qi?void 0:Qi.color,theme:De}).accent,onClick:function(e){var n,t;(0,vi.j)(e);var i=null===A||void 0===A||null===(n=A.current)||void 0===n?void 0:n["".concat(null===Qi||void 0===Qi?void 0:Qi.type,"s/").concat(null===Qi||void 0===Qi?void 0:Qi.uuid,".py")];null===i||void 0===i||null===(t=i.current)||void 0===t||t.scrollIntoView()},preventDefault:!0,children:(0,S.jsx)(_.ZP,{color:(0,C.qn)(null===Qi||void 0===Qi?void 0:Qi.type,{blockColor:null===Qi||void 0===Qi?void 0:Qi.color,theme:De}).accent,inline:!0,monospace:!0,children:null===Qi||void 0===Qi?void 0:Qi.uuid})})]})}):Vi:ir}),W&&s.cloneElement(W,{runBlockAndTrack:ui}),He&&(0,S.jsxs)(Z.Z,{p:O.cd,children:[(0,S.jsx)(_.ZP,{bold:!0,danger:!0,children:null===He||void 0===He?void 0:He.error}),(0,S.jsx)(_.ZP,{muted:!0,children:null===He||void 0===He?void 0:He.message})]}),ai&&kn&&kn>kt&&(0,S.jsx)(C.HC,{children:(0,S.jsxs)(_.ZP,{muted:!0,children:["".concat(Math.round((kn-kt)/1e3)),"s"]})}),!vn&&![m.tf.CALLBACK,m.tf.EXTENSION].includes(Ke)&&(0,S.jsx)(pn,{block:P,blocks:p,openSidekickView:ve})]})),Xi]})]}),!oe&&(0,S.jsxs)(C.gE,{additionalZIndex:tr-w,onMouseEnter:function(){return $e(!0)},onMouseLeave:function(){$e(!1),null===Ze||void 0===Ze||Ze(null)},children:[Je&&u&&(0,S.jsx)(Z.Z,{mt:2,children:(0,S.jsx)(un,{addNewBlock:function(e){var n=e.content,t=e.configuration,i=(0,Kt.eY)(P,e),r=(0,Kt.fA)(be,P,e).map((function(e){var n=Ri({},li[e]||{}),t=n.upstream_blocks;return t&&(n.upstream_blocks=t.filter((function(e){return e!==Ve}))),n}));return[m.tf.DATA_LOADER,m.tf.TRANSFORMER].includes(Ke)&&m.tf.SCRATCHPAD===e.type&&(n="from mage_ai.data_preparation.variable_manager import get_variable\n\n\n df = get_variable('".concat(Cn,"', '").concat(Ve,"', 'output_0')")),n=on(e,n),m.t6.SQL===ze&&(t=Ri(Ri({},(0,Ii.GL)(Ye,[lt,ct,ut,at,pt])),t)),m.t6.SQL===e.language&&(n=rn(n)),u(Ri(Ri({},e),{},{configuration:t,content:n,upstream_blocks:i}),r)},blockIdx:w,blockTemplates:R,compact:!0,hideCustom:Sn,hideDbt:Sn,onClickAddSingleDBTModel:fe,pipeline:be,setAddNewBlockMenuOpenIdx:Ze,setCreatingNewDBTModel:Oe})}),(0,S.jsx)(C.t1,{className:"block-divider-inner"})]})]})})}var Mi=s.forwardRef(Di),Bi=t(90880),Ni=6.25*O.iI,Li=(O.iI,100*O.iI),Fi=v.default.div.withConfig({displayName:"indexstyle__WindowContainerStyle",componentId:"sc-g0cszf-0"})(["border-radius:","px;width:100%;max-width:","px;z-index:101;position:absolute;overflow:hidden;top:50%;left:50%;transform:translate(-50%,-50%);",""],Te.n_,Li,(function(e){return"\n box-shadow: ".concat((e.theme||ue.Z).shadow.window,";\n background-color: ").concat((e.theme||ue.Z).background.panel,";\n ")})),Ui=(0,v.css)(["display:flex;align-items:center;justify-content:space-between;height:","px;padding:","px ","px;",""],Ni,O.iI,O.cd*O.iI,(function(e){return"\n background-color: ".concat((e.theme||ue.Z).background.output,";\n ")})),Hi=v.default.div.withConfig({displayName:"indexstyle__WindowHeaderStyle",componentId:"sc-g0cszf-1"})([""," border-top-left-radius:","px;border-top-right-radius:","px;",""],Ui,Te.n_,Te.n_,(function(e){return"\n border-bottom: ".concat(Te.YF,"px ").concat(Te.M8," ").concat((e.theme||ue.Z).borders.medium,";\n ")})),Gi=v.default.div.withConfig({displayName:"indexstyle__WindowContentStyle",componentId:"sc-g0cszf-2"})(["overflow:auto;padding:","px 0;"," "," "," ",""],O.iI,Pn.w5,(0,Bi.eR)(),(function(e){return e.minMaxHeight&&"\n max-height: ".concat(7*O.iI,"px;\n ")}),(function(e){return!e.minMaxHeight&&"\n max-height: calc(100vh - ".concat(6.5*Ni,"px);\n ")})),zi=v.default.div.withConfig({displayName:"indexstyle__WindowFooterStyle",componentId:"sc-g0cszf-3"})([""," justify-content:flex-end;border-bottom-left-radius:","px;border-bottom-right-radius:","px;",""],Ui,Te.n_,Te.n_,(function(e){return"\n border-top: ".concat(Te.YF,"px ").concat(Te.M8," ").concat((e.theme||ue.Z).borders.medium,";\n ")})),qi=v.default.div.withConfig({displayName:"indexstyle__InputRowStyle",componentId:"sc-g0cszf-4"})(["padding:","px ","px;",""],.75*O.iI,2*O.iI,(function(e){return"\n border-bottom: ".concat(Te.YF,"px ").concat(Te.M8," ").concat((e.theme||ue.Z).borders.medium,";\n ")}));function Ki(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Wi(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Ki(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Ki(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var Qi=function(e){var n=e.blocks,t=e.creatingNewDBTModel,i=e.dbtModelName,r=e.files,o=e.onClose,l=e.onOpenFile,c=e.setDbtModelName,u=(0,s.useState)(!1),a=u[0],d=u[1],f=(0,s.useState)(null),p=f[0],h=f[1],v=(0,s.useMemo)((function(){var e,n,t=null===(e=(0,pe.sE)((null===r||void 0===r||null===(n=r[0])||void 0===n?void 0:n.children)||[],(function(e){return"dbt"===e.name})))||void 0===e?void 0:e.children,i=[];return null===t||void 0===t||t.forEach((function(e){var n=e.children,t=void 0===n?[]:n;t.length>=1&&i.push(Wi(Wi({},e),{},{children:t}))})),i}),[r]),b=(0,s.useMemo)((function(){return(0,pe.HK)(n,(function(e){return e.configuration.file_path}))}),[n]);return(0,S.jsxs)(Fi,{children:[(0,S.jsxs)(Hi,{children:[(0,S.jsx)(j.Z,{alignItems:"center",children:(0,S.jsx)(_.ZP,{disableWordBreak:!0,monospace:!0,children:t?"Create new dbt model":"Select dbt model or snapshot file"})}),(0,S.jsx)(I.Z,{iconOnly:!0,onClick:o,children:(0,S.jsx)(se.x8,{muted:!0})})]}),t&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(qi,{children:(0,S.jsx)(oi,{dynamicSizing:!0,inputValue:i,label:"Model name (cannot be changed):",labelColor:ue.Z.accent.dbt,notRequired:!0,onBlur:function(){d(!1)},onChange:function(e){c(e.target.value),e.preventDefault()},onClick:function(){d(!0)},onFocus:function(){d(!0)},placeholder:"Enter name",required:!0,stacked:!0,suffixValue:".".concat(m.t6.SQL),value:!a&&i})}),(0,S.jsxs)(qi,{children:[(0,S.jsx)(_.ZP,{bold:!0,color:ue.Z.accent.dbt,children:"Select folder location:"}),(0,S.jsx)(_.ZP,{bold:!0,muted:!p,children:p?"dbt".concat(xe.sep).concat(p):"Choose folder below"})]})]}),(0,S.jsx)(Gi,{children:(0,S.jsx)(H.Z,{allowSelectingFolders:t,disableContextMenu:!0,files:v,isFileDisabled:function(e,n){return t?!n||(null===n||void 0===n?void 0:n.some((function(e){return"models"===(null===e||void 0===e?void 0:e.name)}))):!!b[e]||!(null!==n&&void 0!==n&&n.length)&&!e.match(new RegExp(".".concat(m.t6.SQL,"$")))},openFile:l,selectFile:h,uncollapsed:!0,useRootFolder:!0})}),t&&(0,S.jsx)(zi,{children:(0,S.jsx)(I.Z,{backgroundColor:i&&p?ue.Z.accent.dbt:ue.Z.monotone.grey500,disabled:!i||!p,onClick:function(){return l(p)},padding:"6px 8px",children:"Create model"})})]})};function Vi(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Yi(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Vi(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Vi(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function Xi(e,n){var t,i=e.block,r=e.blocks,o=e.onClick,c=e.onDrop,u=i.type,a=(0,an.c)((function(){return{collect:function(e){return{isDragging:!!e.isDragging()}},item:i,type:Mn}}),[i]),d=(0,l.Z)(a,3),f=d[0],p=d[1],h=(d[2],(0,sn.L)((function(){return{accept:Mn,drop:function(e){return null===c||void 0===c?void 0:c(i,e)}}}),[i])),b=(0,l.Z)(h,2)[1],x=(0,s.useContext)(v.ThemeContext),E=(0,C.qn)(u,{blockColor:i.color,theme:x}).accent,P=(0,Ti.cU)([i],r)[0],w=P.dynamic,I=P.dynamicUpstreamBlock,T=P.reduceOutput,A=P.reduceOutputUpstreamBlock,R=(0,s.useMemo)((function(){return(0,Kt._o)({block:i,dynamic:w,dynamicUpstreamBlock:I,reduceOutput:T,reduceOutputUpstreamBlock:A})}),[i,w,I,T,A]).borderColorShareProps,D=(0,s.useMemo)((function(){return m.tf.DBT===(null===i||void 0===i?void 0:i.type)}),[i]);return(0,S.jsx)(Z.Z,{pb:1,ref:b,children:(0,S.jsx)(C.PY,Yi(Yi({},Yi(Yi({},R),f)),{},{ref:p,children:(0,S.jsx)(k.Z,{noHoverUnderline:!0,noOutline:!0,onClick:function(){return o()},preventDefault:!0,ref:n,children:(0,S.jsx)(Z.Z,{p:1,children:(0,S.jsxs)(y.Z,{alignItems:"center",justifyContent:"space-between",children:[(0,S.jsxs)(j.Z,{alignItems:"center",flex:1,children:[(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(dn.Z,{monospace:!0,children:m.dO[i.language]}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(g.Z,{color:E,size:1.5*O.iI,square:!0}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(_.ZP,{color:E,monospace:!0,children:null===(t=D?m.tf.DBT:m.V4[i.type])||void 0===t?void 0:t.toUpperCase()})]}),(0,S.jsx)(Z.Z,{mr:O.cd}),(0,S.jsx)(se.iU,{size:1.5*O.iI}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(_.ZP,{monospace:!0,muted:!0,children:null===i||void 0===i?void 0:i.uuid})]}),(0,S.jsx)(le.Z,{appearAbove:!0,appearBefore:!0,block:!0,label:"Show ".concat(null===i||void 0===i?void 0:i.uuid," block"),size:2*O.iI,widthFitContent:!0,children:(0,S.jsx)(se.Db,{muted:!0,size:2*O.iI})})]})})})}))})}var Ji,$i,er,nr,tr=s.forwardRef(Xi),ir=t(4804),rr=t(65730);!function(e){e.FULL_TABLE="FULL_TABLE",e.INCREMENTAL="INCREMENTAL",e.LOG_BASED="LOG_BASED"}($i||($i={})),function(e){e.IGNORE="IGNORE",e.UPDATE="UPDATE"}(er||(er={})),function(e){e.DATE_TIME="date-time",e.UUID="uuid"}(nr||(nr={}));var or,lr="datetime",cr=(Ji={},(0,o.Z)(Ji,nr.DATE_TIME,lr),(0,o.Z)(Ji,nr.UUID,nr.UUID),Ji);!function(e){e.ARRAY="array",e.BOOLEAN="boolean",e.INTEGER="integer",e.NULL="null",e.NUMBER="number",e.OBJECT="object",e.STRING="string"}(or||(or={}));var ur,ar,sr,dr,fr,pr=[or.ARRAY,or.BOOLEAN,lr,or.INTEGER,or.NULL,or.NUMBER,or.OBJECT,or.STRING,nr.UUID];!function(e){e.PROPERTIES="properties"}(ur||(ur={})),function(e){e.AUTOMATIC="automatic",e.AVAILABLE="available",e.UNSUPPORTED="unsupported"}(ar||(ar={})),function(e){e.FORCED_REPLICATION_METHOD="forced-replication-method",e.KEY_PROPERTIES="table-key-properties",e.REPLICATION_KEYS="valid-replication-keys",e.SCHEMA_NAME="schema-name"}(sr||(sr={})),function(e){e.AMPLITUDE="amplitude",e.BIGQUERY="bigquery",e.CHARGEBEE="chargebee",e.GOOGLE_ADS="google_ads",e.GOOGLE_SEARCH_CONSOLE="google_search_console",e.GOOGLE_SHEETS="google_sheets",e.INTERCOM="intercom",e.MYSQL="mysql",e.PIPEDRIVE="pipedrive",e.POSTGRESQL="postgresql",e.REDSHIFT="redshift",e.SALESFORCE="salesforce",e.STRIPE="stripe"}(dr||(dr={})),function(e){e.BIGQUERY="bigquery",e.DELTA_LAKE_S3="delta_lake_s3",e.MYSQL="mysql",e.POSTGRESQL="postgresql",e.SNOWFLAKE="snowflake"}(fr||(fr={}));var hr=t(79891),mr=t(70902),vr=t(85307);function br(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function gr(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?br(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):br(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var xr="4px",jr=[fr.BIGQUERY,fr.DELTA_LAKE_S3];var yr=function(e){var n=e.bookmarkValues,t=e.destination,i=e.isLoadingLoadSampleData,r=e.isLoadingUpdateDestinationBlockState,c=e.loadSampleData,u=e.source,a=e.stream,d=e.streams,f=e.updateAllStreams,p=e.updateDestinationBlockState,h=e.updateMetadataForColumns,m=e.updateSchemaProperty,v=e.updateStream,g=(0,s.useRef)(null),x=a.bookmark_properties,k=a.destination_table,C=void 0===k?"":k,E=a.key_properties,P=a.metadata,w=a.partition_keys,T=a.replication_method,A=a.schema.properties,D=a.tap_stream_id,B=a.unique_constraints,N=a.unique_conflict_method,L=(0,s.useState)(C),F=L[0],U=L[1],H=(0,s.useState)(!1),G=H[0],z=H[1],q=(0,s.useState)(null),K=q[0],W=q[1],V=(0,s.useState)(!1),Y=V[0],X=V[1],J=(0,s.useState)((0,o.Z)({},D,n||{})),$=J[0],ee=J[1],ne=(0,ae.Z)(D);(0,s.useEffect)((function(){ne!==D&&(U(C),W(null))}),[C,T,D,ne,N]),(0,s.useEffect)((function(){var e=null===$||void 0===$?void 0:$[D];(null===x||void 0===x?void 0:x.length)>0&&((0,Ii.Qr)(e)||!(0,Ii.Xy)(n,e))&&ee((function(e){return gr(gr({},e),{},(0,o.Z)({},D,n))}))}),[null===x||void 0===x?void 0:x.length,n,D]);var te=(0,s.useMemo)((function(){return(0,pe.HK)(P,(function(e){return e.breadcrumb.join("/")}))}),[P]),ie=(0,s.useMemo)((function(){var e;return null===(e=(0,pe.sE)(P,(function(e){return 0===e.breadcrumb.length})))||void 0===e?void 0:e.metadata}),[P]),re=(0,s.useMemo)((function(){return ie[sr.KEY_PROPERTIES]||[]}),[ie]),oe=(0,s.useMemo)((function(){return ie[sr.REPLICATION_KEYS]||[]}),[ie]),ce=jr.includes(t),ue=d.length>1,se=(0,s.useCallback)((function(e){var n=gr({},null===$||void 0===$?void 0:$[D]);n.hasOwnProperty(e)&&delete n[e],ee((function(e){return gr(gr({},e),{},(0,o.Z)({},D,gr({},n)))})),p({block:{bookmark_values:n,destination_table:F,tap_stream_id:D}})}),[$,F,D,p]),de=(0,s.useMemo)((function(){var e=[],n=[],i=(0,pe.mr)(Object.entries(A)).map((function(i,r){var o=(0,l.Z)(i,2),c=o[0],u=o[1],a=u.anyOf,s=void 0===a?[]:a,d=u.format,p=u.type,g=void 0===p?[]:p,k=new Set(Array.isArray(g)?g:[g]),C=new Set(k);s.forEach((function(e){var n=e.format,t=(e.items,e.type);Array.isArray(t)?t.forEach((function(e){k.add(e),C.add(e)})):(k.add(t),C.add(t),n&&C.add(n))}));var P=Array.from(k);d&&C.add(d);var T=(te["properties/".concat(c)]||{}).metadata,A=(T.inclusion,T.selected);e.push(A),n.push(c);var R=pr.reduce((function(e,n){return P.indexOf(n)>=0||lr===String(n)&&nr.DATE_TIME===d||nr.UUID===String(n)&&nr.UUID===d?e:e.concat((0,S.jsx)("option",{value:n,children:n},n))}),[]),M=P.findIndex((function(e){return e===or.STRING})),N=[(0,S.jsx)(b.Z,{checked:A,onClick:function(){h(D,[c],{selected:!A})}},"".concat(D,"/").concat(c,"/selected")),(0,S.jsx)(_.ZP,{children:c},"".concat(D,"/").concat(c,"/name")),(0,S.jsxs)(y.Z,{children:[(0,S.jsx)(j.Z,{flex:1,children:(0,S.jsx)(y.Z,{alignItems:"center",flexWrap:"wrap",fullWidth:!0,children:P.map((function(e,n){return(0,S.jsx)(Z.Z,{mb:1,mr:1,children:(0,S.jsx)(hr.Z,{border:!0,label:d&&or.STRING===e&&M===n?cr[d]:e,onClick:function(){var n={format:d,type:P.filter((function(n){return n!==e}))};nr.DATE_TIME!==d&&nr.UUID!==d||or.STRING!==e||(n.format=null),m(D,c,n)},small:!0})},"".concat(D,"/").concat(c,"/").concat(e,"/").concat(n,"/chip"))}))})}),R.length>=1&&(0,S.jsxs)(hi.Z,{compact:!0,onChange:function(e){var n=e.target.value,t={format:d,type:P};lr===String(n)?(t.format=nr.DATE_TIME,t.type.push(or.STRING)):nr.UUID===String(n)?(t.format=nr.UUID,t.type.push(or.STRING)):t.type.push(n),m(D,c,t)},primary:!0,small:!0,value:"",width:10*O.iI,children:[(0,S.jsx)("option",{value:""}),R]})]},"".concat(D,"/").concat(c,"/type")),(0,S.jsx)(b.Z,{checked:!(null===B||void 0===B||!B.includes(c)),disabled:re.length>=1&&!re.includes(c),onClick:re.length>=1&&!re.includes(c)?null:function(){return v(D,(function(e){var n;return null!==(n=e.unique_constraints)&&void 0!==n&&n.includes(c)?e.unique_constraints=(0,pe.Od)(e.unique_constraints,(function(e){return c===e})):e.unique_constraints=[c].concat(e.unique_constraints||[]),e}))}},"".concat(D,"/").concat(c,"/unique")),(0,S.jsx)(b.Z,{checked:!(null===x||void 0===x||!x.includes(c)),disabled:oe.length>=1&&!oe.includes(c),onClick:oe.length>=1&&!oe.includes(c)?null:function(){return v(D,(function(e){var n;return null!==(n=e.bookmark_properties)&&void 0!==n&&n.includes(c)?(se(c),e.bookmark_properties=(0,pe.Od)(e.bookmark_properties,(function(e){return c===e}))):e.bookmark_properties=[c].concat(e.bookmark_properties||[]),e}))}},"".concat(D,"/").concat(c,"/bookmark")),(0,S.jsx)(b.Z,{checked:!(null===E||void 0===E||!E.includes(c)),onClick:function(){return v(D,(function(e){var n;return null!==(n=e.key_properties)&&void 0!==n&&n.includes(c)?e.key_properties=(0,pe.Od)(e.key_properties,(function(e){return c===e})):e.key_properties=[c].concat(e.key_properties||[]),e}))}},"".concat(D,"/").concat(c,"/key_property"))];if(ce){var L=t!==fr.DELTA_LAKE_S3,F=L&&(re.includes(c)||!C.has(nr.DATE_TIME));N.push((0,S.jsx)(b.Z,{checked:!(null===w||void 0===w||!w.includes(c)),disabled:F,onClick:F?null:function(){return v(D,(function(e){var n,t;null!==(n=e.partition_keys)&&void 0!==n&&n.includes(c)?e.partition_keys=(0,pe.Od)(e.partition_keys,(function(e){return c===e})):L&&1===(null===(t=e.partition_keys)||void 0===t?void 0:t.length)?e.partition_keys=[c]:e.partition_keys=[c].concat(e.partition_keys||[]);return e}))}},"".concat(D,"/").concat(c,"/partition_key")))}if(ue){var U=K===r;N.push((0,S.jsx)(I.Z,{compact:!0,disabled:U,onClick:function(){W(r),setTimeout((function(){return W(null)}),2e3),f((function(e){var n,t;if((null===e||void 0===e?void 0:e.tap_stream_id)!==D&&null!==e&&void 0!==e&&null!==(n=e.schema)&&void 0!==n&&null!==(t=n.properties)&&void 0!==t&&t[c]){var i,r,o,l,u,a,s,f,p;e.schema.properties[c]={format:d||null,type:P};var h=null===(i=(0,pe.sE)((null===e||void 0===e?void 0:e.metadata)||[],(function(e){return 0===e.breadcrumb.length})))||void 0===i?void 0:i.metadata,m=h[sr.REPLICATION_KEYS]||[],v=h[sr.KEY_PROPERTIES]||[];null===B||void 0===B||!B.includes(c)||null!==e&&void 0!==e&&null!==(r=e.unique_constraints)&&void 0!==r&&r.includes(c)||!v.includes(c)?null!==B&&void 0!==B&&B.includes(c)||null===e||void 0===e||null===(o=e.unique_constraints)||void 0===o||!o.includes(c)||(e.unique_constraints=(0,pe.Od)(e.unique_constraints,(function(e){return c===e}))):e.unique_constraints=[c].concat(e.unique_constraints||[]),null===x||void 0===x||!x.includes(c)||null!==e&&void 0!==e&&null!==(l=e.bookmark_properties)&&void 0!==l&&l.includes(c)||!m.includes(c)?null!==x&&void 0!==x&&x.includes(c)||null===e||void 0===e||null===(u=e.bookmark_properties)||void 0===u||!u.includes(c)||(e.bookmark_properties=(0,pe.Od)(e.bookmark_properties,(function(e){return c===e}))):e.bookmark_properties=[c].concat(e.bookmark_properties||[]),null===E||void 0===E||!E.includes(c)||null!==e&&void 0!==e&&null!==(a=e.key_properties)&&void 0!==a&&a.includes(c)?null!==E&&void 0!==E&&E.includes(c)||null===e||void 0===e||null===(s=e.key_properties)||void 0===s||!s.includes(c)||(e.key_properties=(0,pe.Od)(e.key_properties,(function(e){return c===e}))):e.key_properties=[c].concat(e.key_properties||[]),null===w||void 0===w||!w.includes(c)||null!==e&&void 0!==e&&null!==(f=e.partition_keys)&&void 0!==f&&f.includes(c)?null!==w&&void 0!==w&&w.includes(c)||null===e||void 0===e||null===(p=e.partition_keys)||void 0===p||!p.includes(c)||(e.partition_keys=(0,pe.Od)(e.partition_keys,(function(e){return c===e}))):e.partition_keys=[c].concat(e.partition_keys||[])}return gr({},e)}))},pill:!0,secondary:!0,children:(0,S.jsx)(_.ZP,{success:U,children:U?"Applied!":"Apply"})}))}return N})),r=e.every((function(e){return e})),o=[null,2,1,null,null,null],c=[{label:function(){return(0,S.jsx)(b.Z,{checked:r,onClick:function(){h(D,n,{selected:!r})}})},uuid:"Selected"},{uuid:"Name"},{uuid:"Type"},{uuid:"Unique"},{uuid:"Bookmark"},{uuid:"Key prop"}];return ce&&(o.push(null),c.push({uuid:"Partition key"})),ue&&(o.push(null),c.push({tooltipMessage:"This will apply this individual feature's schema settings to all selected streams that have the same feature. Unique features must be valid key properties in other streams. Bookmark features must be valid replication keys in other streams.",uuid:"All streams"})),(0,S.jsx)(vr.cl,{children:(0,S.jsx)(mi.Z,{alignTop:!0,columnFlex:o,columns:c,rows:i,stickyHeader:!0})})}),[x,t,ue,K,E,te,w,A,ce,D,B,f,h,m,v,re,oe]);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(ui.Z,{condensed:!0,level:4,spacingBelow:!0,children:[(0,S.jsx)(ui.Z,{condensed:!0,inline:!0,level:4,monospace:!0,children:D})," schema"]}),(0,S.jsx)(Z.Z,{mb:3,children:(0,S.jsx)(R.Z,{headerTitle:"Output",overflowVisible:!0,children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(_.ZP,{children:"Destination table name"}),(0,S.jsx)(Z.Z,{ml:xr}),(0,S.jsx)(le.Z,{label:(0,S.jsxs)(_.ZP,{children:["By default, this stream will be saved to your destination under the table named ",(0,S.jsx)(_.ZP,{bold:!0,inline:!0,monospace:!0,children:D}),". To change the table name, enter in a different value."]}),lightBackground:!0,primary:!0}),(0,S.jsx)(Z.Z,{ml:1}),(0,S.jsx)(M.Z,{compact:!0,monospace:!0,onChange:function(e){var n=e.target.value;U(n),clearTimeout(g.current),g.current=setTimeout((function(){v(D,(function(e){return gr(gr({},e),{},{destination_table:n})}))}),300)},value:F||"",width:45*O.iI})]})})}),(0,S.jsx)(Z.Z,{mb:3,children:(0,S.jsx)(R.Z,{headerTitle:"Usage",overflowVisible:!0,children:(0,S.jsxs)(y.Z,{alignItems:"center",justifyContent:"space-between",children:[(0,S.jsxs)(j.Z,{alignItems:"center",children:[(0,S.jsx)(_.ZP,{children:"Replication method"}),(0,S.jsx)(Z.Z,{ml:xr}),(0,S.jsx)(le.Z,{label:(0,S.jsxs)(_.ZP,{children:["Do you want to synchronize the entire stream (",(0,S.jsx)(_.ZP,{bold:!0,inline:!0,monospace:!0,children:$i.FULL_TABLE}),") on each integration pipeline run or only new records (",(0,S.jsx)(_.ZP,{bold:!0,inline:!0,monospace:!0,children:$i.INCREMENTAL}),")?",u===dr.POSTGRESQL&&(0,S.jsxs)(_.ZP,{children:["Log-based incremental replication (",(0,S.jsx)(_.ZP,{bold:!0,inline:!0,monospace:!0,children:$i.LOG_BASED}),") is also available for PostgreSQL sources."]})]}),lightBackground:!0,primary:!0}),(0,S.jsx)(Z.Z,{ml:1}),(0,S.jsxs)(hi.Z,{compact:!0,onChange:function(e){v(D,(function(n){return gr(gr({},n),{},{replication_method:e.target.value})}))},primary:!0,value:T,children:[(0,S.jsx)("option",{value:""}),Object.values($i).filter((function(e){return u===dr.POSTGRESQL||e!==$i.LOG_BASED})).map((function(e){return(0,S.jsx)("option",{value:e,children:e},e)}))]}),(0,S.jsx)(Z.Z,{ml:3}),(0,S.jsx)(_.ZP,{children:"Unique conflict method"}),(0,S.jsx)(Z.Z,{ml:xr}),(0,S.jsx)(le.Z,{label:(0,S.jsxs)(_.ZP,{wordBreak:!0,children:["If a new record has the same value as an existing record in the ",(0,Q._6)("column",null===B||void 0===B?void 0:B.length),(null===B||void 0===B?void 0:B.length)>0&&(0,S.jsx)(S.Fragment,{children:"\xa0"}),null===B||void 0===B?void 0:B.sort().map((function(e,n){return(0,S.jsxs)(_.ZP,{bold:!0,inline:!0,monospace:!0,children:[1!==(null===B||void 0===B?void 0:B.length)&&n===(null===B||void 0===B?void 0:B.length)-1?(0,S.jsx)(_.ZP,{inline:!0,children:" and "},e):n>=1&&(0,S.jsx)(S.Fragment,{children:",\xa0"}),e]},e)})),", how do you want to resolve the conflict? The conflict method ",(0,S.jsx)(_.ZP,{bold:!0,inline:!0,monospace:!0,children:er.IGNORE})," will skip the new record if it\u2019s a duplicate of an existing record. The conflict method ",(0,S.jsx)(_.ZP,{bold:!0,inline:!0,monospace:!0,children:er.UPDATE})," will not save the new record and instead update the existing record with the new record\u2019s properties."]}),lightBackground:!0,primary:!0}),(0,S.jsx)(Z.Z,{ml:1}),(0,S.jsxs)(hi.Z,{compact:!0,inputWidth:11*O.iI,onChange:function(e){v(D,(function(n){return gr(gr({},n),{},{unique_conflict_method:e.target.value})}))},primary:!0,value:N,children:[(0,S.jsx)("option",{value:""}),(0,S.jsx)("option",{value:er.IGNORE,children:er.IGNORE}),(0,S.jsx)("option",{value:er.UPDATE,children:er.UPDATE})]})]}),ue&&(0,S.jsxs)(j.Z,{alignItems:"center",children:[(0,S.jsx)(_.ZP,{default:!0,children:"All streams"}),(0,S.jsx)(Z.Z,{ml:xr}),(0,S.jsx)(le.Z,{appearBefore:!0,label:(0,S.jsx)(_.ZP,{children:"This will apply this stream's replication method and unique conflict method settings to all selected streams."}),lightBackground:!0,primary:!0}),(0,S.jsx)(Z.Z,{ml:1}),(0,S.jsx)(I.Z,{compact:!0,disabled:G,onClick:function(){z(!0),setTimeout((function(){return z(!1)}),2e3),f((function(e){return gr(gr({},e),{},{replication_method:T,unique_conflict_method:N})}))},pill:!0,secondary:!0,children:(0,S.jsx)(_.ZP,{bold:!G,success:G,children:G?"Applied!":"Apply"})})]})]})})}),(0,S.jsx)(R.Z,{headerTitle:"Features",noPadding:!0,children:de}),(0,S.jsx)(Z.Z,{mt:2,children:(0,S.jsx)(I.Z,{loading:i,onClick:function(){return c(D)},primary:!0,small:!0,children:"Load sample data"})}),(0,S.jsxs)(Z.Z,{mt:5,children:[(0,S.jsx)(ui.Z,{condensed:!0,level:4,spacingBelow:!0,children:"Settings"}),$i.INCREMENTAL===T&&(0,S.jsxs)(Z.Z,{mb:5,children:[(0,S.jsxs)(Z.Z,{mb:1,children:[(0,S.jsx)(_.ZP,{bold:!0,large:!0,children:"Bookmark properties"}),(0,S.jsxs)(_.ZP,{default:!0,children:["After each integration pipeline run, the last record that was successfully synchronized will be used as the bookmark. The properties listed below will be extracted from the last record and used as the bookmark.",(0,S.jsx)("br",{}),"On the next run, the synchronization will start after the bookmarked record."]})]}),(0,S.jsxs)(y.Z,{alignItems:"center",flexWrap:"wrap",children:[!(null!==x&&void 0!==x&&x.length)&&(0,S.jsxs)(_.ZP,{italic:!0,children:["Click the checkbox under the column ",(0,S.jsx)(_.ZP,{bold:!0,inline:!0,italic:!0,children:"Bookmark"})," to use a specific column as a bookmark property."]}),null===x||void 0===x?void 0:x.sort().map((function(e){return(0,S.jsx)(Z.Z,{mb:1,mr:1,children:(0,S.jsx)(hr.Z,{label:e,onClick:function(){se(e),v(D,(function(n){return gr(gr({},n),{},{bookmark_properties:(0,pe.Od)(n.bookmark_properties||[],(function(n){return n===e}))})}))},primary:!0})},"bookmark_properties/".concat(e))}))]}),(null===x||void 0===x?void 0:x.length)>0&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Z.Z,{my:2,children:(0,S.jsxs)(y.Z,{alignItems:"center",justifyContent:"space-between",children:[(0,S.jsxs)(Z.Z,{mr:2,children:[(0,S.jsx)(_.ZP,{bold:!0,large:!0,children:"Manually edit bookmark property values"}),(0,S.jsx)(_.ZP,{default:!0,children:'In order to override the bookmark values for the next sync, you must first select a destination. Then click the toggle to edit the values for the bookmark properties in the table below. Click the "Save" button to save your changes.'})]}),(0,S.jsx)(mr.Z,{checked:Y,disabled:!t,onCheck:function(){return X((function(e){return!e}))}})]})}),Y&&!!t&&(0,S.jsx)(R.Z,{header:(0,S.jsxs)(y.Z,{alignItems:"center",justifyContent:"space-between",children:[(0,S.jsx)(_.ZP,{bold:!0,default:!0,children:"Bookmark property values"}),(0,S.jsx)(I.Z,{compact:!0,loading:r,onClick:function(){p({block:{bookmark_values:(null===$||void 0===$?void 0:$[D])||{},destination_table:F,tap_stream_id:D}})},pill:!0,secondary:!0,children:"Save"})]}),headerPaddingVertical:O.iI,noPadding:!0,overflowVisible:!0,children:(0,S.jsx)(mi.Z,{columnBorders:!0,columnFlex:[null,1],columns:[{uuid:"Bookmark property"},{uuid:"Value"}],rows:x.map((function(e){var n;return[(0,S.jsx)(_.ZP,{default:!0,monospace:!0,children:e},e),(0,S.jsx)(M.Z,{borderless:!0,monospace:!0,onChange:function(n){n.preventDefault(),ee((function(t){return gr(gr({},t),{},(0,o.Z)({},D,gr(gr({},t[D]),{},(0,o.Z)({},e,n.target.value))))}))},paddingHorizontal:0,placeholder:"Enter value",value:null===$||void 0===$||null===(n=$[D])||void 0===n?void 0:n[e]},"".concat(e,"_value"))]}))})})]})]}),(0,S.jsxs)(Z.Z,{mb:5,children:[(0,S.jsxs)(Z.Z,{mb:1,children:[(0,S.jsx)(_.ZP,{bold:!0,large:!0,children:"Unique constraints"}),(0,S.jsx)(_.ZP,{default:!0,children:"Multiple records (e.g. 2 or more) with the same values in the columns listed below will be considered duplicates."})]}),(0,S.jsxs)(y.Z,{alignItems:"center",flexWrap:"wrap",children:[!(null!==B&&void 0!==B&&B.length)&&(0,S.jsxs)(_.ZP,{italic:!0,children:["Click the checkbox under the column ",(0,S.jsx)(_.ZP,{bold:!0,inline:!0,italic:!0,children:"Unique"})," to use a specific column as a unique constraint."]}),null===B||void 0===B?void 0:B.sort().map((function(e){return(0,S.jsx)(Z.Z,{mb:1,mr:1,children:(0,S.jsx)(hr.Z,{label:e,onClick:function(){v(D,(function(n){return gr(gr({},n),{},{unique_constraints:(0,pe.Od)(n.unique_constraints||[],(function(n){return n===e}))})}))},primary:!0})},"unique_constraints/".concat(e))}))]})]}),(0,S.jsxs)(Z.Z,{mb:5,children:[(0,S.jsxs)(Z.Z,{mb:1,children:[(0,S.jsx)(_.ZP,{bold:!0,large:!0,children:"Key properties"}),(0,S.jsx)(_.ZP,{default:!0,children:"Key properties are used as the primary key for the destination table."})]}),(0,S.jsxs)(y.Z,{alignItems:"center",flexWrap:"wrap",children:[!(null!==E&&void 0!==E&&E.length)&&(0,S.jsxs)(_.ZP,{italic:!0,children:["Click the checkbox under the column ",(0,S.jsx)(_.ZP,{bold:!0,inline:!0,italic:!0,children:"Key prop"})," to use a specific column as a key property."]}),null===E||void 0===E?void 0:E.sort().map((function(e){return(0,S.jsx)(Z.Z,{mb:1,mr:1,children:(0,S.jsx)(hr.Z,{label:e,onClick:function(){v(D,(function(n){return gr(gr({},n),{},{key_properties:(0,pe.Od)(n.key_properties||[],(function(n){return n===e}))})}))},primary:!0})},"key_properties/".concat(e))}))]})]}),ce&&(0,S.jsxs)(Z.Z,{mb:3,children:[(0,S.jsxs)(Z.Z,{mb:1,children:[(0,S.jsx)(_.ZP,{bold:!0,large:!0,children:"Partition keys"}),(0,S.jsx)(_.ZP,{default:!0,children:"One datetime column can be used to partition the table. (Note: Partition keys currently only work with BigQuery destinations. Support for other destinations is WIP.)"})]}),(0,S.jsxs)(y.Z,{alignItems:"center",flexWrap:"wrap",children:[!(null!==w&&void 0!==w&&w.length)&&(0,S.jsxs)(_.ZP,{italic:!0,children:["Click the checkbox under the column ",(0,S.jsx)(_.ZP,{bold:!0,inline:!0,italic:!0,children:"Partition key"})," to use a specific column as a partition key."]}),null===w||void 0===w?void 0:w.sort().map((function(e){return(0,S.jsx)(Z.Z,{mb:1,mr:1,children:(0,S.jsx)(hr.Z,{label:e,onClick:function(){v(D,(function(n){return gr(gr({},n),{},{partition_keys:(0,pe.Od)(n.partition_keys||[],(function(n){return n===e}))})}))},primary:!0})},"key_properties/".concat(e))}))]})]})]})]})},kr=["catalog","pipeline","setErrors","setSelectedStream"];function Zr(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function _r(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Zr(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Zr(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var Or=function(e){var n,t=e.catalog,i=e.pipeline,r=e.setErrors,o=e.setSelectedStream,c=(0,$t.Z)(e,kr),u=(0,s.useState)(null),a=u[0],f=u[1],p=(0,s.useMemo)((function(){return(null===t||void 0===t?void 0:t.streams)||[]}),[t]),h=(0,s.useMemo)((function(){return(0,pe.YC)(p,"stream").map((function(e){return{uuid:e.stream}}))}),[p]),v=(0,s.useMemo)((function(){return(0,pe.HK)(p,(function(e){return e.stream}))}),[p]),b=(0,s.useMemo)((function(){return v[null===a||void 0===a?void 0:a.uuid]}),[a,v]),g=(0,s.useMemo)((function(){return(0,pe.sE)((null===i||void 0===i?void 0:i.blocks)||[],(function(e){var n=e.type;return m.tf.DATA_EXPORTER===n}))}),[null===i||void 0===i?void 0:i.blocks]),x=b||{},j=x.destination_table,y=x.tap_stream_id,k=!(!y||!j),O=ce.ZP.blocks.pipelines.detail(k?null===i||void 0===i?void 0:i.uuid:null,k?null===g||void 0===g?void 0:g.uuid:null,{destination_table:j,state_stream:y}),C=O.data,E=O.mutate,P=null===C||void 0===C||null===(n=C.block)||void 0===n?void 0:n.bookmarks,w=(0,d.Db)(ce.ZP.blocks.pipelines.useUpdate(null===i||void 0===i?void 0:i.uuid,null===g||void 0===g?void 0:g.uuid,{query:{update_state:!0}}),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(){null===E||void 0===E||E()},onErrorCallback:function(e,n){return null===r||void 0===r?void 0:r({errors:n,response:e})}})}}),I=(0,l.Z)(w,2),A=I[0],R=I[1].isLoading;(0,s.useEffect)((function(){h.length>0&&(a&&(0,pe.sE)(h,(function(e){var n=e.uuid;return a.uuid===n}))||f(h[0]))}),[a,f,h]);var D=(0,s.useMemo)((function(){var e=[{uuid:"Stream"},{uuid:"Columns Selected"},{uuid:"Replication Method"},{uuid:"Destination Table"},{uuid:"Bookmark Props"},{uuid:"Key Props"},{uuid:"Unique Constraints"},{uuid:"Unique Conflict Method"},{uuid:"Partition Keys"}];return(0,S.jsx)(vr.cl,{children:(0,S.jsx)(mi.Z,{alignTop:!0,columnBorders:!0,columnFlex:e.map((function(e){return 1})),columns:e,rows:p.map((function(e){var n=e.replication_method,t=e.destination_table,i=e.bookmark_properties,r=e.key_properties,o=e.metadata,l=e.unique_constraints,c=e.unique_conflict_method,u=e.partition_keys,a=e.tap_stream_id,s=o.reduce((function(e,n){var t=n.breadcrumb,i=n.metadata.selected,r=(null===t||void 0===t?void 0:t.length)>0,o=i&&r?1:0,l=r?1:0;return{selectedCount:e.selectedCount+o,totalCount:e.totalCount+l}}),{selectedCount:0,totalCount:0}),d=(0,S.jsx)(_.ZP,{children:"".concat(s.selectedCount," of ").concat(s.totalCount," total")},"".concat(a,"_col_selected")),f=[a,n,t,i,r,l,c,u].map((function(e,n){return(0,S.jsx)(_.ZP,{bold:0===n,children:Array.isArray(e)?e.sort().join(", "):e},"".concat(a,"_cell_").concat(n))}));return f.slice(0,1).concat(d).concat(f.slice(1))})),stickyFirstColumn:!0,stickyHeader:!0,wrapColumns:!0})})}),[p]);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(T.Z,{allowScroll:!0,noPadding:!0,onClickTab:function(e){f(e),o(e.uuid)},selectedTabUUID:null===a||void 0===a?void 0:a.uuid,tabs:h}),b&&(0,S.jsx)(Z.Z,{mt:1,children:(0,S.jsx)(vr.dE,{children:(0,S.jsx)(yr,_r(_r({},c),{},{bookmarkValues:P,isLoadingUpdateDestinationBlockState:R,stream:b,streams:p,updateDestinationBlockState:A}))})}),p.length>=1&&(0,S.jsx)(Z.Z,{mt:1,children:(0,S.jsxs)(vr.dE,{children:[(0,S.jsx)(ui.Z,{level:4,children:"Streams Summary"}),(0,S.jsx)(Z.Z,{mt:1}),D]})})]})},Cr=v.default.div.withConfig({displayName:"indexstyle__PanelStyle",componentId:"sc-1rfr5wd-0"})(["border-radius:","px;"," ",""],Te.n_,(function(e){return"\n background-color: ".concat((e.theme.background||ue.Z.background).panel,";\n ")}),(function(e){return e.fullWidth&&"\n width: 100%;\n "}));var Sr,Er=function(e){var n=e.children,t=e.fullWidth,i=void 0===t||t;return(0,S.jsx)(Cr,{fullWidth:i,children:n})};function Pr(e){return Object.values(e).filter((function(e){return null!==e})).map((function(e){return e.tap_stream_id}))}function wr(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Ir(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?wr(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):wr(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}!function(e){e.ALL="All",e.SELECTED="Selected",e.NOT_SELECTED="Not selected"}(Sr||(Sr={}));var Tr=45*O.iI;var Ar=function(e){var n=e.catalog,t=e.isLoading,i=e.onActionCallback,r=e.streams,l=(0,pe.HK)((null===n||void 0===n?void 0:n.streams)||[],(function(e){return e.stream})),c=(0,s.useMemo)((function(){var e=new Set(r.map((function(e){return e.stream})));return Object.values(l).filter((function(n){var t=n.stream;return!e.has(t)})).map((function(e){return Ir(Ir({},e),{},{isMissingStream:!0})}))}),[l,r]),u=Ir({},l);c.forEach((function(e){var n=e.stream;delete u[n]}));var a=(0,s.useState)(u),d=a[0],f=a[1],p=(0,s.useState)(null),h=p[0],m=p[1],v=(0,s.useState)(!1),g=v[0],j=v[1],k=(0,s.useState)(Sr.ALL),C=k[0],E=k[1],P=(0,s.useRef)(null),w=Pr(d),T=(0,s.useMemo)((function(){var e=r;return e=e.filter((function(e){var n=e.tap_stream_id;return C===Sr.SELECTED?w.includes(n):C!==Sr.NOT_SELECTED||!w.includes(n)})),h?e.filter((function(e){var n=e.tap_stream_id;return null===n||void 0===n?void 0:n.toLowerCase().includes(null===h||void 0===h?void 0:h.toLowerCase())})):e}),[C,h,w,r]),A=(0,s.useMemo)((function(){return r.every((function(e){var n=e.stream;return!!d[n]}))}),[d,r]);return(0,S.jsxs)(Er,{children:[(0,S.jsx)(vr.cv,{rounded:!0,children:(0,S.jsx)(_.ZP,{bold:!0,large:!0,children:"Select streams to sync"})}),(0,S.jsx)(vr.cv,{padding:1.25*O.iI,children:(0,S.jsxs)(y.Z,{alignItems:"center",justifyContent:"space-between",children:[(0,S.jsx)(M.Z,{beforeIcon:(0,S.jsx)(se.HN,{}),compact:!0,noBackground:!0,noBorder:!0,onChange:function(e){return m(e.target.value)},placeholder:"Search",value:h}),(0,S.jsx)(Z.Z,{pr:1,children:(0,S.jsx)(we.Z,{items:[{label:function(){return Sr.ALL},onClick:function(){return E(Sr.ALL)},uuid:"all_streams"},{label:function(){return Sr.SELECTED},onClick:function(){return E(Sr.SELECTED)},uuid:"selected"},{label:function(){return Sr.NOT_SELECTED},onClick:function(){return E(Sr.NOT_SELECTED)},uuid:"unselected"}],onClickCallback:function(){return j(!1)},onClickOutside:function(){return j(!1)},open:g,parentRef:P,uuid:"SelectStreams/filter",children:(0,S.jsx)(I.Z,{beforeIcon:(0,S.jsx)(se.wn,{}),noBackground:!0,onClick:function(){return j((function(e){return!e}))},ref:P,children:(0,S.jsx)(_.ZP,{children:C})})})})]})}),(0,S.jsx)(vr.cl,{height:"55vh",hideHorizontalScrollbar:!0,width:"".concat(Tr,"px"),children:(0,S.jsx)(mi.Z,{borderCollapseSeparate:!0,columnFlex:[1,6],columns:[{label:function(){return(0,S.jsx)(b.Z,{checked:A,onClick:function(){var e=(0,pe.HK)(r||[],(function(e){return e.stream}));f(A?{}:e)}})},uuid:"Selected"},{uuid:"Stream name"}],rows:T.concat(c).map((function(e){var n=e.isMissingStream,t=e.stream,i=!!d[t];return[(0,S.jsx)(b.Z,{checked:i,disabled:!i&&n,onClick:function(){f((function(n){return Ir(Ir({},n),{},(0,o.Z)({},t,i?null:e))}))}},"selected-".concat(t)),(0,S.jsxs)(_.ZP,{danger:n,title:t,width:Tr-48-32,children:[t,n?" (no longer available)":""]},"stream-".concat(t))]})),stickyHeader:!0})}),(0,S.jsx)(x.Z,{medium:!0}),(0,S.jsxs)(Z.Z,{p:2,children:[(null===w||void 0===w?void 0:w.length)>50&&(0,S.jsx)(Z.Z,{pb:2,children:(0,S.jsxs)(_.ZP,{danger:!0,maxWidth:Tr-4*O.iI,rightAligned:!0,whiteSpaceNormal:!0,children:["WARNING: Selecting too many streams (e.g. >50)",(0,S.jsx)("br",{}),"may cause app performance issues."]})}),(0,S.jsx)(y.Z,{justifyContent:"flex-end",children:(0,S.jsx)(I.Z,{loading:t,onClick:function(){return i(d)},primary:!0,children:"Confirm ".concat(Pr(d).length," streams")})})]})]})};function Rr(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Dr(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Rr(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Rr(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var Mr=function(e){var n=e.api,t=e.block,i=e.blockContent,r=e.onChangeCodeBlock,c=e.pipeline,u=(0,s.useState)(null),a=u[0],f=u[1];(0,s.useEffect)((function(){i&&!a&&f((0,ir.Pz)(null===i||void 0===i?void 0:i.config))}),[a,i]);var p=(0,s.useState)(null),h=p[0],v=p[1],b=(0,s.useState)(),g=b[0],x=b[1],j=(0,d.Db)(ce.ZP[n].useCreate(),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(e){var t,i,r=(0,Q.C5)(n);v(null===e||void 0===e||null===(t=e[r])||void 0===t?void 0:t.success),x(null===e||void 0===e||null===(i=e[r])||void 0===i?void 0:i.error_message)},onErrorCallback:function(e){var n=e.error,t=n.errors,i=n.message;console.log(t,i)}})}}),k=(0,l.Z)(j,2),O=k[0],C=k[1].isLoading;return t?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(vr.$W,{children:(0,S.jsx)(hn.Z,{autoHeight:!0,language:m.t6.YAML,onChange:function(e){f(e),r(t.type,t.uuid,(0,ir.Pz)(Dr(Dr({},i),{},{config:(0,ir.Qc)(e)})))},tabSize:2,value:a||void 0,width:"100%"})}),(0,S.jsxs)(Z.Z,{mt:1,children:[(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(I.Z,{onClick:function(){O((0,o.Z)({},(0,Q.C5)(n),{action_type:"test_connection",config:a,pipeline_uuid:c.uuid})),x(null)},small:!0,success:!0,children:"Test connection"}),(0,S.jsx)(Z.Z,{ml:1,children:C?(0,S.jsx)(qt.Z,{color:"white",small:!0}):(0,S.jsxs)(S.Fragment,{children:[h&&(0,S.jsx)(_.ZP,{small:!0,success:!0,children:"Connected successfully!"}),!1===h&&(0,S.jsx)(_.ZP,{small:!0,warning:!0,children:"Failed to connect, see error below."})]})})]}),g&&(0,S.jsx)(Z.Z,{mt:1,children:(0,S.jsx)(_.ZP,{small:!0,warning:!0,children:g})})]})]}):null};function Br(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Nr(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Br(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Br(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var Lr=function(e){var n,t,i,r=e.addNewBlockAtIndex,o=e.blocks,c=e.codeBlocks,u=e.fetchFileTree,a=e.fetchPipeline,f=e.fetchSampleData,p=e.globalVariables,h=e.onChangeCodeBlock,v=e.openSidekickView,b=e.pipeline,g=e.savePipelineContent,x=e.setErrors,j=e.setIntegrationStreams,C=e.setOutputBlocks,E=e.setSelectedBlock,P=e.setSelectedOutputBlock,w=e.setSelectedStream,T=(0,s.useState)(!0),A=T[0],R=T[1],D=(0,s.useState)(!0),M=D[0],B=D[1],N=(0,s.useState)(!0),L=N[0],F=N[1],U=ce.ZP.integration_sources.list({},{revalidateOnFocus:!1}).data,H=(0,s.useMemo)((function(){return(null===U||void 0===U?void 0:U.integration_sources)||[]}),[U]),G=(0,s.useMemo)((function(){return(0,pe.HK)(H,(function(e){return e.uuid}))}),[H]),z=ce.ZP.integration_destinations.list({},{revalidateOnFocus:!1}).data,q=(0,s.useMemo)((function(){return(null===z||void 0===z?void 0:z.integration_destinations)||[]}),[z]),K=(0,s.useMemo)((function(){return(0,pe.HK)(q,(function(e){return e.uuid}))}),[q]),W=(0,s.useMemo)((function(){return(0,pe.sE)(o,(function(e){var n=e.type;return m.tf.DATA_LOADER===n}))}),[o]),Q=(0,s.useMemo)((function(){return W?(0,ir.Qc)(W.content):{}}),[W]),V=(0,s.useMemo)((function(){return(0,S.jsx)(Mr,{api:"integration_sources",block:W,blockContent:Q,onChangeCodeBlock:h,pipeline:b})}),[W,Q,h,b]),Y=(0,s.useMemo)((function(){return(0,pe.sE)(o,(function(e){var n=e.type;return m.tf.DATA_EXPORTER===n}))}),[o]),X=(0,s.useMemo)((function(){return Y?(0,ir.Qc)(Y.content):{}}),[Y]),J=(0,s.useMemo)((function(){return(0,S.jsx)(Mr,{api:"integration_destinations",block:Y,blockContent:X,onChangeCodeBlock:h,pipeline:b})}),[Y,X,h,b]),$=(0,s.useMemo)((function(){return(0,pe.sE)(o,(function(e){var n=e.type;return m.tf.TRANSFORMER===n}))}),[o]),ee=(0,s.useMemo)((function(){var e;return(0,Ii.Qr)(null===Q||void 0===Q?void 0:Q.catalog)?null===b||void 0===b||null===(e=b.data_integration)||void 0===e?void 0:e.catalog:null===Q||void 0===Q?void 0:Q.catalog}),[Q,null===b||void 0===b||null===(n=b.data_integration)||void 0===n?void 0:n.catalog]),ne=((null===ee||void 0===ee?void 0:ee.streams)||[]).every((function(e){return e.auto_add_new_fields})),te=((null===ee||void 0===ee?void 0:ee.streams)||[]).every((function(e){return e.disable_column_type_check})),ie=(0,ae.Z)(ee);(0,s.useEffect)((function(){!ie&&ee&&(C((function(){return P(W),[W]})),j((function(e){var n;return e||(null===ee||void 0===ee||null===(n=ee.streams)||void 0===n?void 0:n.map((function(e){return e.tap_stream_id})))})))}),[ee]);var re=(0,s.useState)(),oe=re[0],le=re[1],ue=(0,d.Db)(ce.ZP.integration_sources.useCreate(),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(e){var n=e.integration_source;if(n.success){var t=(null===n||void 0===n?void 0:n.streams)||[];C((function(){return P(W),[W]})),t.length>0&&w(t[0]),j((function(e){var n=(e||[]).concat(t);return Array.from(new Set(n)).sort()})),v(fn.cH.DATA),f()}else le(null===n||void 0===n?void 0:n.error_message)},onErrorCallback:function(e,n){return x({errors:n,response:e})}})}}),de=(0,l.Z)(ue,2),fe=de[0],he=de[1].isLoading,be=(0,d.Db)(ce.ZP.integration_sources.useUpdate(null===b||void 0===b?void 0:b.uuid),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(e){var n=e.integration_source,t=n.selected_streams,i=n.streams,r=((null===ee||void 0===ee?void 0:ee.streams)||[]).filter((function(e){var n=e.tap_stream_id;return t.includes(n)})),o=r.map((function(e){return e.tap_stream_id})),l=i.filter((function(e){var n=e.tap_stream_id;return t.includes(n)&&!o.includes(n)}));l.forEach((function(e){e.metadata.forEach((function(n,t){var i=n.metadata;if(ar.UNSUPPORTED!==i.inclusion){var r;if(e.replication_method||(e.replication_method=$i.FULL_TABLE),e.unique_conflict_method||(e.unique_conflict_method=er.UPDATE),!e.destination_table)e.destination_table=null===e||void 0===e||null===(r=e.tap_stream_id)||void 0===r?void 0:r.replace(/\W+/g,"_");e.metadata[t]=Nr(Nr({},n),{},{metadata:Nr(Nr({},i),{},{selected:!0})})}}))}));var c={streams:r.concat(l)};j(Me.map((function(e){return e.tap_stream_id})));var s=null===Q||void 0===Q?void 0:Q.catalog;(0,Ii.Qr)(s)||h(W.type,W.uuid,(0,ir.Pz)(Nr(Nr({},Q),{},{catalog:{}})));var d={pipeline:Nr(Nr({},b),{},{data_integration:Nr(Nr({},(null===b||void 0===b?void 0:b.data_integration)||{}),{},{catalog:c})})};g(d).then((function(){a(),u()}))},onErrorCallback:function(e,n){return x({errors:n,response:e})}})}}),ge=(0,l.Z)(be,2),xe=ge[0],je=ge[1].isLoading,ye=(0,s.useState)(null),ke=ye[0],Ze=ye[1],_e=(0,d.Db)(ce.ZP.integration_source_streams.useUpdate(null===b||void 0===b?void 0:b.uuid),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(e){Ze(e.integration_source_stream)},onErrorCallback:function(e,n){return x({errors:n,response:e})}})}}),Oe=(0,l.Z)(_e,2),Ce=Oe[0],Se=Oe[1].isLoading,Ee=(0,s.useCallback)((function(e,n){var t=function(e,n){var t,i=[];return e.streams.forEach((function(e){e.tap_stream_id===n?t=e:i.push(e)})),{stream:t,streams:i}}(ee,e),i=t.stream,r=t.streams,o=Nr(Nr({},ee),{},{streams:r.concat(n(i))}),l=null===Q||void 0===Q?void 0:Q.catalog;(0,Ii.Qr)(l)||h(W.type,W.uuid,(0,ir.Pz)(Nr(Nr({},Q),{},{catalog:{}})));var c={pipeline:Nr(Nr({},b),{},{data_integration:Nr(Nr({},(null===b||void 0===b?void 0:b.data_integration)||{}),{},{catalog:o})})};g(c).then((function(){return a()}))}),[ee,W,Q,a,h,b,g]),Pe=(0,s.useCallback)((function(e){if(null!==ee&&void 0!==ee&&ee.streams){var n=Nr(Nr({},ee),{},{streams:ee.streams.map((function(n){return e(n)}))}),t=null===Q||void 0===Q?void 0:Q.catalog;(0,Ii.Qr)(t)||h(W.type,W.uuid,(0,ir.Pz)(Nr(Nr({},Q),{},{catalog:{}})));var i={pipeline:Nr(Nr({},b),{},{data_integration:Nr(Nr({},(null===b||void 0===b?void 0:b.data_integration)||{}),{},{catalog:n})})};g(i).then((function(){return a()}))}}),[ee,W,Q,a,h,b,g]),we=(0,s.useCallback)((function(e,n,t){Ee(e,(function(e){return e.schema.properties[n]=t,e}))}),[Ee]),Ie=(0,s.useCallback)((function(e,n,t){Ee(e,(function(e){var i=e.metadata;return n.forEach((function(n){var r=i.findIndex((function(e){var t=e.breadcrumb,i=void 0===t?[]:t;return 2===i.length&&"properties"===i[0]&&i[1]===n}));if(r>=0){var o=i[r].metadata;e.metadata[r].metadata=Nr(Nr({},o),t)}})),e}))}),[Ee]),Te=(0,d.Db)(ce.ZP.blocks.pipelines.useUpdate(null===b||void 0===b?void 0:b.uuid,null===Y||void 0===Y?void 0:Y.uuid),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(){null===a||void 0===a||a()},onErrorCallback:function(e,n){return null===x||void 0===x?void 0:x({errors:n,response:e})}})}}),Ae=(0,l.Z)(Te,1)[0],Re=(0,s.useMemo)((function(){var e=[];return null===p||void 0===p||p.forEach((function(n){var t=n.variables;return null===t||void 0===t?void 0:t.forEach((function(n){var t=n.uuid,i=n.value,r="\"{{ variables('".concat(t,"') }}\"");if(!t.startsWith("output"))return e.push([(0,S.jsx)(_.ZP,{monospace:!0,children:t},"variable-uuid-".concat(t)),(0,S.jsx)(_.ZP,{monospace:!0,children:i},"variable-uuid-".concat(t,"-{value}")),(0,S.jsx)(_.ZP,{monospace:!0,children:r},"variable-uuid-".concat(t,"-{value}-code")),(0,S.jsx)(rr.Z,{copiedText:r,monospace:!0,withCopyIcon:!0},"variable-uuid-".concat(t,"-{value}-code-copy"))])}))})),(0,S.jsx)(mi.Z,{alignTop:!0,columnFlex:[null,null,1],columns:[{uuid:"Key"},{uuid:"Value"},{uuid:"Code"}],rows:e})}),[p]),De=(0,s.useCallback)((function(e){return(0,S.jsxs)(Z.Z,{mt:2,children:[(0,S.jsxs)(_.ZP,{default:!0,children:["Use the following variables to interpolate sensitive or dynamic information into the configuration.",(0,S.jsx)("br",{}),"You can also access values from your environment variables by using the following syntax: ",(0,S.jsx)(_.ZP,{inline:!0,monospace:!0,children:"\"{{ env_var('MY_ENV_VARIABLE_NAME') }}\""}),(0,S.jsx)("br",{}),"For more information, check out the ",(0,S.jsx)(k.Z,{href:e,openNewWindow:!0,primary:!0,children:"documentation"}),"."]}),(0,S.jsx)(Z.Z,{mt:1,children:Re})]})}),[Re]),Me=(0,s.useMemo)((function(){return(null===ke||void 0===ke?void 0:ke.streams)||[]}),[ke]),Be=(0,ve.dd)((function(){return(0,S.jsx)(Ar,{catalog:ee,isLoading:je,onActionCallback:function(e){var n=Object.entries(e).reduce((function(e,n){var t=(0,l.Z)(n,2),i=t[0];return t[1]?e.concat(i):e}),[]);if(n.length>0)xe({integration_source:{streams:n}}),Fe();else{var t=null===Q||void 0===Q?void 0:Q.catalog;(0,Ii.Qr)(t)||h(W.type,W.uuid,(0,ir.Pz)(Nr(Nr({},Q),{},{catalog:{}}))),g({pipeline:Nr(Nr({},b),{},{data_integration:Nr(Nr({},(null===b||void 0===b?void 0:b.data_integration)||{}),{},{catalog:null})})}).then((function(){return a()})),Fe()}},streams:Me})}),{},[ee,W,Q,a,je,h,g,Me],{background:!0,uuid:"select_streams"}),Ne=(0,l.Z)(Be,2),Le=Ne[0],Fe=Ne[1];return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Z.Z,{mb:1,children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(I.Z,{iconOnly:!0,onClick:function(){return B((function(e){return!e}))},children:(0,S.jsxs)(S.Fragment,{children:[M&&(0,S.jsx)(se.Kh,{size:1.5*O.iI}),!M&&(0,S.jsx)(se._M,{size:1.5*O.iI})]})}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(ui.Z,{children:"Source"}),!M&&(0,S.jsxs)(ui.Z,{default:!0,inline:!0,children:["\xa0",null===(t=G[null===Q||void 0===Q?void 0:Q.source])||void 0===t?void 0:t.name]})]})]})}),M&&(0,S.jsxs)(Z.Z,{mb:5,children:[(0,S.jsxs)(vr.dE,{children:[(0,S.jsxs)(Z.Z,{mb:5,children:[(0,S.jsx)(ui.Z,{condensed:!0,level:4,spacingBelow:!0,children:"Select source"}),(null===H||void 0===H?void 0:H.length)>0?(0,S.jsxs)(hi.Z,{onChange:function(e){var n,t,i=e.target.value;if(i){var o=null===(n=G[i])||void 0===n||null===(t=n.templates)||void 0===t?void 0:t.config;o&&Object.keys(o).forEach((function(e){o[e]=o[e]||null})),W?h(W.type,W.uuid,(0,ir.Pz)(Nr(Nr({},Q),{},{catalog:{},config:o,source:i}))):r({content:(0,ir.Pz)({config:o,source:i}),language:m.t6.YAML,type:m.tf.DATA_LOADER},0,E),Ze(null),g().then((function(){a()}))}},primary:!0,value:null===Q||void 0===Q?void 0:Q.source,children:[(0,S.jsx)("option",{value:""}),H.map((function(e){var n=e.name,t=e.uuid;return(0,S.jsx)("option",{value:t,children:n},t)}))]}):(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(qt.Z,{inverted:!0}),(0,S.jsx)(Z.Z,{ml:1}),(0,S.jsx)(ui.Z,{level:5,primary:!0,children:"Loading sources..."})]})]}),W&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(Z.Z,{mb:5,children:[(0,S.jsx)(ui.Z,{condensed:!0,level:4,spacingBelow:!0,children:"Configuration"}),(null===Q||void 0===Q?void 0:Q.source)&&(0,S.jsxs)(Z.Z,{mb:2,children:[(0,S.jsxs)(_.ZP,{default:!0,children:["For more information on how to configure this source, read the ",(0,S.jsxs)(k.Z,{href:"https://github.com/mage-ai/mage-ai/blob/master/mage_integrations/mage_integrations/sources/".concat(Q.source,"/README.md"),openNewWindow:!0,primary:!0,children:[Q.source," documentation"]})]}),De("https://docs.mage.ai/guides/data-integration-pipeline#configure-source")]}),V]}),(0,S.jsxs)("div",{children:[(0,S.jsx)(ui.Z,{condensed:!0,level:4,spacingBelow:!0,children:"Select stream"}),(0,S.jsx)(I.Z,{loading:Se,onClick:function(){g().then((function(){Ce().then((function(){return Le()})),a()}))},primary:!0,small:!0,children:"View and select streams"})]}),oe&&(0,S.jsx)(_.ZP,{warning:!0,children:oe})]})]}),je&&(0,S.jsx)(Z.Z,{p:2,children:(0,S.jsx)(qt.Z,{})}),!je&&(0,S.jsx)(Z.Z,{mt:3,children:(0,S.jsx)(Or,{catalog:ee,destination:null===X||void 0===X?void 0:X.destination,isLoadingLoadSampleData:he,loadSampleData:function(e){return fe({integration_source:{action_type:"sample_data",pipeline_uuid:null===b||void 0===b?void 0:b.uuid,streams:[e]}})},pipeline:b,setErrors:x,setSelectedStream:w,source:null===Q||void 0===Q?void 0:Q.source,updateAllStreams:Pe,updateMetadataForColumns:Ie,updateSchemaProperty:we,updateStream:Ee})})]}),(0,S.jsx)(Z.Z,{mb:1,children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(I.Z,{disabled:!W,iconOnly:!0,onClick:function(){return F((function(e){return!e}))},children:(0,S.jsxs)(S.Fragment,{children:[L&&W&&(0,S.jsx)(se.Kh,{size:1.5*O.iI}),(!L||!W)&&(0,S.jsx)(se._M,{disabled:!W,size:1.5*O.iI})]})}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(y.Z,{alignItems:"center",children:(0,S.jsx)(ui.Z,{children:"Transformers"})})]})}),L&&W&&(0,S.jsx)(Z.Z,{mb:5,children:(0,S.jsxs)(vr.dE,{children:[c.length>0&&(0,S.jsx)(Z.Z,{mb:1,children:c.map((function(e,n){return(0,S.jsx)(Z.Z,{mb:1,children:e},n)}))}),(0,S.jsx)(Z.Z,{mt:1,children:(0,S.jsx)(un,{addNewBlock:function(e){var n=e.content,t=e.configuration,i=[];return W&&i.push(W.uuid),r(Nr(Nr({},e),{},{configuration:t,content:n,upstream_blocks:i}),o.length-1,(function(e){Y&&(Ae({block:Nr(Nr({},Y),{},{upstream_blocks:[e.uuid]})}),E(e))}))},compact:!0,hideCustom:!0,hideDataExporter:!0,hideDataLoader:!0,hideDbt:!0,hideMarkdown:!0,hideScratchpad:!0,hideSensor:!0,hideTransformer:!!$,hideTransformerDataSources:!0,pipeline:b})})]})}),(0,S.jsx)(Z.Z,{mb:1,children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(I.Z,{disabled:!W,iconOnly:!0,onClick:function(){return R((function(e){return!e}))},children:(0,S.jsxs)(S.Fragment,{children:[A&&W&&(0,S.jsx)(se.Kh,{size:1.5*O.iI}),(!A||!W)&&(0,S.jsx)(se._M,{disabled:!W,size:1.5*O.iI})]})}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(ui.Z,{children:"Destination"}),!A&&(0,S.jsxs)(ui.Z,{default:!0,inline:!0,children:["\xa0",null===(i=K[null===X||void 0===X?void 0:X.destination])||void 0===i?void 0:i.name]})]})]})}),A&&W&&(0,S.jsxs)(vr.dE,{children:[(0,S.jsxs)(Z.Z,{mb:5,children:[(0,S.jsx)(ui.Z,{condensed:!0,level:4,spacingBelow:!0,children:"Select destination"}),(null===q||void 0===q?void 0:q.length)>0?(0,S.jsxs)(hi.Z,{onChange:function(e){var n=e.target.value;if(n){if(Y)h(Y.type,Y.uuid,(0,ir.Pz)(Nr(Nr({},X),{},{destination:n})));else{var t,i,l=null===(t=K[n])||void 0===t||null===(i=t.templates)||void 0===i?void 0:i.config;l&&(Object.keys(l).forEach((function(e){l[e]=l[e]||null})),l.hasOwnProperty("table")&&delete l.table);var c=[];if((null===o||void 0===o?void 0:o.length)>=2){var u=o.find((function(e){var n=e.uuid;return(null===W||void 0===W?void 0:W.uuid)!==n}));u&&c.push(u.uuid)}else W&&c.push(W.uuid);r({content:(0,ir.Pz)({config:l,destination:n}),language:m.t6.YAML,type:m.tf.DATA_EXPORTER,upstream_blocks:c},1,E)}g().then((function(){a()}))}},primary:!0,value:null===X||void 0===X?void 0:X.destination,children:[(0,S.jsx)("option",{value:""}),q.map((function(e){var n=e.name,t=e.uuid;return(0,S.jsx)("option",{value:t,children:n},t)}))]}):(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(qt.Z,{inverted:!0}),(0,S.jsx)(Z.Z,{ml:1}),(0,S.jsx)(ui.Z,{level:5,primary:!0,children:"Loading destinations..."})]})]}),Y&&(0,S.jsxs)(Z.Z,{mb:5,children:[(0,S.jsx)(ui.Z,{condensed:!0,level:4,spacingBelow:!0,children:"Configuration"}),(null===X||void 0===X?void 0:X.destination)&&(0,S.jsx)(S.Fragment,{children:(0,S.jsxs)(Z.Z,{mb:2,children:[(0,S.jsxs)(_.ZP,{default:!0,children:["For more information on how to configure this destination, read the ",(0,S.jsxs)(k.Z,{href:"https://github.com/mage-ai/mage-ai/blob/master/mage_integrations/mage_integrations/destinations/".concat(X.destination,"/README.md"),openNewWindow:!0,primary:!0,children:[X.destination," documentation"]}),".",(0,S.jsx)("br",{}),(0,S.jsx)("br",{}),"If your configuration contains a key named ",(0,S.jsx)(_.ZP,{inline:!0,monospace:!0,children:"table"}),", it\u2019s optional.",(0,S.jsx)("br",{}),"The table that\u2019s created in this destination will have a name corresponding to the stream\u2019s unique name (by default) or the value you entered under the input field labeled ",(0,S.jsx)(_.ZP,{bold:!0,inline:!0,children:"Table name"})," in a previous section."]}),De("https://docs.mage.ai/guides/data-integration-pipeline#configure-destination")]})}),J,(0,S.jsx)(Z.Z,{mt:3,children:(0,S.jsxs)(y.Z,{alignItems:"center",justifyContent:"space-between",children:[(0,S.jsxs)(Z.Z,{mr:2,children:[(0,S.jsx)(_.ZP,{bold:!0,large:!0,children:"Automatically add new fields"}),(0,S.jsx)(_.ZP,{default:!0,children:"Turn the toggle on if you want new table columns in each data source stream to be automatically added and synced with the data destination."})]}),(0,S.jsx)(mr.Z,{checked:!!ne,disabled:!(null!==ee&&void 0!==ee&&ee.streams),onCheck:function(){return Pe((function(e){return Nr(Nr({},e),{},{auto_add_new_fields:!ne})}))}})]})}),(0,S.jsx)(Z.Z,{mt:3,children:(0,S.jsxs)(y.Z,{alignItems:"center",justifyContent:"space-between",children:[(0,S.jsxs)(Z.Z,{mr:2,children:[(0,S.jsx)(_.ZP,{bold:!0,large:!0,children:"Disable column type check"}),(0,S.jsxs)(_.ZP,{default:!0,children:["By default, the value for each column is validated according to the schema property for that column.",(0,S.jsx)("br",{}),"If a value in a column doesn\u2019t match its type, an error will be raised and the process will be stopped.",(0,S.jsx)("br",{}),"Turn this toggle on if you want to disable this strict type checking."]})]}),(0,S.jsx)(mr.Z,{checked:!!te,disabled:!(null!==ee&&void 0!==ee&&ee.streams),onCheck:function(){return Pe((function(e){return Nr(Nr({},e),{},{disable_column_type_check:!te})}))}})]})})]})]})]})};function Fr(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Ur(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Fr(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Fr(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var Hr=function(e){var n=e.addNewBlockAtIndex,t=e.addWidget,i=e.allBlocks,c=e.allowCodeBlockShortcuts,u=e.anyInputFocused,a=e.autocompleteItems,f=e.blockRefs,p=e.blocks,h=void 0===p?[]:p,v=e.dataProviders,b=e.deleteBlock,g=e.disableShortcuts,x=e.fetchFileTree,j=e.fetchPipeline,y=e.fetchSampleData,k=e.files,_=e.globalVariables,C=e.hiddenBlocks,E=e.interruptKernel,P=e.mainContainerRef,w=e.mainContainerWidth,I=e.messages,T=e.onChangeCallbackBlock,A=e.onChangeCodeBlock,R=e.openSidekickView,M=e.pipeline,N=e.pipelineContentTouched,L=e.restartKernel,U=e.runBlock,H=e.runningBlocks,G=void 0===H?[]:H,q=e.savePipelineContent,K=e.selectedBlock,W=e.setAnyInputFocused,Y=e.setDisableShortcuts,X=e.setEditingBlock,J=e.setErrors,$=e.setIntegrationStreams,ee=e.setHiddenBlocks,ne=e.setOutputBlocks,te=e.setPipelineContentTouched,ie=e.setSelectedBlock,re=e.setSelectedOutputBlock,oe=e.setSelectedStream,le=e.setTextareaFocused,ue=e.textareaFocused,se=e.widgets,fe=(0,s.useState)(!1),he=fe[0],ve=fe[1],be=(0,s.useState)(!1),Ze=be[0],_e=be[1],Oe=(0,s.useState)(!0),Ce=Oe[0],Se=Oe[1],Ee=(0,s.useState)(null),Pe=Ee[0],we=Ee[1],Ie=(0,s.useState)(null),Te=Ie[0],Ae=Ie[1],Re=(0,s.useState)(!1),De=Re[0],Me=Re[1],Be=(0,s.useState)(""),Ne=Be[0],Le=Be[1],Fe=(0,s.useMemo)((function(){return G.reduce((function(e,n,t){return Ur(Ur({},e),{},(0,o.Z)({},n.uuid,Ur(Ur({},n),{},{priority:t})))}),{})}),[G]),Ue=(0,ae.Z)(K),He=(0,s.useMemo)((function(){return h.length}),[h]),Ge=(0,s.useMemo)((function(){return D.qL.INTEGRATION===(null===M||void 0===M?void 0:M.type)}),[M]),ze=(0,s.useMemo)((function(){return D.qL.STREAMING===(null===M||void 0===M?void 0:M.type)}),[M]),qe=ce.ZP.block_templates.list({},{revalidateOnFocus:!1}).data,Ke=(0,s.useMemo)((function(){return(null===qe||void 0===qe?void 0:qe.block_templates)||[]}),[qe]),We="PipelineDetail/index",Qe=(0,V.y)(),Ve=Qe.disableGlobalKeyboardShortcuts,Ye=Qe.registerOnKeyDown,Xe=Qe.unregisterOnKeyDown;(0,s.useEffect)((function(){return function(){Xe(We)}}),[Xe,We]),Ye(We,(function(e,n,t){if(N&&(0,F.y)([B.zX,B.hS],n)){e.preventDefault();"undefined"!==typeof location&&window.confirm("You have changes that are unsaved. Click cancel and save your changes before reloading page.")&&location.reload()}if(!g&&!Ve)if((0,F.y)([B.zX,B.Um],n)||(0,F.y)([B.PQ,B.Um],n))e.preventDefault(),q();else if(ue)n[B.vP]?le(!1):N||B.Z1.find((function(e){return n[e]}))||te(!0);else if(!Ge){if(K){var i=h.findIndex((function(e){var n=e.uuid;return K.uuid===n}));if(n[B.vP])ie(null);else if(t[0]===B.xD&&t[1]===B.xD)E();else if(t[0]===B.l1&&t[1]===B.l1&&-1!==i)b(K).then((function(e){null!==e&&void 0!==e&&e.error||setTimeout((function(){i===h.length-1?ie(h[i-1]):h.length>=0?ie(h[i+1]):ie(null)}),100)}));else if(n[B.Bu]&&i>=1){var r=h[i-1];if(r){var o,l;ie(r);var c="".concat(r.type,"s/").concat(r.uuid,".py");null===(o=f.current[c])||void 0===o||null===(l=o.current)||void 0===l||l.scrollIntoView()}}else if(n[B.kD]&&i<=He-2){var a=h[i+1];if(a){var s,d;ie(a);var p="".concat(a.type,"s/").concat(a.uuid,".py");null===(s=f.current[p])||void 0===s||null===(d=s.current)||void 0===d||d.scrollIntoView()}}else(0,F.y)([B.Uq],n)&&le(!0)}else Ue&&n[B.Uq]&&ie(Ue);u||t[0]!==B.OC||t[1]!==B.OC||L()}}),[n,u,f.current,h,E,Ge,He,N,L,q,K,Ue,te,ie,le,ue]),(0,s.useEffect)((function(){var e=setInterval((function(){N&&q()}),1e4);return function(){clearInterval(e)}}),[N,q]),(0,s.useEffect)((function(){setTimeout((function(){return _e(!0)}),2*de.zn)}),[M]);var Je=(0,d.Db)((function(e){var n=e.block,t=e.upstreamBlocks;return ce.ZP.blocks.pipelines.useUpdate(null===M||void 0===M?void 0:M.uuid,null===n||void 0===n?void 0:n.uuid)({block:{upstream_blocks:t}})}),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(){j()},onErrorCallback:function(e,n){return null===J||void 0===J?void 0:J({errors:n,response:e})}})}}),$e=(0,l.Z)(Je,1)[0],en=(0,s.useCallback)((function(e){ve(!0),Ae(e),Y(!0)}),[ve,Y,Ae]),nn=(0,s.useCallback)((function(){ve(!1),Me(!1),Le(""),Y(!1)}),[Y]),tn=(0,s.useCallback)((function(e,n){var t,i;h.forEach((function(r,o){var l=r.uuid;t>=0&&i>=0||(l===e.uuid?t=o:l===n.uuid&&(i=o))}));var r=(0,pe.oM)(h,i);return r=(0,pe.Hk)(n,Math.max(t,0),r),q({pipeline:{blocks:r,uuid:null===M||void 0===M?void 0:M.uuid}})}),[h,M,q]),ln=(0,s.useMemo)((function(){var e=[];return h.filter((function(e){var n=e.type;return!Ge||m.tf.TRANSFORMER===n})).forEach((function(l,u){var d,p=l.type,y=l.uuid,k=(null===K||void 0===K?void 0:K.uuid)===y,Z=Fe[y],_=Z?0===Z.priority?ge.uF.BUSY:ge.uF.QUEUED:ge.uF.IDLE,O="".concat(p,"s/").concat(y,".py");f.current[O]=(0,s.createRef)();var D=p===m.tf.MARKDOWN,B=p===m.tf.TRANSFORMER,N=!(null===C||void 0===C||!C[y]),L=u===He-1||Ge,F=f.current[O];d=N?(0,S.jsx)(tr,{block:l,blocks:h,onClick:function(){return ee((function(e){return Ur(Ur({},e),{},(0,o.Z)({},y,!N))}))},onDrop:tn,ref:F},y):(0,S.jsx)(Mi,{addNewBlock:function(e,t){le(!0);return n(e,u+1,(function(e){if(1===(null===t||void 0===t?void 0:t.length)){var n,i,o=null===(n=t[0])||void 0===n?void 0:n.uuid,l=(null===(i=t[0])||void 0===i?void 0:i.upstream_blocks)||[];$e({block:{uuid:o},upstreamBlocks:[e.uuid].concat((0,r.Z)(l))})}null===ie||void 0===ie||ie(e)}))},addNewBlockMenuOpenIdx:Pe,addWidget:t,allBlocks:i,allowCodeBlockShortcuts:c,autocompleteItems:a,block:l,blockIdx:u,blockRefs:f,blockTemplates:Ke,blocks:h,dataProviders:v,defaultValue:l.content,deleteBlock:function(e){b(e),W(!1)},disableShortcuts:g,executionState:_,fetchFileTree:x,fetchPipeline:j,hideRunButton:ze||D||Ge&&B,interruptKernel:E,mainContainerRef:P,mainContainerWidth:w,messages:I[y],noDivider:L,onCallbackChange:function(e){return T(p,y,e)},onChange:function(e){return A(p,y,e)},onClickAddSingleDBTModel:en,onDrop:tn,openSidekickView:R,pipeline:M,ref:F,runBlock:U,runningBlocks:G,savePipelineContent:q,selected:k,setAddNewBlockMenuOpenIdx:we,setAnyInputFocused:W,setCreatingNewDBTModel:Me,setEditingBlock:X,setErrors:J,setOutputBlocks:ne,setSelected:function(e){return ie(!0===e?l:null)},setSelectedOutputBlock:re,setTextareaFocused:le,textareaFocused:k&&ue,widgets:se},y),e.push(d)})),e}),[n,Pe,t,i,c,a,f,Ke,h,v,b,g,x,j,C,E,Ge,ze,P,w,I,He,T,A,en,tn,R,M,U,G,Fe,q,K,we,W,X,J,ee,ne,ie,re,le,ue,$e,se]),cn=(0,s.useMemo)((function(){return(0,S.jsx)(Lr,{addNewBlockAtIndex:n,blocks:h,codeBlocks:ln,fetchFileTree:x,fetchPipeline:j,fetchSampleData:y,globalVariables:_,onChangeCodeBlock:A,openSidekickView:R,pipeline:M,savePipelineContent:q,setErrors:J,setIntegrationStreams:$,setOutputBlocks:ne,setSelectedBlock:ie,setSelectedOutputBlock:re,setSelectedStream:oe})}),[n,h,ln,x,j,y,_,A,R,M,q,J,$,ne,ie,re,oe]),an=(0,s.useMemo)((function(){return(0,S.jsx)(un,{addNewBlock:function(e){var t=h[h.length-1],i=null,r={},o=t?(0,Kt.eY)(t,e):[];t&&([m.tf.DATA_LOADER,m.tf.TRANSFORMER].includes(t.type)&&m.tf.SCRATCHPAD===e.type&&(i="from mage_ai.data_preparation.variable_manager import get_variable\n\n\ndf = get_variable('".concat(M.uuid,"', '").concat(t.uuid,"', 'output_0')\n")),m.t6.SQL===t.language&&(r=Ur(Ur({},(0,Ii.GL)(t.configuration,[lt,ct,ut,at,pt])),r))),m.t6.SQL===e.language&&(i=rn(i)),i=on(e,i),n(Ur(Ur({},e),{},{configuration:r,content:i,upstream_blocks:o}),He,ie),le(!0)},blockTemplates:Ke,hideCustom:Ge||ze,hideDataExporter:Ge,hideDataLoader:Ge,hideDbt:Ge||ze,hideScratchpad:Ge,hideSensor:Ge,onClickAddSingleDBTModel:en,pipeline:M,setCreatingNewDBTModel:Me})}),[n,Ke,h,Ge,ze,He,en,M,ie,le]);return(0,S.jsxs)(ye.W,{backend:ke.PD,children:[(0,S.jsx)(de.lO,{children:Ce&&(0,S.jsx)(je.Z,{classNames:"pipeline-detail",in:Ze,onEntered:function(){return setTimeout((function(){return Se(!1)}),de.zn)},timeout:1,children:(0,S.jsx)(de.fm,{})})}),(0,S.jsxs)(Z.Z,{mt:1,px:O.cd,children:[Ge&&cn,!Ge&&(0,S.jsxs)(S.Fragment,{children:[ln,(0,S.jsx)(Z.Z,{mt:O.cd,children:an})]}),he&&(0,S.jsx)(z.Z,{onClickOutside:nn,open:!0,children:(0,S.jsx)(Qi,{blocks:h,creatingNewDBTModel:De,dbtModelName:Ne,files:k,onClose:nn,onOpenFile:function(e){var t=e;if(De){var i=(0,Q.RA)(Ne||(0,Q.Y6)()),r=".".concat(Cn.Lu.SQL);i.endsWith(r)&&(i=i.slice(0,-4)),t="".concat(e).concat(xe.sep).concat(i,".").concat(Cn.Lu.SQL)}var o={configuration:{file_path:t,limit:1e3},language:m.t6.SQL,name:(0,Q.wE)(t),type:m.tf.DBT};De&&(o.content="--Docs: https://docs.mage.ai/dbt/sources\n");var l="undefined"===typeof Te||null===Te,c=h[l?h.length-1:Te],u=c?(0,Kt.eY)(c,o):[];n(Ur(Ur({},o),{},{upstream_blocks:u}),l?He:Te+1,ie),nn(),le(!0)},setDbtModelName:Le})})]})]})},Gr=t(49894),zr=t(41424),qr=t(32063),Kr=t(82386),Wr=t(70543),Qr=t(24141);function Vr(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Yr(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Vr(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Vr(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var Xr=function(e){var n=e.after,t=e.afterHeader,i=e.afterHeightOffset,r=e.afterHidden,o=e.afterNavigationItems,c=e.afterOverflow,u=e.afterSubheader,a=e.before,d=e.beforeHeader,f=e.beforeHeightOffset,p=e.beforeNavigationItems,h=e.children,m=e.errors,v=e.headerOffset,b=e.mainContainerHeader,g=e.mainContainerRef,x=e.page,j=e.pipeline,y=e.setAfterHidden,k=e.setAfterWidthForChildren,Z=e.setErrors,_=e.setMainContainerWidth,O=(0,Qr.i)().width,C=(0,s.useState)((0,L.U2)(L.L8,Kr.Zt)),E=C[0],P=C[1],w=(0,s.useState)((0,L.U2)(L.J3,Kr.ve)),I=w[0],T=w[1],A=(0,s.useState)(!!(0,L.U2)(L.Uu)),R=A[0],D=A[1],M=(0,s.useState)(!1),B=M[0],N=M[1],F=(0,s.useState)(!1),U=F[0],H=F[1],G=r,q=y;if(!q){var K=(0,s.useState)(!!(0,L.U2)(L.zg)),W=(0,l.Z)(K,2);G=W[0],q=W[1]}(0,s.useEffect)((function(){null===g||void 0===g||!g.current||B||U||null===_||void 0===_||_(g.current.getBoundingClientRect().width)}),[B,U,G,E,R,I,g,_,O]),(0,s.useEffect)((function(){B||(null===k||void 0===k||k(E),(0,L.t8)(L.L8,E))}),[B,E,k]),(0,s.useEffect)((function(){U||(0,L.t8)(L.J3,I)}),[U,I]);var V=ce.ZP.projects.list({},{revalidateOnFocus:!1}).data,Y=null===V||void 0===V?void 0:V.projects,X=(0,s.useMemo)((function(){var e,n=[{label:function(){return"Pipelines"},linkProps:{as:"/pipelines",href:"/pipelines"}}];return j&&(n.push.apply(n,[{bold:Wr.b7!==x,label:function(){return null===j||void 0===j?void 0:j.uuid},linkProps:{as:"/pipelines/".concat(null===j||void 0===j?void 0:j.uuid),href:"/pipelines/[pipeline]"}}]),Wr.b7===x&&n.push.apply(n,[{bold:!0,label:function(){return(0,Q.kC)(x)}}])),(0,S.jsx)(zr.Z,{breadcrumbs:n,project:null===Y||void 0===Y?void 0:Y[0],version:null===Y||void 0===Y||null===(e=Y[0])||void 0===e?void 0:e.version})}),[x,j,Y]);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(te.Z,{title:null===j||void 0===j?void 0:j.name}),(0,S.jsx)(qr.Z,{after:n,afterHeader:t,afterHeightOffset:i,afterHidden:G,afterMousedownActive:B,afterNavigationItems:o,afterOverflow:c,afterSubheader:u,afterWidth:E,before:a,beforeHeader:d,beforeHeightOffset:f,beforeHidden:R,beforeMousedownActive:U,beforeNavigationItems:p,beforeWidth:I,header:X,headerOffset:v,mainContainerHeader:b,mainContainerRef:g,navigationShowMore:!0,setAfterHidden:q,setAfterMousedownActive:N,setAfterWidth:P,setBeforeHidden:D,setBeforeMousedownActive:H,setBeforeWidth:T,children:h}),m&&(0,S.jsx)(z.Z,{disableClickOutside:!0,isOpen:!0,onClickOutside:function(){return Z(null)},children:(0,S.jsx)(Gr.Z,Yr(Yr({},m),{},{onClose:function(){return Z(null)}}))})]})},Jr=t(41788),$r=t(70001),eo=t(26226),no=t(29989),to=t(53655),io=t(84181),ro=t(31969);function oo(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function lo(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?oo(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):oo(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var co=v.default.div.withConfig({displayName:"HeatMap__YAxisLabelContainer",componentId:"sc-h2irj-0"})(["-webkit-transform:rotate(-90deg);-moz-transform:rotate(-90deg);-o-transform:rotate(-90deg);-ms-transform:rotate(-90deg);transform:rotate(-90deg);white-space:nowrap;"]);function uo(e,n){return Math.max.apply(Math,(0,r.Z)(e.map(n)))}function ao(e,n){return Math.min.apply(Math,(0,r.Z)(e.map(n)))}var so=function(e){return e.bins},fo=function(e){return e.count},po={top:0,left:0,right:0,bottom:0};function ho(e){var n=e.countMidpoint,t=e.data,i=(e.events,e.height),r=e.margin,o=void 0===r?{}:r,l=e.minCount,c=e.width,u=(e.yLabels,(0,s.useContext)(v.ThemeContext)),a=(u.monotone||ro.Z.monotone).grey300,d=(u.brand||ro.Z.brand).wind400,f=(u.content||ro.Z.content).default,p=(u.monotone||ro.Z.monotone).white,h=lo(lo({},po),o),m=[];t[0].forEach((function(e,n){var i=t.map((function(e){return e[n]}));m.push({bin:n,bins:i.reverse().map((function(e,n){return{bin:n,count:e}}))})}));var b=uo(m,(function(e){return uo(so(e),fo)})),g=ao(m,(function(e){return ao(so(e),fo)})),x=uo(m,(function(e){return so(e).length})),j="undefined"!==typeof n?n:0,y="undefined"!==typeof l?l:g,k=(0,io.Z)({domain:[0,m.length]}),Z=(0,io.Z)({domain:[0,x]}),_=(0,io.Z)({range:[a,d],domain:[j,b]}),O=(0,io.Z)({range:[.1,1],domain:[j,b]}),C=(0,io.Z)({range:[a,d],domain:[y,j]}),E=(0,io.Z)({range:[1,.1],domain:[y,j]}),P=c-(h.left+h.right),w=i-(h.bottom+h.top),I=P/m.length,T=w/x;return k.range([0,P]),Z.range([w,0]),c<10?null:(0,S.jsx)(S.Fragment,{children:(0,S.jsx)("svg",{width:c,height:i,children:(0,S.jsx)(no.Z,{left:h.left,top:h.top,children:(0,S.jsx)(to.Z,{data:m,xScale:k,yScale:Z,colorScale:_,opacityScale:O,binWidth:I,binHeight:I,gap:0,children:function(e){return e.map((function(e){return e.map((function(e){var t=e.opacity,i=e.color;return"undefined"!==typeof n&&e.count<n&&(t=E(e.count),i=C(e.count)),(0,S.jsxs)("svg",{height:T,width:I,x:e.x,y:e.y-T,children:[(0,S.jsx)("rect",{className:"visx-heatmap-rect",fill:i,fillOpacity:t,height:T,width:I}),(0,S.jsx)("text",{alignmentBaseline:"middle",fill:e.count>=.8*b?p:f,fontFamily:ai.ry,fontSize:14,textAnchor:"middle",x:"50%",y:"50%",children:e.count})]},"heatmap-rect-".concat(e.row,"-").concat(e.column))}))}))}})})})})}var mo=function(e){var n=e.countMidpoint,t=e.data,i=e.height,r=e.margin,o=e.minCount,l=e.xAxisLabel,c=e.xLabels,u=e.yAxisLabel,a=e.yLabels,s=function(e){return e.length>12?"".concat(e.substring(0,12),"..."):e},d=4*O.iI,f=8*O.iI,p=0;return u&&(p+=d+1*O.iI),a&&(p+=f+1*O.iI),(0,S.jsxs)(S.Fragment,{children:[(l||c)&&(0,S.jsx)("div",{style:{marginBottom:null===r||void 0===r?void 0:r.bottom,marginLeft:null===r||void 0===r?void 0:r.left,marginRight:null===r||void 0===r?void 0:r.right,marginTop:null===r||void 0===r?void 0:r.top,paddingLeft:p},children:(0,S.jsxs)(Z.Z,{mb:{xs:1},children:[l&&(0,S.jsx)(Z.Z,{mb:1,children:(0,S.jsx)(_.ZP,{center:!0,muted:!0,xsmall:!0,children:l})}),c&&(0,S.jsx)(y.Z,{children:c.map((function(e){var n=e.label,t=e.linkProps;return(0,S.jsx)(j.Z,{flex:"1",justifyContent:"center",children:t?(0,S.jsx)(k.Z,{bold:!0,centerAlign:!0,minWidth:70,onClick:t.onClick,xsmall:!0,children:n}):(0,S.jsx)(_.ZP,{bold:!0,center:!0,minWidth:70,title:String(n),xsmall:!0,children:s(String(n))})},n)}))})]})}),(0,S.jsxs)("div",{style:{height:i,display:"flex",width:"100%"},children:[u&&(0,S.jsx)("div",{style:{marginRight:1*O.iI,width:d},children:(0,S.jsx)(y.Z,{alignItems:"center",justifyContent:"center",children:(0,S.jsx)(co,{children:(0,S.jsx)(_.ZP,{center:!0,muted:!0,xsmall:!0,children:u})})})}),a&&(0,S.jsx)("div",{style:{marginRight:1*O.iI},children:(0,S.jsx)(y.Z,{alignItems:"center",flexDirection:"column",fullHeight:!0,width:f,children:a.map((function(e){var n=e.label,t=e.linkProps;return(0,S.jsx)(j.Z,{alignItems:"center",flex:"1",children:t?(0,S.jsx)(k.Z,{bold:!0,centerAlign:!0,onClick:t.onClick,xsmall:!0,children:n}):(0,S.jsx)(_.ZP,{bold:!0,center:!0,title:String(n),xsmall:!0,children:s(String(n))})},n)}))})}),(0,S.jsx)("div",{style:{height:i,width:"100%"},children:(0,S.jsx)(eo.Z,{children:function(e){var i=e.width,l=e.height;return(0,S.jsx)(ho,{countMidpoint:n,data:t,height:l,margin:r,minCount:o,width:i,yLabels:a})}})})]})]})},vo=t(11754);var bo=function(e){var n=e.afterWidth,t=e.features,i=e.insightsOverview,r=e.statistics,o=i.correlations,c=void 0===o?[]:o,u=n-(2*O.cd*O.iI+Pn.nn),a=function(e){var n=[];return{heatmapData:null===e||void 0===e?void 0:e.map((function(e,t){var i=e.correlations,r=e.feature.uuid;n.push({label:r});var o=i[0].y.map((function(e){var n=e.value;return(0,Q.QV)(n)}));return o.splice(t,0,1),o})),xyLabels:n}}(c),s=a.heatmapData,d=a.xyLabels,f=function(e,n){return(0,pe.YC)(null===e||void 0===e?void 0:e.map((function(e){return{feature:e,value:1-n["".concat(e.uuid,"/null_value_rate")]}})),"value")}(t,r),p=function(e,n){return(0,pe.YC)(null===e||void 0===e?void 0:e.map((function(e){return{feature:e,value:n["".concat(e.uuid,"/count_distinct")]}})),"value")}(t,r),h=function(e,n){return(0,pe.YC)(null===e||void 0===e?void 0:e.map((function(e){var t=Object.entries(n["".concat(e.uuid,"/value_counts")]||{})[0]||[],i=(0,l.Z)(t,2),r=i[0],o=i[1];return{feature:e,percentage:Number(o)/n.count,value:r}})),"percentage")}(t,r);return(0,S.jsxs)(y.Z,{flexDirection:"column",children:[(null===f||void 0===f?void 0:f.length)>=1&&(0,S.jsx)(vo.Z,{headerTitle:"Data completion",width:u,children:(0,S.jsx)($r.Z,{data:f.map((function(e){var n=e.feature;return{x:e.value,y:n.uuid}})),height:Math.max(3*f.length*O.iI,50*O.iI),renderTooltipContent:function(e){var n=e.x;return"".concat((0,Q.T3)(n)," of rows have a value")},xNumTicks:2,ySerialize:function(e){return e.y}})}),(null===p||void 0===p?void 0:p.length)>=1&&(0,S.jsx)(vo.Z,{headerTitle:"Number of unique values",width:u,children:(0,S.jsx)($r.Z,{data:p.map((function(e){var n=e.feature;return{x:e.value,y:n.uuid}})),height:Math.max(3*f.length*O.iI,50*O.iI),renderTooltipContent:function(e){var n=e.x;return"".concat(n," unique values")},xNumTicks:2,ySerialize:function(e){return e.y}})}),h.length>=1&&(0,S.jsx)(vo.Z,{headerTitle:"Distribution of values",width:u,children:(0,S.jsx)($r.Z,{data:h.map((function(e){var n=e.feature,t=e.percentage;return{feature:n,value:e.value,x:t,y:n.uuid}})),height:Math.max(3*h.length*O.iI,50*O.iI),renderTooltipContent:function(e){var n=e.value,t=e.x;return"".concat(n," is ").concat((0,Q.T3)(t)," of all rows")},xNumTicks:2,ySerialize:function(e){return e.y}})}),c&&(null===s||void 0===s?void 0:s.length)>=1&&(0,S.jsx)(vo.Z,{headerTitle:"Correlations",children:(0,S.jsx)(Z.Z,{p:1,children:(0,S.jsx)(mo,{countMidpoint:0,data:s,height:8*O.iI*d.length,minCount:-1,xLabels:d,yLabels:d})})})]})};function go(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function xo(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?go(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):go(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var jo=function(e){var n,t,i=e.block,r=e.blockActionDescription,o=e.blocks,l=e.inputPlaceholder,c=e.loading,u=e.onClickTag,a=e.runBlockAndTrack,d=e.supportedUpstreamBlockLanguages,f=e.supportedUpstreamBlockTypes,p=e.updateBlock,h=(0,s.useContext)(v.ThemeContext),m=(0,s.useState)(""),k=m[0],E=m[1],P=(0,s.useState)(!1),w=P[0],T=P[1],A=(0,s.useState)(null),R=A[0],D=A[1],B=(0,s.useMemo)((function(){return(0,pe.HK)(o,(function(e){return e.uuid}))}),[o]);(0,s.useEffect)((function(){R||D((0,pe.HK)((null===i||void 0===i?void 0:i.upstream_blocks)||[],(function(e){return e})))}),[i,R]);var N=(0,s.useMemo)((function(){return(null===o||void 0===o?void 0:o.filter((function(e){var n=e.name,t=e.type,i=e.uuid;return((null===n||void 0===n?void 0:n.toLowerCase().includes(null===k||void 0===k?void 0:k.toLowerCase()))||(null===i||void 0===i?void 0:i.toLowerCase().includes(null===k||void 0===k?void 0:k.toLowerCase())))&&(null===f||void 0===f?void 0:f.includes(t))})))||[]}),[k,o,f]),L=(0,s.useMemo)((function(){var e=[];return null===N||void 0===N||N.forEach((function(n,t){var i=n.color,r=n.language,o=n.type,l=n.uuid,c=(0,C.qn)(o,{blockColor:i,theme:h}).accent;t>=1&&e.push((0,S.jsx)(x.Z,{light:!0},"divider-".concat(l)));var u=!(null===R||void 0===R||!R[l]),a=null!==d&&"undefined"!==typeof d&&!(null!==d&&void 0!==d&&d.includes(r));e.push((0,S.jsx)(Z.Z,{px:2,py:1,children:(0,S.jsxs)(y.Z,{alignItems:"center",justifyContent:"space-between",children:[(0,S.jsxs)(j.Z,{alignItems:"center",children:[(0,S.jsx)(g.Z,{color:c,size:1.5*O.iI,square:!0}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(_.ZP,{monospace:!0,muted:a,small:!0,children:l})]}),a&&(0,S.jsxs)(_.ZP,{inline:!0,monospace:!0,muted:!0,small:!0,children:[r," support coming soon"]}),!a&&(0,S.jsx)(b.Z,{checked:!a&&u,disabled:a,onClick:function(){D((function(e){var n=xo({},e);return u?delete n[l]:n[l]=l,n}))}})]})},"option-".concat(l)))})),e}),[N,h,R]);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(z.Z,{onClickOutside:function(){return T(!1)},open:!0,children:[(0,S.jsx)(M.Z,{beforeIcon:(0,S.jsx)(se.HN,{}),borderless:!0,compact:!0,onChange:function(e){return E(e.target.value)},onClick:function(e){(0,vi.j)(e),T(!0)},onFocus:function(e){(0,vi.j)(e),T(!0)},placeholder:l,small:!0,value:k}),w&&(0,S.jsxs)(S.Fragment,{children:[L,(0,S.jsx)(Z.Z,{mx:1,children:(0,S.jsx)(y.Z,{justifyContent:"flex-end",children:(0,S.jsx)(I.Z,{compact:!0,loading:c,onClick:function(){return p({block:i,upstream_blocks:Object.keys(R)}).then((function(){return T(!1)}))},small:!0,children:"Save selected blocks"})})})]})]}),!w&&(null===i||void 0===i||null===(n=i.upstream_blocks)||void 0===n?void 0:n.length)>=1&&(0,S.jsxs)(Z.Z,{pb:1,pr:1,children:[r&&(0,S.jsx)(Z.Z,{mt:1,pl:1,children:(0,S.jsx)(_.ZP,{muted:!0,small:!0,children:r})}),(0,S.jsx)(y.Z,{alignItems:"center",children:null===i||void 0===i||null===(t=i.upstream_blocks)||void 0===t?void 0:t.map((function(e){var n=null===B||void 0===B?void 0:B[e];if(!n)return(0,S.jsx)("div",{},e);var t=n.color,r=n.type,o=(0,C.qn)(r,{blockColor:t,theme:h}).accentLight;return(0,S.jsx)(Z.Z,{ml:1,mt:1,children:(0,S.jsx)(I.Z,{backgroundColor:o,compact:!0,disabled:!a,onClick:function(e){(0,vi.j)(e),u?u(n):null===a||void 0===a||a({block:xo(xo({},i),{},{upstream_blocks:[null===n||void 0===n?void 0:n.uuid]})})},small:!0,children:(0,S.jsx)(_.ZP,{monospace:!0,small:!0,children:e})})},e)}))})]})]})},yo=t(59e3);function ko(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Zo(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?ko(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ko(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var _o=function(e){var n=e.addNewBlockAtIndex,t=e.autocompleteItems,i=e.blockRefs,r=e.blocks,c=e.blocksInNotebook,u=e.deleteBlock,a=e.fetchFileTree,f=e.fetchPipeline,p=e.interruptKernel,h=e.messages,v=e.onChangeCallbackBlock,b=e.onChangeCodeBlock,g=e.onSelectBlockFile,x=e.pipeline,j=e.runBlock,y=e.runningBlocks,C=e.savePipelineContent,E=e.selectedBlock,P=e.setAnyInputFocused,w=e.setErrors,I=e.setHiddenBlocks,T=e.setSelectedBlock,R=e.setTextareaFocused,D=e.textareaFocused,M=(0,s.useRef)(null),N=(0,s.useState)(!1),L=N[0],U=N[1],H=(0,yo.iV)().block_uuid;(0,s.useEffect)((function(){var e=r.find((function(e){var n,t=e.uuid;return(null===H||void 0===H||null===(n=H.split(":"))||void 0===n?void 0:n[0])===t}));e&&(E&&(null===e||void 0===e?void 0:e.uuid)===(null===E||void 0===E?void 0:E.uuid)||(I((function(n){return Zo(Zo({},n),{},(0,o.Z)({},e.uuid,!1))})),g(e.uuid,e.type,null)))}),[H,r,g,E,I]);var G=(x||{}).type,q=(0,s.useMemo)((function(){return(null===x||void 0===x?void 0:x.callbacks)||[]}),[x]),K=(0,s.useMemo)((function(){return(0,pe.HK)(q,(function(e){return e.uuid}))}),[q]),W=ce.ZP.block_templates.list({},{revalidateOnFocus:!1}).data,Q=(0,s.useMemo)((function(){return(null===W||void 0===W?void 0:W.block_templates)||[]}),[W]),Y=(0,s.useCallback)((function(e){return n(e,(null===q||void 0===q?void 0:q.length)||0)}),[n,q]),X=(0,s.useMemo)((function(){return Je(Q,Y)}),[Y,Q]),J=(0,s.useMemo)((function(){return $e(Y,m.tf.CALLBACK,G,{blockTemplatesByBlockType:X,languages:[m.t6.PYTHON]})}),[Y,X,G]),$=(0,s.useMemo)((function(){return K[null===E||void 0===E?void 0:E.uuid]}),[K,E]),ee=(0,s.useMemo)((function(){return y.reduce((function(e,n,t){return Zo(Zo({},e),{},(0,o.Z)({},n.uuid,Zo(Zo({},n),{},{priority:t})))}),{})}),[y]),ne=(0,d.Db)((function(e){var n=e.block,t=e.upstream_blocks;return ce.ZP.blocks.pipelines.useUpdate(null===x||void 0===x?void 0:x.uuid,encodeURIComponent(null===n||void 0===n?void 0:n.uuid),{query:{block_type:null===n||void 0===n?void 0:n.type}})({block:{upstream_blocks:t}})}),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(){f()},onErrorCallback:function(e,n){return null===w||void 0===w?void 0:w({errors:n,response:e})}})}}),te=(0,l.Z)(ne,2),ie=te[0],re=te[1].isLoading,oe=(0,s.useMemo)((function(){return q.map((function(e,n){var l=e.type,d=e.uuid,k=(null===E||void 0===E?void 0:E.uuid)===d,_=ee[d],A=_?0===_.priority?ge.uF.BUSY:ge.uF.QUEUED:ge.uF.IDLE,M="".concat(l,"s/").concat(d,".py");return i.current[M]=(0,s.createRef)(),(0,S.jsx)(Z.Z,{mt:O.cd,children:(0,S.jsx)(Mi,{allBlocks:r,autocompleteItems:t,block:e,blockIdx:n,blockRefs:i,blocks:r,defaultValue:e.content,deleteBlock:function(e){u(Zo({},e)),P(!1)},executionState:A,extraContent:(0,S.jsx)(jo,{block:e,blocks:c,inputPlaceholder:"Select blocks to add callbacks to",loading:re,onClickTag:function(e){I((function(n){return Zo(Zo({},n),{},(0,o.Z)({},e.uuid,!1))})),g(e.uuid,e.type,null)},supportedUpstreamBlockTypes:[m.tf.CUSTOM,m.tf.DATA_EXPORTER,m.tf.DATA_LOADER,m.tf.DBT,m.tf.SCRATCHPAD,m.tf.SENSOR,m.tf.TRANSFORMER],updateBlock:ie}),fetchFileTree:a,fetchPipeline:f,hideRunButton:!0,interruptKernel:p,messages:h[d],noDivider:!0,onCallbackChange:function(e){return v(l,d,e)},onChange:function(e){return b(l,d,e)},pipeline:x,ref:i.current[M],runBlock:j,runningBlocks:y,savePipelineContent:C,selected:k,setAnyInputFocused:P,setErrors:w,setSelected:function(n){return T(!0===n?e:null)},setTextareaFocused:R,textareaFocused:k&&D})},d)}))}),[t,i,r,c,q,u,a,f,p,re,h,v,b,g,x,j,y,ee,C,E,P,w,I,T,R,D,ie]),le="Callbacks/index",ue=(0,V.y)(),ae=ue.disableGlobalKeyboardShortcuts,de=ue.registerOnKeyDown,fe=ue.unregisterOnKeyDown;return(0,s.useEffect)((function(){return function(){fe(le)}}),[fe,le]),de(le,(function(e,n){!ae&&$&&((0,F.y)([B.zX,B.Um],n)||(0,F.y)([B.PQ,B.Um],n))&&(e.preventDefault(),C())}),[$,C]),(0,S.jsx)(ye.W,{backend:ke.PD,children:(0,S.jsxs)(Z.Z,{p:O.cd,children:[(0,S.jsxs)(Z.Z,{mb:O.cd,children:[(0,S.jsx)(_.ZP,{default:!0,children:"Run 1 or more callback block functions whenever another block succeeds or fails."}),(0,S.jsx)(Z.Z,{mt:1,children:(0,S.jsxs)(_.ZP,{default:!0,children:["Learn more about ",(0,S.jsx)(k.Z,{href:"https://docs.mage.ai/development/blocks/callbacks/overview",openNewWindow:!0,children:"callbacks"}),"."]})})]}),oe,(0,S.jsx)(Z.Z,{mt:O.cd,children:(0,S.jsx)(z.Z,{onClickOutside:function(){return U(!1)},open:!0,children:(0,S.jsx)(we.Z,{disableKeyboardShortcuts:!0,items:J,onClickCallback:function(){return U(!1)},open:L,parentRef:M,uuid:"Callback",children:(0,S.jsx)(A.ZP,{beforeElement:(0,S.jsx)(Re,{rose:!0,children:(0,S.jsx)(se.mm,{size:Ae})}),inline:!0,onClick:function(e){e.preventDefault(),U(!0)},uuid:"AddNewBlocks/Callback",children:"Callback block"})})})})]})})},Oo=t(92083),Co=t.n(Oo),So=t(84969),Eo=t(90948),Po=t(65743),wo=t(39048),Io=t(79487),To=t(61655),Ao=t(16853),Ro=t(65376),Do=t(52359),Mo=t(48072),Bo=t(24903),No=t(98677),Lo=t(73899);function Fo(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Uo(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Fo(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Fo(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var Ho={bottom:O.iI*(3+O.cd),left:O.iI*O.cd,right:O.iI*O.cd,top:O.iI*O.cd};function Go(e,n){return Math.max.apply(Math,(0,r.Z)(e.map(n)))}function zo(e){var n=e.data,t=e.height,i=e.keyForYData,o=e.large,l=e.margin,c=void 0===l?{}:l,u=e.orientationVertical,a=void 0!==u&&u,d=e.showTooltip,f=e.width,p=e.yLabelFormat,h=(0,s.useContext)(v.ThemeContext),m=(0,s.useCallback)((function(e){return e[i]}),[i]),b=p;b||(b=function(e){return e.length>20?"".concat(e.substring(0,20),"..."):e});var g=o?si.iD:si.J5,x=Uo(Uo({},Ho),c),j=n.slice(Math.max(0,n.length-50)),y=(0,s.useMemo)((function(){return Object.keys((null===j||void 0===j?void 0:j[0])||{}).filter((function(e){return e!==i}))}),[j,i]),k=(0,Bo.Z)({domain:y,range:[Lo.a$,Lo.Ej,Lo.hM,Lo.ZA,Lo.$R,Lo.X_,Lo.er,Lo.hl,Lo.nQ]}),Z=(0,s.useMemo)((function(){return j.map(m)}),[j,m]),_=(0,No.Z)({domain:Z,padding:.1}),O=(0,No.Z)({domain:y,padding:.1}),C=(0,io.Z)({domain:[0,Go(j,(function(e){return Go(y,(function(n){return Number(e[n])}))}))]}),S={active:(null===h||void 0===h?void 0:h.content.default)||ue.Z.content.default,backgroundPrimary:(null===h||void 0===h?void 0:h.chart.backgroundPrimary)||ue.Z.chart.backgroundPrimary,backgroundSecondary:(null===h||void 0===h?void 0:h.chart.backgroundSecondary)||ue.Z.chart.backgroundSecondary,muted:(null===h||void 0===h?void 0:h.content.muted)||ue.Z.content.muted,primary:(null===h||void 0===h?void 0:h.chart.primary)||ue.Z.chart.primary,tooltipBackground:(null===h||void 0===h?void 0:h.background.navigation)||ue.Z.background.navigation},E=Z;a&&(E=j.reduce((function(e,n){return e.concat(y.map((function(e){var t=n[e];return(0,Q.HW)(t)?parseInt(String(t)):t})))}),[]));var P=Math.min(Math.max.apply(Math,(0,r.Z)(E.map((function(e){return String(e).length})))),20);x.left+=7*P;var w=f-(x.left+x.right),I=t-(x.top+x.bottom);a?(_.rangeRound([0,w]),C.rangeRound([I,0])):(_.rangeRound([I,0]),C.rangeRound([0,w])),O.rangeRound([0,_.bandwidth()]);var T=j.map(m).length,A=0;a||(A=_(E[T-1]));var R=(0,s.useCallback)((function(e){var n=(0,Mo.Z)(e)||{x:0,y:0},t=n.x,i=n.y,r=t-x.left,o=i-x.top,l=0;l=a?(r-A/2)/(w-A):1-(o-A/2)/(I-A);var c=Math.floor(l*T),u=j[c];"undefined"===typeof u&&(u=j[c-1]),a?r>A&&r<w+x.left-A&&d({tooltipData:u,tooltipLeft:t,tooltipTop:i}):o>A&&o<I-A&&d({tooltipData:u,tooltipLeft:t,tooltipTop:i})}),[j,T,x.left,x.top,a,d,A,w,I]);return{colorScale:k,colors:S,data:j,fontSize:g,handleTooltip:R,margin:x,tempScale:C,tickValues:E,xKeys:y,xMax:w,y1Scale:O,yLabelFormat:b,yMax:I,yScale:_,ySerialize:m}}var qo=["height","width","xAxisLabel","yAxisLabel"];function Ko(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Wo(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Ko(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Ko(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var Qo=3*O.iI,Vo=(O.iI,O.iI,O.iI,(0,To.Z)((function(e){var n=e.data,t=e.height,i=e.hideTooltip,r=e.keyForYData,o=void 0===r?"__y":r,c=e.large,u=e.margin,a=void 0===u?{}:u,s=e.renderNoDataText,d=e.renderTooltipContent,f=e.showTooltip,p=e.tooltipData,h=e.tooltipLeft,m=e.tooltipOpen,v=e.tooltipTop,b=e.width,g=e.xAxisLabel,x=e.xNumTicks,j=e.yLabelFormat,y=zo({data:n,height:t,keyForYData:o,large:c,margin:a,showTooltip:f,width:b,yLabelFormat:j}),k=y.colorScale,Z=y.colors,O=y.data,C=y.fontSize,E=y.handleTooltip,P=y.margin,w=y.tempScale,I=y.tickValues,T=y.xKeys,A=y.xMax,R=y.y1Scale,D=y.yLabelFormat,M=y.yMax,B=y.yScale,N=y.ySerialize,L=[],F=Math.floor((null===I||void 0===I?void 0:I.length)/Math.floor(t/Qo));return null===I||void 0===I||I.forEach((function(e,n){n%F===0&&L.push(e)})),b<10?null:(0,S.jsxs)("div",{children:[(0,S.jsxs)("svg",{height:t,width:b,children:[s&&!(null!==O&&void 0!==O&&O.length)&&(0,S.jsx)("text",{fill:Z.active,dominantBaseline:"middle",textAnchor:"middle",fontFamily:ai.ry,fontSize:C,x:"50%",y:"50%",children:s()}),(0,S.jsx)(Po.Z,{fill:"transparent",height:t-(P.top+P.bottom),onMouseLeave:function(){return i()},onMouseMove:E,onTouchMove:E,onTouchStart:E,rx:14,width:b-(P.left+P.right),x:P.left,y:P.top}),(null===O||void 0===O?void 0:O.length)&&(0,S.jsxs)(no.Z,{left:P.left,top:P.top,children:[(0,S.jsx)(wo.Z,{color:k,data:O,keys:T,width:A,xScale:w,y0:N,y0Scale:B,y1Scale:R,children:function(e){return e.map((function(e){return(0,S.jsx)(no.Z,{top:e.y0,children:e.bars.map((function(n){return(0,S.jsx)("g",{children:(0,S.jsx)(S.Fragment,{children:(0,S.jsx)("rect",{fill:n.color,height:n.height,pointerEvents:"none",rx:4,width:n.width,x:n.x,y:n.y})})},"".concat(e.index,"-").concat(n.index,"-").concat(n.key))}))},"bar-group-horizontal-".concat(e.index,"-").concat(e.y0))}))}}),(0,S.jsx)(So.Z,{hideTicks:!0,scale:B,stroke:Z.muted,tickFormat:function(e){return D(e)},tickLabelProps:function(){return{fill:Z.active,fontFamily:ai.ry,fontSize:C,style:{width:"10px"},textAnchor:"end"}},tickStroke:Z.muted,tickValues:L,top:2}),(0,S.jsx)(Eo.Z,{label:g,labelProps:{fill:Z.muted,fontFamily:ai.ry,fontSize:C,textAnchor:"middle"},numTicks:x,scale:w,stroke:Z.muted,tickLabelProps:function(){return{fill:Z.active,fontFamily:ai.ry,fontSize:C,textAnchor:"middle"}},tickStroke:Z.muted,top:M})]}),p&&(0,S.jsx)("g",{children:(0,S.jsx)(Io.Z,{from:{x:P.left,y:v},pointerEvents:"none",stroke:Z.active,strokeDasharray:"5,2",strokeWidth:1,to:{x:A+P.left,y:v}})})]}),m&&p&&(0,S.jsxs)(Ao.Z,{left:h,style:Wo(Wo({},Ro.j),{},{backgroundColor:Z.tooltipBackground}),top:v,children:[d&&d(p),!d&&Object.entries(p).map((function(e){var n=(0,l.Z)(e,2),t=n[0],i=n[1];if(o!==t){var r=i;return(0,Q.HW)(r)&&String(r).split(".").length>=2&&(r=r.toFixed(4)),(0,S.jsxs)(_.ZP,{inverted:!0,small:!0,children:[t,": ",r]},t)}}))]})]})})));var Yo=function(e){var n,t=e.height,i=e.width,r=e.xAxisLabel,o=e.yAxisLabel,l=(0,$t.Z)(e,qo);return n="undefined"===typeof i?"100%":o?0===i?i:i-28:i,(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)("div",{style:{display:"flex",height:t,marginBottom:r?O.iI:null,width:"100%"},children:[o&&(0,S.jsx)(y.Z,{alignItems:"center",fullHeight:!0,justifyContent:"center",width:28,children:(0,S.jsx)(Do.Z,{children:(0,S.jsx)(_.ZP,{center:!0,muted:!0,small:!0,children:o})})}),(0,S.jsx)("div",{style:{height:t,width:n},children:(0,S.jsx)(eo.Z,{children:function(e){var n=e.width,t=e.height;return(0,S.jsx)(Vo,Wo(Wo({},l),{},{height:t,width:n}))}})})]}),r&&(0,S.jsx)("div",{style:{paddingLeft:o?36:0,paddingTop:4},children:(0,S.jsx)(_.ZP,{center:!0,muted:!0,small:!0,children:r})})]})},Xo=t(95422),Jo=["keyForYData"],$o=["height","width","xAxisLabel","yAxisLabel"];function el(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function nl(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?el(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):el(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var tl=6*O.iI,il=(0,To.Z)((function(e){var n=e.keyForYData,t=void 0===n?"__y":n,i=(0,$t.Z)(e,Jo),r=i.height,o=i.hideTooltip,c=i.renderNoDataText,u=i.renderTooltipContent,a=i.tooltipData,s=i.tooltipLeft,d=i.tooltipOpen,f=i.tooltipTop,p=i.width,h=i.xLabelFormat,m=i.xNumTicks,v=i.yNumTicks,b=zo(nl(nl({},i),{},{keyForYData:t,orientationVertical:!0})),g=b.colorScale,x=b.colors,j=b.data,y=b.fontSize,k=b.handleTooltip,Z=b.margin,O=b.tempScale,C=(b.tickValues,b.xKeys),E=(b.xMax,b.y1Scale),P=b.yLabelFormat,w=b.yMax,I=b.yScale,T=b.ySerialize,A=Math.min(m,p/tl);return p<10?null:(0,S.jsxs)("div",{children:[(0,S.jsxs)("svg",{height:r,width:p,children:[c&&!(null!==j&&void 0!==j&&j.length)&&(0,S.jsx)("text",{fill:x.active,dominantBaseline:"middle",textAnchor:"middle",fontFamily:ai.ry,fontSize:y,x:"50%",y:"50%",children:c()}),(null===j||void 0===j?void 0:j.length)&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Po.Z,{fill:"transparent",height:r-(Z.top+Z.bottom),onMouseLeave:function(){return o()},onMouseMove:k,onTouchMove:k,onTouchStart:k,rx:14,width:p-(Z.left+Z.right),x:Z.left,y:2*Z.top}),(0,S.jsxs)(no.Z,{top:Z.top,children:[(0,S.jsx)(Xo.Z,{color:g,data:j,height:w,keys:C,x0:T,x0Scale:I,x1Scale:E,yScale:O,children:function(e){return e.map((function(e){return(0,S.jsx)(no.Z,{left:e.x0+Z.left,top:Z.top,children:e.bars.map((function(n){return(0,S.jsx)("g",{children:(0,S.jsx)("rect",{fill:n.color,height:n.height,pointerEvents:"none",rx:4,width:n.width,x:n.x,y:n.y})},"".concat(e.index,"-").concat(n.index,"-").concat(n.key))}))},"bar-group-horizontal-".concat(e.index,"-").concat(e.x0))}))}}),(0,S.jsx)(So.Z,{left:Z.left,numTicks:v,scale:O,stroke:x.muted,tickFormat:function(e){return P(e)},tickLabelProps:function(){return{fill:x.active,fontFamily:ai.ry,fontSize:y,textAnchor:"end",transform:"translate(-2,2.5)"}},tickStroke:x.muted,top:Z.top}),(0,S.jsx)(Eo.Z,{hideTicks:!0,left:Z.left,numTicks:A,scale:I,stroke:x.muted,tickFormat:h,tickLabelProps:function(){return{fill:x.active,fontFamily:ai.ry,fontSize:y,textAnchor:"middle"}},tickStroke:x.muted,top:w+Z.top})]})]}),a&&(0,S.jsx)("g",{children:(0,S.jsx)(Io.Z,{from:{x:s,y:2*Z.top},pointerEvents:"none",stroke:x.active,strokeDasharray:"5,2",strokeWidth:1,to:{x:s,y:w+2*Z.top}})})]}),d&&a&&(0,S.jsxs)(Ao.Z,{left:s,style:nl(nl({},Ro.j),{},{backgroundColor:x.tooltipBackground}),top:f,children:[u&&u(a),!u&&Object.entries(a).map((function(e){var n=(0,l.Z)(e,2),i=n[0],r=n[1];if(t!==i){var o=r;return(0,Q.HW)(o)&&String(o).split(".").length>=2&&(o=o.toFixed(4)),(0,S.jsxs)(_.ZP,{inverted:!0,small:!0,children:[i,": ",o]},i)}})),(0,S.jsx)("br",{}),(0,S.jsxs)(_.ZP,{inverted:!0,small:!0,children:[h&&h(T(a)),!h&&T(a)]})]})]})}));var rl=function(e){var n=e.height,t=e.width,i=e.xAxisLabel,r=e.yAxisLabel,o=(0,$t.Z)(e,$o);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)("div",{style:{display:"flex",height:n,marginBottom:i?O.iI:null,width:"100%"},children:[r&&(0,S.jsx)(y.Z,{alignItems:"center",fullHeight:!0,justifyContent:"center",width:28,children:(0,S.jsx)(Do.Z,{children:(0,S.jsx)(_.ZP,{center:!0,muted:!0,small:!0,children:r})})}),(0,S.jsx)("div",{style:{height:n,width:r?0===t?t:t-28:t},children:(0,S.jsx)(eo.Z,{children:function(e){var n=e.height,t=e.width;return(0,S.jsx)(il,nl(nl({},o),{},{height:n,width:t}))}})})]}),i&&(0,S.jsx)("div",{style:{paddingLeft:r?36:0,paddingTop:4},children:(0,S.jsx)(_.ZP,{center:!0,muted:!0,small:!0,children:i})})]})},ol=t(66872),ll=t(68735),cl=t(320),ul=40*O.iI,al=v.default.div.withConfig({displayName:"indexstyle__ChartBlockStyle",componentId:"sc-1c3ufnj-0"})(["border-radius:","px;margin-left:","px;margin-right:","px;margin-top:","px;",""],Te.n_,.5*O.iI,.5*O.iI,1*O.iI,(function(e){return"\n background-color: ".concat((e.theme.background||ue.Z.background).codeArea,";\n ")})),sl=v.default.div.withConfig({displayName:"indexstyle__ConfigurationOptionsStyle",componentId:"sc-1c3ufnj-1"})(["flex:4;padding-left:","px;padding-right:","px;"],1*O.iI,1*O.iI),dl=v.default.div.withConfig({displayName:"indexstyle__CodeStyle",componentId:"sc-1c3ufnj-2"})(["padding-top:","px;",""],O.iI/2,(function(e){return"\n background-color: ".concat((e.theme.background||ue.Z.background).codeTextarea,";\n ")})),fl=v.default.div.withConfig({displayName:"indexstyle__CodeHelperStyle",componentId:"sc-1c3ufnj-3"})(["margin-bottom:","px;padding-bottom:","px;padding-left:","px;",""],O.cd*O.iI,O.iI,O.iI,(function(e){return"\n border-bottom: 1px solid ".concat((e.theme.borders||ue.Z.borders).medium,";\n ")}));function pl(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function hl(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?pl(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):pl(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var ml=function(e){var n,t=e.block,i=e.data,r=e.width,c=t.configuration,u=void 0===c?{}:c,a=u||{},s=a.chart_style,d=a.chart_type,f=a.y_sort_order,p=u.height||ul,h=(null===u||void 0===u||null===(n=u.metrics)||void 0===n?void 0:n.map((function(e){return"".concat((n=e).aggregation,"(").concat(n.column,")");var n})))||[],m=fe.n1,v=u.time_interval;if([_t.HOUR,_t.MINUTE,_t.SECOND].includes(v)&&(m=fe.OC),qn.BAR_CHART===d||qn.TIME_SERIES_BAR_CHART===d){var b=i.x,g=i.y,x=qn.TIME_SERIES_BAR_CHART===d;if(b&&g&&Array.isArray(b)&&Array.isArray(g)){var j,y=null===(j=u.group_by)||void 0===j?void 0:j.join(", "),k=null===h||void 0===h?void 0:h.join(", ");h.length||h.push(rt);var Z=h[0],C=b.map((function(e,n){return hl({__y:e},h.reduce((function(e,t,i){var r,l=null===g||void 0===g||null===(r=g[i])||void 0===r?void 0:r[n];return"undefined"===typeof l?e:hl(hl({},e),{},(0,o.Z)({},t,l))}),{}))}));Zt.ASCENDING===f?C=(0,pe.YC)(C,(function(e){return e[Z]}),{ascending:!1}):Zt.DESCENDING===f&&(C=(0,pe.YC)(C,(function(e){return e[Z]}),{ascending:!0}));var E={data:C,height:p,renderNoDataText:function(){return"No data matching query"},width:r,xNumTicks:3};return jt.HORIZONTAL===s?(0,S.jsx)(Yo,hl(hl({},E),{},{xAxisLabel:k||u.y,yAxisLabel:y||u.x})):(0,S.jsx)(rl,hl(hl({},E),{},{xAxisLabel:y,xLabelFormat:function(e){return x?Co()(1e3*e).format(fe.n1):e},xNumTicks:C.length,yAxisLabel:k,yNumTicks:5}))}}else if(qn.HISTOGRAM===d){var P,w=i.x,I=i.y,T=null===(P=u.group_by)||void 0===P?void 0:P.join(", ");if(w&&I&&Array.isArray(w))return(0,S.jsx)(ol.Z,{data:w.map((function(e,n){var t,i=e.max,r=e.min;return[i,null===I||void 0===I||null===(t=I[n])||void 0===t?void 0:t.value,r]})),height:p,width:r,large:!0,margin:{left:5*O.iI,right:1*O.iI,top:3*O.iI},noPadding:!0,renderTooltipContent:function(e){var n=(0,l.Z)(e,3),t=n[0],i=n[1],r=n[2];return(0,S.jsxs)(_.ZP,{inverted:!0,monospace:!0,small:!0,children:["Count : ",i,(0,S.jsx)("br",{}),"Bucket: ",r,"-",t]})},showAxisLabels:!0,showYAxisLabels:!0,showZeroes:!0,sortData:function(e){return(0,pe.YC)(e,"[0]")},xAxisLabel:T||u.x,yAxisLabel:T?"count(".concat(T,")"):u.y})}else if(qn.LINE_CHART===d||qn.TIME_SERIES_LINE_CHART===d){var A=i.x,R=i.y,D=qn.TIME_SERIES_LINE_CHART===d;if(A&&R&&Array.isArray(A)&&Array.isArray(R)&&Array.isArray(null===R||void 0===R?void 0:R[0])){var M,B=h;u.legend_labels&&(B=u.legend_labels.split(",").map((function(e){return e.trim()})));var N=A.map((function(e,n){return{x:e,y:(0,pe.w6)(R.length).map((function(e,t){var i=R[t][n];return"undefined"===typeof i||null===i?0:i}))}})),L=null===(M=u.group_by)||void 0===M?void 0:M.join(", "),F=h.join(", ");return(0,S.jsx)(ll.Z,{data:N,height:p,lineLegendNames:B,margin:{bottom:8*O.iI,left:5*O.iI},noCurve:!0,renderXTooltipContent:function(e){e.index;var n=e.x,t=u.x,i=n;return u.group_by&&(t=u.group_by.map(String).join(", ")),D&&(i=Co()(1e3*n).format(m)),(0,S.jsxs)(_.ZP,{inverted:!0,small:!0,children:[t,": ",i]})},renderYTooltipContent:function(e,n){var t=e.y;return(0,S.jsxs)(_.ZP,{inverted:!0,small:!0,children:[B&&B[n]&&"".concat(B[n],": "),t&&(0,Q.x6)((0,Q.QV)(t[n],4))]})},width:r?r-3*O.iI:r,xAxisLabel:L||String(u.x),xLabelFormat:function(e){return D?Co()(1e3*e).format(fe.n1):e},yAxisLabel:F||String(u.y),yLabelFormat:function(e){return e}})}}else if(qn.PIE_CHART===d){var U,H=i[String(u.x)],G=null===(U=u.group_by)||void 0===U?void 0:U.join(", ");if(H)return(0,S.jsx)(cl.Z,{data:Object.entries(H),getX:function(e){var n=(0,l.Z)(e,2),t=n[0],i=n[1];return"".concat(t," (").concat((0,Q.x6)(i),")")},getY:function(e){return(0,l.Z)(e,2)[1]},height:p,width:r,xAxisLabel:G||String(u.x)})}else if(qn.TABLE===d){var z=i.index,q=i.x,K=i.y;return Array.isArray(q)&&Array.isArray(K)&&Array.isArray(K[0])&&(0,S.jsx)(bn.Z,{columns:q,index:z,height:u.height?null:p,maxHeight:u.height?p:null,noBorderBottom:!0,noBorderLeft:!0,noBorderRight:!0,noBorderTop:!0,rows:K,width:r})}return(0,S.jsx)("div",{})},vl=t(76096);var bl=function(e){var n=e.children,t=e.onChange,i=(0,s.useState)(s.Children.map(n,(function(){return null}))),r=i[0],o=i[1],l=(0,s.useState)(0),c=l[0],u=l[1];return(0,S.jsx)(y.Z,{children:s.Children.map(n,(function(e,n){return(0,S.jsx)(Z.Z,{ml:n>=1?1:0,style:{display:"flex",flex:1},children:s.cloneElement(e,{onChange:function(e){o((function(i){return i[n]=e.target.value,t(i,{resetValues:function(){return u((function(e){return e+1}))},setValues:o}),i}))},value:r[n]})},"multi-select-child-".concat(n,"-").concat(c))}))})};function gl(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function xl(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?gl(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):gl(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function jl(e,n){var t,i,r,c,u=e.autocompleteItems,a=e.block,f=e.blockRefs,p=e.blocks,h=e.deleteWidget,b=e.executionState,g=e.fetchPipeline,x=e.fetchFileTree,E=e.messages,P=void 0===E?[]:E,w=e.onChangeContent,I=e.pipeline,T=e.runBlock,R=e.runningBlocks,D=e.savePipelineContent,N=e.selected,L=e.setAnyInputFocused,F=e.setErrors,U=e.setSelectedBlock,H=e.setTextareaFocused,G=e.textareaFocused,z=e.updateWidget,q=e.width,K=(0,s.useRef)(null),W=(0,s.useContext)(v.ThemeContext),Y=ce.ZP.blocks.pipelines.detail(null===I||void 0===I?void 0:I.uuid,null===a||void 0===a?void 0:a.upstream_blocks[0]).data,X=(null===Y||void 0===Y||null===(t=Y.block)||void 0===t?void 0:t.outputs)||(null===a||void 0===a?void 0:a.outputs)||[],J=(0,s.useState)(null),$=J[0],ee=J[1],ne=(0,s.useState)(null===(i=a.configuration)||void 0===i?void 0:i.chart_type),te=ne[0],ie=ne[1],re=(0,s.useState)(a.configuration),oe=re[0],de=re[1],fe=(0,s.useState)(a.content),he=fe[0],ve=fe[1],be=(0,s.useState)(!te||0===X.length),xe=be[0],je=be[1],ye=(0,s.useState)(!1),ke=ye[0],Ze=ye[1],_e=(0,s.useState)(null),Oe=_e[0],Ce=_e[1],Se=(0,s.useState)(null===a||void 0===a?void 0:a.upstream_blocks),Ee=Se[0],Pe=Se[1],we=(0,s.useState)((null===X||void 0===X?void 0:X.length)||0),Ie=we[0],Te=we[1],Ae=(0,s.useState)(a.uuid),Re=Ae[0],De=Ae[1],Me=Rt[te],Be=Dt[te],Ne=(0,s.useMemo)((function(){return null===p||void 0===p?void 0:p.filter((function(e){var n=e.type;return[m.tf.DATA_LOADER,m.tf.TRANSFORMER].includes(n)}))}),[p]),Le=(0,s.useMemo)((function(){return(0,pe.HK)(Ne,(function(e){return e.uuid}))}),[Ne]),Fe=!!R.find((function(e){return e.uuid===a.uuid}))||(null===P||void 0===P?void 0:P.length)>=1&&b!==ge.uF.IDLE,Ue=(0,s.useMemo)((function(){return null===P||void 0===P?void 0:P.filter((function(e){return null===e||void 0===e?void 0:e.type}))}),[P]),He=!!Ue.find((function(e){return e.error})),Ge=Ue.length>=1,ze=(0,s.useMemo)((function(){return{blockType:a.type,hasError:He,selected:N}}),[a.type,He,N]);if(null!==Ue&&void 0!==Ue&&Ue.length){var qe,Ke,We=Ue.length-1;c=null===Ue||void 0===Ue||null===(qe=Ue[We])||void 0===qe||null===(Ke=qe.data)||void 0===Ke?void 0:Ke[0]}c?(c=(c=c.slice(1,c.length-1)).replaceAll('\\"','"').replaceAll("\\'","'"),(0,Q.Pb)(c)&&(r=JSON.parse(c))):(null===X||void 0===X?void 0:X.length)>=1&&(r={},X.forEach((function(e){var n=e||{},t=n.text_data,i=n.type,o=n.variable_uuid;ge.Gi.TEXT===i&&(0,Q.Pb)(t)&&(r[o]=JSON.parse(t))})));var Qe=(0,s.useCallback)((function(e){var n=xl(xl(xl({},a),e),{},{configuration:xl(xl({},a.configuration),e.configuration)});D().then((function(){T({block:n,code:he,ignoreAlreadyRunning:!0,runUpstream:!!Ee.find((function(e){var n;return![m.DA.EXECUTED,m.DA.UPDATED].includes(null===(n=Le[e])||void 0===n?void 0:n.status)}))})})),Te((function(e){return e+1}))}),[a,Le,he,Te,Ee]),Ve=(0,s.useCallback)((function(e){ve(e),w(e)}),[w,ve]),Ye=(0,s.useCallback)((function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=n.autoRun;de((function(n){return xl(xl({},n),e)}));var i=xl(xl({},a),{},{configuration:xl(xl(xl({},oe),e),{},{chart_type:te})});z(i),Ie&&t&&Qe(i)}),[a,te,oe,Ie,Qe,de,z]);(0,s.useEffect)((function(){ee({python:Si({autocompleteItems:u,block:a,blocks:p,pipeline:I})})}),[u,a,p,I]);var Xe=(0,s.useMemo)((function(){return(0,S.jsx)(hn.Z,{autoHeight:!0,autocompleteProviders:$,onChange:Ve,selected:N,setSelected:function(e){return U(!0===e?a:null)},setTextareaFocused:H,showLineNumbers:!1,textareaFocused:G||qn.TABLE===te&&!xe,value:he,width:"100%"})}),[$,a,te,he,xe,N,U,H,G,Ve]),Je=(0,s.useMemo)((function(){return(He||Ge)&&(0,S.jsx)(Kn,xl(xl({},ze),{},{block:a,contained:!1,hideExtraInfo:!0,isInProgress:Fe,messages:Ue,selected:N}))}),[a,ze,He,Ge,Fe,Ue,N]),$e=(0,ae.Z)(xe),en=(0,ae.Z)(q);(0,s.useEffect)((function(){var e,n=null===K||void 0===K||null===(e=K.current)||void 0===e?void 0:e.getBoundingClientRect();$e!==xe||en!==q?(Ce(0),setTimeout((function(){var e,n,t=null===K||void 0===K||null===(e=K.current)||void 0===e||null===(n=e.getBoundingClientRect())||void 0===n?void 0:n.width;t&&Ce(t)}),100)):n&&Ce(n.width)}),[xe,$e,K,Ce,q,en]);var nn=(0,s.useMemo)((function(){var e=[];return Ee.forEach((function(n,t){var i=Le[n],r=(0,C.qn)(null===i||void 0===i?void 0:i.type,{blockColor:null===i||void 0===i?void 0:i.color,theme:W}).accent;e.push((0,S.jsxs)(Z.Z,{ml:2,children:[(0,S.jsxs)(_.ZP,{bold:!0,inline:!0,monospace:!0,small:!0,children:["df_",t+1]})," ",(0,S.jsx)(_.ZP,{inline:!0,monospace:!0,muted:!0,small:!0,children:"->"})," ",(0,S.jsx)(k.Z,{color:r,inline:!0,onClick:function(){var e,n,t=null===f||void 0===f||null===(e=f.current)||void 0===e?void 0:e["".concat(null===i||void 0===i?void 0:i.type,"s/").concat(null===i||void 0===i?void 0:i.uuid,".py")];null===t||void 0===t||null===(n=t.current)||void 0===n||n.scrollIntoView()},preventDefault:!0,small:!0,children:(0,S.jsx)(_.ZP,{color:r,monospace:!0,small:!0,children:n})})]},n))})),e}),[f,Le,W,Ee]),tn=(0,s.useMemo)((function(){var e,n=[],t=null===Me||void 0===Me||null===(e=Me.code)||void 0===e?void 0:e.reduce((function(e,n){var t=n.uuid;return xt.includes(t)?e.concat(t):e}),[]);return null===t||void 0===t||t.forEach((function(e){var t=oe[e];if(t){var i,r,o=null===(i=Mt[te])||void 0===i||null===(r=i[e])||void 0===r?void 0:r.call(i);n.push((0,S.jsxs)(Z.Z,{ml:2,children:[(0,S.jsx)(_.ZP,{bold:!0,inline:!0,monospace:!0,small:!0,children:t})," ",o&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(_.ZP,{inline:!0,monospace:!0,muted:!0,small:!0,children:"->"})," ",(0,S.jsx)(_.ZP,{default:!0,inline:!0,small:!0,children:o})]})]},t))}})),n}),[te,oe,Me]),rn=(0,ae.Z)(te),on=(0,ae.Z)(Ee);(0,s.useEffect)((function(){if((!rn&&te&&null!==Ee&&void 0!==Ee&&Ee.length||(null===on||void 0===on||!on.length)&&(null===Ee||void 0===Ee?void 0:Ee.length)>=1&&te)&&!he&&(0,Ii.Qr)(oe)&&Be){var e=xl(xl({},a),{},{upstream_blocks:Ee});Be.configuration&&Ye(Be.configuration(e)),Be.content&&Ve(Be.content(e))}}),[a,te,rn,oe,he,Be,Ye,Ve,Ee,on]);var ln=(0,s.useMemo)((function(){return oe.width_percentage||1}),[oe]),cn=(0,s.useMemo)((function(){return Object.entries(Me||{}).reduce((function(e,n){var t=(0,l.Z)(n,2),i=t[0],r=t[1];return xl(xl({},e),{},(0,o.Z)({},i,r.map((function(e){var n,t=e.autoRun,i=e.label,r=e.monospace,l=e.options,c=e.settings,u=void 0===c?{}:c,s=e.type,d=e.uuid,f={fullWidth:!0,key:d,label:(0,Q.kC)(i()),monospace:r,onBlur:function(){return U(a)},onChange:function(e){return Ye((0,o.Z)({},d,e.target.value),{autoRun:t})},onFocus:function(){return U(a)},value:(null===oe||void 0===oe?void 0:oe[d])||""},p=(null!==Y&&void 0!==Y&&Y.block?[Y.block]:[]).reduce((function(e,n){var t=n.outputs;return t?e.concat(t.reduce((function(e,n){var t=n.sample_data;return null!==t&&void 0!==t&&t.columns?e.concat(t.columns):e}),[])):e}),[]);if(It.COLUMNS===s){var h=oe[d]||[];n=(0,S.jsxs)(S.Fragment,{children:[(!u.maxValues||h.length<u.maxValues)&&(0,S.jsx)(hi.Z,xl(xl({},f),{},{onChange:function(e){var n=oe[d]||[],i=e.target.value;n.includes(i)?n=(0,pe.Od)(n,(function(e){return e===i})):n.push(i),Ye((0,o.Z)({},d,n),{autoRun:t})},value:null,children:(0,pe.YC)(p.filter((function(e){return!h.includes(e)})),(function(e){return e})).map((function(e){return(0,S.jsx)("option",{value:e,children:e},e)}))})),h.map((function(e){return(0,S.jsx)("div",{style:{display:"inline-block",marginRight:2,marginTop:2},children:(0,S.jsx)(hr.Z,{label:e,onClick:function(){Ye((0,o.Z)({},d,(0,pe.Od)(h,(function(n){return n===e}))),{autoRun:t})}})},e)}))]})}else if(It.METRICS===s){var m=oe[d]||[];n=(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(_.ZP,{bold:!0,children:"Metrics"}),(0,S.jsx)(_.ZP,{muted:!0,small:!0,children:"Select a column and an aggregation function."}),(0,S.jsxs)(bl,{onChange:function(e,n){var i=n.resetValues,r=n.setValues;2===e.filter((function(e){return!!e})).length&&(m.find((function(n){var t=n.aggregation;return n.column===e[1]&&t===e[0]}))||(Ye((0,o.Z)({},d,m.concat({aggregation:e[0],column:e[1]})),{autoRun:t}),r([null,null]),i()))},children:[(0,S.jsx)(hi.Z,xl(xl({},f),{},{label:"aggregation",children:(0,pe.YC)(Tt,(function(e){return e})).map((function(e){return(0,S.jsx)("option",{value:e,children:e},e)}))})),(0,S.jsx)(hi.Z,xl(xl({},f),{},{label:"column",children:(0,pe.YC)(p,(function(e){return e})).map((function(e){return(0,S.jsx)("option",{value:e,children:e},e)}))}))]}),m.map((function(e){var n=e.aggregation,i=e.column;return(0,S.jsx)("div",{style:{display:"inline-block",marginRight:2,marginTop:2},children:(0,S.jsx)(hr.Z,{label:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(_.ZP,{inline:!0,monospace:!0,children:[n,"("]}),i,(0,S.jsx)(_.ZP,{inline:!0,monospace:!0,children:")"})]}),onClick:function(){Ye((0,o.Z)({},d,(0,pe.Od)(m,(function(e){var t=e.aggregation,r=e.column;return n===t&&i===r}))),{autoRun:t})}})},"".concat(n,"(").concat(i,")"))}))]})}else n=l?(0,S.jsx)(hi.Z,xl(xl({},f),{},{children:l.map((function(e){return(0,S.jsx)("option",{value:e,children:e},e)}))})):(0,S.jsx)(M.Z,xl(xl({},f),{},{type:s}));return(0,S.jsx)(Z.Z,{mb:1,children:n},d)}))))}),{noCode:[]})}),[a,oe,Me,Y,U,Ye]),un=cn.code,an=cn.noCode,sn=(0,d.Db)(ce.ZP.widgets.pipelines.useUpdate(null===I||void 0===I?void 0:I.uuid,a.uuid),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(){Ze(!1),g(),x()},onErrorCallback:function(e,n){return null===F||void 0===F?void 0:F({errors:n,response:e})}})}}),dn=(0,l.Z)(sn,1)[0],fn="ChartBlock/".concat(a.uuid),pn=(0,V.y)(),mn=pn.registerOnKeyDown,vn=pn.unregisterOnKeyDown;return(0,s.useEffect)((function(){return function(){vn(fn)}}),[vn,fn]),mn(fn,(function(e,n,t){ke&&String(t[0])===String(B.Uq)&&String(t[1])!==String(B.zX)&&dn({widget:xl(xl({},a),{},{name:Re})})}),[a,ke,Re,dn]),(0,S.jsx)(vl.Z,{sm:12,md:12*ln,children:(0,S.jsxs)(al,{ref:n,children:[(0,S.jsx)(Z.Z,{mt:1,pt:1,px:1,children:(0,S.jsxs)(y.Z,{alignItems:"center",fullWidth:!0,justifyContent:"space-between",children:[(0,S.jsxs)(j.Z,{flex:1,style:{position:"relative"},children:[(0,S.jsx)(oi,{bold:!1,fullWidth:!0,inputValue:Re,notRequired:!0,onBlur:function(){return setTimeout((function(){return Ze(!1)}),300)},onChange:function(e){De(e.target.value),e.preventDefault()},onClick:function(){L(!0),Ze(!0)},onFocus:function(){L(!0),Ze(!0)},small:!0,stacked:!0,value:!ke&&a.uuid}),ke&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Z.Z,{ml:1}),(0,S.jsx)(k.Z,{noWrapping:!0,onClick:function(){return dn({widget:xl(xl({},a),{},{name:Re})})},preventDefault:!0,sameColorAsText:!0,small:!0,children:"Update chart name"})]})]}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(hi.Z,{compact:!0,onChange:function(e){var n=[e.target.value],t=xl(xl({},a),{},{upstream_blocks:n});z(t),Qe(t),Pe(n)},placeholder:"Source block",small:!0,value:(null===Ee||void 0===Ee?void 0:Ee[0])||"",children:null===Ne||void 0===Ne?void 0:Ne.map((function(e){var n=e.uuid;return(0,S.jsx)("option",{value:n,children:n},n)}))}),(0,S.jsx)(Z.Z,{mr:1}),!Fe&&(0,S.jsx)(le.Z,{appearBefore:!0,default:!0,label:"Run chart block",size:null,widthFitContent:!0,children:(0,S.jsx)(A.ZP,{blackBorder:!0,compact:!0,inline:!0,onClick:function(){return Qe(a)},uuid:"ChartBlock/run/".concat(a.uuid),children:(0,S.jsx)(se.Py,{size:2*O.iI})})}),ge.uF.QUEUED===b&&(0,S.jsx)(qt.Z,{color:(W||ue.Z).content.active,small:!0,type:"cylon"}),ge.uF.BUSY===b&&(0,S.jsx)(qt.Z,{color:(W||ue.Z).content.active,small:!0}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(le.Z,{appearBefore:!0,default:!0,label:"Edit chart",size:null,widthFitContent:!0,children:(0,S.jsx)(A.ZP,{blackBorder:!0,compact:!0,inline:!0,onClick:function(){return je((function(e){return!e}))},selected:xe,uuid:"ChartBlock/edit/".concat(a.uuid),children:(0,S.jsx)(se.I8,{size:2*O.iI})})}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(le.Z,{appearBefore:!0,default:!0,label:"Delete chart",size:null,widthFitContent:!0,children:(0,S.jsx)(A.ZP,{blackBorder:!0,compact:!0,inline:!0,onClick:function(){return h(a)},uuid:"ChartBlock/delete/".concat(a.uuid),children:(0,S.jsx)(se.rF,{size:2*O.iI})})})]})]})}),(0,S.jsx)(Z.Z,{mt:1}),(0,S.jsxs)(y.Z,{fullWidth:!0,justifyContent:"space-between",children:[(0,S.jsx)(j.Z,{flex:6,ref:K,children:r&&!(0,Ii.Qr)(r)&&(0,S.jsx)(Z.Z,{pb:3,children:(0,S.jsx)(ml,{block:xl(xl({},a),{},{configuration:xl(xl({},a.configuration),oe)}),data:r,width:Oe})})}),xe&&(0,S.jsx)(sl,{children:(0,S.jsxs)(y.Z,{flexDirection:"column",fullWidth:!0,children:[(0,S.jsx)(Z.Z,{mb:1,children:(0,S.jsx)(hi.Z,{onChange:function(e){var n=e.target.value,t=xl(xl({},a),{},{configuration:xl(xl({},oe),{},{chart_type:n})});z(t),Qe(t),ie(n)},placeholder:"Select chart type",value:te,children:kt.map((function(e){return(0,S.jsx)("option",{value:e,children:(0,Q.kC)(e)},e)}))})}),(0,S.jsx)(Z.Z,{mb:1,children:(0,S.jsx)(hi.Z,{onChange:function(e){return Ye((0,o.Z)({},tt,e.target.value))},placeholder:"Chart width",value:(null===oe||void 0===oe?void 0:oe.width_percentage)||1,children:[["1/2 width",.5],["full width",1]].map((function(e){var n=(0,l.Z)(e,2),t=n[0],i=n[1];return(0,S.jsx)("option",{value:i,children:t},t)}))})}),an]})})]}),xe&&!(null===un||void 0===un||!un.length)&&m.t6.SQL!==a.language&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(Z.Z,{my:1,px:1,children:[(0,S.jsx)(_.ZP,{bold:!0,children:"Custom chart code"}),(0,S.jsxs)(_.ZP,{muted:!0,children:["Write custom logic mapping data to input values for your chart.",(0,S.jsx)("br",{}),"This code is only executed if you don\u2019t have any columns or metrics selected."]})]}),(0,S.jsxs)(dl,{children:[Ee.length>=1&&(0,S.jsxs)(fl,{children:[(0,S.jsxs)(_.ZP,{muted:!0,small:!0,children:["Variables you can use in your code: ",nn]}),(0,S.jsxs)(_.ZP,{muted:!0,small:!0,children:["Variables that you must define: ",tn]})]}),Xe]})]}),Je&&(0,S.jsx)(Z.Z,{px:1,children:Je})]})})}var yl=s.forwardRef(jl),kl=t(97361),Zl=["blockRefs","blocks","chartRefs","deleteWidget","messages","onChangeChartBlock","runBlock","runningBlocks","savePipelineContent","selectedBlock","setAnyInputFocused","setErrors","setSelectedBlock","setTextareaFocused","textareaFocused","updateWidget","widgets","width"];function _l(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Ol(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?_l(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):_l(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var Cl=function(e){var n=e.blockRefs,t=e.blocks,i=e.chartRefs,r=e.deleteWidget,l=e.messages,c=e.onChangeChartBlock,u=e.runBlock,a=e.runningBlocks,d=e.savePipelineContent,f=e.selectedBlock,p=e.setAnyInputFocused,h=e.setErrors,m=e.setSelectedBlock,v=e.setTextareaFocused,b=e.textareaFocused,g=e.updateWidget,x=e.widgets,j=e.width,k=(0,$t.Z)(e,Zl),Z=(0,s.useMemo)((function(){return a.reduce((function(e,n,t){return Ol(Ol({},e),{},(0,o.Z)({},n.uuid,Ol(Ol({},n),{},{priority:t})))}),{})}),[a]);return(0,S.jsxs)(y.Z,{flexDirection:"column",fullWidth:!0,children:[(0,S.jsx)(kl.Z,{fullHeight:!0,style:{marginLeft:.5*O.iI,marginRight:.5*O.iI},children:null===x||void 0===x?void 0:x.map((function(e){var o=e.uuid,x=Z[o],y=x?0===x.priority?ge.uF.BUSY:ge.uF.QUEUED:ge.uF.IDLE;return i.current[o]=(0,s.createRef)(),(0,s.createElement)(yl,Ol(Ol({},k),{},{block:e,blockRefs:n,blocks:t,chartRefs:i,deleteWidget:r,executionState:y,key:o,messages:l[o],onChangeContent:function(e){return c(o,e)},ref:i.current[o],runBlock:u,runningBlocks:a,savePipelineContent:d,selected:(null===f||void 0===f?void 0:f.uuid)===o,setAnyInputFocused:p,setErrors:h,setSelectedBlock:m,setTextareaFocused:v,textareaFocused:b,updateWidget:g,width:j}))}))}),(0,S.jsx)("div",{style:{height:"80vh"}})]})},Sl=v.default.svg.withConfig({displayName:"EmptyCharts__SVGStyle",componentId:"sc-ttsjrp-0"})([""]),El=function(e){var n=e.size,t=void 0===n?20:n,i=e.viewBox,r=void 0===i?"0 0 358 305":i;return(0,S.jsxs)(Sl,{height:t*(305/358),viewBox:r,width:t,children:[(0,S.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M290 47H66c-3.866 0-7 3.134-7 7v200c0 3.866 3.134 7 7 7h224c3.866 0 7-3.134 7-7V54c0-3.866-3.134-7-7-7zM66 46c-4.4183 0-8 3.5817-8 8v200c0 4.418 3.5817 8 8 8h224c4.418 0 8-3.582 8-8V54c0-4.4183-3.582-8-8-8H66z",fill:"#000"}),(0,S.jsx)("path",{fill:"#000",d:"M118 46h1v216h-1zM178 46h1v216h-1zM238 46h1v216h-1z"}),(0,S.jsx)("path",{fill:"#000",d:"M59 208.25v-1h239v1zM59 154.5v-1h239v1zM59 100.75v-1h239v1z"}),(0,S.jsx)("rect",{x:"209.651",y:"17.1125",width:"1.0163",height:"14.2284",rx:".5082",transform:"rotate(24.933 209.651 17.1125)",fill:"#2AB2FE"}),(0,S.jsx)("path",{fill:"#2AB2FE",d:"M207.788 23.5313l35.4813 16.4949-.4285.9215-35.4812-16.4948zM247.033 31.9316c.946-2.0359 3.364-2.9191 5.4-1.9726l31.795 14.7811-11.383 24.4836-31.794-14.7811c-2.036-.9465-2.92-3.3642-1.973-5.4002l7.955-17.1108z"}),(0,S.jsx)("path",{d:"M284.228 44.7401l31.795 14.7811c2.036.9465 2.919 3.3642 1.972 5.4001l-7.954 17.1109c-.947 2.0359-3.365 2.9191-5.401 1.9726l-31.795-14.7811 11.383-24.4836z",fill:"#0093E4"}),(0,S.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M352.959 83.7347a.5082.5082 0 00-.675.2466l-2.571 5.5296-35.481-16.4949-.428.9216 35.481 16.4949-2.571 5.5295a.5081.5081 0 00.247.675.5082.5082 0 00.675-.2466l5.57-11.9806a.5083.5083 0 00-.247-.6751z",fill:"#2AB2FE"}),(0,S.jsx)("circle",{cx:"55.2178",cy:"34.6274",r:"5.2954",fill:"#8ADE00"}),(0,S.jsx)("circle",{cx:"113.818",cy:"106.582",r:"5.2954",fill:"#8ADE00"}),(0,S.jsx)("circle",{cx:"84.2832",cy:"80.6953",r:"5.2954",fill:"#8ADE00"}),(0,S.jsx)("circle",{cx:"117.115",cy:"43.6274",r:"5.2954",fill:"#8ADE00"}),(0,S.jsx)("path",{d:"M337.354 256.065a38.3848 38.3848 0 01-10.816 21.271 38.3722 38.3722 0 01-21.293 10.768 38.3787 38.3787 0 01-23.542-3.895 38.3764 38.3764 0 01-16.691-17.054l17.208-8.494a19.1932 19.1932 0 0020.117 10.475 19.189 19.189 0 0010.647-5.385c2.886-2.88 4.78-6.605 5.407-10.635l18.963 2.949z",fill:"#FF3C3C"}),(0,S.jsx)("path",{d:"M294.876 288.277a38.3849 38.3849 0 01-21.64-10.056 38.3818 38.3818 0 01-11.516-20.899 38.3896 38.3896 0 013.06-23.666 38.386 38.386 0 0116.453-17.283l9.098 16.897a19.1904 19.1904 0 00-9.757 20.474 19.1937 19.1937 0 005.758 10.45 19.194 19.194 0 0010.82 5.028l-2.276 19.055z",fill:"#2ECDF7"}),(0,S.jsx)("path",{d:"M275.892 219.85a38.3804 38.3804 0 0145.342-1.268 38.3803 38.3803 0 0114.45 18.989 38.3873 38.3873 0 01.436 23.858l-18.346-5.631a19.1827 19.1827 0 00-.218-11.929 19.1907 19.1907 0 00-7.225-9.495 19.1875 19.1875 0 00-11.439-3.39 19.192 19.192 0 00-11.232 4.024l-11.768-15.158z",fill:"#885EFF"}),(0,S.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M259.206 102.57c.241.135.327.439.193.68l-39.314 70.576c-.613 1.1-1.962 1.565-3.124 1.093-3.766-1.53-13.762-5.285-26.356-7.597-12.6-2.314-27.762-3.177-41.881 1.037-16.112 4.81-27.78 14.07-35.424 22.135-3.822 4.032-6.635 7.763-8.491 10.483-.928 1.36-1.616 2.467-2.072 3.232-.228.383-.397.68-.509.881-.057.1-.098.177-.126.227l-.03.057-.008.014-.001.003a.5008.5008 0 01-.676.21.5005.5005 0 01-.209-.676l.442.233-.442-.233.001-.001.002-.005.009-.016.033-.062c.03-.055.073-.135.132-.239.116-.208.29-.513.523-.904.465-.782 1.165-1.906 2.105-3.285 1.881-2.756 4.727-6.53 8.591-10.607 7.727-8.153 19.539-17.532 35.864-22.405 14.331-4.278 29.668-3.391 42.347-1.063 12.685 2.329 22.748 6.109 26.552 7.654.699.284 1.51.002 1.875-.653l39.313-70.575a.5008.5008 0 01.681-.194z",fill:"#7D55EC"}),(0,S.jsx)("path",{d:"M221.651 176.111c0 2.139-1.734 3.873-3.873 3.873-2.139 0-3.873-1.734-3.873-3.873 0-2.139 1.734-3.873 3.873-3.873 2.139 0 3.873 1.734 3.873 3.873zM157.778 166.428c0 2.139-1.734 3.873-3.873 3.873-2.139 0-3.873-1.734-3.873-3.873 0-2.139 1.734-3.873 3.873-3.873 2.139 0 3.873 1.734 3.873 3.873zM106.428 204.191c0 2.139-1.734 3.873-3.873 3.873-2.139 0-3.8726-1.734-3.8726-3.873 0-2.139 1.7336-3.873 3.8726-3.873s3.873 1.734 3.873 3.873zM262.35 104.459c0 2.139-1.734 3.873-3.873 3.873-2.139 0-3.873-1.734-3.873-3.873 0-2.139 1.734-3.873 3.873-3.873 2.139 0 3.873 1.734 3.873 3.873z",fill:"#7D55EC"}),(0,S.jsx)("path",{d:"M8.5523 214.855c-.3562-1.045.2025-2.181 1.248-2.538l13.7251-4.677c1.0456-.356 2.1819.203 2.5382 1.248l29.6737 87.084-17.5112 5.967-29.6738-87.084z",fill:"#4776FF"}),(0,S.jsx)("path",{d:"M45.0935 264.735c-.3562-1.045.2025-2.182 1.2481-2.538l13.725-4.677c1.0455-.356 2.1819.203 2.5382 1.248l10.6438 31.237-17.5112 5.967-10.6439-31.237z",fill:"#FFCC19"}),(0,S.jsx)("path",{d:"M54.4607 234.868c-.3563-1.046.2025-2.182 1.248-2.538l13.7251-4.677c1.0455-.356 2.1819.202 2.5382 1.248l18.7879 55.137-17.5113 5.967-18.7879-55.137z",fill:"#4776FF"})]})};var Pl,wl=function(e){var n=e.blocksInNotebook;return e.extensionOption,(0,s.useMemo)((function(){return(null===n||void 0===n?void 0:n.filter((function(e){var n=e.type;return m.tf.DBT===n})))||[]}),[n]),(0,S.jsx)(S.Fragment,{})};function Il(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Tl(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Il(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Il(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}!function(e){e.DBT="dbt",e.GREAT_EXPECTATIONS="great_expectations"}(Pl||(Pl={}));var Al=function(e){var n=e.addNewBlockAtIndex,t=e.autocompleteItems,i=e.blockRefs,r=e.blocks,c=e.blocksInNotebook,u=e.deleteBlock,a=e.extensionOption,f=e.fetchFileTree,p=e.fetchPipeline,h=e.interruptKernel,v=e.messages,b=e.onChangeCallbackBlock,g=e.onChangeCodeBlock,x=e.pipeline,j=e.runBlock,y=e.runningBlocks,C=e.savePipelineContent,E=e.selectedBlock,P=e.setAnyInputFocused,w=e.setErrors,I=e.setSelectedBlock,T=e.setTextareaFocused,R=e.textareaFocused,D=(0,s.useRef)(null),M=(0,s.useState)(!1),N=M[0],L=M[1],U=(a||{}).uuid,H=(x||{}).extensions,G=(0,s.useMemo)((function(){return(null===a||void 0===a?void 0:a.templates)||[]}),[a]),q=(0,s.useMemo)((function(){return null===H||void 0===H?void 0:H[U]}),[U,H]),K=(0,s.useMemo)((function(){return(null===q||void 0===q?void 0:q.blocks)||[]}),[q]),W=(0,s.useMemo)((function(){return(0,pe.HK)(K,(function(e){return e.uuid}))}),[K]),Q=(0,s.useMemo)((function(){return U===(null===E||void 0===E?void 0:E.extension_uuid)&&W[null===E||void 0===E?void 0:E.uuid]}),[W,U,E]),Y=(0,s.useMemo)((function(){return y.reduce((function(e,n,t){return Tl(Tl({},e),{},(0,o.Z)({},n.uuid,Tl(Tl({},n),{},{priority:t})))}),{})}),[y]),X=(0,d.Db)((function(e){var n=e.block,t=e.upstream_blocks;return ce.ZP.blocks.pipelines.useUpdate(null===x||void 0===x?void 0:x.uuid,encodeURIComponent(null===n||void 0===n?void 0:n.uuid),{query:{extension_uuid:null===n||void 0===n?void 0:n.extension_uuid}})({block:{upstream_blocks:t}})}),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(){p()},onErrorCallback:function(e,n){return null===w||void 0===w?void 0:w({errors:n,response:e})}})}}),J=(0,l.Z)(X,2),$=J[0],ee=J[1].isLoading,ne=(0,s.useMemo)((function(){return K.map((function(e,n){var o=Tl(Tl({},e),{},{extension_uuid:U}),l=o.type,a=o.uuid,d=(null===E||void 0===E?void 0:E.uuid)===a,k=Y[a],_=k?0===k.priority?ge.uF.BUSY:ge.uF.QUEUED:ge.uF.IDLE,A="".concat(l,"s/").concat(a,".py");return i.current[A]=(0,s.createRef)(),(0,S.jsx)(Z.Z,{mt:O.cd,children:(0,S.jsx)(Mi,{allBlocks:r,autocompleteItems:t,block:o,blockIdx:n,blockRefs:i,blocks:r,defaultValue:o.content,deleteBlock:function(e){u(Tl(Tl({},e),{},{extension_uuid:U})),P(!1)},executionState:_,extraContent:(0,S.jsx)(jo,{block:o,blockActionDescription:"Click a block name to run expectations on it.",blocks:c,inputPlaceholder:"Select blocks to run expectations on",loading:ee,supportedUpstreamBlockLanguages:[m.t6.PYTHON],supportedUpstreamBlockTypes:[m.tf.DATA_EXPORTER,m.tf.DATA_LOADER,m.tf.DBT,m.tf.TRANSFORMER],updateBlock:$}),fetchFileTree:f,fetchPipeline:p,hideRunButton:!0,interruptKernel:h,messages:v[a],noDivider:!0,onCallbackChange:function(e){return b(l,a,e)},onChange:function(e){return g(l,a,e)},pipeline:x,ref:i.current[A],runBlock:j,runningBlocks:y,savePipelineContent:C,selected:d,setAnyInputFocused:P,setErrors:w,setSelected:function(e){return I(!0===e?o:null)},setTextareaFocused:T,textareaFocused:d&&R})},a)}))}),[t,i,r,c,u,K,U,f,p,h,ee,v,b,g,x,j,y,Y,C,E,P,w,I,T,R,$]),te="Extensions/GreatExpectations/index",ie=(0,V.y)(),re=ie.disableGlobalKeyboardShortcuts,oe=ie.registerOnKeyDown,le=ie.unregisterOnKeyDown;return(0,s.useEffect)((function(){return function(){le(te)}}),[le,te]),oe(te,(function(e,n){!re&&Q&&((0,F.y)([B.zX,B.Um],n)||(0,F.y)([B.PQ,B.Um],n))&&(e.preventDefault(),C())}),[Q,C]),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(Z.Z,{mb:O.cd,children:[(0,S.jsx)(_.ZP,{default:!0,children:"Add an extension block to start writing expectations for blocks in the current pipeline."}),(0,S.jsx)(Z.Z,{mt:1,children:(0,S.jsxs)(_.ZP,{default:!0,children:["When a block in your pipeline runs, it\u2019ll run any tests you define in its code. All associated extension blocks will also run during that phase. Learn more about the ",(0,S.jsx)(k.Z,{href:"https://docs.mage.ai/development/testing/great-expectations",openNewWindow:!0,children:"Great Expectation power up"}),"."]})}),(0,S.jsx)(Z.Z,{mt:1,children:(0,S.jsxs)(_.ZP,{default:!0,children:["For all available expectations, read Great Expectation\u2019s ",(0,S.jsx)(k.Z,{href:"https://greatexpectations.io/expectations/",openNewWindow:!0,children:"documentation"}),"."]})})]}),ne,(0,S.jsx)(Z.Z,{mt:O.cd,children:(0,S.jsx)(z.Z,{onClickOutside:function(){return L(!1)},open:!0,children:(0,S.jsx)(we.Z,{disableKeyboardShortcuts:!0,items:null===G||void 0===G?void 0:G.map((function(e){var t=e.description,i=e.name,r=e.path;return{label:function(){return i},onClick:function(){return n({config:{template_path:r},extension_uuid:U,type:m.tf.EXTENSION},(null===K||void 0===K?void 0:K.length)||0)},tooltip:function(){return t},uuid:e.uuid}})),onClickCallback:function(){return L(!1)},open:N,parentRef:D,uuid:"Extension",children:(0,S.jsx)(A.ZP,{beforeElement:(0,S.jsx)(Re,{teal:!0,children:(0,S.jsx)(se.mm,{size:Ae})}),inline:!0,onClick:function(e){e.preventDefault(),L(!0)},uuid:"AddNewBlocks/Extension",children:"Extension block"})})})})]})},Rl=["pipeline"];function Dl(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Ml(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Dl(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Dl(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var Bl=function(e){var n=e.pipeline,t=(0,$t.Z)(e,Rl),i=(0,f.useRouter)(),r=ce.ZP.extension_options.list().data,o=(0,s.useMemo)((function(){return(null===r||void 0===r?void 0:r.extension_options)||[]}),[r]),l=(0,s.useMemo)((function(){return(0,pe.HK)(o,(function(e){return e.uuid}))}),[o]),c=(0,s.useState)(null),u=c[0],a=c[1],d=(0,s.useMemo)((function(){return l[u]}),[l,u]),p=(0,s.useMemo)((function(){return Ml(Ml({},t),{},{pipeline:n})}),[n,t]);(0,s.useEffect)((function(){var e;a(null===(e=(0,yo.iV)())||void 0===e?void 0:e.extension)}),[i.asPath]);var h=(0,s.useMemo)((function(){return n?(Pl.GREAT_EXPECTATIONS===u?e=Al:Pl.DBT===u&&(e=wl),e?(0,S.jsx)(e,Ml(Ml({},p),{},{extensionOption:d})):void 0):null;var e}),[d,n,u,p]);return(0,S.jsx)(ye.W,{backend:ke.PD,children:(0,S.jsxs)(Z.Z,{p:O.cd,children:[!u&&(0,S.jsxs)(Z.Z,{mb:O.cd,children:[(0,S.jsxs)(_.ZP,{default:!0,children:["Power up your pipeline with extensions. Learn more about ",(0,S.jsx)(k.Z,{href:"https://docs.mage.ai/design/blocks/extension",openNewWindow:!0,children:"extension blocks"}),"."]}),(0,S.jsx)(Z.Z,{mt:1,children:(0,S.jsxs)(_.ZP,{default:!0,children:["Click on a power up below to add and configure it for the ",(0,S.jsx)(_.ZP,{inline:!0,monospace:!0,children:null===n||void 0===n?void 0:n.uuid})," pipeline."]})})]}),!r&&!u&&(0,S.jsx)(qt.Z,{}),h,!u&&(null===o||void 0===o?void 0:o.map((function(e,n){var t=e.description,i=e.name,r=e.uuid;return(0,S.jsx)(Z.Z,{mt:n>=1?O.cd:0,children:(0,S.jsx)(k.Z,{block:!0,noHoverUnderline:!0,onClick:function(){return(0,he.u7)({extension:r},{pushHistory:!0})},preventDefault:!0,children:(0,S.jsx)(R.Z,{dark:!0,children:(0,S.jsxs)(y.Z,{alignItems:"center",justifyContent:"space-between",children:[(0,S.jsxs)(j.Z,{alignItems:"center",children:[(0,S.jsx)(Er,{fullWidth:!1,children:(0,S.jsx)(Z.Z,{p:O.cd,children:(0,S.jsx)(y.Z,{alignItems:"center",children:(0,S.jsx)("img",{alt:i,height:3*O.iI,src:"/images/extensions/".concat(r,"/logo.png"),width:3*O.iI})})})}),(0,S.jsx)(Z.Z,{mr:O.cd}),(0,S.jsxs)(j.Z,{flexDirection:"column",children:[(0,S.jsx)(_.ZP,{bold:!0,children:i}),(0,S.jsx)(_.ZP,{default:!0,small:!0,children:t})]})]}),(0,S.jsx)(se._Q,{})]})})})},r)})))]})})},Nl=t(88560),Ll=t(86585),Fl=(v.default.div.withConfig({displayName:"indexstyle__ContainerStyle",componentId:"sc-43nc8t-0"})(["border-radius:","px;",""],Te.TR,(function(e){return"\n border: 1px solid ".concat((e.theme.interactive||ro.Z.interactive).defaultBorder,";\n ")})),v.default.div.withConfig({displayName:"indexstyle__ColumnProfileStyle",componentId:"sc-43nc8t-1"})(["",""],(function(e){return"\n background: ".concat((e.theme.background||ro.Z.background).table,";\n border-bottom: 1px solid ").concat((e.theme.interactive||ro.Z.interactive).defaultBorder,";\n border-right: 1px solid ").concat((e.theme.interactive||ro.Z.interactive).defaultBorder,";\n ")}))),Ul=(v.default.div.withConfig({displayName:"indexstyle__HeaderStyle",componentId:"sc-43nc8t-2"})(["background:",";padding:","px ","px;"," border-top-left-radius:","px;border-top-right-radius:","px;"],Lo.Uq,1.75*O.iI,O.tr,(function(e){return"\n border-bottom: 1px solid ".concat((e.theme.interactive||ro.Z.interactive).defaultBorder,";\n ")}),Te.TR,Te.TR),v.default.div.withConfig({displayName:"indexstyle__FeatureProfileStyle",componentId:"sc-43nc8t-3"})(["",""],(function(e){return"\n border-bottom: 1px solid ".concat((e.theme.interactive||ro.Z.interactive).defaultBorder,";\n ")}))),Hl=(v.default.div.withConfig({displayName:"indexstyle__BodyStyle",componentId:"sc-43nc8t-4"})(["border-bottom-left-radius:","px;border-bottom-right-radius:","px;overflow-y:scroll;"],Te.TR,Te.TR),v.default.div.withConfig({displayName:"indexstyle__CellStyle",componentId:"sc-43nc8t-5"})([""," padding:","px;"],(function(e){return e.backgroundColor&&"\n background-color: ".concat(e.backgroundColor,";\n ")}),O.iI)),Gl=v.default.div.withConfig({displayName:"indexstyle__ScrollOverflowStyle",componentId:"sc-43nc8t-6"})([""," overflow-x:auto;"],Pn.w5);function zl(e,n){return{average:e["".concat(n,"/average")],avg_string_length:e["".concat(n,"/avg_string_length")],avg_word_count:e["".concat(n,"/avg_word_count")],completeness:e["".concat(n,"/completeness")],count:e["".concat(n,"/count")],count_distinct:e["".concat(n,"/count_distinct")],invalid_indices:e["".concat(n,"/invalid_indices")],invalid_value_count:e["".concat(n,"/invalid_value_count")],invalid_value_rate:e["".concat(n,"/invalid_value_rate")],invalid_values:e["".concat(n,"/invalid_values")],max:e["".concat(n,"/max")],max_character_count:e["".concat(n,"/max_character_count")],max_null_seq:e["".concat(n,"/max_null_seq")],max_word_count:e["".concat(n,"/max_word_count")],median:e["".concat(n,"/median")],min:e["".concat(n,"/min")],min_character_count:e["".concat(n,"/min_character_count")],min_word_count:e["".concat(n,"/min_word_count")],mode:e["".concat(n,"/mode")],null_value_count:e["".concat(n,"/null_value_count")],null_value_rate:e["".concat(n,"/null_value_rate")],outlier_count:e["".concat(n,"/outlier_count")],outlier_ratio:e["".concat(n,"/outlier_ratio")],outliers:e["".concat(n,"/outliers")],quality:e["".concat(n,"/quality")],skew:e["".concat(n,"/skew")],std:e["".concat(n,"/std")],sum:e["".concat(n,"/sum")],unique_value_rate:e["".concat(n,"/unique_value_rate")],validity:e["".concat(n,"/validity")],value_counts:e["".concat(n,"/value_counts")]}}var ql=["Type","Missing","Unique","Min","Max","Mean","Median","Mode","Invalid","Outliers","Skewness","Std dev"],Kl={Missing:0,Invalid:0,Outliers:0,Unique:.9};function Wl(e){var n=e.columns,t=e.feature,i=e.shouldLink,r=e.statistics,o=(0,s.useContext)(v.ThemeContext),l=t.columnType,c=t.uuid,u=zl(r,c),a=u.average,d=u.avg_string_length,f=u.avg_word_count,p=u.count,h=u.count_distinct,m=u.invalid_value_count,b=u.invalid_value_rate,g=u.max,x=u.max_character_count,C=u.max_word_count,E=u.min,P=u.min_character_count,w=u.min_word_count,I=u.median,T=u.mode,A=u.null_value_count,R=u.null_value_rate,D=u.outlier_count,M=u.skew,B=u.std,N=u.unique_value_rate,L=[l,A,h,E,g,a,I,T,m,D,M,B],F={Min:w,Max:C,Mean:f},U={Min:"".concat((0,Q._6)("character",P)),Max:"".concat((0,Q._6)("character",x)),Mean:"".concat((0,Q._6)("character",(0,Q.QV)(d)))},H={Invalid:(0,Q.T3)(b),Missing:(0,Q.T3)(R),Unique:(0,Q.T3)(N)},G=Ll.T5[l],z=[o.background.row,o.background.row2],q=z[0],K=z[1],W=i?k.Z:_.ZP;return(0,S.jsxs)(j.Z,{flexDirection:"column",children:[(0,S.jsx)(Ul,{children:(0,S.jsx)(Z.Z,{px:1,py:2,children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[G&&(0,S.jsxs)(j.Z,{title:Nl.Rp[l],children:[(0,S.jsx)(G,{size:2*O.iI}),"\xa0"]}),(0,S.jsx)(W,{inline:!0,onClick:i?function(){return(0,he.u7)({column:n.indexOf(c)},{pushHistory:!0})}:void 0,preventDefault:!0,secondary:!0,children:(0,S.jsx)(_.ZP,{bold:!0,default:!i,maxWidth:25*O.iI,monospace:!0,secondary:i,textOverflow:!0,title:c,children:c})})]})})}),L.map((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"-",n=arguments.length>1?arguments[1]:void 0,t=ql[n],i=l===Nl.RL.TEXT&&t in F,r=i?F[t]:e,o=isNaN(r)?r:(0,Q.QV)(r),c=t in Kl&&o/p>Kl[t];return(0,S.jsx)(Hl,{backgroundColor:n%2===0?q:K,children:(0,S.jsxs)(_.ZP,{bold:c,danger:c,default:!0,textOverflow:!0,title:i?U[t]:"",children:[i?"".concat((0,Q._6)("word",o)):o,t in H&&" (".concat(H[t],")")]})},n)}))]})}var Ql=function(e){var n=e.features,t=void 0===n?[]:n,i=e.shouldLink,r=e.statistics,o=(0,s.useContext)(v.ThemeContext),l=(0,s.useMemo)((function(){return t.map((function(e){return e.uuid}))}),[t]);return(0,S.jsx)(vo.Z,{headerTitle:"Feature profiles",children:(0,S.jsxs)(y.Z,{children:[(0,S.jsx)(Fl,{children:(0,S.jsxs)(j.Z,{flex:1,flexDirection:"column",style:{background:o.background.table},children:[(0,S.jsx)(Z.Z,{mr:1.25*O.iI,mt:"".concat(53,"px")}),ql.map((function(e,n){return(0,S.jsx)(Hl,{children:(0,S.jsx)(_.ZP,{default:!i,secondary:i,children:e})},"".concat(e,"-").concat(n))}))]})}),(0,S.jsx)(Gl,{children:(0,S.jsx)(y.Z,{children:t.map((function(e,n){return(0,S.jsx)(Ul,{children:(0,S.jsx)(Wl,{columns:l,feature:e,shouldLink:i,statistics:r})},"".concat(e,"-").concat(n))}))})})]})})},Vl=t(23351),Yl=t(21764),Xl=t(22673),Jl=t(52769),$l=t(1286),ec=(O.iI,$l.O$,O.iI,si.dN,v.default.div.withConfig({displayName:"indexstyle__SidekickContainerStyle",componentId:"sc-cr39lf-0"})(["height:calc(100vh - ","px - ","px);width:fit-content;",""],Kr.Wi,Pn.nn,(function(e){return e.fullWidth&&"\n width: 100%;\n "})),v.default.div.withConfig({displayName:"indexstyle__PaddingContainerStyle",componentId:"sc-cr39lf-1"})(["padding:","px;",""],2*O.iI,(function(e){return e.noPadding&&"\n padding: 0;\n "})),v.default.table.withConfig({displayName:"indexstyle__TableStyle",componentId:"sc-cr39lf-2"})(["",""],(function(e){return e.width&&"\n width: ".concat(e.width,"px;\n ")}))),nc=v.default.td.withConfig({displayName:"indexstyle__CellStyle",componentId:"sc-cr39lf-3"})(["display:flex;align-items:center;justify-content:space-between;border:1px solid #1C1C1C;height:100%;",""],(function(e){return!e.noPadding&&"\n padding: 0 ".concat(2*O.iI,"px;\n ")})),tc=t(19963);var ic=function(e){var n=e.copyText,t=e.deleteVariable,i=e.fetchVariables,r=e.hideEdit,o=e.obfuscate,c=e.pipelineUUID,u=e.variable,a=u.uuid,f=(u.type,u.value),p=(0,s.useRef)(null),h=(0,s.useState)(!1),m=h[0],v=h[1],b=(0,s.useState)(a),g=b[0],x=b[1],y=(0,s.useState)(f),k=y[0],Z=y[1],C=(0,s.useState)(!1),E=C[0],P=C[1],w=(0,d.Db)(ce.ZP.variables.pipelines.useUpdate(c,a),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(){P(!1),i()}})}}),I=(0,l.Z)(w,1)[0],T=(0,s.useCallback)((function(e){if("Enter"===e.key){var n=k;try{n=JSON.parse(k)}catch(t){}I({variable:{name:g,value:n}})}else"Escape"===e.key&&P(!1)}),[g,k]);(0,s.useEffect)((function(){var e;E&&(null===p||void 0===p||null===(e=p.current)||void 0===e||e.focus())}),[E,p]);var R=n||"kwargs['".concat(a,"']");return(0,S.jsx)("div",{onMouseEnter:function(){return v(!0)},onMouseLeave:function(){return v(!1)},children:(0,S.jsxs)(kl.Z,{children:[(0,S.jsx)(vl.Z,{md:1,hiddenSmDown:!0,children:(0,S.jsx)(nc,{noPadding:!0,children:(0,S.jsx)(A.ZP,{backgroundColor:tc.qJ,borderless:!0,centerText:!0,muted:!0,onClick:function(){navigator.clipboard.writeText(R),Yl.Am.success("Successfully copied to clipboard.",{position:Yl.Am.POSITION.BOTTOM_RIGHT,toastId:a})},small:!0,uuid:"Sidekick/GlobalVariables/".concat(a),withIcon:!0,children:(0,S.jsx)(se.CK,{size:2.5*O.iI})})})}),(0,S.jsx)(vl.Z,{md:4,children:E?(0,S.jsx)(nc,{children:(0,S.jsx)(M.Z,{compact:!0,borderless:!0,fullWidth:!0,monospace:!0,onChange:function(e){x(e.target.value),e.preventDefault()},onKeyDown:T,paddingHorizontal:0,placeholder:"variable",small:!0,value:g})}):(0,S.jsx)(nc,{children:(0,S.jsx)(_.ZP,{color:Lo.Or,monospace:!0,small:!0,textOverflow:!0,children:a})})}),(0,S.jsx)(vl.Z,{md:7,children:E?(0,S.jsx)(nc,{children:(0,S.jsx)(M.Z,{compact:!0,borderless:!0,fullWidth:!0,monospace:!0,onChange:function(e){Z(e.target.value),e.preventDefault()},onKeyDown:T,paddingHorizontal:0,placeholder:"enter value",ref:p,small:!0,value:k})}):(0,S.jsxs)(nc,{children:[o?(0,S.jsx)(_.ZP,{monospace:!0,small:!0,children:"********"}):(0,S.jsx)(_.ZP,{monospace:!0,small:!0,children:f}),(0,S.jsxs)(j.Z,{children:[!r&&m&&(0,S.jsx)(A.ZP,{backgroundColor:tc.qJ,borderless:!0,inline:!0,muted:!0,onClick:function(){P(!0)},small:!0,uuid:"Sidekick/GlobalVariables/edit_".concat(a),withIcon:!0,children:(0,S.jsx)(se.I8,{size:2.5*O.iI})}),t&&m&&(0,S.jsx)(A.ZP,{backgroundColor:tc.qJ,borderless:!0,inline:!0,muted:!0,onClick:t,small:!0,uuid:"Sidekick/GlobalVariables/delete_".concat(a),withIcon:!0,children:(0,S.jsx)(se.rF,{size:2.5*O.iI})})]})]})})]})})},rc=t(93348),oc=t(58122);var lc=function(e){e.blocks;var n=e.fetchVariables,t=e.pipeline,i=e.selectedBlock,r=e.setErrorMessages,o=e.variables,c=e.width,u=(0,s.useState)(!1),a=u[0],f=u[1],p=(0,s.useState)(),h=p[0],v=p[1],b=(0,s.useState)(),g=b[0],x=b[1],j=null===t||void 0===t?void 0:t.uuid,C=(0,d.Db)(ce.ZP.variables.pipelines.useCreate(j),{onSuccess:function(e){return(0,me.wD)(e,{onErrorCallback:function(e){var n=e.error,t=n.message,i=n.exception;r((function(e){var n=e||[];return i&&(n=n.concat(i)),t&&(n=n.concat(t)),n}))}})}}),E=(0,l.Z)(C,1)[0],P=(0,d.Db)((function(e){return ce.ZP.variables.pipelines.useDelete(j,e)()}),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(){n()},onErrorCallback:function(e){var n=e.error,t=(n.errors,n.message);r((function(e){return e.concat(t)}))}})}}),w=(0,l.Z)(P,1)[0],I=(0,s.useCallback)((function(e){if("Enter"===e.key){var t=g;try{t=JSON.parse(g)}catch(i){}E({variable:{name:h,value:t}}).then((function(){n(),v(null),x(null)})),f(!1)}else"Escape"===e.key&&f(!1)}),[E,n,h,g]),T=(0,s.useMemo)((function(){return c-4*O.iI}),[c]),R=(0,s.useMemo)((function(){return(0,oc.wx)(o,(function(e){return e.uuid===Jl.C}))}),[o]),D=(0,s.useMemo)((function(){return(0,oc.wx)(o,(function(e){return e.uuid===(null===i||void 0===i?void 0:i.uuid)}))}),[i,o]),B=(0,s.useMemo)((function(){return(0,S.jsxs)(ec,{width:T,children:[a&&(0,S.jsxs)(kl.Z,{children:[(0,S.jsx)(vl.Z,{md:1,children:(0,S.jsx)(nc,{noPadding:!0,children:(0,S.jsx)(A.ZP,{backgroundColor:tc.qJ,borderless:!0,centerText:!0,muted:!0,onClick:function(){navigator.clipboard.writeText(h),Yl.Am.success("Successfully copied to clipboard.",{position:Yl.Am.POSITION.BOTTOM_RIGHT,toastId:h})},uuid:"Sidekick/GlobalVariables/".concat(h),withIcon:!0,children:(0,S.jsx)(se.CK,{size:2.5*O.iI})})})}),(0,S.jsx)(vl.Z,{md:4,children:(0,S.jsx)(nc,{children:(0,S.jsx)(M.Z,{compact:!0,borderless:!0,fullWidth:!0,monospace:!0,onChange:function(e){v(e.target.value),e.preventDefault()},onKeyDown:I,paddingHorizontal:0,placeholder:"variable",small:!0,value:h})})}),(0,S.jsx)(vl.Z,{md:7,children:(0,S.jsx)(nc,{children:(0,S.jsx)(M.Z,{compact:!0,borderless:!0,fullWidth:!0,monospace:!0,onChange:function(e){x(e.target.value),e.preventDefault()},onKeyDown:I,paddingHorizontal:0,placeholder:"enter value",small:!0,value:g})})})]}),null===R||void 0===R?void 0:R.map((function(e){return(0,S.jsx)(ic,{deleteVariable:function(){return w(e.uuid)},fetchVariables:n,pipelineUUID:j,variable:e},e.uuid)}))]})}),[w,R,h,g,j,v,x,f,a,T]),N=(0,s.useMemo)((function(){return(0,S.jsx)(ec,{width:T,children:null===D||void 0===D?void 0:D.map((function(e){return(0,S.jsx)(ic,{copyText:(n=e.uuid,"from mage_ai.data_preparation.variable_manager import (\n get_variable,\n)\n\n".concat(function(e,n,t){return"\n".concat(t," = get_variable('").concat(e,"', '").concat(n,"', '").concat(t,"')\n")}(j,null===i||void 0===i?void 0:i.uuid,n))),hideEdit:!0,pipelineUUID:j,variable:e},e.uuid);var n}))})}),[D,i,T]);return(0,S.jsxs)(Z.Z,{p:O.cd,children:[(0,S.jsx)(Z.Z,{mb:O.cd,children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(ui.Z,{level:4,monospace:!0,children:"Global Variables"}),(0,S.jsx)(Z.Z,{ml:2}),(0,S.jsx)(A.ZP,{Icon:se.mm,blackBorder:!0,inline:!0,onClick:function(){return f((function(e){return!e}))},uuid:"Sidekick/GlobalVariables/addNewVariable",children:"New"})]})}),(0,S.jsx)(Z.Z,{mb:O.cd,children:(0,S.jsxs)(_.ZP,{muted:!0,children:["Press ",(0,S.jsx)(_.ZP,{bold:!0,default:!0,inline:!0,monospace:!0,children:"Enter"})," or ",(0,S.jsx)(_.ZP,{bold:!0,default:!0,inline:!0,monospace:!0,children:"Return"})," to save changes."]})}),(0,S.jsx)(Z.Z,{mb:O.cd,children:B}),(0,S.jsx)(Z.Z,{mb:O.cd,children:(0,S.jsx)(_.ZP,{children:"Global variables will be passed into all non-scratchpad blocks as keyword arguments (Python), interpolated variables (SQL), or vector elements (R). To load a global variable, use the following syntax:"})}),(0,S.jsxs)(Z.Z,{mb:O.cd,children:[(0,S.jsxs)(_.ZP,{bold:!0,large:!0,children:["For Python (",(0,S.jsx)(k.Z,{href:"https://docs.mage.ai/production/configuring-production-settings/runtime-variable",large:!0,openNewWindow:!0,primary:!0,children:"docs"}),"):"]}),(0,S.jsx)(Xl.Z,{language:"python",small:!0,source:"\n var = kwargs['variable_name']\n"})]}),(0,S.jsxs)(Z.Z,{mb:O.cd,children:[(0,S.jsxs)(_.ZP,{bold:!0,large:!0,children:["For SQL (",(0,S.jsx)(k.Z,{href:"https://docs.mage.ai/guides/sql-blocks#variables",large:!0,openNewWindow:!0,primary:!0,children:"docs"}),"):"]}),(0,S.jsx)(Xl.Z,{language:"sql",small:!0,source:"\n {{ variable_name }}\n"})]}),(0,S.jsxs)(Z.Z,{mb:O.cd,children:[(0,S.jsxs)(_.ZP,{bold:!0,large:!0,children:["For R (",(0,S.jsx)(k.Z,{href:"https://docs.mage.ai/guides/r-blocks#runtime-variables",large:!0,openNewWindow:!0,primary:!0,children:"docs"}),"):"]}),(0,S.jsx)(Xl.Z,{language:"r",small:!0,source:"\n var <- global_vars['variable_name']\n"})]}),(0,S.jsxs)(Z.Z,{mb:O.cd,children:[(0,S.jsx)(ui.Z,{level:4,monospace:!0,children:"Trigger Runtime Variables"}),(0,S.jsx)(Z.Z,{mb:O.cd}),(0,S.jsx)(_.ZP,{children:"Depending on what kind of trigger you use for this pipeline, some default runtime variables will be provided."})]}),Object.values(rc.Xm).map((function(e,n){var t;return(0,S.jsxs)(Z.Z,{mb:O.cd,children:[(0,S.jsx)(Z.Z,{mb:O.cd,children:(0,S.jsx)(_.ZP,{large:!0,monospace:!0,children:(0,Q.vg)(null===(t=rc.Z4[e])||void 0===t?void 0:t.call(rc.Z4))})}),(0,oc.JZ)([],e).map((function(n,t){return(0,S.jsx)(ic,{hideEdit:!0,pipelineUUID:j,variable:n},"var_".concat(e,"_").concat(t))}))]},"".concat(e,"_").concat(n))})),D&&D.length>0&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Z.Z,{my:2,children:(0,S.jsx)(ui.Z,{level:4,monospace:!0,children:"Block Output Variables"})}),(0,S.jsx)(Z.Z,{mb:2,children:N}),(0,S.jsx)(Z.Z,{mb:O.cd,children:(0,S.jsxs)(_.ZP,{children:["Output variables can be used in any ",(0,S.jsx)(_.ZP,{bold:!0,inline:!0,monospace:!0,warning:!0,children:m.tf.SCRATCHPAD})," block. They are for scratchpad blocks, specifically. To get upstream block outputs inside of other blocks, use the positional arguments."]})}),(0,S.jsx)(Z.Z,{mb:O.cd,children:(0,S.jsx)(_.ZP,{children:"To load the variable in a scratchpad block, use the following syntax:"})}),(0,S.jsx)(Z.Z,{mb:O.cd,children:(0,S.jsx)(Xl.Z,{language:"python",small:!0,source:"\n from mage_ai.data_preparation.variable_manager import (\n get_variable,\n )\n\n\n df = get_variable(\n 'pipeline_uuid',\n 'block_uuid',\n 'variable_name',\n )\n"})})]})]})},cc=v.default.div.withConfig({displayName:"indexstyle__OutputContainerStyle",componentId:"sc-wkjnrg-0"})([""," overflow-y:scroll;"," ",""],Pn.w5,(function(e){return e.height&&"\n height: ".concat(e.height,"px;\n ")}),(function(e){return!e.height&&"\n max-height: ".concat(e.maxHeight||300,"px;\n ")}));function uc(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function ac(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?uc(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):uc(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var sc=function(e){var n=e.cancelPipeline,t=e.checkIfPipelineRunning,i=e.executePipeline,r=e.isPipelineExecuting,o=e.pipelineExecutionHidden,l=e.pipelineMessages,c=e.setPipelineExecutionHidden,u=(0,s.useMemo)((function(){return(null===l||void 0===l?void 0:l.length)||0}),[l]),a=(0,s.useMemo)((function(){return u>100?l.slice(-100):l}),[u,l]),d=(0,s.useCallback)((function(){var e=!o;c(e),(0,L.t8)(L.Q9,e)}),[o,c]);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(y.Z,{alignItems:"center",justifyContent:"space-between",children:[(0,S.jsxs)(j.Z,{children:[(0,S.jsx)(I.Z,{beforeIcon:(0,S.jsx)(se.JM,{inverted:!0,size:2*O.iI}),compact:r,disabled:r,loading:r,onClick:i,success:!0,children:(0,S.jsx)(_.ZP,{bold:!0,inverted:!0,primary:!1,children:"Execute pipeline"})}),(0,S.jsx)(Z.Z,{ml:1}),r&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(I.Z,{beforeIcon:(0,S.jsx)(se.x8,{inverted:!0,size:2*O.iI}),onClick:n,success:!0,children:(0,S.jsx)(_.ZP,{bold:!0,inverted:!0,primary:!1,children:"Cancel pipeline"})}),(0,S.jsx)(Z.Z,{ml:1})]}),(0,S.jsx)(I.Z,{onClick:t,secondary:!0,children:"Running status"})]}),(0,S.jsxs)(j.Z,{alignItems:"center",children:[(0,S.jsx)(Z.Z,{ml:1}),(0,S.jsx)(_.ZP,{children:"Hide"}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(mr.Z,{checked:o,onCheck:d})]})]}),!o&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Z.Z,{mb:1}),(0,S.jsx)(cc,{noScrollbarTrackBackground:!0,children:(0,S.jsx)(jn,{executedAndIdle:!0,hasError:!1,selected:!0,children:a.map((function(e,n){var t=e.data,i=e.type,r=[],o=(r=(r=Array.isArray(t)?t:[t]).filter((function(e){return e}))).length;return r.map((function(e,t){var r,l={first:0===n&&0===t,last:n===u-1&&t===o-1};return ge.jU.includes(i)?r=(0,S.jsx)(yn,ac(ac({},l),{},{children:(0,S.jsx)(_.ZP,{monospace:!0,preWrap:!0,children:(0,S.jsx)(vn(),{children:e})})})):i===ge.Gi.IMAGE_PNG&&(r=(0,S.jsx)("div",{style:{backgroundColor:"white"},children:(0,S.jsx)("img",{alt:"Image ".concat(n," from code output"),src:"data:image/png;base64, ".concat(e)})})),(0,S.jsx)("div",{children:r},"code-output-".concat(n,"-").concat(t))}))}))})})]})]})};var dc=function(e){var n=e.fetchSecrets,t=e.pipelineUUID,i=e.secrets,r=e.setErrorMessages,o=e.width,c=(0,s.useState)(!1),u=c[0],a=c[1],f=(0,s.useState)(),p=f[0],h=f[1],m=(0,s.useState)(),v=m[0],b=m[1],g=(0,s.useMemo)((function(){return o-O.cd*O.iI*2}),[o]),x=(0,d.Db)(ce.ZP.secrets.useCreate(),{onSuccess:function(e){return(0,me.wD)(e,{onErrorCallback:function(e){var n=e.error,t=n.message,i=n.exception;r((function(e){var n=e||[];return i&&(n=n.concat(i)),t&&(n=n.concat(t)),n}))}})}}),j=(0,l.Z)(x,1)[0],k=(0,d.Db)((function(e){return ce.ZP.secrets.useDelete(e)()}),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(){n()},onErrorCallback:function(e){var n=e.error,t=(n.errors,n.message);r((function(e){return e.concat(t)}))}})}}),C=(0,l.Z)(k,1)[0],E=(0,s.useCallback)((function(e){"Enter"===e.key?(j({secret:{name:p,value:v}}).then((function(){n(),h(null),b(null)})),a(!1)):"Escape"===e.key&&a(!1)}),[j,n,p,v]);return(0,S.jsxs)(Z.Z,{p:O.cd,children:[(0,S.jsx)(Z.Z,{mb:O.cd,children:(0,S.jsxs)(y.Z,{alignItems:"center",children:[(0,S.jsx)(ui.Z,{level:4,monospace:!0,children:"Secrets"}),(0,S.jsx)(Z.Z,{ml:2}),(0,S.jsx)(A.ZP,{Icon:se.mm,blackBorder:!0,inline:!0,onClick:function(){return a((function(e){return!e}))},uuid:"Sidekick/Secrets/addNewSecret",children:"New"})]})}),(0,S.jsx)(Z.Z,{mb:O.cd,children:(0,S.jsxs)(_.ZP,{children:[(0,S.jsx)(_.ZP,{inline:!0,warning:!0,children:"WARNING:"})," the encryption key is stored in a file on your machine. If you need more secure encryption, we recommend using a secrets manager."]})}),u&&(0,S.jsx)(Z.Z,{mb:O.cd,children:(0,S.jsxs)(_.ZP,{muted:!0,children:["Press ",(0,S.jsx)(_.ZP,{bold:!0,default:!0,inline:!0,monospace:!0,children:"Enter"})," or ",(0,S.jsx)(_.ZP,{bold:!0,default:!0,inline:!0,monospace:!0,children:"Return"})," to save changes."]})}),(0,S.jsx)(Z.Z,{mb:O.cd,children:(0,S.jsxs)(ec,{width:g,children:[u&&(0,S.jsxs)(kl.Z,{children:[(0,S.jsx)(vl.Z,{md:1,children:(0,S.jsx)(nc,{noPadding:!0,children:(0,S.jsx)(A.ZP,{backgroundColor:tc.qJ,borderless:!0,centerText:!0,muted:!0,onClick:function(){navigator.clipboard.writeText("{{ mage_secret_var(".concat(p,") }}")),Yl.Am.success("Successfully copied to clipboard.",{position:Yl.Am.POSITION.BOTTOM_RIGHT,toastId:p})},uuid:"Sidekick/Secrets/".concat(p),withIcon:!0,children:(0,S.jsx)(se.CK,{size:2.5*O.iI})})})}),(0,S.jsx)(vl.Z,{md:4,children:(0,S.jsx)(nc,{children:(0,S.jsx)(M.Z,{borderless:!0,compact:!0,fullWidth:!0,monospace:!0,onChange:function(e){h(e.target.value),e.preventDefault()},onKeyDown:E,paddingHorizontal:0,placeholder:"secret name",small:!0,value:p})})}),(0,S.jsx)(vl.Z,{md:7,children:(0,S.jsx)(nc,{children:(0,S.jsx)(M.Z,{borderless:!0,compact:!0,fullWidth:!0,monospace:!0,onChange:function(e){b(e.target.value),e.preventDefault()},onKeyDown:E,paddingHorizontal:0,placeholder:"secret value",small:!0,value:v})})})]}),null===i||void 0===i?void 0:i.map((function(e){return(0,S.jsx)(ic,{deleteVariable:function(){return C(e.name)},fetchVariables:n,hideEdit:!0,obfuscate:!0,pipelineUUID:t,variable:{uuid:e.name,value:e.value}},e.name)}))]})}),(0,S.jsx)(Z.Z,{mb:O.cd,children:(0,S.jsx)(_.ZP,{children:"Secrets are not editable, they can only be created and deleted. Secrets are shared across the project, and can be used in configuration fields. To reference a secret, use the following templating syntax:"})}),(0,S.jsx)(Z.Z,{mb:O.cd,children:(0,S.jsx)(Xl.Z,{language:"yaml",small:!0,source:"\n \"{{ mage_secret_var('<secret_name>') }}\"\n ",maxWidth:g})}),(0,S.jsx)(Z.Z,{mb:O.cd,children:(0,S.jsx)(_.ZP,{children:"To reference a secret in code, you can import the `get_secret_value` helper method:"})}),(0,S.jsx)(Z.Z,{mb:O.cd,children:(0,S.jsx)(Xl.Z,{language:"python",small:!0,source:"\n from mage_ai.data_preparation.shared.secrets import get_secret_value\n\n get_secret_value('<secret_name>')\n ",maxWidth:g})})]})},fc=t(66607),pc=t(33699),hc=t(72454),mc=t(64155);function vc(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function bc(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?vc(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):vc(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var gc=function(e){var n=e.activeView,t=e.addNewBlockAtIndex,i=e.afterWidth,r=e.autocompleteItems,l=e.blockRefs,c=e.blocks,u=e.blocksInNotebook,a=e.cancelPipeline,d=e.chartRefs,f=e.checkIfPipelineRunning,h=e.deleteBlock,m=e.deleteWidget,v=e.editingBlock,b=e.executePipeline,g=e.fetchFileTree,x=e.fetchPipeline,j=e.fetchSecrets,k=e.fetchVariables,C=e.globalVariables,E=e.insights,P=e.interruptKernel,w=e.isPipelineExecuting,T=e.lastTerminalMessage,A=e.messages,R=e.metadata,M=e.onChangeCallbackBlock,B=e.onChangeChartBlock,N=e.onChangeCodeBlock,F=e.onSelectBlockFile,U=e.pipeline,H=e.pipelineMessages,G=e.runBlock,z=e.runningBlocks,q=e.sampleData,K=e.savePipelineContent,W=e.secrets,Q=e.selectedBlock,V=e.selectedFilePath,Y=e.sendTerminalMessage,X=e.setAllowCodeBlockShortcuts,J=e.setAnyInputFocused,$=e.setDepGraphZoom,ee=e.setDisableShortcuts,ne=e.setEditingBlock,te=e.setErrors,ie=e.setHiddenBlocks,re=e.setSelectedBlock,oe=e.setTextareaFocused,le=e.statistics,ce=e.textareaFocused,ue=e.treeRef,ae=e.updateWidget,de=e.widgets,fe=(0,Qr.i)().height,he=Kr.uX,me=(0,s.useState)([]),ve=me[0],be=me[1],ge=(0,s.useState)(!!(0,L.U2)(L.Q9)),xe=ge[0],je=ge[1],ye=(0,s.useMemo)((function(){return i-(hc.k1+1)}),[i]),ke=((null===v||void 0===v?void 0:v.upstreamBlocks)||{}).block,Ze=((null===q||void 0===q?void 0:q.columns)||[]).slice(0,100),_e=(null===q||void 0===q?void 0:q.rows)||[],Oe=(null===R||void 0===R?void 0:R.column_types)||{},Ce=null===Ze||void 0===Ze?void 0:Ze.map((function(e){return{columnType:Oe[e],uuid:e}})),Se=(null===E||void 0===E?void 0:E[1])||{},Ee=(0,s.useMemo)((function(){return(0,pe.HK)((null===E||void 0===E?void 0:E[0])||[],(function(e){return e.feature.uuid}))}),[E]),Pe=(0,oc.v0)({statistics:le}),we=(0,oc.CL)({columnTypes:Oe,statistics:le}),Ie=!!q,Te=(0,s.useMemo)((function(){return D.qL.INTEGRATION===(null===U||void 0===U?void 0:U.type)}),[U]),Ae=D.qL.STREAMING!==(null===U||void 0===U?void 0:U.type)?-70:xe?-16:300,Re=(0,s.useCallback)((0,$l.Fk)({columnTypes:Oe,columns:Ze,insightsByFeatureUUID:Ee,insightsOverview:Se,noColumnLinks:!0,statistics:le}),[Oe,Ze,Ee,Se,le]),De=(0,s.useMemo)((function(){return(0,S.jsx)(lc,{blocks:c,fetchVariables:k,pipeline:U,selectedBlock:Q,setErrorMessages:be,variables:C,width:ye})}),[ye,c,k,C,U,Q]),Me=(0,s.useMemo)((function(){return(0,S.jsx)(Vl.Z,{selectedBlock:Q,selectedFilePath:V,setErrors:te,width:ye>Pn.nn?ye-Pn.nn:ye})}),[ye,Q,V,te]),Be=(0,s.useMemo)((function(){return(0,S.jsx)(dc,{fetchSecrets:j,pipelineUUID:null===U||void 0===U?void 0:U.uuid,secrets:W,setErrorMessages:be,width:ye})}),[ye,j,U,W]),Ne={addNewBlockAtIndex:t,autocompleteItems:r,blockRefs:l,blocks:c,blocksInNotebook:u,deleteBlock:h,fetchFileTree:g,fetchPipeline:x,interruptKernel:P,messages:A,onChangeCallbackBlock:M,onChangeCodeBlock:N,onSelectBlockFile:F,pipeline:U,runBlock:G,runningBlocks:z,savePipelineContent:K,selectedBlock:Q,setAnyInputFocused:J,setErrors:te,setHiddenBlocks:ie,setSelectedBlock:re,setTextareaFocused:oe,textareaFocused:ce};return(0,S.jsxs)(S.Fragment,{children:[(null===ve||void 0===ve?void 0:ve.length)>=1&&(0,S.jsxs)(Z.Z,{mb:3,mt:2,mx:2,children:[(0,S.jsxs)(y.Z,{justifyContent:"space-between",children:[(0,S.jsx)(_.ZP,{bold:!0,danger:!0,children:"Errors"}),(0,S.jsx)(I.Z,{basic:!0,iconOnly:!0,noPadding:!0,onClick:function(){return be([])},transparent:!0,children:(0,S.jsx)(se.x8,{muted:!0})})]}),null===ve||void 0===ve?void 0:ve.map((function(e){return(0,S.jsx)(Z.Z,{pb:1,children:(0,S.jsx)(_.ZP,{monospace:!0,xsmall:!0,children:e})},e)}))]}),(0,S.jsxs)(mc.t0,{fullWidth:!0,heightOffset:fn.cH.TERMINAL===n?0:Pn.nn,onBlur:function(){V||ee(!1),null===X||void 0===X||X(!1)},onFocus:function(){ee(!0),n===fn.cH.TREE&&(null===X||void 0===X||X(!0))},children:[n===fn.cH.TREE&&(0,S.jsx)(p.Z,{uuid:"PipelineDetail/".concat(null===U||void 0===U?void 0:U.uuid),children:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(gn.Z,{blockRefs:l,editingBlock:v,enablePorts:!Te,fetchPipeline:x,height:fe-he-Ae,onClickNode:function(e){var n=e.block.uuid;return ie((function(e){var t=!(null===e||void 0===e||!e[n]);return t?bc(bc({},e),{},(0,o.Z)({},n,!t)):e}))},pipeline:U,runningBlocks:z,selectedBlock:Q,setEditingBlock:ne,setErrors:te,setSelectedBlock:re,setZoom:$,treeRef:ue}),!ke&&D.qL.STREAMING===(null===U||void 0===U?void 0:U.type)&&(0,S.jsx)(Z.Z,{p:1,children:(0,S.jsx)(sc,{cancelPipeline:a,checkIfPipelineRunning:f,executePipeline:b,isPipelineExecuting:w,pipelineExecutionHidden:xe,pipelineMessages:H,setPipelineExecutionHidden:je})})]})}),n===fn.cH.DATA&&Ze.length>0&&(0,S.jsx)(bn.Z,{columnHeaderHeight:(0,Ii.Qr)(Oe)&&(0,Ii.Qr)(Ee)&&(0,Ii.Qr)(Se)?0:mc.Eh,columns:Ze,height:fe-he-Kr.OM,noBorderBottom:!0,noBorderLeft:!0,noBorderRight:!0,noBorderTop:!0,renderColumnHeader:Re,rows:_e,width:ye}),n===fn.cH.REPORTS&&(0,S.jsx)(mc.ht,{noPadding:!Q||!Ie,children:(0,S.jsxs)(y.Z,{flexDirection:"column",fullWidth:!0,children:[Pe&&(0,S.jsx)(fc.Z,{stats:Pe,title:"Quality metrics"}),we&&(0,S.jsx)(Z.Z,{mt:O.cd,children:(0,S.jsx)(fc.Z,{stats:we,title:"Statistics"})}),Ce.length>0&&(0,S.jsx)(Z.Z,{mt:O.cd,children:(0,S.jsx)(Ql,{features:Ce,statistics:le})})]})}),n===fn.cH.GRAPHS&&(0,S.jsx)(mc.ht,{noPadding:!Q||!Ie,children:(0,S.jsx)(bo,{afterWidth:ye,features:Ce,insightsOverview:Se,statistics:le})}),fn.cH.SECRETS===n&&Be,fn.cH.VARIABLES===n&&De,fn.cH.FILE_VERSIONS===n&&(0,S.jsx)(p.Z,{uuid:"FileVersions/".concat(V?decodeURIComponent(V):""),children:Me}),Te||Q&&Ie||!Q&&Ie&&n===fn.cH.DATA?null:fn.du.includes(n)&&(0,S.jsx)(y.Z,{alignItems:"center",justifyContent:"center",verticalHeight:fn.fp,verticalHeightOffset:he,width:ye,children:(0,S.jsx)(_.ZP,{center:!0,default:!0,disableWordBreak:!0,large:!0,monospace:!0,children:Q?!Ie&&"No data or insights available":"Select a block for insights"})}),fn.cH.CHARTS===n&&(de.length>0?(0,S.jsx)(Cl,{autocompleteItems:r,blockRefs:l,blocks:c,chartRefs:d,deleteWidget:m,fetchFileTree:g,fetchPipeline:x,messages:A,onChangeChartBlock:B,pipeline:U,runBlock:G,runningBlocks:z,savePipelineContent:K,selectedBlock:Q,setAnyInputFocused:J,setErrors:te,setSelectedBlock:re,setTextareaFocused:oe,textareaFocused:ce,updateWidget:ae,widgets:de,width:ye}):(0,S.jsxs)(y.Z,{alignItems:"center",flexDirection:"column",justifyContent:"center",verticalHeight:fn.fp,verticalHeightOffset:he,width:ye,children:[(0,S.jsx)(Z.Z,{px:1,children:(0,S.jsx)(y.Z,{flexDirection:"row",children:(0,S.jsxs)(_.ZP,{center:!0,default:!0,children:["Add a chart by clicking the chart icon \xa0",(0,S.jsx)(se.GQ,{size:1.5*O.iI}),"\xa0in",(0,S.jsx)("br",{}),"the top right corner of a block (if applicable)."]})})}),(0,S.jsx)(Z.Z,{mt:O.cd,px:1,children:(0,S.jsx)(El,{size:40*O.iI})})]})),fn.cH.TERMINAL===n&&(0,S.jsx)("div",{style:{height:"100%",position:"relative",width:ye},children:(0,S.jsx)(pc.Z,{lastMessage:T,onFocus:function(){return re(null)},sendMessage:Y,width:ye})}),fn.cH.EXTENSIONS===n&&(0,S.jsx)(Bl,bc({},Ne)),fn.cH.CALLBACKS===n&&(0,S.jsx)(_o,bc({},Ne))]})]})},xc=t(12691),jc=t.n(xc),yc=t(35438);function kc(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Zc(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?kc(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):kc(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var _c=function(e){var n,t=e.activeView,i=e.depGraphZoom,r=e.pipeline,o=e.secrets,l=e.treeRef,c=e.variables,u=null===r||void 0===r?void 0:r.uuid,a=(0,yo.iV)(),d=(0,oc.wx)(c,(function(e){return e.uuid===Jl.C})),f=fn.Qq[t],p=(null===f||void 0===f||null===(n=f.buildLabel)||void 0===n?void 0:n.call(f,{pipeline:r,secrets:o,variables:d}))||(null===f||void 0===f?void 0:f.label),h=(0,S.jsx)(_.ZP,{bold:!0,children:p}),m=fn.cH.EXTENSIONS===t&&(null===a||void 0===a?void 0:a.extension),v=ce.ZP.extension_options.list({},{},{pauseFetch:!m}).data,b=(0,s.useMemo)((function(){return(null===v||void 0===v?void 0:v.extension_options)||[]}),[v]),g=(0,s.useMemo)((function(){return(0,pe.HK)(b,(function(e){return e.uuid}))}),[b]);if(!t)return(0,S.jsx)("div",{});if(l&&fn.cH.TREE===t)h=(0,S.jsxs)(y.Z,{alignItems:"center",fullWidth:!0,justifyContent:"space-between",children:[h,(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsxs)(j.Z,{alignItems:"center",children:[(0,S.jsx)(I.Z,Zc(Zc({},yc.Ai),{},{onClick:function(){var e,n;null===l||void 0===l||null===(e=l.current)||void 0===e||null===(n=e.zoomIn)||void 0===n||n.call(e)},children:(0,S.jsx)(_.ZP,{noWrapping:!0,children:"Zoom in"})})),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(I.Z,Zc(Zc({},yc.Ai),{},{onClick:function(){var e,n;null===l||void 0===l||null===(e=l.current)||void 0===e||null===(n=e.zoomOut)||void 0===n||n.call(e)},children:(0,S.jsx)(_.ZP,{noWrapping:!0,children:"Zoom out"})})),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsx)(le.Z,{appearAbove:!0,appearBefore:!0,default:!0,label:"Shortcut: Double-click canvas",lightBackground:!0,size:null,widthFitContent:!0,children:(0,S.jsx)(I.Z,Zc(Zc({},yc.Ai),{},{onClick:function(){var e,n;null===l||void 0===l||null===(e=l.current)||void 0===e||null===(n=e.fitCanvas)||void 0===n||n.call(e)},children:(0,S.jsx)(_.ZP,{noWrapping:!0,children:"Reset"})}))}),(0,S.jsx)(Z.Z,{mr:1}),(0,S.jsxs)(_.ZP,{bold:!0,children:[null===i||void 0===i?void 0:i.toFixed(2),"x"]})]})]});else if(m){var x=g[null===a||void 0===a?void 0:a.extension];h=(0,S.jsxs)(y.Z,{children:[(0,S.jsx)(jc(),{as:"/pipelines/".concat(u,"/edit?").concat(fn.uM,"=").concat(fn.cH.EXTENSIONS),href:"/pipelines/[pipeline]/edit",passHref:!0,children:(0,S.jsx)(k.Z,{default:!0,children:p})}),(0,S.jsx)(_.ZP,{monospace:!0,muted:!0,children:"\xa0/\xa0"}),(0,S.jsx)(_.ZP,{bold:!0,children:null===x||void 0===x?void 0:x.name})]})}return(0,S.jsx)(Kr.ym,{children:h})},Oc=t(3055),Cc=t(94353),Sc=t(59920),Ec=t(36405);function Pc(e){var n=e.activeView,t=e.pipeline,i=e.secrets,r=e.setActiveSidekickView,o=e.variables,l=(0,oc.wx)(o,(function(e){return e.uuid===Jl.C}));return fn.j5.map((function(e){var o=e.buildLabel,c=e.key,u=e.label;return{Icon:fn.Z7[c],id:c,isSelected:function(){return n===c},label:function(){return(null===o||void 0===o?void 0:o({pipeline:t,secrets:i,variables:l}))||u},onClick:function(){return r(c,!0)}}}))}var wc=t(28799);function Ic(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,i)}return t}function Tc(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Ic(Object(t),!0).forEach((function(n){(0,o.Z)(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Ic(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function Ac(e){var n,t,i=e.page,c=e.pipeline,u=(0,f.useRouter)(),v=(0,Qr.i)().height,b=u.query.pipeline,g=c.uuid||b,x=(0,s.useState)(!!(0,L.U2)(L.zg)),j=x[0],k=x[1],_=(0,s.useState)(null),C=_[0],E=_[1],P=(0,s.useState)(null),R=P[0],M=P[1],B=(0,s.useState)(null),F=B[0],z=B[1],q=(0,s.useState)(null),K=q[0],W=q[1],V=(0,s.useState)([]),Y=V[0],X=V[1],J=(0,s.useState)({}),$=J[0],ie=J[1],re=(0,s.useState)(!1),le=re[0],ue=re[1],xe=(0,s.useState)(!1),je=xe[0],ye=xe[1],ke=(0,s.useState)(!1),Ze=ke[0],_e=ke[1],Oe=(0,s.useState)(!1),Ce=Oe[0],Se=Oe[1],Ee=(0,s.useState)(1),Pe=Ee[0],we=Ee[1],Ie="".concat(N.H8,"_").concat(g),Te=(0,L.U2)(Ie),Ae=(0,s.useState)((0,pe.sE)(Wr.NR,(function(e){return e.uuid===Te}))||Wr.NR[0]),Re=Ae[0],De=Ae[1],Me=(0,s.useCallback)((function(e){De(e),(0,L.t8)(Ie,null===e||void 0===e?void 0:e.uuid)}),[Ie,De]),Be="".concat(N.g6,"_").concat(g),Ne=(0,s.useState)({}),Le=Ne[0],Fe=Ne[1],Ue=(0,s.useCallback)((function(e){Fe((function(n){var t=e(n);return(0,L.t8)(Be,JSON.stringify(t)),t}))}),[Be,Fe]);(0,s.useEffect)((function(){var e=(0,L.U2)(Be);e&&(0,Q.Pb)(e)&&Fe(JSON.parse(e))}),[Be,Fe]);var He=(0,s.useRef)(null),Ge=ce.ZP.statuses.list({},{revalidateOnFocus:!1}).data,ze=(0,s.useMemo)((function(){var e,n;return null===Ge||void 0===Ge||null===(e=Ge.statuses)||void 0===e||null===(n=e[0])||void 0===n?void 0:n.disable_pipeline_edit_access}),[Ge]),qe=(0,s.useMemo)((function(){var e,n;return null===Ge||void 0===Ge||null===(e=Ge.statuses)||void 0===e||null===(n=e[0])||void 0===n?void 0:n.max_print_output_lines}),[Ge]),Ke=(0,s.useState)({}),We=Ke[0],Qe=Ke[1],Ve=(0,s.useState)([]),Ye=Ve[0],Xe=Ve[1],Je=ce.ZP.kernels.list({},{refreshInterval:5e3,revalidateOnFocus:!0}),$e=Je.data,en=Je.mutate,nn=null===$e||void 0===$e?void 0:$e.kernels,tn=(null===nn||void 0===nn?void 0:nn.find((function(e){return e.name===D.a_[null===pn||void 0===pn?void 0:pn.type]})))||(null===nn||void 0===nn?void 0:nn[0]),rn=(0,ae.Z)(g),on=ce.ZP.pipelines.detail(g,{includes_outputs:(0,Ii.Qr)(We)},{refreshInterval:6e4}),ln=on.data,cn=on.mutate,un=ce.ZP.files.list(),an=un.data,sn=un.mutate,dn=(0,s.useMemo)((function(){return(null===an||void 0===an?void 0:an.files)||[]}),[an]),pn=null===ln||void 0===ln?void 0:ln.pipeline,hn=(0,s.useMemo)((function(){return D.qL.INTEGRATION===(null===pn||void 0===pn?void 0:pn.type)}),[pn]),mn=(0,s.useState)(null),vn=mn[0],bn=mn[1],gn=(0,s.useState)((0,fe.Tz)({dateObj:!0})),xn=gn[0],jn=gn[1],yn=(0,s.useState)(!1),kn=yn[0],Zn=yn[1],_n=(0,ve.dd)((function(){return(0,S.jsx)(oe.Z,{centerOnScreen:!0,neutral:!0,onClick:Pn,subtitle:"Please refresh your page to have the most up-to-date data before making any changes.",title:"Your pipeline may be stale.",width:34*O.iI})}),{},[],{background:!0,uuid:"stale_pipeline_message"}),On=(0,l.Z)(_n,2),En=On[0],Pn=On[1];(0,s.useEffect)((function(){var e,n;null!==ln&&void 0!==ln&&null!==(e=ln.pipeline)&&void 0!==e&&e.updated_at&&(null===vn||void 0===vn?void 0:vn.toISOString())!==new Date(null===ln||void 0===ln||null===(n=ln.pipeline)||void 0===n?void 0:n.updated_at).toISOString()&&bn(new Date(ln.pipeline.updated_at)),vn&&Number(vn)>Number(xn)&&En()}),[null===ln||void 0===ln||null===(n=ln.pipeline)||void 0===n?void 0:n.updated_at,vn,xn,En]),(0,s.useEffect)((function(){(0,me.bB)(ln,M)}),[ln]);var wn=(0,yo.iV)(),In=wn[fn.uM],Tn=wn.block_uuid,An=wn.file_path,Rn=(0,s.useMemo)((function(){var e=wn["file_paths[]"]||[];return Array.isArray(e)||(e=[e]),e}),[wn]),Dn=(0,s.useCallback)((function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],t=arguments.length>2?arguments[2]:void 0,i=(0,o.Z)({},fn.uM,e);null!==t&&void 0!==t&&t.blockUUID&&(i.block_uuid=null===t||void 0===t?void 0:t.blockUUID),(0,he.u7)(i,{preserveParams:["block_uuid","file_path","file_paths[]"],pushHistory:n,replaceParams:!0})}),[]);(0,s.useEffect)((function(){In||Dn(fn.cH.TREE,!1)}),[In,Dn]);var Mn=(0,s.useCallback)((function(e,n,t){k(!1),setTimeout((function(){return Dn(e,n,t)}),1)}),[Dn]),Bn=(0,s.useRef)({}),Nn=(0,s.useRef)({}),Gn=(0,s.useRef)(null),zn=(0,s.useRef)({}),qn=(0,s.useRef)({}),Kn=(0,s.useRef)({}),Wn=(0,s.useCallback)((function(e,n,t){var i=zn.current||{};zn.current=Tc(Tc({},i),{},(0,o.Z)({},e,Tc(Tc({},i[e]||{}),{},(0,o.Z)({},n,t))))}),[zn]),Qn=(0,s.useCallback)((function(e,n,t){var i=qn.current||{};qn.current=Tc(Tc({},i),{},(0,o.Z)({},e,Tc(Tc({},i[e]||{}),{},(0,o.Z)({},n,t))))}),[qn]),Vn=(0,s.useCallback)((function(e,n,t){Wn(e,n,t),Zn(!0)}),[Wn,Zn]),Yn=(0,s.useCallback)((function(e,n,t){Qn(e,n,t),Zn(!0)}),[Qn,Zn]),Xn=(0,s.useCallback)((function(e){Kn.current=Tc(Tc({},Kn.current),e)}),[Kn]),Jn=(0,s.useCallback)((function(e,n){Xn((0,o.Z)({},e,n)),Zn(!0)}),[Xn,Zn]),$n=(0,s.useState)(null),et=$n[0],nt=$n[1],tt=ce.ZP.data_providers.list({},{revalidateOnFocus:!1}).data,it=null===tt||void 0===tt?void 0:tt.data_providers,rt=ce.ZP.variables.pipelines.list(g,{},{revalidateOnFocus:!1}),ot=rt.data,lt=rt.mutate,ct=null===ot||void 0===ot?void 0:ot.variables,ut=ce.ZP.secrets.list({},{revalidateOnFocus:!1}),at=ut.data,st=ut.mutate,dt=null===at||void 0===at?void 0:at.secrets,ft=(0,s.useState)([]),pt=ft[0],ht=ft[1],mt=(0,s.useState)([]),vt=mt[0],bt=mt[1],gt=(0,s.useRef)({}),xt=(0,s.useCallback)((function(e){var n;Zn(!0);var t=gt.current[e.uuid]||{},i=t.upstream_blocks;(null===e||void 0===e||null===(n=e.upstream_blocks)||void 0===n?void 0:n.length)>=1&&(i=e.upstream_blocks),gt.current[e.uuid]=Tc(Tc(Tc({},t),e),{},{configuration:Tc(Tc({},t.configuration),e.configuration),upstream_blocks:i})}),[Zn,gt]),jt=(0,s.useState)(!1),yt=jt[0],kt=jt[1],Zt=(0,s.useState)({upstreamBlocks:null}),_t=Zt[0],Ot=Zt[1],Ct=(0,s.useState)([]),St=Ct[0],Et=Ct[1],Pt=(0,s.useState)(null),wt=Pt[0],It=Pt[1],Tt=function(e,n){var t=(0,pe.HK)(n,(function(e){return e.uuid}));return e.map((function(e){return t[e]})).filter((function(e){return!!e}))}(Hn(g),pt),At=(0,s.useState)(Tt),Rt=At[0],Dt=At[1],Mt=(0,s.useState)(),Bt=Mt[0],Nt=Mt[1],Lt=(0,s.useState)(),Ft=Lt[0],Ut=Lt[1],Ht=(0,s.useState)(null),Gt=Ht[0],zt=Ht[1],qt=(0,ae.Z)(Rt),Kt=(0,s.useCallback)((function(){Ot({upstreamBlocks:{block:null,values:[]}}),Qe({}),Zn(!1),Et([]),It(null)}),[]);(0,s.useEffect)((function(){g!==rn&&(zn.current={},qn.current={})}),[g,rn]);var Wt=ce.ZP.block_outputs.detail((null===Gt||void 0===Gt?void 0:Gt.type)!==m.tf.SCRATCHPAD&&(null===Gt||void 0===Gt?void 0:Gt.type)!==m.tf.CHART&&(null===Gt||void 0===Gt?void 0:Gt.uuid)&&encodeURIComponent(null===Gt||void 0===Gt?void 0:Gt.uuid),{pipeline_uuid:!j&&g}),Qt=Wt.data,Vt=Wt.mutate,Yt=(0,s.useMemo)((function(){return null===Qt||void 0===Qt?void 0:Qt.block_output}),[Qt]),Xt=(0,s.useMemo)((function(){var e,n,t;return hn?null===(e=(0,pe.sE)(null===Yt||void 0===Yt?void 0:Yt.outputs,(function(e){return e.variable_uuid==="output_sample_data_".concat((0,Q.kE)(Ft))})))||void 0===e?void 0:e.sample_data:null===Yt||void 0===Yt||null===(n=Yt.outputs)||void 0===n||null===(t=n[0])||void 0===t?void 0:t.sample_data}),[Yt,hn,Ft]),Jt=ce.ZP.blocks.pipelines.analyses.detail(!j&&g,(null===Gt||void 0===Gt?void 0:Gt.type)!==m.tf.SCRATCHPAD&&(null===Gt||void 0===Gt?void 0:Gt.type)!==m.tf.CHART&&(null===Gt||void 0===Gt?void 0:Gt.uuid)&&encodeURIComponent(null===Gt||void 0===Gt?void 0:Gt.uuid)),$t=Jt.data,ei=Jt.mutate,ni=(null===$t||void 0===$t||null===(t=$t.analyses)||void 0===t?void 0:t[0])||{},ti=ni.insights,ii=void 0===ti?{}:ti,ri=ni.metadata,oi=void 0===ri?{}:ri,li=ni.statistics,ci=void 0===li?{}:li;(0,s.useEffect)((function(){0===St.length&&(ei(),Vt(),lt())}),[ei,Vt,lt,St]),(0,s.useEffect)((function(){if(0===Rt.length)zt(null);else if((null===qt||void 0===qt?void 0:qt.length)!==(null===Rt||void 0===Rt?void 0:Rt.length)&&(null===Rt||void 0===Rt?void 0:Rt.length)<(null===qt||void 0===qt?void 0:qt.length)){var e=qt.findIndex((function(e){return e.uuid===(null===Gt||void 0===Gt?void 0:Gt.uuid)})),n=qt.length-1===e?e-1:e+1;zt(qt[Math.max(0,n)])}}),[Rt,qt,null===Gt||void 0===Gt?void 0:Gt.uuid]),(0,s.useEffect)((function(){var e;null!==(e=_t.upstreamBlocks)&&void 0!==e&&e.block&&(k(!1),Dn(fn.cH.TREE))}),[_t.upstreamBlocks,Dn]);var ui=ce.ZP.autocomplete_items.list({},{refreshInterval:!1,revalidateOnFocus:!1}),ai=ui.data,si=ui.mutate,di=null===ai||void 0===ai?void 0:ai.autocomplete_items;(0,s.useEffect)((function(){An||_e(!1),W(An)}),[An]),(0,s.useEffect)((function(){(0,pe.fS)(Rn,Y)||X(Rn)}),[Rn,Y]);var fi=(0,d.Db)(ce.ZP.pipelines.useCreate(),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(e){var n=e.pipeline.uuid;u.push("/pipelines/[pipeline]/edit","/pipelines/".concat(n,"/edit")),sn()},onErrorCallback:function(e,n){return M({errors:n,response:e})}})}}),pi=(0,l.Z)(fi,1)[0],hi=(0,d.Db)(ce.ZP.pipelines.useUpdate(g,{update_content:!0}),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(){Zn(!1),cn()},onErrorCallback:function(e,n){return M({errors:n,response:e})}})}}),mi=(0,l.Z)(hi,2),vi=mi[0],bi=mi[1].isLoading,gi=(0,s.useCallback)((function(e,n){var t=e||{},i=t.block,r=t.pipeline,o=void 0===r?{extensions:{}}:r,c=(n||{}).contentOnly;if(!(vn&&Number(vn)>Number(xn))){var u=(0,fe.Tz)({dateObj:!0}),a=(0,fe.Tz)();jn(u);var s={},d={},f={};pt.forEach((function(e){var n,t,r,o=e.extension_uuid,u=e.type,a=e.uuid,p=null===(n=qn.current[u])||void 0===n?void 0:n[a];"undefined"===typeof p&&(p=e.content);var h,v=null===(t=zn.current[u])||void 0===t?void 0:t[a];"undefined"===typeof v&&(v=e.callback_content);var b=null===(r=We[a])||void 0===r?void 0:r.filter((function(e){return!!e})),g=null===b||void 0===b?void 0:b.find((function(e){return e.error}));if(b){var x=[],j=0;b.forEach((function(n){var t=n.data,i=n.type;(m.tf.SCRATCHPAD===e.type||g||"table"!==i)&&(Array.isArray(t)&&(n.data=t.reduce((function(e,n){return n.match(Sn)?e:e.concat(n)}),[]),i===ge.Gi.TEXT_PLAIN&&(j+=(null===t||void 0===t?void 0:t.length)||0)),(!qe||j<qe+5)&&x.push(n))})),h=x.map((function(e,n){return{text_data:JSON.stringify(e),variable_uuid:"".concat(a,"_").concat(n)}}))}var y=Tc(Tc({},e),{},{callback_content:v,content:p,outputs:h});(null===i||void 0===i?void 0:i.uuid)===a&&Object.entries(i).forEach((function(e){var n=(0,l.Z)(e,2),t=n[0],i=n[1];"object"===typeof i&&!Array.isArray(i)&&i?Object.entries(i).forEach((function(e){var n=(0,l.Z)(e,2),i=n[0],r=n[1];y[t]||(y[t]={}),y[t][i]=r})):y[t]=i})),c?d[y.uuid]={callback_content:y.callback_content,content:y.content,outputs:y.outputs,uuid:y.uuid}:[m.tf.EXTENSION].includes(u)?(s[o]||(s[o]=[]),s[o].push(y)):m.tf.CALLBACK===u?f[y.uuid]=y:d[y.uuid]=y}));var p=Tc(Tc({},null===pn||void 0===pn?void 0:pn.extensions),null===o||void 0===o?void 0:o.extensions);Object.entries(s).forEach((function(e){var n=(0,l.Z)(e,2),t=n[0],i=n[1];p[t]||(p[t]={}),p[t].blocks=i}));var h=[],v=[];return((null===o||void 0===o?void 0:o.blocks)||pt).forEach((function(e){var n=e.uuid,t=d[n],i=f[n];"undefined"!==typeof t?h.push(t):"undefined"!==typeof i&&v.push(i)})),vi({pipeline:Tc(Tc(Tc({},pn),o),{},{blocks:h,callbacks:v,extensions:p,updated_at:a,widgets:vt.map((function(e){var n,t,i=Kn.current[e.uuid],r=gt.current[e.uuid]||{};"undefined"===typeof i&&(i=e.content);var o=null===(n=We[e.uuid])||void 0===n?void 0:n.filter((function(e){return!!e})),l=null===o||void 0===o?void 0:o.find((function(e){return e.error}));if(o){var c=[];o.forEach((function(n){var t=n.data,i=n.type;(m.tf.SCRATCHPAD===e.type||l||"table"!==i)&&(Array.isArray(t)&&(n.data=t.reduce((function(e,n){return n.match(Sn)?e:e.concat(n)}),[])),c.push(n))})),t=c.map((function(n,t){return{text_data:JSON.stringify(n),variable_uuid:"".concat(e.uuid,"_").concat(t)}}))}return Tc(Tc(Tc({},e),r),{},{configuration:Tc(Tc({},e.configuration),r.configuration),content:i,outputs:t})}))})})}En()}),[pt,We,pn,vn,xn,En,vi,vt]),xi=(0,s.useCallback)((function(e){gi();var n=encodeURIComponent(e),t=(0,yo.iV)()["file_paths[]"]||[];Array.isArray(t)||(t=[t]),t.includes(n)||t.push(n),(0,he.u7)({file_path:n,"file_paths[]":t})}),[gi]),ji=(0,s.useMemo)((function(){var e=[],n=[];return pt.forEach((function(t){m.tf.EXTENSION===t.type||m.tf.CALLBACK===t.type?n.push(t):e.push(t)})),{blocksInNotebook:e,blocksInSidekick:n}}),[pt]),yi=ji.blocksInNotebook,ki=ji.blocksInSidekick,Zi=(0,s.useCallback)((function(e,n){return gi({pipeline:{name:e,type:n}}).then((function(e){var t,i;if(null!==e&&void 0!==e&&null!==(t=e.data)&&void 0!==t&&t.pipeline){var r=e.data.pipeline.uuid;g!==r?window.location.href="/pipelines/".concat(r,"/edit"):(sn(),n!==(null===pn||void 0===pn?void 0:pn.type)&&cn(),Fn(yi,g,r),Fn(ki,g,r))}else null!==e&&void 0!==e&&null!==(i=e.data)&&void 0!==i&&i.error&&M((function(e){return Tc(Tc({},e),{},{links:[{label:"Check pipeline configuration",onClick:function(){xi("pipelines/".concat(g,"/").concat(Cn.dT.METADATA_YAML)),M(null)}}]})}))}))}),[yi,ki,sn,cn,xi,null===pn||void 0===pn?void 0:pn.type,g,gi]),_i=(0,d.Db)((function(e){var n=e.type,t=e.extension_uuid,i=e.uuid,r={};return n&&(r.block_type=n),t&&(r.extension_uuid=t),ce.ZP.blocks.pipelines.useDelete(g,encodeURIComponent(i),r)()}),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(e){var n=e.block,t=n.type,i=n.uuid;ht((function(e){return(0,pe.oM)(e,e.findIndex((function(e){var n=e.type,r=e.uuid;return t===n&&i===r})))})),cn(),It(null),t===m.tf.SCRATCHPAD&&sn()},onErrorCallback:function(e,n){var t=e.url_parameters,i=n.messages;M({errors:n,response:e}),null!==t&&void 0!==t&&t.block_uuid&&Qe((function(e){return Tc(Tc({},e),{},(0,o.Z)({},t.block_uuid,i.map((function(e){return{data:"".concat(e,"\n"),error:"".concat(e,"\n"),type:ge.Gi.TEXT_PLAIN}}))))}))}})}}),Oi=(0,l.Z)(_i,1)[0],Ci=(0,d.Db)((function(e){var n=e.uuid;return ce.ZP.widgets.pipelines.useDelete(g,n)()}),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(e){var n=e.widget.uuid;bt((function(e){return(0,pe.oM)(e,e.findIndex((function(e){var t=e.uuid;return n===t})))})),cn(),sn()},onErrorCallback:function(e,n){var t=e.url_parameters,i=n.messages;M({errors:n,response:e}),null!==t&&void 0!==t&&t.block_uuid&&Qe((function(e){return Tc(Tc({},e),{},(0,o.Z)({},t.block_uuid,i.map((function(e){return{data:"".concat(e,"\n"),error:"".concat(e,"\n"),type:ge.Gi.TEXT_PLAIN}}))))}))}})}}),Si=(0,l.Z)(Ci,1)[0],Ei=(0,ve.dd)((function(e){return(0,S.jsx)(oe.Z,{centerOnScreen:!0,neutral:!0,onCancel:Ti,onClick:function(){return Ri(e)},subtitle:"Deleting this block is dangerous. Your block may have downstream dependencies that depend on this block. You can delete this block anyway and remove it as a dependency from downstream blocks.",title:"Your block has dependencies",width:34*O.iI})})),Pi=(0,l.Z)(Ei,2),wi=Pi[0],Ti=Pi[1],Ai=(0,d.Db)((function(e){var n=e.language,t=e.type,i=e.uuid,r="".concat(t,"/").concat(i);return n&&Cn.JD[n]&&(r="".concat(r,".").concat(Cn.JD[n].toLowerCase())),ce.ZP.blocks.useDelete(encodeURIComponent(r))()}),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(){si(),cn(),sn()},onErrorCallback:function(e,n){wi(),M({displayMessage:e.exception,errors:n,response:e})}})}}),Ri=(0,l.Z)(Ai,1)[0],Di=(0,d.Db)(ce.ZP.kernels.useUpdate(null===tn||void 0===tn?void 0:tn.id),{onSuccess:function(e){return(0,me.wD)(e,{callback:function(){return en()},onErrorCallback:function(e,n){return M({errors:n,response:e})}})}}),Mi=(0,l.Z)(Di,1)[0],Bi=(0,s.useCallback)((function(){return Mi({kernel:{action_type:"restart"}})}),[Mi]),Ni=(0,s.useCallback)((function(){Mi({kernel:{action_type:"interrupt"}}),Et([])}),[Mi]),Li=(0,d.Db)(ce.ZP.blocks.pipelines.useCreate(g)),Fi=(0,l.Z)(Li,1)[0],Ui=(0,s.useCallback)((function(e,n,t){var i,o,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:(0,Q.Y6)();e.converted_from_type&&e.converted_from_uuid&&(i=null===(o=qn.current[e.converted_from_type])||void 0===o?void 0:o[e.converted_from_uuid]);var u=e.language,a=e.type;if(hn){var s=(0,pe.HK)((null===pn||void 0===pn?void 0:pn.blocks)||[],(function(e){return e.type})),d=s[m.tf.DATA_EXPORTER],f=s[m.tf.DATA_LOADER],p=s[m.tf.TRANSFORMER];if(m.tf.DATA_LOADER===a){if(m.t6.YAML!==u)return void M({displayMessage:"The source you\u2019re trying to add must contain the language ".concat(m.t6.YAML," and not ").concat(u,".")});if(f)return void M({displayMessage:"Pipeline ".concat(null===pn||void 0===pn?void 0:pn.uuid," already has a source: ").concat(null===f||void 0===f?void 0:f.uuid,".")})}else if(m.tf.TRANSFORMER===a){if(p)return void M({displayMessage:"Pipeline ".concat(null===pn||void 0===pn?void 0:pn.uuid," already has a transformer: ").concat(null===p||void 0===p?void 0:p.uuid,".")})}else if(m.tf.DATA_EXPORTER===a){if(m.t6.YAML!==u)return void M({displayMessage:"The destination you\u2019re trying to add must contain the language ".concat(m.t6.YAML," and not ").concat(u,".")});if(d)return void M({displayMessage:"Pipeline ".concat(null===pn||void 0===pn?void 0:pn.uuid," already has a destination: ").concat(null===d||void 0===d?void 0:d.uuid,".")})}}return Fi({block:Tc({content:i,name:c,priority:n},e)}).then((function(e){(0,me.wD)(e,{callback:function(){var n=e.data.block;null===t||void 0===t||t(n),sn(),cn().then((function(e){var n=e.pipeline,t=n.blocks,i=n.extensions;return ht((function(e){var n=(0,r.Z)(t);Object.entries(i||{}).forEach((function(e){var t=(0,l.Z)(e,2),i=t[0],o=t[1].blocks;o&&n.push.apply(n,(0,r.Z)(o.map((function(e){return Tc(Tc({},e),{},{extension_uuid:i})}))))}));var o=(0,pe.HK)(e,(function(e){return e.uuid})),c=[];return n.forEach((function(e){var n=o[e.uuid];n?c.push(n):c.push(e)})),c}))}))},onErrorCallback:function(e,n){return M({errors:n,response:e})}})}))}),[Fi,sn,cn,hn,ht,M,pn]),Hi=(0,s.useState)(!1),Gi=Hi[0],zi=Hi[1];(0,s.useEffect)((function(){zi(!!(0,L.U2)(N.kY))}),[]);var qi=(0,ve.dd)((function(e){var n=e.block,t=e.idx,i=e.name,r=void 0===i?(0,Q.Y6)():i,o=e.onCreateCallback;return(0,S.jsx)(U,{block:n,defaultName:r,onClose:Qi,onSave:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Ui(n,t,o,null===e||void 0===e?void 0:e.name).then((function(){return Qi()}))},pipeline:pn})}),{},[Ui,pn],{background:!0,uuid:"configure_block_name_and_create"}),Ki=(0,l.Z)(qi,2),Wi=Ki[0],Qi=Ki[1],Vi=(0,d.Db)(ce.ZP.widgets.pipelines.useCreate(g)),Yi=(0,l.Z)(Vi,1)[0],Xi=(0,s.useCallback)((function(e,n,t){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:(0,Q.Y6)();return Yi({widget:Tc({name:i,priority:n,type:m.tf.CHART},e)}).then((function(e){return(0,me.wD)(e,{callback:function(){var n=e.data.widget;null===t||void 0===t||t(n),sn(),cn(),Dn(fn.cH.CHARTS),z(n)},onErrorCallback:function(e,n){return M({errors:n,response:e})}})}))}),[sn,cn,Yi,Dn]);(0,s.useEffect)((function(){if(F){var e,n=null===(e=Nn.current[F.uuid])||void 0===e?void 0:e.current;n&&(n.scrollIntoView(),z(null))}}),[F,z]),(0,s.useEffect)((function(){rn!==g&&(ht([]),bt([]),Dt([]),Xe([]))}),[g,rn]),(0,s.useEffect)((function(){if("undefined"!==typeof(null===pn||void 0===pn?void 0:pn.blocks)||"undefined"!==typeof(null===pn||void 0===pn?void 0:pn.extensions)){var e=[];"undefined"!==typeof(null===pn||void 0===pn?void 0:pn.blocks)&&e.push.apply(e,(0,r.Z)(null===pn||void 0===pn?void 0:pn.blocks)),"undefined"!==typeof(null===pn||void 0===pn?void 0:pn.callbacks)&&e.push.apply(e,(0,r.Z)(null===pn||void 0===pn?void 0:pn.callbacks)),"undefined"!==typeof(null===pn||void 0===pn?void 0:pn.extensions)&&Object.entries((null===pn||void 0===pn?void 0:pn.extensions)||{}).forEach((function(n){var t=(0,l.Z)(n,2),i=t[0],o=t[1].blocks;o&&e.push.apply(e,(0,r.Z)(o.map((function(e){return Tc(Tc({},e),{},{extension_uuid:i})}))))})),ht(e)}}),[null===pn||void 0===pn?void 0:pn.blocks,null===pn||void 0===pn?void 0:pn.callbacks,null===pn||void 0===pn?void 0:pn.extensions]),(0,s.useEffect)((function(){"undefined"!==typeof(null===pn||void 0===pn?void 0:pn.widgets)&&bt(pn.widgets)}),[null===pn||void 0===pn?void 0:pn.widgets]),(0,s.useEffect)((function(){(null===Tt||void 0===Tt?void 0:Tt.length)>0&&0===(null===Rt||void 0===Rt?void 0:Rt.length)&&(Dt(Tt),zt(Tt[0]))}),[Rt,Tt]);var Ji=(0,ae.Z)(pt);(0,s.useEffect)((function(){if("undefined"!==typeof(null===pn||void 0===pn?void 0:pn.blocks)&&(!pt.length||!(0,pe.fS)(null===Ji||void 0===Ji?void 0:Ji.map((function(e){return e.uuid})).sort(),null===pt||void 0===pt?void 0:pt.map((function(e){return e.uuid})).sort()))){var e=Ln(pn.blocks),n=e.content,t=e.messages;qn.current=n,Qe((function(e){return Tc(Tc({},t),e)}))}}),[pt,Ji,null===pn||void 0===pn?void 0:pn.blocks,Qe]),(0,s.useEffect)((function(){if(!vt.length&&"undefined"!==typeof(null===pn||void 0===pn?void 0:pn.widgets)){var e=Ln(pn.widgets),n=e.content,t=e.messages;Kn.current=n,Qe((function(e){return Tc(Tc({},t),e)}))}}),[null===pn||void 0===pn?void 0:pn.widgets,Qe,vt]);var $i=(0,s.useCallback)((function(e,n,t){var i=pt.find((function(t){var i=t.type,r=t.uuid;return i===n&&r===e}));if(i){if(It(i),null!==Bn&&void 0!==Bn&&Bn.current){var r,o=Bn.current["".concat(i.type,"s/").concat(i.uuid,".py")];null===o||void 0===o||null===(r=o.current)||void 0===r||r.scrollIntoView()}(0,he.u7)({block_uuid:null,file_path:null,"file_paths[]":[]})}else if(n===m.tf.CHART){var l=vt.find((function(n){return n.uuid===e}));if(l&&(It(l),null!==Nn&&void 0!==Nn&&Nn.current)){var c,u=Nn.current[l.uuid];null===u||void 0===u||null===(c=u.current)||void 0===c||c.scrollIntoView()}}else t&&xi(t)}),[pt,xi,vt]);(0,s.useEffect)((function(){if(Tn&&!wt){var e=pt.find((function(e){var n,t=e.uuid;return(null===Tn||void 0===Tn||null===(n=Tn.split(":"))||void 0===n?void 0:n[0])===t}));e&&(Ue((function(n){return Tc(Tc({},n),{},(0,o.Z)({},e.uuid,!1))})),$i(e.uuid,e.type,null))}else(null===Ji||void 0===Ji?void 0:Ji.length)!==(null===pt||void 0===pt?void 0:pt.length)&&wt&&(Ue((function(e){return Tc(Tc({},e),{},(0,o.Z)({},wt.uuid,!1))})),$i(wt.uuid,wt.type,null))}),[Tn,pt,null===Ji||void 0===Ji?void 0:Ji.length,$i,wt,Ue]);var er=(0,s.useMemo)((function(){return new h.Z}),[]),nr=(0,s.useMemo)((function(){return{api_key:Cc.l,token:er.decodedToken.token}}),[er]),tr=(0,a.ZP)((0,wc.Ib)(),{onClose:function(){return console.log("socketUrlPublish closed")},onMessage:function(e){if(e){var n=JSON.parse(e.data),t=n.block_type,i=n.execution_state,l=n.msg_type,c=n.pipeline_uuid,u=n.uuid;if(!u&&!c)return;var a=pt.find((function(e){var n=e.type,i=e.uuid;return t===n&&u===i}));"stream_pipeline"!==l?Qe((function(e){var t=e[u]||[];return Tc(Tc({},e),{},(0,o.Z)({},u,t.concat(n)))})):(Xe((function(e){return[].concat((0,r.Z)(e),[n])})),ge.uF.IDLE===i&&(Et([]),cn(),u||kt(!1))),ge.uF.BUSY===i?Et((function(e){return e.find((function(e){var n=e.uuid;return u===n}))||!a?e:e.concat(a)})):ge.uF.IDLE===i&&Et((function(e){return e.filter((function(e){var n=e.uuid;return u!==n}))})),ze||Zn(!0)}},onOpen:function(){return console.log("socketUrlPublish opened")},reconnectAttempts:10,reconnectInterval:3e3,shouldReconnect:function(){return console.log("Attempting to reconnect..."),!0}}).sendMessage,ir=(0,s.useCallback)((function(){gi().then((function(){kt(!0),Xe([]),tr(JSON.stringify(Tc(Tc({},nr),{},{execute_pipeline:!0,pipeline_uuid:g})))}))}),[g,gi,tr,nr]),rr=(0,s.useCallback)((function(){tr(JSON.stringify(Tc(Tc({},nr),{},{cancel_pipeline:!0,pipeline_uuid:g})))}),[g,tr,nr]),or=(0,s.useCallback)((function(){tr(JSON.stringify(Tc(Tc({},nr),{},{cancel_pipeline:!0,pipeline_uuid:g,skip_publish_message:!0})))}),[g,tr,nr]),lr=(0,s.useCallback)((function(){tr(JSON.stringify(Tc(Tc({},nr),{},{check_if_pipeline_running:!0,pipeline_uuid:g})))}),[g,tr,nr]);(0,s.useEffect)((function(){var e;return window.addEventListener("pagehide",or),null===u||void 0===u||null===(e=u.events)||void 0===e||e.on("routeChangeStart",or),function(){var e;null===u||void 0===u||null===(e=u.events)||void 0===e||e.off("routeChangeStart",or),window.removeEventListener("pagehide",or)}}),[or,null===u||void 0===u?void 0:u.events]);var cr=(0,s.useCallback)((function(e){var n=e.block,t=e.code,i=e.ignoreAlreadyRunning,r=e.runDownstream,o=void 0!==r&&r,l=e.runSettings,c=void 0===l?{}:l,u=e.runUpstream,a=void 0!==u&&u,s=e.runTests,d=void 0!==s&&s,f=n.extension_uuid,p=n.upstream_blocks,h=n.uuid;St.find((function(e){var n=e.uuid;return h===n}))&&!i||(tr(JSON.stringify(Tc(Tc({},nr),{},{code:t,extension_uuid:f,pipeline_uuid:null===pn||void 0===pn?void 0:pn.uuid,run_downstream:o,run_settings:c,run_tests:d,run_upstream:a,type:n.type,upstream_blocks:p,uuid:h}))),Qe((function(e){return delete e[h],e})),ue(!1),Et((function(e){return e.find((function(e){var n=e.uuid;return h===n}))?e:e.concat(n)}))),cn()}),[cn,pn,St,tr,Qe,Et,ue,nr]),ur=(0,s.useCallback)((function(e){var n=e.block;return ze?cr(e):gi({block:{outputs:[],uuid:n.uuid}},{contentOnly:!0}).then((function(){return cr(e)}))}),[ze,cr,gi]),ar=(0,a.ZP)((0,wc.Ib)("terminal"),{queryParams:nr,shouldReconnect:function(){return!0}}),sr=ar.lastMessage,dr=ar.sendMessage,fr=(0,s.useMemo)((function(){return(0,S.jsx)(gc,{activeView:In,addNewBlockAtIndex:function(e,n,t,i){return new Promise((function(){return Wi({block:e,idx:n,name:i,onCreateCallback:t})}))},afterWidth:C,autocompleteItems:di,blockRefs:Bn,blocks:pt,blocksInNotebook:yi,cancelPipeline:rr,chartRefs:Nn,checkIfPipelineRunning:lr,deleteBlock:Oi,deleteWidget:Si,editingBlock:_t,executePipeline:ir,fetchFileTree:sn,fetchPipeline:cn,fetchSecrets:st,fetchVariables:lt,globalVariables:ct,insights:ii,interruptKernel:Ni,isPipelineExecuting:yt,isPipelineUpdating:bi,lastTerminalMessage:sr,messages:We,metadata:oi,onChangeCallbackBlock:Vn,onChangeChartBlock:Jn,onChangeCodeBlock:Yn,onSelectBlockFile:$i,pipeline:pn,pipelineMessages:Ye,runBlock:ur,runningBlocks:St,sampleData:Xt,savePipelineContent:gi,secrets:dt,selectedBlock:wt,selectedFilePath:K,sendTerminalMessage:dr,setActiveSidekickView:Dn,setAllowCodeBlockShortcuts:Se,setAnyInputFocused:ye,setDepGraphZoom:we,setDisableShortcuts:_e,setEditingBlock:Ot,setErrors:M,setHiddenBlocks:Ue,setSelectedBlock:It,setTextareaFocused:ue,statistics:ci,textareaFocused:le,treeRef:Gn,updatePipelineMetadata:Zi,updateWidget:xt,widgets:vt})}),[In,C,di,Bn,pt,yi,rr,lr,Oi,Si,_t,ir,sn,cn,st,lt,ct,ii,Ni,yt,bi,sr,We,oi,Vn,Jn,Yn,$i,pn,Ye,ur,St,Xt,gi,dt,wt,K,dr,Dn,ye,Ot,M,Ue,ue,Wi,ci,le,Zi,xt,vt]),pr=(0,s.useMemo)((function(){return(0,S.jsx)(Hr,{addNewBlockAtIndex:Gi?Ui:function(e,n,t,i){return new Promise((function(r,o){m.tf.DBT===(null===e||void 0===e?void 0:e.type)&&m.t6.SQL===(null===e||void 0===e?void 0:e.language)?Ui(e,n,t,i):Wi({block:e,idx:n,name:i,onCreateCallback:t})}))},addWidget:function(e,n){var t=n.onCreateCallback;return Xi(e,vt.length,t)},allBlocks:pt,allowCodeBlockShortcuts:Ce,anyInputFocused:je,autocompleteItems:di,blockRefs:Bn,blocks:yi,dataProviders:it,deleteBlock:Oi,disableShortcuts:Ze,fetchFileTree:sn,fetchPipeline:cn,fetchSampleData:Vt,files:dn,globalVariables:ct,hiddenBlocks:Le,interruptKernel:Ni,mainContainerRef:He,mainContainerWidth:et,messages:We,onChangeCallbackBlock:Vn,onChangeCodeBlock:Yn,openSidekickView:Mn,pipeline:pn,pipelineContentTouched:kn,restartKernel:Bi,runBlock:ur,runningBlocks:St,savePipelineContent:gi,selectedBlock:wt,setAnyInputFocused:ye,setDisableShortcuts:_e,setEditingBlock:Ot,setErrors:M,setHiddenBlocks:Ue,setIntegrationStreams:Nt,setOutputBlocks:Dt,setPipelineContentTouched:Zn,setSelectedBlock:It,setSelectedOutputBlock:zt,setSelectedStream:Ut,setTextareaFocused:ue,textareaFocused:le,widgets:vt})}),[Ui,Xi,Ce,je,di,Gi,Bn,pt,yi,it,Oi,Ze,sn,cn,Vt,dn,ct,Le,Ni,He,et,We,Vn,Yn,Mn,pn,kn,Bi,ur,St,gi,wt,ye,Ot,M,Ue,Zn,It,ue,Wi,le,vt]),hr=(0,s.useMemo)((function(){if(i===Wr.b7)return(0,S.jsx)(ee,{cancelPipeline:rr,createPipeline:pi,executePipeline:ir,interruptKernel:Ni,isPipelineExecuting:yt,pipeline:pn,restartKernel:Bi,savePipelineContent:gi,setActiveSidekickView:Dn,setMessages:Qe,children:K&&(0,S.jsx)(Z.Z,{ml:1,children:(0,S.jsx)(y.Z,{alignItems:"center",fullHeight:!0,children:(0,S.jsx)(I.Z,{compact:!0,onClick:function(){return W(null)},small:!0,children:"View pipeline"})})})})}),[rr,pi,ir,Ni,yt,i,pn,Bi,gi,K,Dn,Qe,W]),mr=(0,s.useMemo)((function(){if(i===Wr.b7)return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(be,{filePaths:Y,filesTouched:$,isBusy:St.length>=1,isPipelineUpdating:bi,kernel:tn,pipeline:pn,pipelineContentTouched:kn,pipelineLastSaved:vn,restartKernel:Bi,savePipelineContent:gi,selectedFilePath:K,setErrors:M,setRunningBlocks:Et,updatePipelineMetadata:Zi,children:hr}),(null===Y||void 0===Y?void 0:Y.length)>0&&(0,S.jsx)(de.rK,{relativePosition:!0,secondary:!0,children:(0,S.jsx)(ne.Z,{filePaths:Y,filesTouched:$,savePipelineContent:gi,selectedFilePath:K})})]})}),[hr,$,bi,tn,i,pn,kn,vn,Bi,St,gi,K,Y,M,Zi]),vr=(0,s.useMemo)((function(){var e;return null===Bt||void 0===Bt||null===(e=Bt.filter((function(e){return(0,pe.sE)(null===Yt||void 0===Yt?void 0:Yt.outputs,(function(n){return n.variable_uuid==="output_sample_data_".concat((0,Q.kE)(e))}))})))||void 0===e?void 0:e.map((function(e){return(0,S.jsx)(Z.Z,{pl:1,children:(0,S.jsx)(A.ZP,{blackBorder:!0,compact:!0,muted:!0,onClick:function(){return Ut(e)},selected:Ft===e,uuid:e,children:e})},e)}))}),[Yt,Bt,Ft]),br=(0,s.useRef)(null),gr=(0,s.useMemo)((function(){return(0,S.jsx)(H.Z,{addNewBlock:function(e,n){Ui(e,pt.length,n,e.name),(null===Rn||void 0===Rn?void 0:Rn.length)>=1&&u.push("/pipelines/".concat(g,"/edit"))},blocks:pt,deleteWidget:Si,fetchAutocompleteItems:si,fetchFileTree:sn,fetchPipeline:cn,files:dn,onSelectBlockFile:$i,openFile:xi,openPipeline:function(e){Kt(),u.push("/pipelines/[pipeline]/edit","/pipelines/".concat(e,"/edit"))},openSidekickView:Mn,pipeline:pn,ref:br,setErrors:M,setSelectedBlock:It,widgets:vt})}),[Ui,pt,Si,si,sn,cn,null===Rn||void 0===Rn?void 0:Rn.length,dn,$i,xi,Mn,pn,g,Kt,u,M,It,vt]),xr=(0,s.useMemo)((function(){return(0,S.jsx)(w,{blockRefs:Bn,hiddenBlocks:Le,pipeline:pn,setHiddenBlocks:Ue})}),[Bn,Le,pn,Ue]),jr=(0,s.useMemo)((function(){return Wr.Jf.uuid===(null===Re||void 0===Re?void 0:Re.uuid)?gr:Wr.IY.uuid===(null===Re||void 0===Re?void 0:Re.uuid)?xr:null}),[gr,xr,Re]),yr=(0,s.useMemo)((function(){return(0,S.jsx)(Z.Z,{px:1,children:(0,S.jsx)(T.Z,{noPadding:!0,onClickTab:function(e){Me(e)},selectedTabUUID:null===Re||void 0===Re?void 0:Re.uuid,small:!0,tabs:Wr.NR})})}),[Me,Re]);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(te.Z,{title:null===pn||void 0===pn?void 0:pn.name}),(0,S.jsxs)(Xr,{after:fr,afterHeader:(0,S.jsx)(_c,{activeView:In,depGraphZoom:Pe,pipeline:pn,secrets:dt,treeRef:Gn,variables:ct}),afterHeightOffset:Oc.Mz,afterHidden:j,afterNavigationItems:Pc({activeView:In,pipeline:pn,secrets:dt,setActiveSidekickView:Dn,variables:ct}),afterOverflow:fn.cH.DATA===In?"hidden":null,afterSubheader:(null===Rt||void 0===Rt?void 0:Rt.length)>0&&In===fn.cH.DATA&&(0,S.jsxs)(y.Z,{alignItems:"center",fullHeight:!0,fullWidth:!0,children:[!hn&&Rt.map((function(e){var n=e.uuid,t=(null===Gt||void 0===Gt?void 0:Gt.uuid)===n;return(0,S.jsx)(Z.Z,{pl:1,children:(0,S.jsx)(A.ZP,{afterElement:t?(0,S.jsx)(I.Z,{basic:!0,highlightOnHover:!0,onClick:function(){!function(e,n){var t=Hn(e).filter((function(e){return e!==n}));(0,L.t8)(Un(e),t)}(g,e.uuid),Dt((function(e){return e.filter((function(e){return e.uuid!==n}))}))},padding:"2px",transparent:!0,children:(0,S.jsx)(se.x8,{muted:!0,size:1.25*O.iI})}):null,blackBorder:!0,compact:!0,muted:!0,onClick:function(){return zt(e)},selected:t,uuid:n,children:n})},n)})),hn&&vr]}),before:jr,beforeHeader:yr,beforeHeightOffset:Oc.Mz,beforeNavigationItems:(0,Ec.H)(Sc.M.EDIT,pn),errors:R,headerOffset:(null===Y||void 0===Y?void 0:Y.length)>0?36:0,mainContainerHeader:mr,mainContainerRef:He,page:i,pipeline:pn,setAfterHidden:k,setAfterWidthForChildren:E,setErrors:M,setMainContainerWidth:nt,children:[(0,S.jsx)("div",{style:{height:K?0:null,opacity:K?0:null,visibility:K?"hidden":null},children:(0,S.jsx)(p.Z,{uuid:"PipelineDetail/".concat(g),children:pr})}),null===Rn||void 0===Rn?void 0:Rn.map((function(e){return(0,S.jsx)("div",{style:{display:K===e?null:"none"},children:(0,S.jsx)(p.Z,{uuid:"FileEditor/".concat(decodeURIComponent(e)),children:(0,S.jsx)(G.Z,{active:K===e,addNewBlock:function(e,n){Ui(e,pt.length,n,e.name),u.push("/pipelines/".concat(g,"/edit"))},fetchPipeline:cn,fetchVariables:lt,filePath:e,openSidekickView:Mn,pipeline:pn,selectedFilePath:K,sendTerminalMessage:dr,setDisableShortcuts:_e,setErrors:M,setFilesTouched:ie,setSelectedBlock:It})})},e)})),(0,S.jsx)(Z.Z,{pb:An?0:Math.max(Math.floor(v*(2/3)/O.iI),0)})]})]})}Ac.getInitialProps=function(){var e=(0,i.Z)(u().mark((function e(n){var t,i,r;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.query.pipeline,i=Wr.b7,r={page:i,pipeline:{uuid:t}},e.abrupt("return",r);case 4:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}();var Rc=(0,Jr.Z)(Ac)},11366:function(e,n,t){"use strict";t.d(n,{H8:function(){return r},g6:function(){return o},kY:function(){return i}});var i="automatically_name_blocks",r="pipeline_edit_before_tab_selected",o="pipeline_edit_hidden_blocks"},76419:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/pipelines/[pipeline]/edit",function(){return t(35533)}])}},function(e){e.O(0,[3662,844,7607,5896,4804,1774,9350,5872,2714,2125,7011,8789,7107,1424,1005,8180,3714,3752,1286,9270,4822,4476,8735,9774,2888,179],(function(){return n=76419,e(e.s=n);var n}));var n=e.O();_N_E=n}]);