@michelangelo-ai/core 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/dist/components/breadcrumb-bar/menu-drawer.d.ts.map +1 -1
  2. package/dist/components/breadcrumb-bar/phase-entity-list.d.ts.map +1 -1
  3. package/dist/components/form/__tests__/config-driven-form.test.d.ts +2 -0
  4. package/dist/components/form/__tests__/config-driven-form.test.d.ts.map +1 -0
  5. package/dist/components/form/components/form-dialog/form-dialog.d.ts +1 -1
  6. package/dist/components/form/components/form-dialog/form-dialog.d.ts.map +1 -1
  7. package/dist/components/form/components/form-dialog/types.d.ts +1 -1
  8. package/dist/components/form/components/form-dialog/types.d.ts.map +1 -1
  9. package/dist/components/form/components/form-error-banner/use-form-error-list.d.ts.map +1 -1
  10. package/dist/components/form/config-driven-form.d.ts +24 -0
  11. package/dist/components/form/config-driven-form.d.ts.map +1 -0
  12. package/dist/components/form/constants.d.ts +4 -0
  13. package/dist/components/form/constants.d.ts.map +1 -0
  14. package/dist/components/form/fields/boolean/schema-boolean-field.d.ts +3 -0
  15. package/dist/components/form/fields/boolean/schema-boolean-field.d.ts.map +1 -0
  16. package/dist/components/form/fields/boolean/types.d.ts +4 -1
  17. package/dist/components/form/fields/boolean/types.d.ts.map +1 -1
  18. package/dist/components/form/fields/checkbox/schema-checkbox-field.d.ts +3 -0
  19. package/dist/components/form/fields/checkbox/schema-checkbox-field.d.ts.map +1 -0
  20. package/dist/components/form/fields/checkbox/types.d.ts +4 -1
  21. package/dist/components/form/fields/checkbox/types.d.ts.map +1 -1
  22. package/dist/components/form/fields/date/schema-date-field.d.ts +3 -0
  23. package/dist/components/form/fields/date/schema-date-field.d.ts.map +1 -0
  24. package/dist/components/form/fields/date/types.d.ts +4 -1
  25. package/dist/components/form/fields/date/types.d.ts.map +1 -1
  26. package/dist/components/form/fields/map/schema-map-field.d.ts +3 -0
  27. package/dist/components/form/fields/map/schema-map-field.d.ts.map +1 -0
  28. package/dist/components/form/fields/map/types.d.ts +4 -1
  29. package/dist/components/form/fields/map/types.d.ts.map +1 -1
  30. package/dist/components/form/fields/markdown/schema-markdown-field.d.ts +3 -0
  31. package/dist/components/form/fields/markdown/schema-markdown-field.d.ts.map +1 -0
  32. package/dist/components/form/fields/markdown/types.d.ts +4 -1
  33. package/dist/components/form/fields/markdown/types.d.ts.map +1 -1
  34. package/dist/components/form/fields/number/schema-number-field.d.ts +3 -0
  35. package/dist/components/form/fields/number/schema-number-field.d.ts.map +1 -0
  36. package/dist/components/form/fields/number/types.d.ts +6 -0
  37. package/dist/components/form/fields/number/types.d.ts.map +1 -0
  38. package/dist/components/form/fields/radio/schema-radio-field.d.ts +3 -0
  39. package/dist/components/form/fields/radio/schema-radio-field.d.ts.map +1 -0
  40. package/dist/components/form/fields/radio/types.d.ts +4 -1
  41. package/dist/components/form/fields/radio/types.d.ts.map +1 -1
  42. package/dist/components/form/fields/schema-field.d.ts +12 -0
  43. package/dist/components/form/fields/schema-field.d.ts.map +1 -0
  44. package/dist/components/form/fields/select/schema-select-field.d.ts +3 -0
  45. package/dist/components/form/fields/select/schema-select-field.d.ts.map +1 -0
  46. package/dist/components/form/fields/select/types.d.ts +11 -1
  47. package/dist/components/form/fields/select/types.d.ts.map +1 -1
  48. package/dist/components/form/fields/string/schema-string-field.d.ts +4 -0
  49. package/dist/components/form/fields/string/schema-string-field.d.ts.map +1 -0
  50. package/dist/components/form/fields/string/types.d.ts +10 -0
  51. package/dist/components/form/fields/string/types.d.ts.map +1 -1
  52. package/dist/components/form/fields/textarea/schema-textarea-field.d.ts +3 -0
  53. package/dist/components/form/fields/textarea/schema-textarea-field.d.ts.map +1 -0
  54. package/dist/components/form/fields/textarea/types.d.ts +4 -1
  55. package/dist/components/form/fields/textarea/types.d.ts.map +1 -1
  56. package/dist/components/form/fields/types.d.ts +5 -0
  57. package/dist/components/form/fields/types.d.ts.map +1 -1
  58. package/dist/components/form/fields/url/schema-url-field.d.ts +3 -0
  59. package/dist/components/form/fields/url/schema-url-field.d.ts.map +1 -0
  60. package/dist/components/form/fields/url/types.d.ts +4 -1
  61. package/dist/components/form/fields/url/types.d.ts.map +1 -1
  62. package/dist/components/form/form-context.d.ts +1 -1
  63. package/dist/components/form/form-context.d.ts.map +1 -1
  64. package/dist/components/form/form.d.ts +1 -1
  65. package/dist/components/form/form.d.ts.map +1 -1
  66. package/dist/components/form/hooks/use-array-field.d.ts +1 -1
  67. package/dist/components/form/hooks/use-array-field.d.ts.map +1 -1
  68. package/dist/components/form/hooks/use-field-renderer.d.ts +7 -0
  69. package/dist/components/form/hooks/use-field-renderer.d.ts.map +1 -0
  70. package/dist/components/form/hooks/use-field.d.ts +1 -1
  71. package/dist/components/form/hooks/use-field.d.ts.map +1 -1
  72. package/dist/components/form/hooks/use-form-state.d.ts +1 -1
  73. package/dist/components/form/hooks/use-form-state.d.ts.map +1 -1
  74. package/dist/components/form/hooks/use-form.d.ts +1 -1
  75. package/dist/components/form/hooks/use-form.d.ts.map +1 -1
  76. package/dist/components/form/layout/condition/__tests__/evaluate-condition.test.d.ts +2 -0
  77. package/dist/components/form/layout/condition/__tests__/evaluate-condition.test.d.ts.map +1 -0
  78. package/dist/components/form/layout/condition/__tests__/form-condition.test.d.ts +2 -0
  79. package/dist/components/form/layout/condition/__tests__/form-condition.test.d.ts.map +1 -0
  80. package/dist/components/form/layout/condition/evaluate-condition.d.ts +4 -0
  81. package/dist/components/form/layout/condition/evaluate-condition.d.ts.map +1 -0
  82. package/dist/components/form/layout/condition/form-condition.d.ts +10 -0
  83. package/dist/components/form/layout/condition/form-condition.d.ts.map +1 -0
  84. package/dist/components/form/layout/condition/types.d.ts +36 -0
  85. package/dist/components/form/layout/condition/types.d.ts.map +1 -0
  86. package/dist/components/form/layout/form-grid/types.d.ts +5 -0
  87. package/dist/components/form/layout/form-grid/types.d.ts.map +1 -1
  88. package/dist/components/form/layout/form-group/types.d.ts +6 -0
  89. package/dist/components/form/layout/form-group/types.d.ts.map +1 -1
  90. package/dist/components/form/layout/form-row/types.d.ts +5 -0
  91. package/dist/components/form/layout/form-row/types.d.ts.map +1 -1
  92. package/dist/components/form/layout/layout-item-list.d.ts +8 -0
  93. package/dist/components/form/layout/layout-item-list.d.ts.map +1 -0
  94. package/dist/components/form/layout/layout-renderer.d.ts +7 -0
  95. package/dist/components/form/layout/layout-renderer.d.ts.map +1 -0
  96. package/dist/components/form/layout/types.d.ts +1 -1
  97. package/dist/components/form/layout/types.d.ts.map +1 -1
  98. package/dist/components/form/types/config-types.d.ts +132 -0
  99. package/dist/components/form/types/config-types.d.ts.map +1 -0
  100. package/dist/components/form/{types.d.ts → types/form-types.d.ts} +2 -2
  101. package/dist/components/form/types/form-types.d.ts.map +1 -0
  102. package/dist/components/form/utils/__tests__/delete-by-path.test.d.ts +2 -0
  103. package/dist/components/form/utils/__tests__/delete-by-path.test.d.ts.map +1 -0
  104. package/dist/components/form/utils/__tests__/filter-hidden-condition-fields.test.d.ts +2 -0
  105. package/dist/components/form/utils/__tests__/filter-hidden-condition-fields.test.d.ts.map +1 -0
  106. package/dist/components/form/utils/__tests__/is-empty-field-value.test.d.ts +2 -0
  107. package/dist/components/form/utils/__tests__/is-empty-field-value.test.d.ts.map +1 -0
  108. package/dist/components/form/utils/delete-by-path.d.ts +6 -0
  109. package/dist/components/form/utils/delete-by-path.d.ts.map +1 -0
  110. package/dist/components/form/utils/filter-hidden-condition-fields.d.ts +11 -0
  111. package/dist/components/form/utils/filter-hidden-condition-fields.d.ts.map +1 -0
  112. package/dist/components/form/utils/is-empty-field-value.d.ts +2 -0
  113. package/dist/components/form/utils/is-empty-field-value.d.ts.map +1 -0
  114. package/dist/components/form/validation/resolve-validation.d.ts +4 -0
  115. package/dist/components/form/validation/resolve-validation.d.ts.map +1 -0
  116. package/dist/components/links-box/types.d.ts +1 -0
  117. package/dist/components/links-box/types.d.ts.map +1 -1
  118. package/dist/components/navigation-bar/navigation-bar.d.ts +2 -1
  119. package/dist/components/navigation-bar/navigation-bar.d.ts.map +1 -1
  120. package/dist/components/signpost/signpost.d.ts +3 -0
  121. package/dist/components/signpost/signpost.d.ts.map +1 -0
  122. package/dist/components/signpost/styled-components.d.ts +2 -0
  123. package/dist/components/signpost/styled-components.d.ts.map +1 -0
  124. package/dist/components/{error-view → signpost}/types.d.ts +1 -1
  125. package/dist/components/signpost/types.d.ts.map +1 -0
  126. package/dist/components/views/phase-entity-view/entity-table.d.ts +1 -1
  127. package/dist/components/views/phase-entity-view/entity-table.d.ts.map +1 -1
  128. package/dist/components/views/phase-entity-view/phase-entity-view.d.ts.map +1 -1
  129. package/dist/components/views/phase-entity-view/types.d.ts +6 -0
  130. package/dist/components/views/phase-entity-view/types.d.ts.map +1 -1
  131. package/dist/components/views/phase-entity-view/utils/inject-list-options.d.ts +8 -0
  132. package/dist/components/views/phase-entity-view/utils/inject-list-options.d.ts.map +1 -0
  133. package/dist/components/views/project/components/phase-card.d.ts.map +1 -1
  134. package/dist/components/views/project/project-detail.d.ts.map +1 -1
  135. package/dist/components/views/sandbox/sandbox.d.ts.map +1 -1
  136. package/dist/config/entities/deployment/deployment-info-page.d.ts +5 -0
  137. package/dist/config/entities/deployment/deployment-info-page.d.ts.map +1 -0
  138. package/dist/config/entities/deployment/deployment-revision-card.d.ts +14 -0
  139. package/dist/config/entities/deployment/deployment-revision-card.d.ts.map +1 -0
  140. package/dist/config/entities/deployment/detail.d.ts.map +1 -1
  141. package/dist/config/entities/deployment/shared.d.ts +8 -0
  142. package/dist/config/entities/deployment/shared.d.ts.map +1 -1
  143. package/dist/config/entities/deployment/types.d.ts +39 -0
  144. package/dist/config/entities/deployment/types.d.ts.map +1 -0
  145. package/dist/config/entities/model/__tests__/model-page.test.d.ts +2 -0
  146. package/dist/config/entities/model/__tests__/model-page.test.d.ts.map +1 -0
  147. package/dist/config/entities/model/constants.d.ts +25 -0
  148. package/dist/config/entities/model/constants.d.ts.map +1 -0
  149. package/dist/config/entities/model/list.d.ts.map +1 -1
  150. package/dist/config/entities/pipeline/__tests__/pipeline.test.d.ts +2 -0
  151. package/dist/config/entities/pipeline/__tests__/pipeline.test.d.ts.map +1 -0
  152. package/dist/config/entities/pipeline/pipeline.d.ts.map +1 -1
  153. package/dist/config/phases/data.d.ts.map +1 -1
  154. package/dist/config/phases/deploy.d.ts.map +1 -1
  155. package/dist/config/phases/monitor-debug.d.ts +3 -0
  156. package/dist/config/phases/monitor-debug.d.ts.map +1 -0
  157. package/dist/config/phases/phases.d.ts +2 -0
  158. package/dist/config/phases/phases.d.ts.map +1 -1
  159. package/dist/config/phases/retrain.d.ts +3 -0
  160. package/dist/config/phases/retrain.d.ts.map +1 -0
  161. package/dist/config/phases/train.d.ts.map +1 -1
  162. package/dist/index.d.ts +3 -1
  163. package/dist/index.d.ts.map +1 -1
  164. package/dist/interpolation/types.d.ts +0 -4
  165. package/dist/interpolation/types.d.ts.map +1 -1
  166. package/dist/michelangelo-core.cjs +16 -16
  167. package/dist/michelangelo-core.js +22295 -21756
  168. package/dist/primitives.cjs +1 -1
  169. package/dist/primitives.d.ts +2 -0
  170. package/dist/primitives.d.ts.map +1 -1
  171. package/dist/primitives.js +25 -24
  172. package/dist/providers/form-provider/form-context.d.ts +3 -0
  173. package/dist/providers/form-provider/form-context.d.ts.map +1 -0
  174. package/dist/providers/form-provider/form-provider.d.ts +21 -0
  175. package/dist/providers/form-provider/form-provider.d.ts.map +1 -0
  176. package/dist/providers/form-provider/types.d.ts +25 -0
  177. package/dist/providers/form-provider/types.d.ts.map +1 -0
  178. package/dist/providers/form-provider/use-form-provider.d.ts +15 -0
  179. package/dist/providers/form-provider/use-form-provider.d.ts.map +1 -0
  180. package/dist/router/router.d.ts.map +1 -1
  181. package/dist/test/wrappers/get-form-provider-wrapper.d.ts +1 -1
  182. package/dist/test/wrappers/get-form-provider-wrapper.d.ts.map +1 -1
  183. package/dist/{theme-provider-BNyeUTHs.js → theme-provider-Ba4vmtVx.js} +5911 -5657
  184. package/dist/theme-provider-H-LNQYdH.cjs +303 -0
  185. package/dist/tsconfig.tsbuildinfo +1 -1
  186. package/dist/types/common/studio-types.d.ts +6 -0
  187. package/dist/types/common/studio-types.d.ts.map +1 -1
  188. package/dist/utils/__tests__/crd-utils.test.d.ts +2 -0
  189. package/dist/utils/__tests__/crd-utils.test.d.ts.map +1 -0
  190. package/dist/utils/__tests__/environment-utils.test.d.ts +2 -0
  191. package/dist/utils/__tests__/environment-utils.test.d.ts.map +1 -0
  192. package/dist/utils/crd-utils.d.ts +32 -0
  193. package/dist/utils/crd-utils.d.ts.map +1 -0
  194. package/dist/utils/environment-utils.d.ts +18 -0
  195. package/dist/utils/environment-utils.d.ts.map +1 -0
  196. package/package.json +1 -1
  197. package/dist/components/error-view/error-view.d.ts +0 -3
  198. package/dist/components/error-view/error-view.d.ts.map +0 -1
  199. package/dist/components/error-view/styled-components.d.ts +0 -2
  200. package/dist/components/error-view/styled-components.d.ts.map +0 -1
  201. package/dist/components/error-view/types.d.ts.map +0 -1
  202. package/dist/components/form/types.d.ts.map +0 -1
  203. package/dist/theme-provider-BEQVBa23.cjs +0 -303
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./theme-provider-BEQVBa23.cjs"),Yg=require("baseui/layer"),Xg=require("baseui/snackbar"),Qg=require("baseui/app-nav-bar"),_=require("baseui/button"),j=require("react"),Ae=require("react-router-dom-v5-compat"),an=require("baseui/layout-grid"),D=require("baseui"),Nt=require("baseui/popover"),sr=require("baseui/tag"),Oi=require("baseui/tooltip"),sa=require("baseui/data-table"),ht=require("baseui/input"),bt=require("baseui/typography"),zt=require("baseui/table-semantic"),Ti=require("baseui/checkbox"),Ws=require("baseui/dnd-list"),Jg=require("baseui/skeleton"),Zg=require("baseui/pagination"),Ji=require("baseui/select"),ru=require("baseui/block"),em=require("baseui/form-control"),tm=require("baseui/icon"),rr=require("baseui/dialog"),im=require("baseui/link"),nm=require("baseui/helpers/overrides"),Ch=require("baseui/textarea"),sm=require("baseui/accordion"),or=require("baseui/banner"),rm=require("baseui/menu"),ro=require("baseui/list"),lr=require("baseui/tabs-motion"),om=require("baseui/breadcrumbs"),ou=require("baseui/drawer"),wi=require("baseui/tile"),oo=require("baseui/radio"),lm=require("baseui/datepicker");function am(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const Se=am(j),um=j.forwardRef(function(e,t){const{children:n,...s}=e;return d.jsxRuntimeExports.jsx(_.Button,{...s,ref:t,children:j.Children.map(n,(r,o)=>o===1&&j.isValidElement(r)?j.cloneElement(r,{overrides:{Svg:{style:{paddingLeft:0}}}}):r)})}),cm=[{label:"Sign out"}];function hm({links:i}){const e=d.useUserProvider(),t=(i==null?void 0:i.map(n=>({label:n.label,info:{href:n.href}})))??[];return d.jsxRuntimeExports.jsx(Qg.AppNavBar,{title:d.jsxRuntimeExports.jsx(d.Link,{href:"/",overrides:{Link:{style:{":hover":{textDecoration:"unset"}}}},children:"Michelangelo Studio"}),mainItems:t,mapItemToNode:n=>{const s=n.info;return s!=null&&s.href?d.jsxRuntimeExports.jsx(_.Button,{href:s.href,target:"_blank",rel:"noopener noreferrer",kind:_.KIND.tertiary,size:_.SIZE.compact,overrides:{BaseButton:{style:{display:"flex",alignItems:"flex-start",whiteSpace:"nowrap"}}},children:n.label}):d.jsxRuntimeExports.jsx(d.jsxRuntimeExports.Fragment,{children:n.label})},username:e.name,usernameSubtitle:e.email,userImgUrl:e.avatarUrl,userItems:cm,overrides:{Root:{style:{position:"relative"}},AppName:{style:{whiteSpace:"nowrap"}},PrimaryMenuContainer:{style:({$theme:n})=>({marginLeft:n.sizing.scale1000})},DesktopMenu:{style:{height:"64px",boxSizing:"border-box",paddingBlockStart:"20px"}},UserMenuButton:{component:um,props:{overrides:{BaseButton:{style:({$theme:n})=>({gap:n.sizing.scale200})}}}}}})}const Hi=({children:i})=>d.jsxRuntimeExports.jsx(an.Grid,{gridColumns:1,gridGutters:0,gridGaps:0,children:d.jsxRuntimeExports.jsx(an.Cell,{children:i})});function fm(i){const{id:e,icon:t,name:n,description:s,docUrl:r,state:o,entities:l,projectId:a}=i,u=Ae.useNavigate(),[c,h]=D.useStyletron(),f=o==="disabled"||o==="comingSoon",p=o==="comingSoon";return d.jsxRuntimeExports.jsxs(d.Box,{title:d.jsxRuntimeExports.jsxs("div",{className:c({display:"flex",alignItems:"center",gap:h.sizing.scale400}),children:[d.jsxRuntimeExports.jsx(d.Icon,{name:t,size:h.sizing.scale500}),n]}),description:s&&d.jsxRuntimeExports.jsxs("div",{className:c({display:"flex",alignItems:"center"}),children:[s,r&&d.jsxRuntimeExports.jsx(_.Button,{"aria-label":"Learn more",kind:_.KIND.tertiary,onClick:()=>window.open(r,"_blank"),shape:_.SHAPE.circle,size:_.SIZE.mini,children:d.jsxRuntimeExports.jsx(d.Icon,{name:"arrowLaunch",size:h.sizing.scale500})})]}),children:[p?d.jsxRuntimeExports.jsx("div",{className:c({display:"flex",justifyContent:"center",alignItems:"center",flex:"1",color:h.colors.contentTertiary}),children:"Coming soon"}):d.jsxRuntimeExports.jsx("div",{className:c({display:"flex",flexDirection:"column"}),children:l.map(g=>f||g.state==="disabled"?d.jsxRuntimeExports.jsx("span",{className:c({...h.typography.ParagraphSmall,cursor:"default",color:h.colors.contentTertiary}),children:d.capitalizeFirstLetter(g.name)},g.id):d.jsxRuntimeExports.jsx(d.Link,{href:`/${a}/${e}/${g.id}`,overrides:{Link:{style:h.typography.ParagraphSmall}},children:d.capitalizeFirstLetter(g.name)},g.id))}),l.some(g=>g.state==="active")&&!f&&d.jsxRuntimeExports.jsx(_.Button,{"aria-label":`Go to ${n}`,kind:_.KIND.secondary,onClick:()=>{const g=l.find(m=>m.state==="active");u(`/${a}/${e}/${g.id}`)},shape:_.SHAPE.circle,overrides:{BaseButton:{style:{marginTop:"auto"}}},children:d.jsxRuntimeExports.jsx(d.Icon,{name:"chevronRight",size:h.sizing.scale700})})]})}const wh=[{id:"metadata.name",label:"Name",url:"${row.metadata.name}"},{id:"metadata.creationTimestamp.seconds",label:"Created",type:d.CellType.DATE},{id:"spec.owner.owningTeam",label:"Owner"},{id:"spec.tier",label:"Tier",type:d.CellType.TAG}];function dm({phases:i}){var r,o,l,a;const[e,t]=D.useStyletron(),{projectId:n}=d.useStudioParams("base"),{data:s}=d.useStudioQuery({queryName:"GetProject",serviceOptions:{name:n,namespace:n}});return d.jsxRuntimeExports.jsxs("div",{className:e({display:"flex",flexDirection:"column",gridGap:t.sizing.scale600,padding:t.sizing.scale400}),children:[d.jsxRuntimeExports.jsx(d.Box,{description:(o=(r=s==null?void 0:s.project)==null?void 0:r.spec)==null?void 0:o.description,title:(a=(l=s==null?void 0:s.project)==null?void 0:l.metadata)==null?void 0:a.name,overrides:{BoxContainer:{style:({$theme:u})=>({backgroundColor:u.colors.backgroundSecondary})}},children:d.jsxRuntimeExports.jsx(d.Row,{items:wh,record:s==null?void 0:s.project})}),d.jsxRuntimeExports.jsx("div",{className:e({display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(300px, 1fr))",gap:t.sizing.scale600,padding:t.sizing.scale400}),children:i.map((u,c)=>d.jsxRuntimeExports.jsx(fm,{...u,projectId:n},`${u.name}-${c}`))})]})}/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./theme-provider-H-LNQYdH.cjs"),bm=require("baseui/layer"),vm=require("baseui/snackbar"),Sm=require("baseui/app-nav-bar"),G=require("baseui/button"),M=require("react"),Ge=require("react-router-dom-v5-compat"),ar=require("baseui/layout-grid"),D=require("baseui"),Nt=require("baseui/popover"),ur=require("baseui/tag"),Pi=require("baseui/tooltip"),ma=require("baseui/data-table"),et=require("baseui/input"),ze=require("baseui/typography"),_t=require("baseui/table-semantic"),Oi=require("baseui/checkbox"),Xs=require("baseui/dnd-list"),Nh=require("baseui/skeleton"),Cm=require("baseui/pagination"),tn=require("baseui/select"),bs=require("baseui/block"),wm=require("baseui/helpers/overrides"),Em=require("baseui/form-control"),Rm=require("baseui/datepicker"),Bh=require("baseui/textarea"),Ri=require("baseui/tile"),fo=require("baseui/radio"),km=require("baseui/icon"),Am=require("baseui/accordion"),cr=require("baseui/dialog"),Tm=require("baseui/link"),Wn=require("baseui/banner"),Mm=require("baseui/spinner"),Om=require("baseui/menu"),po=require("baseui/list"),hr=require("baseui/tabs-motion");function Im(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const Se=Im(M),jm=M.forwardRef(function(e,t){const{children:n,...s}=e;return f.jsxRuntimeExports.jsx(G.Button,{...s,ref:t,children:M.Children.map(n,(r,o)=>o===1&&M.isValidElement(r)?M.cloneElement(r,{overrides:{Svg:{style:{paddingLeft:0}}}}):r)})}),Pm=[{label:"Sign out"}];function Dm({links:i,onSignOut:e}){const t=f.useUserProvider(),n=(i==null?void 0:i.map(s=>({label:s.label,info:{href:s.href}})))??[];return f.jsxRuntimeExports.jsx(Sm.AppNavBar,{title:f.jsxRuntimeExports.jsx(f.Link,{href:"/",overrides:{Link:{style:{":hover":{textDecoration:"unset"}}}},children:"Michelangelo Studio"}),mainItems:n,mapItemToNode:s=>{const r=s.info;return r!=null&&r.href?f.jsxRuntimeExports.jsx(G.Button,{href:r.href,target:"_blank",rel:"noopener noreferrer",kind:G.KIND.tertiary,size:G.SIZE.compact,overrides:{BaseButton:{style:{display:"flex",alignItems:"flex-start",whiteSpace:"nowrap"}}},children:s.label}):f.jsxRuntimeExports.jsx(f.jsxRuntimeExports.Fragment,{children:s.label})},username:t.name,usernameSubtitle:t.email,userImgUrl:t.avatarUrl,userItems:Pm,onUserItemSelect:e,overrides:{Root:{style:{position:"relative"}},AppName:{style:{whiteSpace:"nowrap"}},PrimaryMenuContainer:{style:({$theme:s})=>({marginLeft:s.sizing.scale1000})},DesktopMenu:{style:{height:"64px",boxSizing:"border-box",paddingBlockStart:"20px"}},UserMenuButton:{component:jm,props:{overrides:{BaseButton:{style:({$theme:s})=>({gap:s.sizing.scale200})}}}}}})}const Ui=({children:i})=>f.jsxRuntimeExports.jsx(ar.Grid,{gridColumns:1,gridGutters:0,gridGaps:0,children:f.jsxRuntimeExports.jsx(ar.Cell,{children:i})});function Lm(i){const{id:e,icon:t,name:n,description:s,docUrl:r,state:o,entities:l,projectId:a}=i,u=Ge.useNavigate(),[c,h]=D.useStyletron(),d=o==="disabled"||o==="comingSoon",p=o==="comingSoon";return f.jsxRuntimeExports.jsxs(f.Box,{overrides:{BoxContainer:{style:{minHeight:"220px"}}},title:f.jsxRuntimeExports.jsxs("div",{className:c({display:"flex",alignItems:"center",gap:h.sizing.scale400}),children:[f.jsxRuntimeExports.jsx(f.Icon,{name:t,size:h.sizing.scale500}),n,p&&f.jsxRuntimeExports.jsx(f.Tag,{color:f.TAG_COLOR.blue,size:f.TAG_SIZE.xSmall,closeable:!1,children:"Coming soon"})]}),description:s&&f.jsxRuntimeExports.jsxs("div",{className:c({display:"flex",alignItems:"center"}),children:[s,r&&f.jsxRuntimeExports.jsx(G.Button,{"aria-label":"Learn more",kind:G.KIND.tertiary,onClick:()=>window.open(r,"_blank"),shape:G.SHAPE.circle,size:G.SIZE.mini,children:f.jsxRuntimeExports.jsx(f.Icon,{name:"arrowLaunch",size:h.sizing.scale500})})]}),children:[f.jsxRuntimeExports.jsx("div",{className:c({display:"flex",flexDirection:"column"}),children:l.map(g=>d||g.state==="disabled"?f.jsxRuntimeExports.jsx("span",{className:c({...h.typography.ParagraphSmall,cursor:"default",color:h.colors.contentTertiary}),children:g.name},g.id):f.jsxRuntimeExports.jsx(f.Link,{href:`/${a}/${e}/${g.id}`,overrides:{Link:{style:h.typography.ParagraphSmall}},children:g.name},g.id))}),l.some(g=>g.state==="active")&&!d&&f.jsxRuntimeExports.jsx(G.Button,{"aria-label":`Go to ${n}`,kind:G.KIND.secondary,onClick:()=>{const g=l.find(m=>m.state==="active");u(`/${a}/${e}/${g.id}`)},shape:G.SHAPE.circle,overrides:{BaseButton:{style:{marginTop:"auto"}}},children:f.jsxRuntimeExports.jsx(f.Icon,{name:"chevronRight",size:h.sizing.scale700})})]})}const ul=[{id:"metadata.name",label:"Name",url:"${row.metadata.name}"},{id:"metadata.creationTimestamp.seconds",label:"Created",type:f.CellType.DATE},{id:"spec.owner.owningTeam",label:"Owner"},{id:"spec.tier",label:"Tier",type:f.CellType.TAG}];function Fm({phases:i}){var l,a,u,c,h,d;const[e,t]=D.useStyletron(),{projectId:n}=f.useStudioParams("base"),{data:s}=f.useStudioQuery({queryName:"GetProject",serviceOptions:{name:n,namespace:n}}),r=(a=(l=s==null?void 0:s.project)==null?void 0:l.spec)==null?void 0:a.gitRepo,o=r?[...ul,{id:"spec.gitRepo",label:"Source Code",type:f.CellType.LINK,url:r,accessor:()=>"Link"}]:ul;return f.jsxRuntimeExports.jsxs("div",{className:e({display:"flex",flexDirection:"column",gridGap:t.sizing.scale600,padding:t.sizing.scale400}),children:[f.jsxRuntimeExports.jsx(f.Box,{description:(c=(u=s==null?void 0:s.project)==null?void 0:u.spec)==null?void 0:c.description,title:(d=(h=s==null?void 0:s.project)==null?void 0:h.metadata)==null?void 0:d.name,overrides:{BoxContainer:{style:({$theme:p})=>({backgroundColor:p.colors.backgroundSecondary})}},children:f.jsxRuntimeExports.jsx(f.Row,{items:o,record:s==null?void 0:s.project})}),f.jsxRuntimeExports.jsx("div",{className:e({display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:t.sizing.scale500,padding:t.sizing.scale400}),children:i.map((p,g)=>f.jsxRuntimeExports.jsx(Lm,{...p,projectId:n},`${p.name}-${g}`))})]})}/**
2
2
  * table-core
3
3
  *
4
4
  * Copyright (c) TanStack
@@ -7,10 +7,10 @@
7
7
  * LICENSE.md file in the root directory of this source tree.
8
8
  *
9
9
  * @license MIT
10
- */function li(i,e){return typeof i=="function"?i(e):i}function rt(i,e){return t=>{e.setState(n=>({...n,[i]:li(t,n[i])}))}}function Vr(i){return i instanceof Function}function pm(i){return Array.isArray(i)&&i.every(e=>typeof e=="number")}function Eh(i,e){const t=[],n=s=>{s.forEach(r=>{t.push(r);const o=e(r);o!=null&&o.length&&n(o)})};return n(i),t}function K(i,e,t){let n=[],s;return r=>{let o;t.key&&t.debug&&(o=Date.now());const l=i(r);if(!(l.length!==n.length||l.some((c,h)=>n[h]!==c)))return s;n=l;let u;if(t.key&&t.debug&&(u=Date.now()),s=e(...l),t==null||t.onChange==null||t.onChange(s),t.key&&t.debug&&t!=null&&t.debug()){const c=Math.round((Date.now()-o)*100)/100,h=Math.round((Date.now()-u)*100)/100,f=h/16,p=(g,m)=>{for(g=String(g);g.length<m;)g=" "+g;return g};console.info(`%c⏱ ${p(h,5)} /${p(c,5)} ms`,`
10
+ */function ci(i,e){return typeof i=="function"?i(e):i}function at(i,e){return t=>{e.setState(n=>({...n,[i]:ci(t,n[i])}))}}function Hr(i){return i instanceof Function}function Nm(i){return Array.isArray(i)&&i.every(e=>typeof e=="number")}function Vh(i,e){const t=[],n=s=>{s.forEach(r=>{t.push(r);const o=e(r);o!=null&&o.length&&n(o)})};return n(i),t}function Y(i,e,t){let n=[],s;return r=>{let o;t.key&&t.debug&&(o=Date.now());const l=i(r);if(!(l.length!==n.length||l.some((c,h)=>n[h]!==c)))return s;n=l;let u;if(t.key&&t.debug&&(u=Date.now()),s=e(...l),t==null||t.onChange==null||t.onChange(s),t.key&&t.debug&&t!=null&&t.debug()){const c=Math.round((Date.now()-o)*100)/100,h=Math.round((Date.now()-u)*100)/100,d=h/16,p=(g,m)=>{for(g=String(g);g.length<m;)g=" "+g;return g};console.info(`%c⏱ ${p(h,5)} /${p(c,5)} ms`,`
11
11
  font-size: .6rem;
12
12
  font-weight: bold;
13
- color: hsl(${Math.max(0,Math.min(120-120*f,120))}deg 100% 31%);`,t==null?void 0:t.key)}return s}}function Y(i,e,t,n){return{debug:()=>{var s;return(s=i==null?void 0:i.debugAll)!=null?s:i[e]},key:process.env.NODE_ENV==="development"&&t,onChange:n}}function gm(i,e,t,n){const s=()=>{var o;return(o=r.getValue())!=null?o:i.options.renderFallbackValue},r={id:`${e.id}_${t.id}`,row:e,column:t,getValue:()=>e.getValue(n),renderValue:s,getContext:K(()=>[i,t,e,r],(o,l,a,u)=>({table:o,column:l,row:a,cell:u,getValue:u.getValue,renderValue:u.renderValue}),Y(i.options,"debugCells","cell.getContext"))};return i._features.forEach(o=>{o.createCell==null||o.createCell(r,t,e,i)},{}),r}function mm(i,e,t,n){var s,r;const l={...i._getDefaultColumnDef(),...e},a=l.accessorKey;let u=(s=(r=l.id)!=null?r:a?typeof String.prototype.replaceAll=="function"?a.replaceAll(".","_"):a.replace(/\./g,"_"):void 0)!=null?s:typeof l.header=="string"?l.header:void 0,c;if(l.accessorFn?c=l.accessorFn:a&&(a.includes(".")?c=f=>{let p=f;for(const m of a.split(".")){var g;p=(g=p)==null?void 0:g[m],process.env.NODE_ENV!=="production"&&p===void 0&&console.warn(`"${m}" in deeply nested key "${a}" returned undefined.`)}return p}:c=f=>f[l.accessorKey]),!u)throw process.env.NODE_ENV!=="production"?new Error(l.accessorFn?"Columns require an id when using an accessorFn":"Columns require an id when using a non-string header"):new Error;let h={id:`${String(u)}`,accessorFn:c,parent:n,depth:t,columnDef:l,columns:[],getFlatColumns:K(()=>[!0],()=>{var f;return[h,...(f=h.columns)==null?void 0:f.flatMap(p=>p.getFlatColumns())]},Y(i.options,"debugColumns","column.getFlatColumns")),getLeafColumns:K(()=>[i._getOrderColumnsFn()],f=>{var p;if((p=h.columns)!=null&&p.length){let g=h.columns.flatMap(m=>m.getLeafColumns());return f(g)}return[h]},Y(i.options,"debugColumns","column.getLeafColumns"))};for(const f of i._features)f.createColumn==null||f.createColumn(h,i);return h}const Ve="debugHeaders";function lu(i,e,t){var n;let r={id:(n=t.id)!=null?n:e.id,column:e,index:t.index,isPlaceholder:!!t.isPlaceholder,placeholderId:t.placeholderId,depth:t.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const o=[],l=a=>{a.subHeaders&&a.subHeaders.length&&a.subHeaders.map(l),o.push(a)};return l(r),o},getContext:()=>({table:i,header:r,column:e})};return i._features.forEach(o=>{o.createHeader==null||o.createHeader(r,i)}),r}const xm={createTable:i=>{i.getHeaderGroups=K(()=>[i.getAllColumns(),i.getVisibleLeafColumns(),i.getState().columnPinning.left,i.getState().columnPinning.right],(e,t,n,s)=>{var r,o;const l=(r=n==null?void 0:n.map(h=>t.find(f=>f.id===h)).filter(Boolean))!=null?r:[],a=(o=s==null?void 0:s.map(h=>t.find(f=>f.id===h)).filter(Boolean))!=null?o:[],u=t.filter(h=>!(n!=null&&n.includes(h.id))&&!(s!=null&&s.includes(h.id)));return ms(e,[...l,...u,...a],i)},Y(i.options,Ve,"getHeaderGroups")),i.getCenterHeaderGroups=K(()=>[i.getAllColumns(),i.getVisibleLeafColumns(),i.getState().columnPinning.left,i.getState().columnPinning.right],(e,t,n,s)=>(t=t.filter(r=>!(n!=null&&n.includes(r.id))&&!(s!=null&&s.includes(r.id))),ms(e,t,i,"center")),Y(i.options,Ve,"getCenterHeaderGroups")),i.getLeftHeaderGroups=K(()=>[i.getAllColumns(),i.getVisibleLeafColumns(),i.getState().columnPinning.left],(e,t,n)=>{var s;const r=(s=n==null?void 0:n.map(o=>t.find(l=>l.id===o)).filter(Boolean))!=null?s:[];return ms(e,r,i,"left")},Y(i.options,Ve,"getLeftHeaderGroups")),i.getRightHeaderGroups=K(()=>[i.getAllColumns(),i.getVisibleLeafColumns(),i.getState().columnPinning.right],(e,t,n)=>{var s;const r=(s=n==null?void 0:n.map(o=>t.find(l=>l.id===o)).filter(Boolean))!=null?s:[];return ms(e,r,i,"right")},Y(i.options,Ve,"getRightHeaderGroups")),i.getFooterGroups=K(()=>[i.getHeaderGroups()],e=>[...e].reverse(),Y(i.options,Ve,"getFooterGroups")),i.getLeftFooterGroups=K(()=>[i.getLeftHeaderGroups()],e=>[...e].reverse(),Y(i.options,Ve,"getLeftFooterGroups")),i.getCenterFooterGroups=K(()=>[i.getCenterHeaderGroups()],e=>[...e].reverse(),Y(i.options,Ve,"getCenterFooterGroups")),i.getRightFooterGroups=K(()=>[i.getRightHeaderGroups()],e=>[...e].reverse(),Y(i.options,Ve,"getRightFooterGroups")),i.getFlatHeaders=K(()=>[i.getHeaderGroups()],e=>e.map(t=>t.headers).flat(),Y(i.options,Ve,"getFlatHeaders")),i.getLeftFlatHeaders=K(()=>[i.getLeftHeaderGroups()],e=>e.map(t=>t.headers).flat(),Y(i.options,Ve,"getLeftFlatHeaders")),i.getCenterFlatHeaders=K(()=>[i.getCenterHeaderGroups()],e=>e.map(t=>t.headers).flat(),Y(i.options,Ve,"getCenterFlatHeaders")),i.getRightFlatHeaders=K(()=>[i.getRightHeaderGroups()],e=>e.map(t=>t.headers).flat(),Y(i.options,Ve,"getRightFlatHeaders")),i.getCenterLeafHeaders=K(()=>[i.getCenterFlatHeaders()],e=>e.filter(t=>{var n;return!((n=t.subHeaders)!=null&&n.length)}),Y(i.options,Ve,"getCenterLeafHeaders")),i.getLeftLeafHeaders=K(()=>[i.getLeftFlatHeaders()],e=>e.filter(t=>{var n;return!((n=t.subHeaders)!=null&&n.length)}),Y(i.options,Ve,"getLeftLeafHeaders")),i.getRightLeafHeaders=K(()=>[i.getRightFlatHeaders()],e=>e.filter(t=>{var n;return!((n=t.subHeaders)!=null&&n.length)}),Y(i.options,Ve,"getRightLeafHeaders")),i.getLeafHeaders=K(()=>[i.getLeftHeaderGroups(),i.getCenterHeaderGroups(),i.getRightHeaderGroups()],(e,t,n)=>{var s,r,o,l,a,u;return[...(s=(r=e[0])==null?void 0:r.headers)!=null?s:[],...(o=(l=t[0])==null?void 0:l.headers)!=null?o:[],...(a=(u=n[0])==null?void 0:u.headers)!=null?a:[]].map(c=>c.getLeafHeaders()).flat()},Y(i.options,Ve,"getLeafHeaders"))}};function ms(i,e,t,n){var s,r;let o=0;const l=function(f,p){p===void 0&&(p=1),o=Math.max(o,p),f.filter(g=>g.getIsVisible()).forEach(g=>{var m;(m=g.columns)!=null&&m.length&&l(g.columns,p+1)},0)};l(i);let a=[];const u=(f,p)=>{const g={depth:p,id:[n,`${p}`].filter(Boolean).join("_"),headers:[]},m=[];f.forEach(x=>{const y=[...m].reverse()[0],b=x.column.depth===g.depth;let v,w=!1;if(b&&x.column.parent?v=x.column.parent:(v=x.column,w=!0),y&&(y==null?void 0:y.column)===v)y.subHeaders.push(x);else{const S=lu(t,v,{id:[n,p,v.id,x==null?void 0:x.id].filter(Boolean).join("_"),isPlaceholder:w,placeholderId:w?`${m.filter(E=>E.column===v).length}`:void 0,depth:p,index:m.length});S.subHeaders.push(x),m.push(S)}g.headers.push(x),x.headerGroup=g}),a.push(g),p>0&&u(m,p-1)},c=e.map((f,p)=>lu(t,f,{depth:o,index:p}));u(c,o-1),a.reverse();const h=f=>f.filter(g=>g.column.getIsVisible()).map(g=>{let m=0,x=0,y=[0];g.subHeaders&&g.subHeaders.length?(y=[],h(g.subHeaders).forEach(v=>{let{colSpan:w,rowSpan:S}=v;m+=w,y.push(S)})):m=1;const b=Math.min(...y);return x=x+b,g.colSpan=m,g.rowSpan=x,{colSpan:m,rowSpan:x}});return h((s=(r=a[0])==null?void 0:r.headers)!=null?s:[]),a}const zr=(i,e,t,n,s,r,o)=>{let l={id:e,index:n,original:t,depth:s,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:a=>{if(l._valuesCache.hasOwnProperty(a))return l._valuesCache[a];const u=i.getColumn(a);if(u!=null&&u.accessorFn)return l._valuesCache[a]=u.accessorFn(l.original,n),l._valuesCache[a]},getUniqueValues:a=>{if(l._uniqueValuesCache.hasOwnProperty(a))return l._uniqueValuesCache[a];const u=i.getColumn(a);if(u!=null&&u.accessorFn)return u.columnDef.getUniqueValues?(l._uniqueValuesCache[a]=u.columnDef.getUniqueValues(l.original,n),l._uniqueValuesCache[a]):(l._uniqueValuesCache[a]=[l.getValue(a)],l._uniqueValuesCache[a])},renderValue:a=>{var u;return(u=l.getValue(a))!=null?u:i.options.renderFallbackValue},subRows:r??[],getLeafRows:()=>Eh(l.subRows,a=>a.subRows),getParentRow:()=>l.parentId?i.getRow(l.parentId,!0):void 0,getParentRows:()=>{let a=[],u=l;for(;;){const c=u.getParentRow();if(!c)break;a.push(c),u=c}return a.reverse()},getAllCells:K(()=>[i.getAllLeafColumns()],a=>a.map(u=>gm(i,l,u,u.id)),Y(i.options,"debugRows","getAllCells")),_getAllCellsByColumnId:K(()=>[l.getAllCells()],a=>a.reduce((u,c)=>(u[c.column.id]=c,u),{}),Y(i.options,"debugRows","getAllCellsByColumnId"))};for(let a=0;a<i._features.length;a++){const u=i._features[a];u==null||u.createRow==null||u.createRow(l,i)}return l},ym={createColumn:(i,e)=>{i._getFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,i.id),i.getFacetedRowModel=()=>i._getFacetedRowModel?i._getFacetedRowModel():e.getPreFilteredRowModel(),i._getFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,i.id),i.getFacetedUniqueValues=()=>i._getFacetedUniqueValues?i._getFacetedUniqueValues():new Map,i._getFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,i.id),i.getFacetedMinMaxValues=()=>{if(i._getFacetedMinMaxValues)return i._getFacetedMinMaxValues()}}},Rh=(i,e,t)=>{var n,s;const r=t==null||(n=t.toString())==null?void 0:n.toLowerCase();return!!(!((s=i.getValue(e))==null||(s=s.toString())==null||(s=s.toLowerCase())==null)&&s.includes(r))};Rh.autoRemove=i=>yt(i);const kh=(i,e,t)=>{var n;return!!(!((n=i.getValue(e))==null||(n=n.toString())==null)&&n.includes(t))};kh.autoRemove=i=>yt(i);const Ah=(i,e,t)=>{var n;return((n=i.getValue(e))==null||(n=n.toString())==null?void 0:n.toLowerCase())===(t==null?void 0:t.toLowerCase())};Ah.autoRemove=i=>yt(i);const Th=(i,e,t)=>{var n;return(n=i.getValue(e))==null?void 0:n.includes(t)};Th.autoRemove=i=>yt(i);const Mh=(i,e,t)=>!t.some(n=>{var s;return!((s=i.getValue(e))!=null&&s.includes(n))});Mh.autoRemove=i=>yt(i)||!(i!=null&&i.length);const jh=(i,e,t)=>t.some(n=>{var s;return(s=i.getValue(e))==null?void 0:s.includes(n)});jh.autoRemove=i=>yt(i)||!(i!=null&&i.length);const Oh=(i,e,t)=>i.getValue(e)===t;Oh.autoRemove=i=>yt(i);const Ih=(i,e,t)=>i.getValue(e)==t;Ih.autoRemove=i=>yt(i);const ra=(i,e,t)=>{let[n,s]=t;const r=i.getValue(e);return r>=n&&r<=s};ra.resolveFilterValue=i=>{let[e,t]=i,n=typeof e!="number"?parseFloat(e):e,s=typeof t!="number"?parseFloat(t):t,r=e===null||Number.isNaN(n)?-1/0:n,o=t===null||Number.isNaN(s)?1/0:s;if(r>o){const l=r;r=o,o=l}return[r,o]};ra.autoRemove=i=>yt(i)||yt(i[0])&&yt(i[1]);const Gt={includesString:Rh,includesStringSensitive:kh,equalsString:Ah,arrIncludes:Th,arrIncludesAll:Mh,arrIncludesSome:jh,equals:Oh,weakEquals:Ih,inNumberRange:ra};function yt(i){return i==null||i===""}const bm={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:i=>({columnFilters:[],...i}),getDefaultOptions:i=>({onColumnFiltersChange:rt("columnFilters",i),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(i,e)=>{i.getAutoFilterFn=()=>{const t=e.getCoreRowModel().flatRows[0],n=t==null?void 0:t.getValue(i.id);return typeof n=="string"?Gt.includesString:typeof n=="number"?Gt.inNumberRange:typeof n=="boolean"||n!==null&&typeof n=="object"?Gt.equals:Array.isArray(n)?Gt.arrIncludes:Gt.weakEquals},i.getFilterFn=()=>{var t,n;return Vr(i.columnDef.filterFn)?i.columnDef.filterFn:i.columnDef.filterFn==="auto"?i.getAutoFilterFn():(t=(n=e.options.filterFns)==null?void 0:n[i.columnDef.filterFn])!=null?t:Gt[i.columnDef.filterFn]},i.getCanFilter=()=>{var t,n,s;return((t=i.columnDef.enableColumnFilter)!=null?t:!0)&&((n=e.options.enableColumnFilters)!=null?n:!0)&&((s=e.options.enableFilters)!=null?s:!0)&&!!i.accessorFn},i.getIsFiltered=()=>i.getFilterIndex()>-1,i.getFilterValue=()=>{var t;return(t=e.getState().columnFilters)==null||(t=t.find(n=>n.id===i.id))==null?void 0:t.value},i.getFilterIndex=()=>{var t,n;return(t=(n=e.getState().columnFilters)==null?void 0:n.findIndex(s=>s.id===i.id))!=null?t:-1},i.setFilterValue=t=>{e.setColumnFilters(n=>{const s=i.getFilterFn(),r=n==null?void 0:n.find(c=>c.id===i.id),o=li(t,r?r.value:void 0);if(au(s,o,i)){var l;return(l=n==null?void 0:n.filter(c=>c.id!==i.id))!=null?l:[]}const a={id:i.id,value:o};if(r){var u;return(u=n==null?void 0:n.map(c=>c.id===i.id?a:c))!=null?u:[]}return n!=null&&n.length?[...n,a]:[a]})}},createRow:(i,e)=>{i.columnFilters={},i.columnFiltersMeta={}},createTable:i=>{i.setColumnFilters=e=>{const t=i.getAllLeafColumns(),n=s=>{var r;return(r=li(e,s))==null?void 0:r.filter(o=>{const l=t.find(a=>a.id===o.id);if(l){const a=l.getFilterFn();if(au(a,o.value,l))return!1}return!0})};i.options.onColumnFiltersChange==null||i.options.onColumnFiltersChange(n)},i.resetColumnFilters=e=>{var t,n;i.setColumnFilters(e?[]:(t=(n=i.initialState)==null?void 0:n.columnFilters)!=null?t:[])},i.getPreFilteredRowModel=()=>i.getCoreRowModel(),i.getFilteredRowModel=()=>(!i._getFilteredRowModel&&i.options.getFilteredRowModel&&(i._getFilteredRowModel=i.options.getFilteredRowModel(i)),i.options.manualFiltering||!i._getFilteredRowModel?i.getPreFilteredRowModel():i._getFilteredRowModel())}};function au(i,e,t){return(i&&i.autoRemove?i.autoRemove(e,t):!1)||typeof e>"u"||typeof e=="string"&&!e}const vm=(i,e,t)=>t.reduce((n,s)=>{const r=s.getValue(i);return n+(typeof r=="number"?r:0)},0),Sm=(i,e,t)=>{let n;return t.forEach(s=>{const r=s.getValue(i);r!=null&&(n>r||n===void 0&&r>=r)&&(n=r)}),n},Cm=(i,e,t)=>{let n;return t.forEach(s=>{const r=s.getValue(i);r!=null&&(n<r||n===void 0&&r>=r)&&(n=r)}),n},wm=(i,e,t)=>{let n,s;return t.forEach(r=>{const o=r.getValue(i);o!=null&&(n===void 0?o>=o&&(n=s=o):(n>o&&(n=o),s<o&&(s=o)))}),[n,s]},Em=(i,e)=>{let t=0,n=0;if(e.forEach(s=>{let r=s.getValue(i);r!=null&&(r=+r)>=r&&(++t,n+=r)}),t)return n/t},Rm=(i,e)=>{if(!e.length)return;const t=e.map(r=>r.getValue(i));if(!pm(t))return;if(t.length===1)return t[0];const n=Math.floor(t.length/2),s=t.sort((r,o)=>r-o);return t.length%2!==0?s[n]:(s[n-1]+s[n])/2},km=(i,e)=>Array.from(new Set(e.map(t=>t.getValue(i))).values()),Am=(i,e)=>new Set(e.map(t=>t.getValue(i))).size,Tm=(i,e)=>e.length,lo={sum:vm,min:Sm,max:Cm,extent:wm,mean:Em,median:Rm,unique:km,uniqueCount:Am,count:Tm},Mm={getDefaultColumnDef:()=>({aggregatedCell:i=>{var e,t;return(e=(t=i.getValue())==null||t.toString==null?void 0:t.toString())!=null?e:null},aggregationFn:"auto"}),getInitialState:i=>({grouping:[],...i}),getDefaultOptions:i=>({onGroupingChange:rt("grouping",i),groupedColumnMode:"reorder"}),createColumn:(i,e)=>{i.toggleGrouping=()=>{e.setGrouping(t=>t!=null&&t.includes(i.id)?t.filter(n=>n!==i.id):[...t??[],i.id])},i.getCanGroup=()=>{var t,n;return((t=i.columnDef.enableGrouping)!=null?t:!0)&&((n=e.options.enableGrouping)!=null?n:!0)&&(!!i.accessorFn||!!i.columnDef.getGroupingValue)},i.getIsGrouped=()=>{var t;return(t=e.getState().grouping)==null?void 0:t.includes(i.id)},i.getGroupedIndex=()=>{var t;return(t=e.getState().grouping)==null?void 0:t.indexOf(i.id)},i.getToggleGroupingHandler=()=>{const t=i.getCanGroup();return()=>{t&&i.toggleGrouping()}},i.getAutoAggregationFn=()=>{const t=e.getCoreRowModel().flatRows[0],n=t==null?void 0:t.getValue(i.id);if(typeof n=="number")return lo.sum;if(Object.prototype.toString.call(n)==="[object Date]")return lo.extent},i.getAggregationFn=()=>{var t,n;if(!i)throw new Error;return Vr(i.columnDef.aggregationFn)?i.columnDef.aggregationFn:i.columnDef.aggregationFn==="auto"?i.getAutoAggregationFn():(t=(n=e.options.aggregationFns)==null?void 0:n[i.columnDef.aggregationFn])!=null?t:lo[i.columnDef.aggregationFn]}},createTable:i=>{i.setGrouping=e=>i.options.onGroupingChange==null?void 0:i.options.onGroupingChange(e),i.resetGrouping=e=>{var t,n;i.setGrouping(e?[]:(t=(n=i.initialState)==null?void 0:n.grouping)!=null?t:[])},i.getPreGroupedRowModel=()=>i.getFilteredRowModel(),i.getGroupedRowModel=()=>(!i._getGroupedRowModel&&i.options.getGroupedRowModel&&(i._getGroupedRowModel=i.options.getGroupedRowModel(i)),i.options.manualGrouping||!i._getGroupedRowModel?i.getPreGroupedRowModel():i._getGroupedRowModel())},createRow:(i,e)=>{i.getIsGrouped=()=>!!i.groupingColumnId,i.getGroupingValue=t=>{if(i._groupingValuesCache.hasOwnProperty(t))return i._groupingValuesCache[t];const n=e.getColumn(t);return n!=null&&n.columnDef.getGroupingValue?(i._groupingValuesCache[t]=n.columnDef.getGroupingValue(i.original),i._groupingValuesCache[t]):i.getValue(t)},i._groupingValuesCache={}},createCell:(i,e,t,n)=>{i.getIsGrouped=()=>e.getIsGrouped()&&e.id===t.groupingColumnId,i.getIsPlaceholder=()=>!i.getIsGrouped()&&e.getIsGrouped(),i.getIsAggregated=()=>{var s;return!i.getIsGrouped()&&!i.getIsPlaceholder()&&!!((s=t.subRows)!=null&&s.length)}}};function jm(i,e,t){if(!(e!=null&&e.length)||!t)return i;const n=i.filter(r=>!e.includes(r.id));return t==="remove"?n:[...e.map(r=>i.find(o=>o.id===r)).filter(Boolean),...n]}const Om={getInitialState:i=>({columnOrder:[],...i}),getDefaultOptions:i=>({onColumnOrderChange:rt("columnOrder",i)}),createColumn:(i,e)=>{i.getIndex=K(t=>[Pn(e,t)],t=>t.findIndex(n=>n.id===i.id),Y(e.options,"debugColumns","getIndex")),i.getIsFirstColumn=t=>{var n;return((n=Pn(e,t)[0])==null?void 0:n.id)===i.id},i.getIsLastColumn=t=>{var n;const s=Pn(e,t);return((n=s[s.length-1])==null?void 0:n.id)===i.id}},createTable:i=>{i.setColumnOrder=e=>i.options.onColumnOrderChange==null?void 0:i.options.onColumnOrderChange(e),i.resetColumnOrder=e=>{var t;i.setColumnOrder(e?[]:(t=i.initialState.columnOrder)!=null?t:[])},i._getOrderColumnsFn=K(()=>[i.getState().columnOrder,i.getState().grouping,i.options.groupedColumnMode],(e,t,n)=>s=>{let r=[];if(!(e!=null&&e.length))r=s;else{const o=[...e],l=[...s];for(;l.length&&o.length;){const a=o.shift(),u=l.findIndex(c=>c.id===a);u>-1&&r.push(l.splice(u,1)[0])}r=[...r,...l]}return jm(r,t,n)},Y(i.options,"debugTable","_getOrderColumnsFn"))}},ao=()=>({left:[],right:[]}),Im={getInitialState:i=>({columnPinning:ao(),...i}),getDefaultOptions:i=>({onColumnPinningChange:rt("columnPinning",i)}),createColumn:(i,e)=>{i.pin=t=>{const n=i.getLeafColumns().map(s=>s.id).filter(Boolean);e.setColumnPinning(s=>{var r,o;if(t==="right"){var l,a;return{left:((l=s==null?void 0:s.left)!=null?l:[]).filter(h=>!(n!=null&&n.includes(h))),right:[...((a=s==null?void 0:s.right)!=null?a:[]).filter(h=>!(n!=null&&n.includes(h))),...n]}}if(t==="left"){var u,c;return{left:[...((u=s==null?void 0:s.left)!=null?u:[]).filter(h=>!(n!=null&&n.includes(h))),...n],right:((c=s==null?void 0:s.right)!=null?c:[]).filter(h=>!(n!=null&&n.includes(h)))}}return{left:((r=s==null?void 0:s.left)!=null?r:[]).filter(h=>!(n!=null&&n.includes(h))),right:((o=s==null?void 0:s.right)!=null?o:[]).filter(h=>!(n!=null&&n.includes(h)))}})},i.getCanPin=()=>i.getLeafColumns().some(n=>{var s,r,o;return((s=n.columnDef.enablePinning)!=null?s:!0)&&((r=(o=e.options.enableColumnPinning)!=null?o:e.options.enablePinning)!=null?r:!0)}),i.getIsPinned=()=>{const t=i.getLeafColumns().map(l=>l.id),{left:n,right:s}=e.getState().columnPinning,r=t.some(l=>n==null?void 0:n.includes(l)),o=t.some(l=>s==null?void 0:s.includes(l));return r?"left":o?"right":!1},i.getPinnedIndex=()=>{var t,n;const s=i.getIsPinned();return s?(t=(n=e.getState().columnPinning)==null||(n=n[s])==null?void 0:n.indexOf(i.id))!=null?t:-1:0}},createRow:(i,e)=>{i.getCenterVisibleCells=K(()=>[i._getAllVisibleCells(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,s)=>{const r=[...n??[],...s??[]];return t.filter(o=>!r.includes(o.column.id))},Y(e.options,"debugRows","getCenterVisibleCells")),i.getLeftVisibleCells=K(()=>[i._getAllVisibleCells(),e.getState().columnPinning.left],(t,n)=>(n??[]).map(r=>t.find(o=>o.column.id===r)).filter(Boolean).map(r=>({...r,position:"left"})),Y(e.options,"debugRows","getLeftVisibleCells")),i.getRightVisibleCells=K(()=>[i._getAllVisibleCells(),e.getState().columnPinning.right],(t,n)=>(n??[]).map(r=>t.find(o=>o.column.id===r)).filter(Boolean).map(r=>({...r,position:"right"})),Y(e.options,"debugRows","getRightVisibleCells"))},createTable:i=>{i.setColumnPinning=e=>i.options.onColumnPinningChange==null?void 0:i.options.onColumnPinningChange(e),i.resetColumnPinning=e=>{var t,n;return i.setColumnPinning(e?ao():(t=(n=i.initialState)==null?void 0:n.columnPinning)!=null?t:ao())},i.getIsSomeColumnsPinned=e=>{var t;const n=i.getState().columnPinning;if(!e){var s,r;return!!((s=n.left)!=null&&s.length||(r=n.right)!=null&&r.length)}return!!((t=n[e])!=null&&t.length)},i.getLeftLeafColumns=K(()=>[i.getAllLeafColumns(),i.getState().columnPinning.left],(e,t)=>(t??[]).map(n=>e.find(s=>s.id===n)).filter(Boolean),Y(i.options,"debugColumns","getLeftLeafColumns")),i.getRightLeafColumns=K(()=>[i.getAllLeafColumns(),i.getState().columnPinning.right],(e,t)=>(t??[]).map(n=>e.find(s=>s.id===n)).filter(Boolean),Y(i.options,"debugColumns","getRightLeafColumns")),i.getCenterLeafColumns=K(()=>[i.getAllLeafColumns(),i.getState().columnPinning.left,i.getState().columnPinning.right],(e,t,n)=>{const s=[...t??[],...n??[]];return e.filter(r=>!s.includes(r.id))},Y(i.options,"debugColumns","getCenterLeafColumns"))}};function Pm(i){return i||(typeof document<"u"?document:null)}const xs={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},uo=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),Dm={getDefaultColumnDef:()=>xs,getInitialState:i=>({columnSizing:{},columnSizingInfo:uo(),...i}),getDefaultOptions:i=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:rt("columnSizing",i),onColumnSizingInfoChange:rt("columnSizingInfo",i)}),createColumn:(i,e)=>{i.getSize=()=>{var t,n,s;const r=e.getState().columnSizing[i.id];return Math.min(Math.max((t=i.columnDef.minSize)!=null?t:xs.minSize,(n=r??i.columnDef.size)!=null?n:xs.size),(s=i.columnDef.maxSize)!=null?s:xs.maxSize)},i.getStart=K(t=>[t,Pn(e,t),e.getState().columnSizing],(t,n)=>n.slice(0,i.getIndex(t)).reduce((s,r)=>s+r.getSize(),0),Y(e.options,"debugColumns","getStart")),i.getAfter=K(t=>[t,Pn(e,t),e.getState().columnSizing],(t,n)=>n.slice(i.getIndex(t)+1).reduce((s,r)=>s+r.getSize(),0),Y(e.options,"debugColumns","getAfter")),i.resetSize=()=>{e.setColumnSizing(t=>{let{[i.id]:n,...s}=t;return s})},i.getCanResize=()=>{var t,n;return((t=i.columnDef.enableResizing)!=null?t:!0)&&((n=e.options.enableColumnResizing)!=null?n:!0)},i.getIsResizing=()=>e.getState().columnSizingInfo.isResizingColumn===i.id},createHeader:(i,e)=>{i.getSize=()=>{let t=0;const n=s=>{if(s.subHeaders.length)s.subHeaders.forEach(n);else{var r;t+=(r=s.column.getSize())!=null?r:0}};return n(i),t},i.getStart=()=>{if(i.index>0){const t=i.headerGroup.headers[i.index-1];return t.getStart()+t.getSize()}return 0},i.getResizeHandler=t=>{const n=e.getColumn(i.column.id),s=n==null?void 0:n.getCanResize();return r=>{if(!n||!s||(r.persist==null||r.persist(),co(r)&&r.touches&&r.touches.length>1))return;const o=i.getSize(),l=i?i.getLeafHeaders().map(y=>[y.column.id,y.column.getSize()]):[[n.id,n.getSize()]],a=co(r)?Math.round(r.touches[0].clientX):r.clientX,u={},c=(y,b)=>{typeof b=="number"&&(e.setColumnSizingInfo(v=>{var w,S;const E=e.options.columnResizeDirection==="rtl"?-1:1,A=(b-((w=v==null?void 0:v.startOffset)!=null?w:0))*E,O=Math.max(A/((S=v==null?void 0:v.startSize)!=null?S:0),-.999999);return v.columnSizingStart.forEach(R=>{let[H,N]=R;u[H]=Math.round(Math.max(N+N*O,0)*100)/100}),{...v,deltaOffset:A,deltaPercentage:O}}),(e.options.columnResizeMode==="onChange"||y==="end")&&e.setColumnSizing(v=>({...v,...u})))},h=y=>c("move",y),f=y=>{c("end",y),e.setColumnSizingInfo(b=>({...b,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},p=Pm(t),g={moveHandler:y=>h(y.clientX),upHandler:y=>{p==null||p.removeEventListener("mousemove",g.moveHandler),p==null||p.removeEventListener("mouseup",g.upHandler),f(y.clientX)}},m={moveHandler:y=>(y.cancelable&&(y.preventDefault(),y.stopPropagation()),h(y.touches[0].clientX),!1),upHandler:y=>{var b;p==null||p.removeEventListener("touchmove",m.moveHandler),p==null||p.removeEventListener("touchend",m.upHandler),y.cancelable&&(y.preventDefault(),y.stopPropagation()),f((b=y.touches[0])==null?void 0:b.clientX)}},x=Lm()?{passive:!1}:!1;co(r)?(p==null||p.addEventListener("touchmove",m.moveHandler,x),p==null||p.addEventListener("touchend",m.upHandler,x)):(p==null||p.addEventListener("mousemove",g.moveHandler,x),p==null||p.addEventListener("mouseup",g.upHandler,x)),e.setColumnSizingInfo(y=>({...y,startOffset:a,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:l,isResizingColumn:n.id}))}}},createTable:i=>{i.setColumnSizing=e=>i.options.onColumnSizingChange==null?void 0:i.options.onColumnSizingChange(e),i.setColumnSizingInfo=e=>i.options.onColumnSizingInfoChange==null?void 0:i.options.onColumnSizingInfoChange(e),i.resetColumnSizing=e=>{var t;i.setColumnSizing(e?{}:(t=i.initialState.columnSizing)!=null?t:{})},i.resetHeaderSizeInfo=e=>{var t;i.setColumnSizingInfo(e?uo():(t=i.initialState.columnSizingInfo)!=null?t:uo())},i.getTotalSize=()=>{var e,t;return(e=(t=i.getHeaderGroups()[0])==null?void 0:t.headers.reduce((n,s)=>n+s.getSize(),0))!=null?e:0},i.getLeftTotalSize=()=>{var e,t;return(e=(t=i.getLeftHeaderGroups()[0])==null?void 0:t.headers.reduce((n,s)=>n+s.getSize(),0))!=null?e:0},i.getCenterTotalSize=()=>{var e,t;return(e=(t=i.getCenterHeaderGroups()[0])==null?void 0:t.headers.reduce((n,s)=>n+s.getSize(),0))!=null?e:0},i.getRightTotalSize=()=>{var e,t;return(e=(t=i.getRightHeaderGroups()[0])==null?void 0:t.headers.reduce((n,s)=>n+s.getSize(),0))!=null?e:0}}};let ys=null;function Lm(){if(typeof ys=="boolean")return ys;let i=!1;try{const e={get passive(){return i=!0,!1}},t=()=>{};window.addEventListener("test",t,e),window.removeEventListener("test",t)}catch{i=!1}return ys=i,ys}function co(i){return i.type==="touchstart"}const Fm={getInitialState:i=>({columnVisibility:{},...i}),getDefaultOptions:i=>({onColumnVisibilityChange:rt("columnVisibility",i)}),createColumn:(i,e)=>{i.toggleVisibility=t=>{i.getCanHide()&&e.setColumnVisibility(n=>({...n,[i.id]:t??!i.getIsVisible()}))},i.getIsVisible=()=>{var t,n;const s=i.columns;return(t=s.length?s.some(r=>r.getIsVisible()):(n=e.getState().columnVisibility)==null?void 0:n[i.id])!=null?t:!0},i.getCanHide=()=>{var t,n;return((t=i.columnDef.enableHiding)!=null?t:!0)&&((n=e.options.enableHiding)!=null?n:!0)},i.getToggleVisibilityHandler=()=>t=>{i.toggleVisibility==null||i.toggleVisibility(t.target.checked)}},createRow:(i,e)=>{i._getAllVisibleCells=K(()=>[i.getAllCells(),e.getState().columnVisibility],t=>t.filter(n=>n.column.getIsVisible()),Y(e.options,"debugRows","_getAllVisibleCells")),i.getVisibleCells=K(()=>[i.getLeftVisibleCells(),i.getCenterVisibleCells(),i.getRightVisibleCells()],(t,n,s)=>[...t,...n,...s],Y(e.options,"debugRows","getVisibleCells"))},createTable:i=>{const e=(t,n)=>K(()=>[n(),n().filter(s=>s.getIsVisible()).map(s=>s.id).join("_")],s=>s.filter(r=>r.getIsVisible==null?void 0:r.getIsVisible()),Y(i.options,"debugColumns",t));i.getVisibleFlatColumns=e("getVisibleFlatColumns",()=>i.getAllFlatColumns()),i.getVisibleLeafColumns=e("getVisibleLeafColumns",()=>i.getAllLeafColumns()),i.getLeftVisibleLeafColumns=e("getLeftVisibleLeafColumns",()=>i.getLeftLeafColumns()),i.getRightVisibleLeafColumns=e("getRightVisibleLeafColumns",()=>i.getRightLeafColumns()),i.getCenterVisibleLeafColumns=e("getCenterVisibleLeafColumns",()=>i.getCenterLeafColumns()),i.setColumnVisibility=t=>i.options.onColumnVisibilityChange==null?void 0:i.options.onColumnVisibilityChange(t),i.resetColumnVisibility=t=>{var n;i.setColumnVisibility(t?{}:(n=i.initialState.columnVisibility)!=null?n:{})},i.toggleAllColumnsVisible=t=>{var n;t=(n=t)!=null?n:!i.getIsAllColumnsVisible(),i.setColumnVisibility(i.getAllLeafColumns().reduce((s,r)=>({...s,[r.id]:t||!(r.getCanHide!=null&&r.getCanHide())}),{}))},i.getIsAllColumnsVisible=()=>!i.getAllLeafColumns().some(t=>!(t.getIsVisible!=null&&t.getIsVisible())),i.getIsSomeColumnsVisible=()=>i.getAllLeafColumns().some(t=>t.getIsVisible==null?void 0:t.getIsVisible()),i.getToggleAllColumnsVisibilityHandler=()=>t=>{var n;i.toggleAllColumnsVisible((n=t.target)==null?void 0:n.checked)}}};function Pn(i,e){return e?e==="center"?i.getCenterVisibleLeafColumns():e==="left"?i.getLeftVisibleLeafColumns():i.getRightVisibleLeafColumns():i.getVisibleLeafColumns()}const Nm={createTable:i=>{i._getGlobalFacetedRowModel=i.options.getFacetedRowModel&&i.options.getFacetedRowModel(i,"__global__"),i.getGlobalFacetedRowModel=()=>i.options.manualFiltering||!i._getGlobalFacetedRowModel?i.getPreFilteredRowModel():i._getGlobalFacetedRowModel(),i._getGlobalFacetedUniqueValues=i.options.getFacetedUniqueValues&&i.options.getFacetedUniqueValues(i,"__global__"),i.getGlobalFacetedUniqueValues=()=>i._getGlobalFacetedUniqueValues?i._getGlobalFacetedUniqueValues():new Map,i._getGlobalFacetedMinMaxValues=i.options.getFacetedMinMaxValues&&i.options.getFacetedMinMaxValues(i,"__global__"),i.getGlobalFacetedMinMaxValues=()=>{if(i._getGlobalFacetedMinMaxValues)return i._getGlobalFacetedMinMaxValues()}}},Bm={getInitialState:i=>({globalFilter:void 0,...i}),getDefaultOptions:i=>({onGlobalFilterChange:rt("globalFilter",i),globalFilterFn:"auto",getColumnCanGlobalFilter:e=>{var t;const n=(t=i.getCoreRowModel().flatRows[0])==null||(t=t._getAllCellsByColumnId()[e.id])==null?void 0:t.getValue();return typeof n=="string"||typeof n=="number"}}),createColumn:(i,e)=>{i.getCanGlobalFilter=()=>{var t,n,s,r;return((t=i.columnDef.enableGlobalFilter)!=null?t:!0)&&((n=e.options.enableGlobalFilter)!=null?n:!0)&&((s=e.options.enableFilters)!=null?s:!0)&&((r=e.options.getColumnCanGlobalFilter==null?void 0:e.options.getColumnCanGlobalFilter(i))!=null?r:!0)&&!!i.accessorFn}},createTable:i=>{i.getGlobalAutoFilterFn=()=>Gt.includesString,i.getGlobalFilterFn=()=>{var e,t;const{globalFilterFn:n}=i.options;return Vr(n)?n:n==="auto"?i.getGlobalAutoFilterFn():(e=(t=i.options.filterFns)==null?void 0:t[n])!=null?e:Gt[n]},i.setGlobalFilter=e=>{i.options.onGlobalFilterChange==null||i.options.onGlobalFilterChange(e)},i.resetGlobalFilter=e=>{i.setGlobalFilter(e?void 0:i.initialState.globalFilter)}}},Vm={getInitialState:i=>({expanded:{},...i}),getDefaultOptions:i=>({onExpandedChange:rt("expanded",i),paginateExpandedRows:!0}),createTable:i=>{let e=!1,t=!1;i._autoResetExpanded=()=>{var n,s;if(!e){i._queue(()=>{e=!0});return}if((n=(s=i.options.autoResetAll)!=null?s:i.options.autoResetExpanded)!=null?n:!i.options.manualExpanding){if(t)return;t=!0,i._queue(()=>{i.resetExpanded(),t=!1})}},i.setExpanded=n=>i.options.onExpandedChange==null?void 0:i.options.onExpandedChange(n),i.toggleAllRowsExpanded=n=>{n??!i.getIsAllRowsExpanded()?i.setExpanded(!0):i.setExpanded({})},i.resetExpanded=n=>{var s,r;i.setExpanded(n?{}:(s=(r=i.initialState)==null?void 0:r.expanded)!=null?s:{})},i.getCanSomeRowsExpand=()=>i.getPrePaginationRowModel().flatRows.some(n=>n.getCanExpand()),i.getToggleAllRowsExpandedHandler=()=>n=>{n.persist==null||n.persist(),i.toggleAllRowsExpanded()},i.getIsSomeRowsExpanded=()=>{const n=i.getState().expanded;return n===!0||Object.values(n).some(Boolean)},i.getIsAllRowsExpanded=()=>{const n=i.getState().expanded;return typeof n=="boolean"?n===!0:!(!Object.keys(n).length||i.getRowModel().flatRows.some(s=>!s.getIsExpanded()))},i.getExpandedDepth=()=>{let n=0;return(i.getState().expanded===!0?Object.keys(i.getRowModel().rowsById):Object.keys(i.getState().expanded)).forEach(r=>{const o=r.split(".");n=Math.max(n,o.length)}),n},i.getPreExpandedRowModel=()=>i.getSortedRowModel(),i.getExpandedRowModel=()=>(!i._getExpandedRowModel&&i.options.getExpandedRowModel&&(i._getExpandedRowModel=i.options.getExpandedRowModel(i)),i.options.manualExpanding||!i._getExpandedRowModel?i.getPreExpandedRowModel():i._getExpandedRowModel())},createRow:(i,e)=>{i.toggleExpanded=t=>{e.setExpanded(n=>{var s;const r=n===!0?!0:!!(n!=null&&n[i.id]);let o={};if(n===!0?Object.keys(e.getRowModel().rowsById).forEach(l=>{o[l]=!0}):o=n,t=(s=t)!=null?s:!r,!r&&t)return{...o,[i.id]:!0};if(r&&!t){const{[i.id]:l,...a}=o;return a}return n})},i.getIsExpanded=()=>{var t;const n=e.getState().expanded;return!!((t=e.options.getIsRowExpanded==null?void 0:e.options.getIsRowExpanded(i))!=null?t:n===!0||n!=null&&n[i.id])},i.getCanExpand=()=>{var t,n,s;return(t=e.options.getRowCanExpand==null?void 0:e.options.getRowCanExpand(i))!=null?t:((n=e.options.enableExpanding)!=null?n:!0)&&!!((s=i.subRows)!=null&&s.length)},i.getIsAllParentsExpanded=()=>{let t=!0,n=i;for(;t&&n.parentId;)n=e.getRow(n.parentId,!0),t=n.getIsExpanded();return t},i.getToggleExpandedHandler=()=>{const t=i.getCanExpand();return()=>{t&&i.toggleExpanded()}}}},Jo=0,Zo=10,ho=()=>({pageIndex:Jo,pageSize:Zo}),zm={getInitialState:i=>({...i,pagination:{...ho(),...i==null?void 0:i.pagination}}),getDefaultOptions:i=>({onPaginationChange:rt("pagination",i)}),createTable:i=>{let e=!1,t=!1;i._autoResetPageIndex=()=>{var n,s;if(!e){i._queue(()=>{e=!0});return}if((n=(s=i.options.autoResetAll)!=null?s:i.options.autoResetPageIndex)!=null?n:!i.options.manualPagination){if(t)return;t=!0,i._queue(()=>{i.resetPageIndex(),t=!1})}},i.setPagination=n=>{const s=r=>li(n,r);return i.options.onPaginationChange==null?void 0:i.options.onPaginationChange(s)},i.resetPagination=n=>{var s;i.setPagination(n?ho():(s=i.initialState.pagination)!=null?s:ho())},i.setPageIndex=n=>{i.setPagination(s=>{let r=li(n,s.pageIndex);const o=typeof i.options.pageCount>"u"||i.options.pageCount===-1?Number.MAX_SAFE_INTEGER:i.options.pageCount-1;return r=Math.max(0,Math.min(r,o)),{...s,pageIndex:r}})},i.resetPageIndex=n=>{var s,r;i.setPageIndex(n?Jo:(s=(r=i.initialState)==null||(r=r.pagination)==null?void 0:r.pageIndex)!=null?s:Jo)},i.resetPageSize=n=>{var s,r;i.setPageSize(n?Zo:(s=(r=i.initialState)==null||(r=r.pagination)==null?void 0:r.pageSize)!=null?s:Zo)},i.setPageSize=n=>{i.setPagination(s=>{const r=Math.max(1,li(n,s.pageSize)),o=s.pageSize*s.pageIndex,l=Math.floor(o/r);return{...s,pageIndex:l,pageSize:r}})},i.setPageCount=n=>i.setPagination(s=>{var r;let o=li(n,(r=i.options.pageCount)!=null?r:-1);return typeof o=="number"&&(o=Math.max(-1,o)),{...s,pageCount:o}}),i.getPageOptions=K(()=>[i.getPageCount()],n=>{let s=[];return n&&n>0&&(s=[...new Array(n)].fill(null).map((r,o)=>o)),s},Y(i.options,"debugTable","getPageOptions")),i.getCanPreviousPage=()=>i.getState().pagination.pageIndex>0,i.getCanNextPage=()=>{const{pageIndex:n}=i.getState().pagination,s=i.getPageCount();return s===-1?!0:s===0?!1:n<s-1},i.previousPage=()=>i.setPageIndex(n=>n-1),i.nextPage=()=>i.setPageIndex(n=>n+1),i.firstPage=()=>i.setPageIndex(0),i.lastPage=()=>i.setPageIndex(i.getPageCount()-1),i.getPrePaginationRowModel=()=>i.getExpandedRowModel(),i.getPaginationRowModel=()=>(!i._getPaginationRowModel&&i.options.getPaginationRowModel&&(i._getPaginationRowModel=i.options.getPaginationRowModel(i)),i.options.manualPagination||!i._getPaginationRowModel?i.getPrePaginationRowModel():i._getPaginationRowModel()),i.getPageCount=()=>{var n;return(n=i.options.pageCount)!=null?n:Math.ceil(i.getRowCount()/i.getState().pagination.pageSize)},i.getRowCount=()=>{var n;return(n=i.options.rowCount)!=null?n:i.getPrePaginationRowModel().rows.length}}},fo=()=>({top:[],bottom:[]}),$m={getInitialState:i=>({rowPinning:fo(),...i}),getDefaultOptions:i=>({onRowPinningChange:rt("rowPinning",i)}),createRow:(i,e)=>{i.pin=(t,n,s)=>{const r=n?i.getLeafRows().map(a=>{let{id:u}=a;return u}):[],o=s?i.getParentRows().map(a=>{let{id:u}=a;return u}):[],l=new Set([...o,i.id,...r]);e.setRowPinning(a=>{var u,c;if(t==="bottom"){var h,f;return{top:((h=a==null?void 0:a.top)!=null?h:[]).filter(m=>!(l!=null&&l.has(m))),bottom:[...((f=a==null?void 0:a.bottom)!=null?f:[]).filter(m=>!(l!=null&&l.has(m))),...Array.from(l)]}}if(t==="top"){var p,g;return{top:[...((p=a==null?void 0:a.top)!=null?p:[]).filter(m=>!(l!=null&&l.has(m))),...Array.from(l)],bottom:((g=a==null?void 0:a.bottom)!=null?g:[]).filter(m=>!(l!=null&&l.has(m)))}}return{top:((u=a==null?void 0:a.top)!=null?u:[]).filter(m=>!(l!=null&&l.has(m))),bottom:((c=a==null?void 0:a.bottom)!=null?c:[]).filter(m=>!(l!=null&&l.has(m)))}})},i.getCanPin=()=>{var t;const{enableRowPinning:n,enablePinning:s}=e.options;return typeof n=="function"?n(i):(t=n??s)!=null?t:!0},i.getIsPinned=()=>{const t=[i.id],{top:n,bottom:s}=e.getState().rowPinning,r=t.some(l=>n==null?void 0:n.includes(l)),o=t.some(l=>s==null?void 0:s.includes(l));return r?"top":o?"bottom":!1},i.getPinnedIndex=()=>{var t,n;const s=i.getIsPinned();if(!s)return-1;const r=(t=s==="top"?e.getTopRows():e.getBottomRows())==null?void 0:t.map(o=>{let{id:l}=o;return l});return(n=r==null?void 0:r.indexOf(i.id))!=null?n:-1}},createTable:i=>{i.setRowPinning=e=>i.options.onRowPinningChange==null?void 0:i.options.onRowPinningChange(e),i.resetRowPinning=e=>{var t,n;return i.setRowPinning(e?fo():(t=(n=i.initialState)==null?void 0:n.rowPinning)!=null?t:fo())},i.getIsSomeRowsPinned=e=>{var t;const n=i.getState().rowPinning;if(!e){var s,r;return!!((s=n.top)!=null&&s.length||(r=n.bottom)!=null&&r.length)}return!!((t=n[e])!=null&&t.length)},i._getPinnedRows=(e,t,n)=>{var s;return((s=i.options.keepPinnedRows)==null||s?(t??[]).map(o=>{const l=i.getRow(o,!0);return l.getIsAllParentsExpanded()?l:null}):(t??[]).map(o=>e.find(l=>l.id===o))).filter(Boolean).map(o=>({...o,position:n}))},i.getTopRows=K(()=>[i.getRowModel().rows,i.getState().rowPinning.top],(e,t)=>i._getPinnedRows(e,t,"top"),Y(i.options,"debugRows","getTopRows")),i.getBottomRows=K(()=>[i.getRowModel().rows,i.getState().rowPinning.bottom],(e,t)=>i._getPinnedRows(e,t,"bottom"),Y(i.options,"debugRows","getBottomRows")),i.getCenterRows=K(()=>[i.getRowModel().rows,i.getState().rowPinning.top,i.getState().rowPinning.bottom],(e,t,n)=>{const s=new Set([...t??[],...n??[]]);return e.filter(r=>!s.has(r.id))},Y(i.options,"debugRows","getCenterRows"))}},_m={getInitialState:i=>({rowSelection:{},...i}),getDefaultOptions:i=>({onRowSelectionChange:rt("rowSelection",i),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:i=>{i.setRowSelection=e=>i.options.onRowSelectionChange==null?void 0:i.options.onRowSelectionChange(e),i.resetRowSelection=e=>{var t;return i.setRowSelection(e?{}:(t=i.initialState.rowSelection)!=null?t:{})},i.toggleAllRowsSelected=e=>{i.setRowSelection(t=>{e=typeof e<"u"?e:!i.getIsAllRowsSelected();const n={...t},s=i.getPreGroupedRowModel().flatRows;return e?s.forEach(r=>{r.getCanSelect()&&(n[r.id]=!0)}):s.forEach(r=>{delete n[r.id]}),n})},i.toggleAllPageRowsSelected=e=>i.setRowSelection(t=>{const n=typeof e<"u"?e:!i.getIsAllPageRowsSelected(),s={...t};return i.getRowModel().rows.forEach(r=>{el(s,r.id,n,!0,i)}),s}),i.getPreSelectedRowModel=()=>i.getCoreRowModel(),i.getSelectedRowModel=K(()=>[i.getState().rowSelection,i.getCoreRowModel()],(e,t)=>Object.keys(e).length?po(i,t):{rows:[],flatRows:[],rowsById:{}},Y(i.options,"debugTable","getSelectedRowModel")),i.getFilteredSelectedRowModel=K(()=>[i.getState().rowSelection,i.getFilteredRowModel()],(e,t)=>Object.keys(e).length?po(i,t):{rows:[],flatRows:[],rowsById:{}},Y(i.options,"debugTable","getFilteredSelectedRowModel")),i.getGroupedSelectedRowModel=K(()=>[i.getState().rowSelection,i.getSortedRowModel()],(e,t)=>Object.keys(e).length?po(i,t):{rows:[],flatRows:[],rowsById:{}},Y(i.options,"debugTable","getGroupedSelectedRowModel")),i.getIsAllRowsSelected=()=>{const e=i.getFilteredRowModel().flatRows,{rowSelection:t}=i.getState();let n=!!(e.length&&Object.keys(t).length);return n&&e.some(s=>s.getCanSelect()&&!t[s.id])&&(n=!1),n},i.getIsAllPageRowsSelected=()=>{const e=i.getPaginationRowModel().flatRows.filter(s=>s.getCanSelect()),{rowSelection:t}=i.getState();let n=!!e.length;return n&&e.some(s=>!t[s.id])&&(n=!1),n},i.getIsSomeRowsSelected=()=>{var e;const t=Object.keys((e=i.getState().rowSelection)!=null?e:{}).length;return t>0&&t<i.getFilteredRowModel().flatRows.length},i.getIsSomePageRowsSelected=()=>{const e=i.getPaginationRowModel().flatRows;return i.getIsAllPageRowsSelected()?!1:e.filter(t=>t.getCanSelect()).some(t=>t.getIsSelected()||t.getIsSomeSelected())},i.getToggleAllRowsSelectedHandler=()=>e=>{i.toggleAllRowsSelected(e.target.checked)},i.getToggleAllPageRowsSelectedHandler=()=>e=>{i.toggleAllPageRowsSelected(e.target.checked)}},createRow:(i,e)=>{i.toggleSelected=(t,n)=>{const s=i.getIsSelected();e.setRowSelection(r=>{var o;if(t=typeof t<"u"?t:!s,i.getCanSelect()&&s===t)return r;const l={...r};return el(l,i.id,t,(o=n==null?void 0:n.selectChildren)!=null?o:!0,e),l})},i.getIsSelected=()=>{const{rowSelection:t}=e.getState();return oa(i,t)},i.getIsSomeSelected=()=>{const{rowSelection:t}=e.getState();return tl(i,t)==="some"},i.getIsAllSubRowsSelected=()=>{const{rowSelection:t}=e.getState();return tl(i,t)==="all"},i.getCanSelect=()=>{var t;return typeof e.options.enableRowSelection=="function"?e.options.enableRowSelection(i):(t=e.options.enableRowSelection)!=null?t:!0},i.getCanSelectSubRows=()=>{var t;return typeof e.options.enableSubRowSelection=="function"?e.options.enableSubRowSelection(i):(t=e.options.enableSubRowSelection)!=null?t:!0},i.getCanMultiSelect=()=>{var t;return typeof e.options.enableMultiRowSelection=="function"?e.options.enableMultiRowSelection(i):(t=e.options.enableMultiRowSelection)!=null?t:!0},i.getToggleSelectedHandler=()=>{const t=i.getCanSelect();return n=>{var s;t&&i.toggleSelected((s=n.target)==null?void 0:s.checked)}}}},el=(i,e,t,n,s)=>{var r;const o=s.getRow(e,!0);t?(o.getCanMultiSelect()||Object.keys(i).forEach(l=>delete i[l]),o.getCanSelect()&&(i[e]=!0)):delete i[e],n&&(r=o.subRows)!=null&&r.length&&o.getCanSelectSubRows()&&o.subRows.forEach(l=>el(i,l.id,t,n,s))};function po(i,e){const t=i.getState().rowSelection,n=[],s={},r=function(o,l){return o.map(a=>{var u;const c=oa(a,t);if(c&&(n.push(a),s[a.id]=a),(u=a.subRows)!=null&&u.length&&(a={...a,subRows:r(a.subRows)}),c)return a}).filter(Boolean)};return{rows:r(e.rows),flatRows:n,rowsById:s}}function oa(i,e){var t;return(t=e[i.id])!=null?t:!1}function tl(i,e,t){var n;if(!((n=i.subRows)!=null&&n.length))return!1;let s=!0,r=!1;return i.subRows.forEach(o=>{if(!(r&&!s)&&(o.getCanSelect()&&(oa(o,e)?r=!0:s=!1),o.subRows&&o.subRows.length)){const l=tl(o,e);l==="all"?r=!0:(l==="some"&&(r=!0),s=!1)}}),s?"all":r?"some":!1}const il=/([0-9]+)/gm,Hm=(i,e,t)=>Ph(di(i.getValue(t)).toLowerCase(),di(e.getValue(t)).toLowerCase()),Gm=(i,e,t)=>Ph(di(i.getValue(t)),di(e.getValue(t))),Wm=(i,e,t)=>la(di(i.getValue(t)).toLowerCase(),di(e.getValue(t)).toLowerCase()),Um=(i,e,t)=>la(di(i.getValue(t)),di(e.getValue(t))),qm=(i,e,t)=>{const n=i.getValue(t),s=e.getValue(t);return n>s?1:n<s?-1:0},Km=(i,e,t)=>la(i.getValue(t),e.getValue(t));function la(i,e){return i===e?0:i>e?1:-1}function di(i){return typeof i=="number"?isNaN(i)||i===1/0||i===-1/0?"":String(i):typeof i=="string"?i:""}function Ph(i,e){const t=i.split(il).filter(Boolean),n=e.split(il).filter(Boolean);for(;t.length&&n.length;){const s=t.shift(),r=n.shift(),o=parseInt(s,10),l=parseInt(r,10),a=[o,l].sort();if(isNaN(a[0])){if(s>r)return 1;if(r>s)return-1;continue}if(isNaN(a[1]))return isNaN(o)?-1:1;if(o>l)return 1;if(l>o)return-1}return t.length-n.length}const wn={alphanumeric:Hm,alphanumericCaseSensitive:Gm,text:Wm,textCaseSensitive:Um,datetime:qm,basic:Km},Ym={getInitialState:i=>({sorting:[],...i}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:i=>({onSortingChange:rt("sorting",i),isMultiSortEvent:e=>e.shiftKey}),createColumn:(i,e)=>{i.getAutoSortingFn=()=>{const t=e.getFilteredRowModel().flatRows.slice(10);let n=!1;for(const s of t){const r=s==null?void 0:s.getValue(i.id);if(Object.prototype.toString.call(r)==="[object Date]")return wn.datetime;if(typeof r=="string"&&(n=!0,r.split(il).length>1))return wn.alphanumeric}return n?wn.text:wn.basic},i.getAutoSortDir=()=>{const t=e.getFilteredRowModel().flatRows[0];return typeof(t==null?void 0:t.getValue(i.id))=="string"?"asc":"desc"},i.getSortingFn=()=>{var t,n;if(!i)throw new Error;return Vr(i.columnDef.sortingFn)?i.columnDef.sortingFn:i.columnDef.sortingFn==="auto"?i.getAutoSortingFn():(t=(n=e.options.sortingFns)==null?void 0:n[i.columnDef.sortingFn])!=null?t:wn[i.columnDef.sortingFn]},i.toggleSorting=(t,n)=>{const s=i.getNextSortingOrder(),r=typeof t<"u"&&t!==null;e.setSorting(o=>{const l=o==null?void 0:o.find(p=>p.id===i.id),a=o==null?void 0:o.findIndex(p=>p.id===i.id);let u=[],c,h=r?t:s==="desc";if(o!=null&&o.length&&i.getCanMultiSort()&&n?l?c="toggle":c="add":o!=null&&o.length&&a!==o.length-1?c="replace":l?c="toggle":c="replace",c==="toggle"&&(r||s||(c="remove")),c==="add"){var f;u=[...o,{id:i.id,desc:h}],u.splice(0,u.length-((f=e.options.maxMultiSortColCount)!=null?f:Number.MAX_SAFE_INTEGER))}else c==="toggle"?u=o.map(p=>p.id===i.id?{...p,desc:h}:p):c==="remove"?u=o.filter(p=>p.id!==i.id):u=[{id:i.id,desc:h}];return u})},i.getFirstSortDir=()=>{var t,n;return((t=(n=i.columnDef.sortDescFirst)!=null?n:e.options.sortDescFirst)!=null?t:i.getAutoSortDir()==="desc")?"desc":"asc"},i.getNextSortingOrder=t=>{var n,s;const r=i.getFirstSortDir(),o=i.getIsSorted();return o?o!==r&&((n=e.options.enableSortingRemoval)==null||n)&&(!(t&&(s=e.options.enableMultiRemove)!=null)||s)?!1:o==="desc"?"asc":"desc":r},i.getCanSort=()=>{var t,n;return((t=i.columnDef.enableSorting)!=null?t:!0)&&((n=e.options.enableSorting)!=null?n:!0)&&!!i.accessorFn},i.getCanMultiSort=()=>{var t,n;return(t=(n=i.columnDef.enableMultiSort)!=null?n:e.options.enableMultiSort)!=null?t:!!i.accessorFn},i.getIsSorted=()=>{var t;const n=(t=e.getState().sorting)==null?void 0:t.find(s=>s.id===i.id);return n?n.desc?"desc":"asc":!1},i.getSortIndex=()=>{var t,n;return(t=(n=e.getState().sorting)==null?void 0:n.findIndex(s=>s.id===i.id))!=null?t:-1},i.clearSorting=()=>{e.setSorting(t=>t!=null&&t.length?t.filter(n=>n.id!==i.id):[])},i.getToggleSortingHandler=()=>{const t=i.getCanSort();return n=>{t&&(n.persist==null||n.persist(),i.toggleSorting==null||i.toggleSorting(void 0,i.getCanMultiSort()?e.options.isMultiSortEvent==null?void 0:e.options.isMultiSortEvent(n):!1))}}},createTable:i=>{i.setSorting=e=>i.options.onSortingChange==null?void 0:i.options.onSortingChange(e),i.resetSorting=e=>{var t,n;i.setSorting(e?[]:(t=(n=i.initialState)==null?void 0:n.sorting)!=null?t:[])},i.getPreSortedRowModel=()=>i.getGroupedRowModel(),i.getSortedRowModel=()=>(!i._getSortedRowModel&&i.options.getSortedRowModel&&(i._getSortedRowModel=i.options.getSortedRowModel(i)),i.options.manualSorting||!i._getSortedRowModel?i.getPreSortedRowModel():i._getSortedRowModel())}},Xm=[xm,Fm,Om,Im,ym,bm,Nm,Bm,Ym,Mm,Vm,zm,$m,_m,Dm];function Qm(i){var e,t;process.env.NODE_ENV!=="production"&&(i.debugAll||i.debugTable)&&console.info("Creating Table Instance...");const n=[...Xm,...(e=i._features)!=null?e:[]];let s={_features:n};const r=s._features.reduce((f,p)=>Object.assign(f,p.getDefaultOptions==null?void 0:p.getDefaultOptions(s)),{}),o=f=>s.options.mergeOptions?s.options.mergeOptions(r,f):{...r,...f};let a={...{},...(t=i.initialState)!=null?t:{}};s._features.forEach(f=>{var p;a=(p=f.getInitialState==null?void 0:f.getInitialState(a))!=null?p:a});const u=[];let c=!1;const h={_features:n,options:{...r,...i},initialState:a,_queue:f=>{u.push(f),c||(c=!0,Promise.resolve().then(()=>{for(;u.length;)u.shift()();c=!1}).catch(p=>setTimeout(()=>{throw p})))},reset:()=>{s.setState(s.initialState)},setOptions:f=>{const p=li(f,s.options);s.options=o(p)},getState:()=>s.options.state,setState:f=>{s.options.onStateChange==null||s.options.onStateChange(f)},_getRowId:(f,p,g)=>{var m;return(m=s.options.getRowId==null?void 0:s.options.getRowId(f,p,g))!=null?m:`${g?[g.id,p].join("."):p}`},getCoreRowModel:()=>(s._getCoreRowModel||(s._getCoreRowModel=s.options.getCoreRowModel(s)),s._getCoreRowModel()),getRowModel:()=>s.getPaginationRowModel(),getRow:(f,p)=>{let g=(p?s.getPrePaginationRowModel():s.getRowModel()).rowsById[f];if(!g&&(g=s.getCoreRowModel().rowsById[f],!g))throw process.env.NODE_ENV!=="production"?new Error(`getRow could not find row with ID: ${f}`):new Error;return g},_getDefaultColumnDef:K(()=>[s.options.defaultColumn],f=>{var p;return f=(p=f)!=null?p:{},{header:g=>{const m=g.header.column.columnDef;return m.accessorKey?m.accessorKey:m.accessorFn?m.id:null},cell:g=>{var m,x;return(m=(x=g.renderValue())==null||x.toString==null?void 0:x.toString())!=null?m:null},...s._features.reduce((g,m)=>Object.assign(g,m.getDefaultColumnDef==null?void 0:m.getDefaultColumnDef()),{}),...f}},Y(i,"debugColumns","_getDefaultColumnDef")),_getColumnDefs:()=>s.options.columns,getAllColumns:K(()=>[s._getColumnDefs()],f=>{const p=function(g,m,x){return x===void 0&&(x=0),g.map(y=>{const b=mm(s,y,x,m),v=y;return b.columns=v.columns?p(v.columns,b,x+1):[],b})};return p(f)},Y(i,"debugColumns","getAllColumns")),getAllFlatColumns:K(()=>[s.getAllColumns()],f=>f.flatMap(p=>p.getFlatColumns()),Y(i,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:K(()=>[s.getAllFlatColumns()],f=>f.reduce((p,g)=>(p[g.id]=g,p),{}),Y(i,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:K(()=>[s.getAllColumns(),s._getOrderColumnsFn()],(f,p)=>{let g=f.flatMap(m=>m.getLeafColumns());return p(g)},Y(i,"debugColumns","getAllLeafColumns")),getColumn:f=>{const p=s._getAllFlatColumnsById()[f];return process.env.NODE_ENV!=="production"&&!p&&console.error(`[Table] Column with id '${f}' does not exist.`),p}};Object.assign(s,h);for(let f=0;f<s._features.length;f++){const p=s._features[f];p==null||p.createTable==null||p.createTable(s)}return s}function Jm(){return i=>K(()=>[i.options.data],e=>{const t={rows:[],flatRows:[],rowsById:{}},n=function(s,r,o){r===void 0&&(r=0);const l=[];for(let u=0;u<s.length;u++){const c=zr(i,i._getRowId(s[u],u,o),s[u],u,r,void 0,o==null?void 0:o.id);if(t.flatRows.push(c),t.rowsById[c.id]=c,l.push(c),i.options.getSubRows){var a;c.originalSubRows=i.options.getSubRows(s[u],u),(a=c.originalSubRows)!=null&&a.length&&(c.subRows=n(c.originalSubRows,r+1,c))}}return l};return t.rows=n(e),t},Y(i.options,"debugTable","getRowModel",()=>i._autoResetPageIndex()))}function uu(){return i=>K(()=>[i.getState().expanded,i.getPreExpandedRowModel(),i.options.paginateExpandedRows],(e,t,n)=>!t.rows.length||e!==!0&&!Object.keys(e??{}).length||!n?t:Dh(t),Y(i.options,"debugTable","getExpandedRowModel"))}function Dh(i){const e=[],t=n=>{var s;e.push(n),(s=n.subRows)!=null&&s.length&&n.getIsExpanded()&&n.subRows.forEach(t)};return i.rows.forEach(t),{rows:e,flatRows:i.flatRows,rowsById:i.rowsById}}function Zm(i,e,t){return t.options.filterFromLeafRows?e0(i,e,t):t0(i,e,t)}function e0(i,e,t){var n;const s=[],r={},o=(n=t.options.maxLeafRowFilterDepth)!=null?n:100,l=function(a,u){u===void 0&&(u=0);const c=[];for(let f=0;f<a.length;f++){var h;let p=a[f];const g=zr(t,p.id,p.original,p.index,p.depth,void 0,p.parentId);if(g.columnFilters=p.columnFilters,(h=p.subRows)!=null&&h.length&&u<o){if(g.subRows=l(p.subRows,u+1),p=g,e(p)&&!g.subRows.length){c.push(p),r[p.id]=p,s.push(p);continue}if(e(p)||g.subRows.length){c.push(p),r[p.id]=p,s.push(p);continue}}else p=g,e(p)&&(c.push(p),r[p.id]=p,s.push(p))}return c};return{rows:l(i),flatRows:s,rowsById:r}}function t0(i,e,t){var n;const s=[],r={},o=(n=t.options.maxLeafRowFilterDepth)!=null?n:100,l=function(a,u){u===void 0&&(u=0);const c=[];for(let f=0;f<a.length;f++){let p=a[f];if(e(p)){var h;if((h=p.subRows)!=null&&h.length&&u<o){const m=zr(t,p.id,p.original,p.index,p.depth,void 0,p.parentId);m.subRows=l(p.subRows,u+1),p=m}c.push(p),s.push(p),r[p.id]=p}}return c};return{rows:l(i),flatRows:s,rowsById:r}}function i0(){return i=>K(()=>[i.getPreFilteredRowModel(),i.getState().columnFilters,i.getState().globalFilter],(e,t,n)=>{if(!e.rows.length||!(t!=null&&t.length)&&!n){for(let f=0;f<e.flatRows.length;f++)e.flatRows[f].columnFilters={},e.flatRows[f].columnFiltersMeta={};return e}const s=[],r=[];(t??[]).forEach(f=>{var p;const g=i.getColumn(f.id);if(!g)return;const m=g.getFilterFn();if(!m){process.env.NODE_ENV!=="production"&&console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${g.id}.`);return}s.push({id:f.id,filterFn:m,resolvedValue:(p=m.resolveFilterValue==null?void 0:m.resolveFilterValue(f.value))!=null?p:f.value})});const o=(t??[]).map(f=>f.id),l=i.getGlobalFilterFn(),a=i.getAllLeafColumns().filter(f=>f.getCanGlobalFilter());n&&l&&a.length&&(o.push("__global__"),a.forEach(f=>{var p;r.push({id:f.id,filterFn:l,resolvedValue:(p=l.resolveFilterValue==null?void 0:l.resolveFilterValue(n))!=null?p:n})}));let u,c;for(let f=0;f<e.flatRows.length;f++){const p=e.flatRows[f];if(p.columnFilters={},s.length)for(let g=0;g<s.length;g++){u=s[g];const m=u.id;p.columnFilters[m]=u.filterFn(p,m,u.resolvedValue,x=>{p.columnFiltersMeta[m]=x})}if(r.length){for(let g=0;g<r.length;g++){c=r[g];const m=c.id;if(c.filterFn(p,m,c.resolvedValue,x=>{p.columnFiltersMeta[m]=x})){p.columnFilters.__global__=!0;break}}p.columnFilters.__global__!==!0&&(p.columnFilters.__global__=!1)}}const h=f=>{for(let p=0;p<o.length;p++)if(f.columnFilters[o[p]]===!1)return!1;return!0};return Zm(e.rows,h,i)},Y(i.options,"debugTable","getFilteredRowModel",()=>i._autoResetPageIndex()))}function n0(){return i=>K(()=>[i.getState().grouping,i.getPreGroupedRowModel()],(e,t)=>{if(!t.rows.length||!e.length)return t.rows.forEach(a=>{a.depth=0,a.parentId=void 0}),t;const n=e.filter(a=>i.getColumn(a)),s=[],r={},o=function(a,u,c){if(u===void 0&&(u=0),u>=n.length)return a.map(g=>(g.depth=u,s.push(g),r[g.id]=g,g.subRows&&(g.subRows=o(g.subRows,u+1,g.id)),g));const h=n[u],f=s0(a,h);return Array.from(f.entries()).map((g,m)=>{let[x,y]=g,b=`${h}:${x}`;b=c?`${c}>${b}`:b;const v=o(y,u+1,b);v.forEach(E=>{E.parentId=b});const w=u?Eh(y,E=>E.subRows):y,S=zr(i,b,w[0].original,m,u,void 0,c);return Object.assign(S,{groupingColumnId:h,groupingValue:x,subRows:v,leafRows:w,getValue:E=>{if(n.includes(E)){if(S._valuesCache.hasOwnProperty(E))return S._valuesCache[E];if(y[0]){var A;S._valuesCache[E]=(A=y[0].getValue(E))!=null?A:void 0}return S._valuesCache[E]}if(S._groupingValuesCache.hasOwnProperty(E))return S._groupingValuesCache[E];const O=i.getColumn(E),R=O==null?void 0:O.getAggregationFn();if(R)return S._groupingValuesCache[E]=R(E,w,y),S._groupingValuesCache[E]}}),v.forEach(E=>{s.push(E),r[E.id]=E}),S})},l=o(t.rows,0);return l.forEach(a=>{s.push(a),r[a.id]=a}),{rows:l,flatRows:s,rowsById:r}},Y(i.options,"debugTable","getGroupedRowModel",()=>{i._queue(()=>{i._autoResetExpanded(),i._autoResetPageIndex()})}))}function s0(i,e){const t=new Map;return i.reduce((n,s)=>{const r=`${s.getGroupingValue(e)}`,o=n.get(r);return o?o.push(s):n.set(r,[s]),n},t)}function r0(i){return e=>K(()=>[e.getState().pagination,e.getPrePaginationRowModel(),e.options.paginateExpandedRows?void 0:e.getState().expanded],(t,n)=>{if(!n.rows.length)return n;const{pageSize:s,pageIndex:r}=t;let{rows:o,flatRows:l,rowsById:a}=n;const u=s*r,c=u+s;o=o.slice(u,c);let h;e.options.paginateExpandedRows?h={rows:o,flatRows:l,rowsById:a}:h=Dh({rows:o,flatRows:l,rowsById:a}),h.flatRows=[];const f=p=>{h.flatRows.push(p),p.subRows.length&&p.subRows.forEach(f)};return h.rows.forEach(f),h},Y(e.options,"debugTable","getPaginationRowModel"))}function o0(){return i=>K(()=>[i.getState().sorting,i.getPreSortedRowModel()],(e,t)=>{if(!t.rows.length||!(e!=null&&e.length))return t;const n=i.getState().sorting,s=[],r=n.filter(a=>{var u;return(u=i.getColumn(a.id))==null?void 0:u.getCanSort()}),o={};r.forEach(a=>{const u=i.getColumn(a.id);u&&(o[a.id]={sortUndefined:u.columnDef.sortUndefined,invertSorting:u.columnDef.invertSorting,sortingFn:u.getSortingFn()})});const l=a=>{const u=a.map(c=>({...c}));return u.sort((c,h)=>{for(let p=0;p<r.length;p+=1){var f;const g=r[p],m=o[g.id],x=m.sortUndefined,y=(f=g==null?void 0:g.desc)!=null?f:!1;let b=0;if(x){const v=c.getValue(g.id),w=h.getValue(g.id),S=v===void 0,E=w===void 0;if(S||E){if(x==="first")return S?-1:1;if(x==="last")return S?1:-1;b=S&&E?0:S?x:-x}}if(b===0&&(b=m.sortingFn(c,h,g.id)),b!==0)return y&&(b*=-1),m.invertSorting&&(b*=-1),b}return c.index-h.index}),u.forEach(c=>{var h;s.push(c),(h=c.subRows)!=null&&h.length&&(c.subRows=l(c.subRows))}),u};return{rows:l(t.rows),flatRows:s,rowsById:t.rowsById}},Y(i.options,"debugTable","getSortedRowModel",()=>i._autoResetPageIndex()))}/**
13
+ color: hsl(${Math.max(0,Math.min(120-120*d,120))}deg 100% 31%);`,t==null?void 0:t.key)}return s}}function X(i,e,t,n){return{debug:()=>{var s;return(s=i==null?void 0:i.debugAll)!=null?s:i[e]},key:process.env.NODE_ENV==="development"&&t,onChange:n}}function Bm(i,e,t,n){const s=()=>{var o;return(o=r.getValue())!=null?o:i.options.renderFallbackValue},r={id:`${e.id}_${t.id}`,row:e,column:t,getValue:()=>e.getValue(n),renderValue:s,getContext:Y(()=>[i,t,e,r],(o,l,a,u)=>({table:o,column:l,row:a,cell:u,getValue:u.getValue,renderValue:u.renderValue}),X(i.options,"debugCells","cell.getContext"))};return i._features.forEach(o=>{o.createCell==null||o.createCell(r,t,e,i)},{}),r}function Vm(i,e,t,n){var s,r;const l={...i._getDefaultColumnDef(),...e},a=l.accessorKey;let u=(s=(r=l.id)!=null?r:a?typeof String.prototype.replaceAll=="function"?a.replaceAll(".","_"):a.replace(/\./g,"_"):void 0)!=null?s:typeof l.header=="string"?l.header:void 0,c;if(l.accessorFn?c=l.accessorFn:a&&(a.includes(".")?c=d=>{let p=d;for(const m of a.split(".")){var g;p=(g=p)==null?void 0:g[m],process.env.NODE_ENV!=="production"&&p===void 0&&console.warn(`"${m}" in deeply nested key "${a}" returned undefined.`)}return p}:c=d=>d[l.accessorKey]),!u)throw process.env.NODE_ENV!=="production"?new Error(l.accessorFn?"Columns require an id when using an accessorFn":"Columns require an id when using a non-string header"):new Error;let h={id:`${String(u)}`,accessorFn:c,parent:n,depth:t,columnDef:l,columns:[],getFlatColumns:Y(()=>[!0],()=>{var d;return[h,...(d=h.columns)==null?void 0:d.flatMap(p=>p.getFlatColumns())]},X(i.options,"debugColumns","column.getFlatColumns")),getLeafColumns:Y(()=>[i._getOrderColumnsFn()],d=>{var p;if((p=h.columns)!=null&&p.length){let g=h.columns.flatMap(m=>m.getLeafColumns());return d(g)}return[h]},X(i.options,"debugColumns","column.getLeafColumns"))};for(const d of i._features)d.createColumn==null||d.createColumn(h,i);return h}const Be="debugHeaders";function Su(i,e,t){var n;let r={id:(n=t.id)!=null?n:e.id,column:e,index:t.index,isPlaceholder:!!t.isPlaceholder,placeholderId:t.placeholderId,depth:t.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const o=[],l=a=>{a.subHeaders&&a.subHeaders.length&&a.subHeaders.map(l),o.push(a)};return l(r),o},getContext:()=>({table:i,header:r,column:e})};return i._features.forEach(o=>{o.createHeader==null||o.createHeader(r,i)}),r}const _m={createTable:i=>{i.getHeaderGroups=Y(()=>[i.getAllColumns(),i.getVisibleLeafColumns(),i.getState().columnPinning.left,i.getState().columnPinning.right],(e,t,n,s)=>{var r,o;const l=(r=n==null?void 0:n.map(h=>t.find(d=>d.id===h)).filter(Boolean))!=null?r:[],a=(o=s==null?void 0:s.map(h=>t.find(d=>d.id===h)).filter(Boolean))!=null?o:[],u=t.filter(h=>!(n!=null&&n.includes(h.id))&&!(s!=null&&s.includes(h.id)));return vs(e,[...l,...u,...a],i)},X(i.options,Be,"getHeaderGroups")),i.getCenterHeaderGroups=Y(()=>[i.getAllColumns(),i.getVisibleLeafColumns(),i.getState().columnPinning.left,i.getState().columnPinning.right],(e,t,n,s)=>(t=t.filter(r=>!(n!=null&&n.includes(r.id))&&!(s!=null&&s.includes(r.id))),vs(e,t,i,"center")),X(i.options,Be,"getCenterHeaderGroups")),i.getLeftHeaderGroups=Y(()=>[i.getAllColumns(),i.getVisibleLeafColumns(),i.getState().columnPinning.left],(e,t,n)=>{var s;const r=(s=n==null?void 0:n.map(o=>t.find(l=>l.id===o)).filter(Boolean))!=null?s:[];return vs(e,r,i,"left")},X(i.options,Be,"getLeftHeaderGroups")),i.getRightHeaderGroups=Y(()=>[i.getAllColumns(),i.getVisibleLeafColumns(),i.getState().columnPinning.right],(e,t,n)=>{var s;const r=(s=n==null?void 0:n.map(o=>t.find(l=>l.id===o)).filter(Boolean))!=null?s:[];return vs(e,r,i,"right")},X(i.options,Be,"getRightHeaderGroups")),i.getFooterGroups=Y(()=>[i.getHeaderGroups()],e=>[...e].reverse(),X(i.options,Be,"getFooterGroups")),i.getLeftFooterGroups=Y(()=>[i.getLeftHeaderGroups()],e=>[...e].reverse(),X(i.options,Be,"getLeftFooterGroups")),i.getCenterFooterGroups=Y(()=>[i.getCenterHeaderGroups()],e=>[...e].reverse(),X(i.options,Be,"getCenterFooterGroups")),i.getRightFooterGroups=Y(()=>[i.getRightHeaderGroups()],e=>[...e].reverse(),X(i.options,Be,"getRightFooterGroups")),i.getFlatHeaders=Y(()=>[i.getHeaderGroups()],e=>e.map(t=>t.headers).flat(),X(i.options,Be,"getFlatHeaders")),i.getLeftFlatHeaders=Y(()=>[i.getLeftHeaderGroups()],e=>e.map(t=>t.headers).flat(),X(i.options,Be,"getLeftFlatHeaders")),i.getCenterFlatHeaders=Y(()=>[i.getCenterHeaderGroups()],e=>e.map(t=>t.headers).flat(),X(i.options,Be,"getCenterFlatHeaders")),i.getRightFlatHeaders=Y(()=>[i.getRightHeaderGroups()],e=>e.map(t=>t.headers).flat(),X(i.options,Be,"getRightFlatHeaders")),i.getCenterLeafHeaders=Y(()=>[i.getCenterFlatHeaders()],e=>e.filter(t=>{var n;return!((n=t.subHeaders)!=null&&n.length)}),X(i.options,Be,"getCenterLeafHeaders")),i.getLeftLeafHeaders=Y(()=>[i.getLeftFlatHeaders()],e=>e.filter(t=>{var n;return!((n=t.subHeaders)!=null&&n.length)}),X(i.options,Be,"getLeftLeafHeaders")),i.getRightLeafHeaders=Y(()=>[i.getRightFlatHeaders()],e=>e.filter(t=>{var n;return!((n=t.subHeaders)!=null&&n.length)}),X(i.options,Be,"getRightLeafHeaders")),i.getLeafHeaders=Y(()=>[i.getLeftHeaderGroups(),i.getCenterHeaderGroups(),i.getRightHeaderGroups()],(e,t,n)=>{var s,r,o,l,a,u;return[...(s=(r=e[0])==null?void 0:r.headers)!=null?s:[],...(o=(l=t[0])==null?void 0:l.headers)!=null?o:[],...(a=(u=n[0])==null?void 0:u.headers)!=null?a:[]].map(c=>c.getLeafHeaders()).flat()},X(i.options,Be,"getLeafHeaders"))}};function vs(i,e,t,n){var s,r;let o=0;const l=function(d,p){p===void 0&&(p=1),o=Math.max(o,p),d.filter(g=>g.getIsVisible()).forEach(g=>{var m;(m=g.columns)!=null&&m.length&&l(g.columns,p+1)},0)};l(i);let a=[];const u=(d,p)=>{const g={depth:p,id:[n,`${p}`].filter(Boolean).join("_"),headers:[]},m=[];d.forEach(x=>{const y=[...m].reverse()[0],b=x.column.depth===g.depth;let v,C=!1;if(b&&x.column.parent?v=x.column.parent:(v=x.column,C=!0),y&&(y==null?void 0:y.column)===v)y.subHeaders.push(x);else{const S=Su(t,v,{id:[n,p,v.id,x==null?void 0:x.id].filter(Boolean).join("_"),isPlaceholder:C,placeholderId:C?`${m.filter(E=>E.column===v).length}`:void 0,depth:p,index:m.length});S.subHeaders.push(x),m.push(S)}g.headers.push(x),x.headerGroup=g}),a.push(g),p>0&&u(m,p-1)},c=e.map((d,p)=>Su(t,d,{depth:o,index:p}));u(c,o-1),a.reverse();const h=d=>d.filter(g=>g.column.getIsVisible()).map(g=>{let m=0,x=0,y=[0];g.subHeaders&&g.subHeaders.length?(y=[],h(g.subHeaders).forEach(v=>{let{colSpan:C,rowSpan:S}=v;m+=C,y.push(S)})):m=1;const b=Math.min(...y);return x=x+b,g.colSpan=m,g.rowSpan=x,{colSpan:m,rowSpan:x}});return h((s=(r=a[0])==null?void 0:r.headers)!=null?s:[]),a}const Gr=(i,e,t,n,s,r,o)=>{let l={id:e,index:n,original:t,depth:s,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:a=>{if(l._valuesCache.hasOwnProperty(a))return l._valuesCache[a];const u=i.getColumn(a);if(u!=null&&u.accessorFn)return l._valuesCache[a]=u.accessorFn(l.original,n),l._valuesCache[a]},getUniqueValues:a=>{if(l._uniqueValuesCache.hasOwnProperty(a))return l._uniqueValuesCache[a];const u=i.getColumn(a);if(u!=null&&u.accessorFn)return u.columnDef.getUniqueValues?(l._uniqueValuesCache[a]=u.columnDef.getUniqueValues(l.original,n),l._uniqueValuesCache[a]):(l._uniqueValuesCache[a]=[l.getValue(a)],l._uniqueValuesCache[a])},renderValue:a=>{var u;return(u=l.getValue(a))!=null?u:i.options.renderFallbackValue},subRows:r??[],getLeafRows:()=>Vh(l.subRows,a=>a.subRows),getParentRow:()=>l.parentId?i.getRow(l.parentId,!0):void 0,getParentRows:()=>{let a=[],u=l;for(;;){const c=u.getParentRow();if(!c)break;a.push(c),u=c}return a.reverse()},getAllCells:Y(()=>[i.getAllLeafColumns()],a=>a.map(u=>Bm(i,l,u,u.id)),X(i.options,"debugRows","getAllCells")),_getAllCellsByColumnId:Y(()=>[l.getAllCells()],a=>a.reduce((u,c)=>(u[c.column.id]=c,u),{}),X(i.options,"debugRows","getAllCellsByColumnId"))};for(let a=0;a<i._features.length;a++){const u=i._features[a];u==null||u.createRow==null||u.createRow(l,i)}return l},zm={createColumn:(i,e)=>{i._getFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,i.id),i.getFacetedRowModel=()=>i._getFacetedRowModel?i._getFacetedRowModel():e.getPreFilteredRowModel(),i._getFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,i.id),i.getFacetedUniqueValues=()=>i._getFacetedUniqueValues?i._getFacetedUniqueValues():new Map,i._getFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,i.id),i.getFacetedMinMaxValues=()=>{if(i._getFacetedMinMaxValues)return i._getFacetedMinMaxValues()}}},_h=(i,e,t)=>{var n,s;const r=t==null||(n=t.toString())==null?void 0:n.toLowerCase();return!!(!((s=i.getValue(e))==null||(s=s.toString())==null||(s=s.toLowerCase())==null)&&s.includes(r))};_h.autoRemove=i=>bt(i);const zh=(i,e,t)=>{var n;return!!(!((n=i.getValue(e))==null||(n=n.toString())==null)&&n.includes(t))};zh.autoRemove=i=>bt(i);const $h=(i,e,t)=>{var n;return((n=i.getValue(e))==null||(n=n.toString())==null?void 0:n.toLowerCase())===(t==null?void 0:t.toLowerCase())};$h.autoRemove=i=>bt(i);const Hh=(i,e,t)=>{var n;return(n=i.getValue(e))==null?void 0:n.includes(t)};Hh.autoRemove=i=>bt(i);const Gh=(i,e,t)=>!t.some(n=>{var s;return!((s=i.getValue(e))!=null&&s.includes(n))});Gh.autoRemove=i=>bt(i)||!(i!=null&&i.length);const Wh=(i,e,t)=>t.some(n=>{var s;return(s=i.getValue(e))==null?void 0:s.includes(n)});Wh.autoRemove=i=>bt(i)||!(i!=null&&i.length);const Uh=(i,e,t)=>i.getValue(e)===t;Uh.autoRemove=i=>bt(i);const qh=(i,e,t)=>i.getValue(e)==t;qh.autoRemove=i=>bt(i);const xa=(i,e,t)=>{let[n,s]=t;const r=i.getValue(e);return r>=n&&r<=s};xa.resolveFilterValue=i=>{let[e,t]=i,n=typeof e!="number"?parseFloat(e):e,s=typeof t!="number"?parseFloat(t):t,r=e===null||Number.isNaN(n)?-1/0:n,o=t===null||Number.isNaN(s)?1/0:s;if(r>o){const l=r;r=o,o=l}return[r,o]};xa.autoRemove=i=>bt(i)||bt(i[0])&&bt(i[1]);const Ut={includesString:_h,includesStringSensitive:zh,equalsString:$h,arrIncludes:Hh,arrIncludesAll:Gh,arrIncludesSome:Wh,equals:Uh,weakEquals:qh,inNumberRange:xa};function bt(i){return i==null||i===""}const $m={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:i=>({columnFilters:[],...i}),getDefaultOptions:i=>({onColumnFiltersChange:at("columnFilters",i),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(i,e)=>{i.getAutoFilterFn=()=>{const t=e.getCoreRowModel().flatRows[0],n=t==null?void 0:t.getValue(i.id);return typeof n=="string"?Ut.includesString:typeof n=="number"?Ut.inNumberRange:typeof n=="boolean"||n!==null&&typeof n=="object"?Ut.equals:Array.isArray(n)?Ut.arrIncludes:Ut.weakEquals},i.getFilterFn=()=>{var t,n;return Hr(i.columnDef.filterFn)?i.columnDef.filterFn:i.columnDef.filterFn==="auto"?i.getAutoFilterFn():(t=(n=e.options.filterFns)==null?void 0:n[i.columnDef.filterFn])!=null?t:Ut[i.columnDef.filterFn]},i.getCanFilter=()=>{var t,n,s;return((t=i.columnDef.enableColumnFilter)!=null?t:!0)&&((n=e.options.enableColumnFilters)!=null?n:!0)&&((s=e.options.enableFilters)!=null?s:!0)&&!!i.accessorFn},i.getIsFiltered=()=>i.getFilterIndex()>-1,i.getFilterValue=()=>{var t;return(t=e.getState().columnFilters)==null||(t=t.find(n=>n.id===i.id))==null?void 0:t.value},i.getFilterIndex=()=>{var t,n;return(t=(n=e.getState().columnFilters)==null?void 0:n.findIndex(s=>s.id===i.id))!=null?t:-1},i.setFilterValue=t=>{e.setColumnFilters(n=>{const s=i.getFilterFn(),r=n==null?void 0:n.find(c=>c.id===i.id),o=ci(t,r?r.value:void 0);if(Cu(s,o,i)){var l;return(l=n==null?void 0:n.filter(c=>c.id!==i.id))!=null?l:[]}const a={id:i.id,value:o};if(r){var u;return(u=n==null?void 0:n.map(c=>c.id===i.id?a:c))!=null?u:[]}return n!=null&&n.length?[...n,a]:[a]})}},createRow:(i,e)=>{i.columnFilters={},i.columnFiltersMeta={}},createTable:i=>{i.setColumnFilters=e=>{const t=i.getAllLeafColumns(),n=s=>{var r;return(r=ci(e,s))==null?void 0:r.filter(o=>{const l=t.find(a=>a.id===o.id);if(l){const a=l.getFilterFn();if(Cu(a,o.value,l))return!1}return!0})};i.options.onColumnFiltersChange==null||i.options.onColumnFiltersChange(n)},i.resetColumnFilters=e=>{var t,n;i.setColumnFilters(e?[]:(t=(n=i.initialState)==null?void 0:n.columnFilters)!=null?t:[])},i.getPreFilteredRowModel=()=>i.getCoreRowModel(),i.getFilteredRowModel=()=>(!i._getFilteredRowModel&&i.options.getFilteredRowModel&&(i._getFilteredRowModel=i.options.getFilteredRowModel(i)),i.options.manualFiltering||!i._getFilteredRowModel?i.getPreFilteredRowModel():i._getFilteredRowModel())}};function Cu(i,e,t){return(i&&i.autoRemove?i.autoRemove(e,t):!1)||typeof e>"u"||typeof e=="string"&&!e}const Hm=(i,e,t)=>t.reduce((n,s)=>{const r=s.getValue(i);return n+(typeof r=="number"?r:0)},0),Gm=(i,e,t)=>{let n;return t.forEach(s=>{const r=s.getValue(i);r!=null&&(n>r||n===void 0&&r>=r)&&(n=r)}),n},Wm=(i,e,t)=>{let n;return t.forEach(s=>{const r=s.getValue(i);r!=null&&(n<r||n===void 0&&r>=r)&&(n=r)}),n},Um=(i,e,t)=>{let n,s;return t.forEach(r=>{const o=r.getValue(i);o!=null&&(n===void 0?o>=o&&(n=s=o):(n>o&&(n=o),s<o&&(s=o)))}),[n,s]},qm=(i,e)=>{let t=0,n=0;if(e.forEach(s=>{let r=s.getValue(i);r!=null&&(r=+r)>=r&&(++t,n+=r)}),t)return n/t},Km=(i,e)=>{if(!e.length)return;const t=e.map(r=>r.getValue(i));if(!Nm(t))return;if(t.length===1)return t[0];const n=Math.floor(t.length/2),s=t.sort((r,o)=>r-o);return t.length%2!==0?s[n]:(s[n-1]+s[n])/2},Ym=(i,e)=>Array.from(new Set(e.map(t=>t.getValue(i))).values()),Xm=(i,e)=>new Set(e.map(t=>t.getValue(i))).size,Qm=(i,e)=>e.length,go={sum:Hm,min:Gm,max:Wm,extent:Um,mean:qm,median:Km,unique:Ym,uniqueCount:Xm,count:Qm},Jm={getDefaultColumnDef:()=>({aggregatedCell:i=>{var e,t;return(e=(t=i.getValue())==null||t.toString==null?void 0:t.toString())!=null?e:null},aggregationFn:"auto"}),getInitialState:i=>({grouping:[],...i}),getDefaultOptions:i=>({onGroupingChange:at("grouping",i),groupedColumnMode:"reorder"}),createColumn:(i,e)=>{i.toggleGrouping=()=>{e.setGrouping(t=>t!=null&&t.includes(i.id)?t.filter(n=>n!==i.id):[...t??[],i.id])},i.getCanGroup=()=>{var t,n;return((t=i.columnDef.enableGrouping)!=null?t:!0)&&((n=e.options.enableGrouping)!=null?n:!0)&&(!!i.accessorFn||!!i.columnDef.getGroupingValue)},i.getIsGrouped=()=>{var t;return(t=e.getState().grouping)==null?void 0:t.includes(i.id)},i.getGroupedIndex=()=>{var t;return(t=e.getState().grouping)==null?void 0:t.indexOf(i.id)},i.getToggleGroupingHandler=()=>{const t=i.getCanGroup();return()=>{t&&i.toggleGrouping()}},i.getAutoAggregationFn=()=>{const t=e.getCoreRowModel().flatRows[0],n=t==null?void 0:t.getValue(i.id);if(typeof n=="number")return go.sum;if(Object.prototype.toString.call(n)==="[object Date]")return go.extent},i.getAggregationFn=()=>{var t,n;if(!i)throw new Error;return Hr(i.columnDef.aggregationFn)?i.columnDef.aggregationFn:i.columnDef.aggregationFn==="auto"?i.getAutoAggregationFn():(t=(n=e.options.aggregationFns)==null?void 0:n[i.columnDef.aggregationFn])!=null?t:go[i.columnDef.aggregationFn]}},createTable:i=>{i.setGrouping=e=>i.options.onGroupingChange==null?void 0:i.options.onGroupingChange(e),i.resetGrouping=e=>{var t,n;i.setGrouping(e?[]:(t=(n=i.initialState)==null?void 0:n.grouping)!=null?t:[])},i.getPreGroupedRowModel=()=>i.getFilteredRowModel(),i.getGroupedRowModel=()=>(!i._getGroupedRowModel&&i.options.getGroupedRowModel&&(i._getGroupedRowModel=i.options.getGroupedRowModel(i)),i.options.manualGrouping||!i._getGroupedRowModel?i.getPreGroupedRowModel():i._getGroupedRowModel())},createRow:(i,e)=>{i.getIsGrouped=()=>!!i.groupingColumnId,i.getGroupingValue=t=>{if(i._groupingValuesCache.hasOwnProperty(t))return i._groupingValuesCache[t];const n=e.getColumn(t);return n!=null&&n.columnDef.getGroupingValue?(i._groupingValuesCache[t]=n.columnDef.getGroupingValue(i.original),i._groupingValuesCache[t]):i.getValue(t)},i._groupingValuesCache={}},createCell:(i,e,t,n)=>{i.getIsGrouped=()=>e.getIsGrouped()&&e.id===t.groupingColumnId,i.getIsPlaceholder=()=>!i.getIsGrouped()&&e.getIsGrouped(),i.getIsAggregated=()=>{var s;return!i.getIsGrouped()&&!i.getIsPlaceholder()&&!!((s=t.subRows)!=null&&s.length)}}};function Zm(i,e,t){if(!(e!=null&&e.length)||!t)return i;const n=i.filter(r=>!e.includes(r.id));return t==="remove"?n:[...e.map(r=>i.find(o=>o.id===r)).filter(Boolean),...n]}const e0={getInitialState:i=>({columnOrder:[],...i}),getDefaultOptions:i=>({onColumnOrderChange:at("columnOrder",i)}),createColumn:(i,e)=>{i.getIndex=Y(t=>[Ln(e,t)],t=>t.findIndex(n=>n.id===i.id),X(e.options,"debugColumns","getIndex")),i.getIsFirstColumn=t=>{var n;return((n=Ln(e,t)[0])==null?void 0:n.id)===i.id},i.getIsLastColumn=t=>{var n;const s=Ln(e,t);return((n=s[s.length-1])==null?void 0:n.id)===i.id}},createTable:i=>{i.setColumnOrder=e=>i.options.onColumnOrderChange==null?void 0:i.options.onColumnOrderChange(e),i.resetColumnOrder=e=>{var t;i.setColumnOrder(e?[]:(t=i.initialState.columnOrder)!=null?t:[])},i._getOrderColumnsFn=Y(()=>[i.getState().columnOrder,i.getState().grouping,i.options.groupedColumnMode],(e,t,n)=>s=>{let r=[];if(!(e!=null&&e.length))r=s;else{const o=[...e],l=[...s];for(;l.length&&o.length;){const a=o.shift(),u=l.findIndex(c=>c.id===a);u>-1&&r.push(l.splice(u,1)[0])}r=[...r,...l]}return Zm(r,t,n)},X(i.options,"debugTable","_getOrderColumnsFn"))}},mo=()=>({left:[],right:[]}),t0={getInitialState:i=>({columnPinning:mo(),...i}),getDefaultOptions:i=>({onColumnPinningChange:at("columnPinning",i)}),createColumn:(i,e)=>{i.pin=t=>{const n=i.getLeafColumns().map(s=>s.id).filter(Boolean);e.setColumnPinning(s=>{var r,o;if(t==="right"){var l,a;return{left:((l=s==null?void 0:s.left)!=null?l:[]).filter(h=>!(n!=null&&n.includes(h))),right:[...((a=s==null?void 0:s.right)!=null?a:[]).filter(h=>!(n!=null&&n.includes(h))),...n]}}if(t==="left"){var u,c;return{left:[...((u=s==null?void 0:s.left)!=null?u:[]).filter(h=>!(n!=null&&n.includes(h))),...n],right:((c=s==null?void 0:s.right)!=null?c:[]).filter(h=>!(n!=null&&n.includes(h)))}}return{left:((r=s==null?void 0:s.left)!=null?r:[]).filter(h=>!(n!=null&&n.includes(h))),right:((o=s==null?void 0:s.right)!=null?o:[]).filter(h=>!(n!=null&&n.includes(h)))}})},i.getCanPin=()=>i.getLeafColumns().some(n=>{var s,r,o;return((s=n.columnDef.enablePinning)!=null?s:!0)&&((r=(o=e.options.enableColumnPinning)!=null?o:e.options.enablePinning)!=null?r:!0)}),i.getIsPinned=()=>{const t=i.getLeafColumns().map(l=>l.id),{left:n,right:s}=e.getState().columnPinning,r=t.some(l=>n==null?void 0:n.includes(l)),o=t.some(l=>s==null?void 0:s.includes(l));return r?"left":o?"right":!1},i.getPinnedIndex=()=>{var t,n;const s=i.getIsPinned();return s?(t=(n=e.getState().columnPinning)==null||(n=n[s])==null?void 0:n.indexOf(i.id))!=null?t:-1:0}},createRow:(i,e)=>{i.getCenterVisibleCells=Y(()=>[i._getAllVisibleCells(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,s)=>{const r=[...n??[],...s??[]];return t.filter(o=>!r.includes(o.column.id))},X(e.options,"debugRows","getCenterVisibleCells")),i.getLeftVisibleCells=Y(()=>[i._getAllVisibleCells(),e.getState().columnPinning.left],(t,n)=>(n??[]).map(r=>t.find(o=>o.column.id===r)).filter(Boolean).map(r=>({...r,position:"left"})),X(e.options,"debugRows","getLeftVisibleCells")),i.getRightVisibleCells=Y(()=>[i._getAllVisibleCells(),e.getState().columnPinning.right],(t,n)=>(n??[]).map(r=>t.find(o=>o.column.id===r)).filter(Boolean).map(r=>({...r,position:"right"})),X(e.options,"debugRows","getRightVisibleCells"))},createTable:i=>{i.setColumnPinning=e=>i.options.onColumnPinningChange==null?void 0:i.options.onColumnPinningChange(e),i.resetColumnPinning=e=>{var t,n;return i.setColumnPinning(e?mo():(t=(n=i.initialState)==null?void 0:n.columnPinning)!=null?t:mo())},i.getIsSomeColumnsPinned=e=>{var t;const n=i.getState().columnPinning;if(!e){var s,r;return!!((s=n.left)!=null&&s.length||(r=n.right)!=null&&r.length)}return!!((t=n[e])!=null&&t.length)},i.getLeftLeafColumns=Y(()=>[i.getAllLeafColumns(),i.getState().columnPinning.left],(e,t)=>(t??[]).map(n=>e.find(s=>s.id===n)).filter(Boolean),X(i.options,"debugColumns","getLeftLeafColumns")),i.getRightLeafColumns=Y(()=>[i.getAllLeafColumns(),i.getState().columnPinning.right],(e,t)=>(t??[]).map(n=>e.find(s=>s.id===n)).filter(Boolean),X(i.options,"debugColumns","getRightLeafColumns")),i.getCenterLeafColumns=Y(()=>[i.getAllLeafColumns(),i.getState().columnPinning.left,i.getState().columnPinning.right],(e,t,n)=>{const s=[...t??[],...n??[]];return e.filter(r=>!s.includes(r.id))},X(i.options,"debugColumns","getCenterLeafColumns"))}};function i0(i){return i||(typeof document<"u"?document:null)}const Ss={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},xo=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),n0={getDefaultColumnDef:()=>Ss,getInitialState:i=>({columnSizing:{},columnSizingInfo:xo(),...i}),getDefaultOptions:i=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:at("columnSizing",i),onColumnSizingInfoChange:at("columnSizingInfo",i)}),createColumn:(i,e)=>{i.getSize=()=>{var t,n,s;const r=e.getState().columnSizing[i.id];return Math.min(Math.max((t=i.columnDef.minSize)!=null?t:Ss.minSize,(n=r??i.columnDef.size)!=null?n:Ss.size),(s=i.columnDef.maxSize)!=null?s:Ss.maxSize)},i.getStart=Y(t=>[t,Ln(e,t),e.getState().columnSizing],(t,n)=>n.slice(0,i.getIndex(t)).reduce((s,r)=>s+r.getSize(),0),X(e.options,"debugColumns","getStart")),i.getAfter=Y(t=>[t,Ln(e,t),e.getState().columnSizing],(t,n)=>n.slice(i.getIndex(t)+1).reduce((s,r)=>s+r.getSize(),0),X(e.options,"debugColumns","getAfter")),i.resetSize=()=>{e.setColumnSizing(t=>{let{[i.id]:n,...s}=t;return s})},i.getCanResize=()=>{var t,n;return((t=i.columnDef.enableResizing)!=null?t:!0)&&((n=e.options.enableColumnResizing)!=null?n:!0)},i.getIsResizing=()=>e.getState().columnSizingInfo.isResizingColumn===i.id},createHeader:(i,e)=>{i.getSize=()=>{let t=0;const n=s=>{if(s.subHeaders.length)s.subHeaders.forEach(n);else{var r;t+=(r=s.column.getSize())!=null?r:0}};return n(i),t},i.getStart=()=>{if(i.index>0){const t=i.headerGroup.headers[i.index-1];return t.getStart()+t.getSize()}return 0},i.getResizeHandler=t=>{const n=e.getColumn(i.column.id),s=n==null?void 0:n.getCanResize();return r=>{if(!n||!s||(r.persist==null||r.persist(),yo(r)&&r.touches&&r.touches.length>1))return;const o=i.getSize(),l=i?i.getLeafHeaders().map(y=>[y.column.id,y.column.getSize()]):[[n.id,n.getSize()]],a=yo(r)?Math.round(r.touches[0].clientX):r.clientX,u={},c=(y,b)=>{typeof b=="number"&&(e.setColumnSizingInfo(v=>{var C,S;const E=e.options.columnResizeDirection==="rtl"?-1:1,A=(b-((C=v==null?void 0:v.startOffset)!=null?C:0))*E,I=Math.max(A/((S=v==null?void 0:v.startSize)!=null?S:0),-.999999);return v.columnSizingStart.forEach(R=>{let[H,F]=R;u[H]=Math.round(Math.max(F+F*I,0)*100)/100}),{...v,deltaOffset:A,deltaPercentage:I}}),(e.options.columnResizeMode==="onChange"||y==="end")&&e.setColumnSizing(v=>({...v,...u})))},h=y=>c("move",y),d=y=>{c("end",y),e.setColumnSizingInfo(b=>({...b,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},p=i0(t),g={moveHandler:y=>h(y.clientX),upHandler:y=>{p==null||p.removeEventListener("mousemove",g.moveHandler),p==null||p.removeEventListener("mouseup",g.upHandler),d(y.clientX)}},m={moveHandler:y=>(y.cancelable&&(y.preventDefault(),y.stopPropagation()),h(y.touches[0].clientX),!1),upHandler:y=>{var b;p==null||p.removeEventListener("touchmove",m.moveHandler),p==null||p.removeEventListener("touchend",m.upHandler),y.cancelable&&(y.preventDefault(),y.stopPropagation()),d((b=y.touches[0])==null?void 0:b.clientX)}},x=s0()?{passive:!1}:!1;yo(r)?(p==null||p.addEventListener("touchmove",m.moveHandler,x),p==null||p.addEventListener("touchend",m.upHandler,x)):(p==null||p.addEventListener("mousemove",g.moveHandler,x),p==null||p.addEventListener("mouseup",g.upHandler,x)),e.setColumnSizingInfo(y=>({...y,startOffset:a,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:l,isResizingColumn:n.id}))}}},createTable:i=>{i.setColumnSizing=e=>i.options.onColumnSizingChange==null?void 0:i.options.onColumnSizingChange(e),i.setColumnSizingInfo=e=>i.options.onColumnSizingInfoChange==null?void 0:i.options.onColumnSizingInfoChange(e),i.resetColumnSizing=e=>{var t;i.setColumnSizing(e?{}:(t=i.initialState.columnSizing)!=null?t:{})},i.resetHeaderSizeInfo=e=>{var t;i.setColumnSizingInfo(e?xo():(t=i.initialState.columnSizingInfo)!=null?t:xo())},i.getTotalSize=()=>{var e,t;return(e=(t=i.getHeaderGroups()[0])==null?void 0:t.headers.reduce((n,s)=>n+s.getSize(),0))!=null?e:0},i.getLeftTotalSize=()=>{var e,t;return(e=(t=i.getLeftHeaderGroups()[0])==null?void 0:t.headers.reduce((n,s)=>n+s.getSize(),0))!=null?e:0},i.getCenterTotalSize=()=>{var e,t;return(e=(t=i.getCenterHeaderGroups()[0])==null?void 0:t.headers.reduce((n,s)=>n+s.getSize(),0))!=null?e:0},i.getRightTotalSize=()=>{var e,t;return(e=(t=i.getRightHeaderGroups()[0])==null?void 0:t.headers.reduce((n,s)=>n+s.getSize(),0))!=null?e:0}}};let Cs=null;function s0(){if(typeof Cs=="boolean")return Cs;let i=!1;try{const e={get passive(){return i=!0,!1}},t=()=>{};window.addEventListener("test",t,e),window.removeEventListener("test",t)}catch{i=!1}return Cs=i,Cs}function yo(i){return i.type==="touchstart"}const r0={getInitialState:i=>({columnVisibility:{},...i}),getDefaultOptions:i=>({onColumnVisibilityChange:at("columnVisibility",i)}),createColumn:(i,e)=>{i.toggleVisibility=t=>{i.getCanHide()&&e.setColumnVisibility(n=>({...n,[i.id]:t??!i.getIsVisible()}))},i.getIsVisible=()=>{var t,n;const s=i.columns;return(t=s.length?s.some(r=>r.getIsVisible()):(n=e.getState().columnVisibility)==null?void 0:n[i.id])!=null?t:!0},i.getCanHide=()=>{var t,n;return((t=i.columnDef.enableHiding)!=null?t:!0)&&((n=e.options.enableHiding)!=null?n:!0)},i.getToggleVisibilityHandler=()=>t=>{i.toggleVisibility==null||i.toggleVisibility(t.target.checked)}},createRow:(i,e)=>{i._getAllVisibleCells=Y(()=>[i.getAllCells(),e.getState().columnVisibility],t=>t.filter(n=>n.column.getIsVisible()),X(e.options,"debugRows","_getAllVisibleCells")),i.getVisibleCells=Y(()=>[i.getLeftVisibleCells(),i.getCenterVisibleCells(),i.getRightVisibleCells()],(t,n,s)=>[...t,...n,...s],X(e.options,"debugRows","getVisibleCells"))},createTable:i=>{const e=(t,n)=>Y(()=>[n(),n().filter(s=>s.getIsVisible()).map(s=>s.id).join("_")],s=>s.filter(r=>r.getIsVisible==null?void 0:r.getIsVisible()),X(i.options,"debugColumns",t));i.getVisibleFlatColumns=e("getVisibleFlatColumns",()=>i.getAllFlatColumns()),i.getVisibleLeafColumns=e("getVisibleLeafColumns",()=>i.getAllLeafColumns()),i.getLeftVisibleLeafColumns=e("getLeftVisibleLeafColumns",()=>i.getLeftLeafColumns()),i.getRightVisibleLeafColumns=e("getRightVisibleLeafColumns",()=>i.getRightLeafColumns()),i.getCenterVisibleLeafColumns=e("getCenterVisibleLeafColumns",()=>i.getCenterLeafColumns()),i.setColumnVisibility=t=>i.options.onColumnVisibilityChange==null?void 0:i.options.onColumnVisibilityChange(t),i.resetColumnVisibility=t=>{var n;i.setColumnVisibility(t?{}:(n=i.initialState.columnVisibility)!=null?n:{})},i.toggleAllColumnsVisible=t=>{var n;t=(n=t)!=null?n:!i.getIsAllColumnsVisible(),i.setColumnVisibility(i.getAllLeafColumns().reduce((s,r)=>({...s,[r.id]:t||!(r.getCanHide!=null&&r.getCanHide())}),{}))},i.getIsAllColumnsVisible=()=>!i.getAllLeafColumns().some(t=>!(t.getIsVisible!=null&&t.getIsVisible())),i.getIsSomeColumnsVisible=()=>i.getAllLeafColumns().some(t=>t.getIsVisible==null?void 0:t.getIsVisible()),i.getToggleAllColumnsVisibilityHandler=()=>t=>{var n;i.toggleAllColumnsVisible((n=t.target)==null?void 0:n.checked)}}};function Ln(i,e){return e?e==="center"?i.getCenterVisibleLeafColumns():e==="left"?i.getLeftVisibleLeafColumns():i.getRightVisibleLeafColumns():i.getVisibleLeafColumns()}const o0={createTable:i=>{i._getGlobalFacetedRowModel=i.options.getFacetedRowModel&&i.options.getFacetedRowModel(i,"__global__"),i.getGlobalFacetedRowModel=()=>i.options.manualFiltering||!i._getGlobalFacetedRowModel?i.getPreFilteredRowModel():i._getGlobalFacetedRowModel(),i._getGlobalFacetedUniqueValues=i.options.getFacetedUniqueValues&&i.options.getFacetedUniqueValues(i,"__global__"),i.getGlobalFacetedUniqueValues=()=>i._getGlobalFacetedUniqueValues?i._getGlobalFacetedUniqueValues():new Map,i._getGlobalFacetedMinMaxValues=i.options.getFacetedMinMaxValues&&i.options.getFacetedMinMaxValues(i,"__global__"),i.getGlobalFacetedMinMaxValues=()=>{if(i._getGlobalFacetedMinMaxValues)return i._getGlobalFacetedMinMaxValues()}}},l0={getInitialState:i=>({globalFilter:void 0,...i}),getDefaultOptions:i=>({onGlobalFilterChange:at("globalFilter",i),globalFilterFn:"auto",getColumnCanGlobalFilter:e=>{var t;const n=(t=i.getCoreRowModel().flatRows[0])==null||(t=t._getAllCellsByColumnId()[e.id])==null?void 0:t.getValue();return typeof n=="string"||typeof n=="number"}}),createColumn:(i,e)=>{i.getCanGlobalFilter=()=>{var t,n,s,r;return((t=i.columnDef.enableGlobalFilter)!=null?t:!0)&&((n=e.options.enableGlobalFilter)!=null?n:!0)&&((s=e.options.enableFilters)!=null?s:!0)&&((r=e.options.getColumnCanGlobalFilter==null?void 0:e.options.getColumnCanGlobalFilter(i))!=null?r:!0)&&!!i.accessorFn}},createTable:i=>{i.getGlobalAutoFilterFn=()=>Ut.includesString,i.getGlobalFilterFn=()=>{var e,t;const{globalFilterFn:n}=i.options;return Hr(n)?n:n==="auto"?i.getGlobalAutoFilterFn():(e=(t=i.options.filterFns)==null?void 0:t[n])!=null?e:Ut[n]},i.setGlobalFilter=e=>{i.options.onGlobalFilterChange==null||i.options.onGlobalFilterChange(e)},i.resetGlobalFilter=e=>{i.setGlobalFilter(e?void 0:i.initialState.globalFilter)}}},a0={getInitialState:i=>({expanded:{},...i}),getDefaultOptions:i=>({onExpandedChange:at("expanded",i),paginateExpandedRows:!0}),createTable:i=>{let e=!1,t=!1;i._autoResetExpanded=()=>{var n,s;if(!e){i._queue(()=>{e=!0});return}if((n=(s=i.options.autoResetAll)!=null?s:i.options.autoResetExpanded)!=null?n:!i.options.manualExpanding){if(t)return;t=!0,i._queue(()=>{i.resetExpanded(),t=!1})}},i.setExpanded=n=>i.options.onExpandedChange==null?void 0:i.options.onExpandedChange(n),i.toggleAllRowsExpanded=n=>{n??!i.getIsAllRowsExpanded()?i.setExpanded(!0):i.setExpanded({})},i.resetExpanded=n=>{var s,r;i.setExpanded(n?{}:(s=(r=i.initialState)==null?void 0:r.expanded)!=null?s:{})},i.getCanSomeRowsExpand=()=>i.getPrePaginationRowModel().flatRows.some(n=>n.getCanExpand()),i.getToggleAllRowsExpandedHandler=()=>n=>{n.persist==null||n.persist(),i.toggleAllRowsExpanded()},i.getIsSomeRowsExpanded=()=>{const n=i.getState().expanded;return n===!0||Object.values(n).some(Boolean)},i.getIsAllRowsExpanded=()=>{const n=i.getState().expanded;return typeof n=="boolean"?n===!0:!(!Object.keys(n).length||i.getRowModel().flatRows.some(s=>!s.getIsExpanded()))},i.getExpandedDepth=()=>{let n=0;return(i.getState().expanded===!0?Object.keys(i.getRowModel().rowsById):Object.keys(i.getState().expanded)).forEach(r=>{const o=r.split(".");n=Math.max(n,o.length)}),n},i.getPreExpandedRowModel=()=>i.getSortedRowModel(),i.getExpandedRowModel=()=>(!i._getExpandedRowModel&&i.options.getExpandedRowModel&&(i._getExpandedRowModel=i.options.getExpandedRowModel(i)),i.options.manualExpanding||!i._getExpandedRowModel?i.getPreExpandedRowModel():i._getExpandedRowModel())},createRow:(i,e)=>{i.toggleExpanded=t=>{e.setExpanded(n=>{var s;const r=n===!0?!0:!!(n!=null&&n[i.id]);let o={};if(n===!0?Object.keys(e.getRowModel().rowsById).forEach(l=>{o[l]=!0}):o=n,t=(s=t)!=null?s:!r,!r&&t)return{...o,[i.id]:!0};if(r&&!t){const{[i.id]:l,...a}=o;return a}return n})},i.getIsExpanded=()=>{var t;const n=e.getState().expanded;return!!((t=e.options.getIsRowExpanded==null?void 0:e.options.getIsRowExpanded(i))!=null?t:n===!0||n!=null&&n[i.id])},i.getCanExpand=()=>{var t,n,s;return(t=e.options.getRowCanExpand==null?void 0:e.options.getRowCanExpand(i))!=null?t:((n=e.options.enableExpanding)!=null?n:!0)&&!!((s=i.subRows)!=null&&s.length)},i.getIsAllParentsExpanded=()=>{let t=!0,n=i;for(;t&&n.parentId;)n=e.getRow(n.parentId,!0),t=n.getIsExpanded();return t},i.getToggleExpandedHandler=()=>{const t=i.getCanExpand();return()=>{t&&i.toggleExpanded()}}}},cl=0,hl=10,bo=()=>({pageIndex:cl,pageSize:hl}),u0={getInitialState:i=>({...i,pagination:{...bo(),...i==null?void 0:i.pagination}}),getDefaultOptions:i=>({onPaginationChange:at("pagination",i)}),createTable:i=>{let e=!1,t=!1;i._autoResetPageIndex=()=>{var n,s;if(!e){i._queue(()=>{e=!0});return}if((n=(s=i.options.autoResetAll)!=null?s:i.options.autoResetPageIndex)!=null?n:!i.options.manualPagination){if(t)return;t=!0,i._queue(()=>{i.resetPageIndex(),t=!1})}},i.setPagination=n=>{const s=r=>ci(n,r);return i.options.onPaginationChange==null?void 0:i.options.onPaginationChange(s)},i.resetPagination=n=>{var s;i.setPagination(n?bo():(s=i.initialState.pagination)!=null?s:bo())},i.setPageIndex=n=>{i.setPagination(s=>{let r=ci(n,s.pageIndex);const o=typeof i.options.pageCount>"u"||i.options.pageCount===-1?Number.MAX_SAFE_INTEGER:i.options.pageCount-1;return r=Math.max(0,Math.min(r,o)),{...s,pageIndex:r}})},i.resetPageIndex=n=>{var s,r;i.setPageIndex(n?cl:(s=(r=i.initialState)==null||(r=r.pagination)==null?void 0:r.pageIndex)!=null?s:cl)},i.resetPageSize=n=>{var s,r;i.setPageSize(n?hl:(s=(r=i.initialState)==null||(r=r.pagination)==null?void 0:r.pageSize)!=null?s:hl)},i.setPageSize=n=>{i.setPagination(s=>{const r=Math.max(1,ci(n,s.pageSize)),o=s.pageSize*s.pageIndex,l=Math.floor(o/r);return{...s,pageIndex:l,pageSize:r}})},i.setPageCount=n=>i.setPagination(s=>{var r;let o=ci(n,(r=i.options.pageCount)!=null?r:-1);return typeof o=="number"&&(o=Math.max(-1,o)),{...s,pageCount:o}}),i.getPageOptions=Y(()=>[i.getPageCount()],n=>{let s=[];return n&&n>0&&(s=[...new Array(n)].fill(null).map((r,o)=>o)),s},X(i.options,"debugTable","getPageOptions")),i.getCanPreviousPage=()=>i.getState().pagination.pageIndex>0,i.getCanNextPage=()=>{const{pageIndex:n}=i.getState().pagination,s=i.getPageCount();return s===-1?!0:s===0?!1:n<s-1},i.previousPage=()=>i.setPageIndex(n=>n-1),i.nextPage=()=>i.setPageIndex(n=>n+1),i.firstPage=()=>i.setPageIndex(0),i.lastPage=()=>i.setPageIndex(i.getPageCount()-1),i.getPrePaginationRowModel=()=>i.getExpandedRowModel(),i.getPaginationRowModel=()=>(!i._getPaginationRowModel&&i.options.getPaginationRowModel&&(i._getPaginationRowModel=i.options.getPaginationRowModel(i)),i.options.manualPagination||!i._getPaginationRowModel?i.getPrePaginationRowModel():i._getPaginationRowModel()),i.getPageCount=()=>{var n;return(n=i.options.pageCount)!=null?n:Math.ceil(i.getRowCount()/i.getState().pagination.pageSize)},i.getRowCount=()=>{var n;return(n=i.options.rowCount)!=null?n:i.getPrePaginationRowModel().rows.length}}},vo=()=>({top:[],bottom:[]}),c0={getInitialState:i=>({rowPinning:vo(),...i}),getDefaultOptions:i=>({onRowPinningChange:at("rowPinning",i)}),createRow:(i,e)=>{i.pin=(t,n,s)=>{const r=n?i.getLeafRows().map(a=>{let{id:u}=a;return u}):[],o=s?i.getParentRows().map(a=>{let{id:u}=a;return u}):[],l=new Set([...o,i.id,...r]);e.setRowPinning(a=>{var u,c;if(t==="bottom"){var h,d;return{top:((h=a==null?void 0:a.top)!=null?h:[]).filter(m=>!(l!=null&&l.has(m))),bottom:[...((d=a==null?void 0:a.bottom)!=null?d:[]).filter(m=>!(l!=null&&l.has(m))),...Array.from(l)]}}if(t==="top"){var p,g;return{top:[...((p=a==null?void 0:a.top)!=null?p:[]).filter(m=>!(l!=null&&l.has(m))),...Array.from(l)],bottom:((g=a==null?void 0:a.bottom)!=null?g:[]).filter(m=>!(l!=null&&l.has(m)))}}return{top:((u=a==null?void 0:a.top)!=null?u:[]).filter(m=>!(l!=null&&l.has(m))),bottom:((c=a==null?void 0:a.bottom)!=null?c:[]).filter(m=>!(l!=null&&l.has(m)))}})},i.getCanPin=()=>{var t;const{enableRowPinning:n,enablePinning:s}=e.options;return typeof n=="function"?n(i):(t=n??s)!=null?t:!0},i.getIsPinned=()=>{const t=[i.id],{top:n,bottom:s}=e.getState().rowPinning,r=t.some(l=>n==null?void 0:n.includes(l)),o=t.some(l=>s==null?void 0:s.includes(l));return r?"top":o?"bottom":!1},i.getPinnedIndex=()=>{var t,n;const s=i.getIsPinned();if(!s)return-1;const r=(t=s==="top"?e.getTopRows():e.getBottomRows())==null?void 0:t.map(o=>{let{id:l}=o;return l});return(n=r==null?void 0:r.indexOf(i.id))!=null?n:-1}},createTable:i=>{i.setRowPinning=e=>i.options.onRowPinningChange==null?void 0:i.options.onRowPinningChange(e),i.resetRowPinning=e=>{var t,n;return i.setRowPinning(e?vo():(t=(n=i.initialState)==null?void 0:n.rowPinning)!=null?t:vo())},i.getIsSomeRowsPinned=e=>{var t;const n=i.getState().rowPinning;if(!e){var s,r;return!!((s=n.top)!=null&&s.length||(r=n.bottom)!=null&&r.length)}return!!((t=n[e])!=null&&t.length)},i._getPinnedRows=(e,t,n)=>{var s;return((s=i.options.keepPinnedRows)==null||s?(t??[]).map(o=>{const l=i.getRow(o,!0);return l.getIsAllParentsExpanded()?l:null}):(t??[]).map(o=>e.find(l=>l.id===o))).filter(Boolean).map(o=>({...o,position:n}))},i.getTopRows=Y(()=>[i.getRowModel().rows,i.getState().rowPinning.top],(e,t)=>i._getPinnedRows(e,t,"top"),X(i.options,"debugRows","getTopRows")),i.getBottomRows=Y(()=>[i.getRowModel().rows,i.getState().rowPinning.bottom],(e,t)=>i._getPinnedRows(e,t,"bottom"),X(i.options,"debugRows","getBottomRows")),i.getCenterRows=Y(()=>[i.getRowModel().rows,i.getState().rowPinning.top,i.getState().rowPinning.bottom],(e,t,n)=>{const s=new Set([...t??[],...n??[]]);return e.filter(r=>!s.has(r.id))},X(i.options,"debugRows","getCenterRows"))}},h0={getInitialState:i=>({rowSelection:{},...i}),getDefaultOptions:i=>({onRowSelectionChange:at("rowSelection",i),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:i=>{i.setRowSelection=e=>i.options.onRowSelectionChange==null?void 0:i.options.onRowSelectionChange(e),i.resetRowSelection=e=>{var t;return i.setRowSelection(e?{}:(t=i.initialState.rowSelection)!=null?t:{})},i.toggleAllRowsSelected=e=>{i.setRowSelection(t=>{e=typeof e<"u"?e:!i.getIsAllRowsSelected();const n={...t},s=i.getPreGroupedRowModel().flatRows;return e?s.forEach(r=>{r.getCanSelect()&&(n[r.id]=!0)}):s.forEach(r=>{delete n[r.id]}),n})},i.toggleAllPageRowsSelected=e=>i.setRowSelection(t=>{const n=typeof e<"u"?e:!i.getIsAllPageRowsSelected(),s={...t};return i.getRowModel().rows.forEach(r=>{dl(s,r.id,n,!0,i)}),s}),i.getPreSelectedRowModel=()=>i.getCoreRowModel(),i.getSelectedRowModel=Y(()=>[i.getState().rowSelection,i.getCoreRowModel()],(e,t)=>Object.keys(e).length?So(i,t):{rows:[],flatRows:[],rowsById:{}},X(i.options,"debugTable","getSelectedRowModel")),i.getFilteredSelectedRowModel=Y(()=>[i.getState().rowSelection,i.getFilteredRowModel()],(e,t)=>Object.keys(e).length?So(i,t):{rows:[],flatRows:[],rowsById:{}},X(i.options,"debugTable","getFilteredSelectedRowModel")),i.getGroupedSelectedRowModel=Y(()=>[i.getState().rowSelection,i.getSortedRowModel()],(e,t)=>Object.keys(e).length?So(i,t):{rows:[],flatRows:[],rowsById:{}},X(i.options,"debugTable","getGroupedSelectedRowModel")),i.getIsAllRowsSelected=()=>{const e=i.getFilteredRowModel().flatRows,{rowSelection:t}=i.getState();let n=!!(e.length&&Object.keys(t).length);return n&&e.some(s=>s.getCanSelect()&&!t[s.id])&&(n=!1),n},i.getIsAllPageRowsSelected=()=>{const e=i.getPaginationRowModel().flatRows.filter(s=>s.getCanSelect()),{rowSelection:t}=i.getState();let n=!!e.length;return n&&e.some(s=>!t[s.id])&&(n=!1),n},i.getIsSomeRowsSelected=()=>{var e;const t=Object.keys((e=i.getState().rowSelection)!=null?e:{}).length;return t>0&&t<i.getFilteredRowModel().flatRows.length},i.getIsSomePageRowsSelected=()=>{const e=i.getPaginationRowModel().flatRows;return i.getIsAllPageRowsSelected()?!1:e.filter(t=>t.getCanSelect()).some(t=>t.getIsSelected()||t.getIsSomeSelected())},i.getToggleAllRowsSelectedHandler=()=>e=>{i.toggleAllRowsSelected(e.target.checked)},i.getToggleAllPageRowsSelectedHandler=()=>e=>{i.toggleAllPageRowsSelected(e.target.checked)}},createRow:(i,e)=>{i.toggleSelected=(t,n)=>{const s=i.getIsSelected();e.setRowSelection(r=>{var o;if(t=typeof t<"u"?t:!s,i.getCanSelect()&&s===t)return r;const l={...r};return dl(l,i.id,t,(o=n==null?void 0:n.selectChildren)!=null?o:!0,e),l})},i.getIsSelected=()=>{const{rowSelection:t}=e.getState();return ya(i,t)},i.getIsSomeSelected=()=>{const{rowSelection:t}=e.getState();return fl(i,t)==="some"},i.getIsAllSubRowsSelected=()=>{const{rowSelection:t}=e.getState();return fl(i,t)==="all"},i.getCanSelect=()=>{var t;return typeof e.options.enableRowSelection=="function"?e.options.enableRowSelection(i):(t=e.options.enableRowSelection)!=null?t:!0},i.getCanSelectSubRows=()=>{var t;return typeof e.options.enableSubRowSelection=="function"?e.options.enableSubRowSelection(i):(t=e.options.enableSubRowSelection)!=null?t:!0},i.getCanMultiSelect=()=>{var t;return typeof e.options.enableMultiRowSelection=="function"?e.options.enableMultiRowSelection(i):(t=e.options.enableMultiRowSelection)!=null?t:!0},i.getToggleSelectedHandler=()=>{const t=i.getCanSelect();return n=>{var s;t&&i.toggleSelected((s=n.target)==null?void 0:s.checked)}}}},dl=(i,e,t,n,s)=>{var r;const o=s.getRow(e,!0);t?(o.getCanMultiSelect()||Object.keys(i).forEach(l=>delete i[l]),o.getCanSelect()&&(i[e]=!0)):delete i[e],n&&(r=o.subRows)!=null&&r.length&&o.getCanSelectSubRows()&&o.subRows.forEach(l=>dl(i,l.id,t,n,s))};function So(i,e){const t=i.getState().rowSelection,n=[],s={},r=function(o,l){return o.map(a=>{var u;const c=ya(a,t);if(c&&(n.push(a),s[a.id]=a),(u=a.subRows)!=null&&u.length&&(a={...a,subRows:r(a.subRows)}),c)return a}).filter(Boolean)};return{rows:r(e.rows),flatRows:n,rowsById:s}}function ya(i,e){var t;return(t=e[i.id])!=null?t:!1}function fl(i,e,t){var n;if(!((n=i.subRows)!=null&&n.length))return!1;let s=!0,r=!1;return i.subRows.forEach(o=>{if(!(r&&!s)&&(o.getCanSelect()&&(ya(o,e)?r=!0:s=!1),o.subRows&&o.subRows.length)){const l=fl(o,e);l==="all"?r=!0:(l==="some"&&(r=!0),s=!1)}}),s?"all":r?"some":!1}const pl=/([0-9]+)/gm,d0=(i,e,t)=>Kh(gi(i.getValue(t)).toLowerCase(),gi(e.getValue(t)).toLowerCase()),f0=(i,e,t)=>Kh(gi(i.getValue(t)),gi(e.getValue(t))),p0=(i,e,t)=>ba(gi(i.getValue(t)).toLowerCase(),gi(e.getValue(t)).toLowerCase()),g0=(i,e,t)=>ba(gi(i.getValue(t)),gi(e.getValue(t))),m0=(i,e,t)=>{const n=i.getValue(t),s=e.getValue(t);return n>s?1:n<s?-1:0},x0=(i,e,t)=>ba(i.getValue(t),e.getValue(t));function ba(i,e){return i===e?0:i>e?1:-1}function gi(i){return typeof i=="number"?isNaN(i)||i===1/0||i===-1/0?"":String(i):typeof i=="string"?i:""}function Kh(i,e){const t=i.split(pl).filter(Boolean),n=e.split(pl).filter(Boolean);for(;t.length&&n.length;){const s=t.shift(),r=n.shift(),o=parseInt(s,10),l=parseInt(r,10),a=[o,l].sort();if(isNaN(a[0])){if(s>r)return 1;if(r>s)return-1;continue}if(isNaN(a[1]))return isNaN(o)?-1:1;if(o>l)return 1;if(l>o)return-1}return t.length-n.length}const Rn={alphanumeric:d0,alphanumericCaseSensitive:f0,text:p0,textCaseSensitive:g0,datetime:m0,basic:x0},y0={getInitialState:i=>({sorting:[],...i}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:i=>({onSortingChange:at("sorting",i),isMultiSortEvent:e=>e.shiftKey}),createColumn:(i,e)=>{i.getAutoSortingFn=()=>{const t=e.getFilteredRowModel().flatRows.slice(10);let n=!1;for(const s of t){const r=s==null?void 0:s.getValue(i.id);if(Object.prototype.toString.call(r)==="[object Date]")return Rn.datetime;if(typeof r=="string"&&(n=!0,r.split(pl).length>1))return Rn.alphanumeric}return n?Rn.text:Rn.basic},i.getAutoSortDir=()=>{const t=e.getFilteredRowModel().flatRows[0];return typeof(t==null?void 0:t.getValue(i.id))=="string"?"asc":"desc"},i.getSortingFn=()=>{var t,n;if(!i)throw new Error;return Hr(i.columnDef.sortingFn)?i.columnDef.sortingFn:i.columnDef.sortingFn==="auto"?i.getAutoSortingFn():(t=(n=e.options.sortingFns)==null?void 0:n[i.columnDef.sortingFn])!=null?t:Rn[i.columnDef.sortingFn]},i.toggleSorting=(t,n)=>{const s=i.getNextSortingOrder(),r=typeof t<"u"&&t!==null;e.setSorting(o=>{const l=o==null?void 0:o.find(p=>p.id===i.id),a=o==null?void 0:o.findIndex(p=>p.id===i.id);let u=[],c,h=r?t:s==="desc";if(o!=null&&o.length&&i.getCanMultiSort()&&n?l?c="toggle":c="add":o!=null&&o.length&&a!==o.length-1?c="replace":l?c="toggle":c="replace",c==="toggle"&&(r||s||(c="remove")),c==="add"){var d;u=[...o,{id:i.id,desc:h}],u.splice(0,u.length-((d=e.options.maxMultiSortColCount)!=null?d:Number.MAX_SAFE_INTEGER))}else c==="toggle"?u=o.map(p=>p.id===i.id?{...p,desc:h}:p):c==="remove"?u=o.filter(p=>p.id!==i.id):u=[{id:i.id,desc:h}];return u})},i.getFirstSortDir=()=>{var t,n;return((t=(n=i.columnDef.sortDescFirst)!=null?n:e.options.sortDescFirst)!=null?t:i.getAutoSortDir()==="desc")?"desc":"asc"},i.getNextSortingOrder=t=>{var n,s;const r=i.getFirstSortDir(),o=i.getIsSorted();return o?o!==r&&((n=e.options.enableSortingRemoval)==null||n)&&(!(t&&(s=e.options.enableMultiRemove)!=null)||s)?!1:o==="desc"?"asc":"desc":r},i.getCanSort=()=>{var t,n;return((t=i.columnDef.enableSorting)!=null?t:!0)&&((n=e.options.enableSorting)!=null?n:!0)&&!!i.accessorFn},i.getCanMultiSort=()=>{var t,n;return(t=(n=i.columnDef.enableMultiSort)!=null?n:e.options.enableMultiSort)!=null?t:!!i.accessorFn},i.getIsSorted=()=>{var t;const n=(t=e.getState().sorting)==null?void 0:t.find(s=>s.id===i.id);return n?n.desc?"desc":"asc":!1},i.getSortIndex=()=>{var t,n;return(t=(n=e.getState().sorting)==null?void 0:n.findIndex(s=>s.id===i.id))!=null?t:-1},i.clearSorting=()=>{e.setSorting(t=>t!=null&&t.length?t.filter(n=>n.id!==i.id):[])},i.getToggleSortingHandler=()=>{const t=i.getCanSort();return n=>{t&&(n.persist==null||n.persist(),i.toggleSorting==null||i.toggleSorting(void 0,i.getCanMultiSort()?e.options.isMultiSortEvent==null?void 0:e.options.isMultiSortEvent(n):!1))}}},createTable:i=>{i.setSorting=e=>i.options.onSortingChange==null?void 0:i.options.onSortingChange(e),i.resetSorting=e=>{var t,n;i.setSorting(e?[]:(t=(n=i.initialState)==null?void 0:n.sorting)!=null?t:[])},i.getPreSortedRowModel=()=>i.getGroupedRowModel(),i.getSortedRowModel=()=>(!i._getSortedRowModel&&i.options.getSortedRowModel&&(i._getSortedRowModel=i.options.getSortedRowModel(i)),i.options.manualSorting||!i._getSortedRowModel?i.getPreSortedRowModel():i._getSortedRowModel())}},b0=[_m,r0,e0,t0,zm,$m,o0,l0,y0,Jm,a0,u0,c0,h0,n0];function v0(i){var e,t;process.env.NODE_ENV!=="production"&&(i.debugAll||i.debugTable)&&console.info("Creating Table Instance...");const n=[...b0,...(e=i._features)!=null?e:[]];let s={_features:n};const r=s._features.reduce((d,p)=>Object.assign(d,p.getDefaultOptions==null?void 0:p.getDefaultOptions(s)),{}),o=d=>s.options.mergeOptions?s.options.mergeOptions(r,d):{...r,...d};let a={...{},...(t=i.initialState)!=null?t:{}};s._features.forEach(d=>{var p;a=(p=d.getInitialState==null?void 0:d.getInitialState(a))!=null?p:a});const u=[];let c=!1;const h={_features:n,options:{...r,...i},initialState:a,_queue:d=>{u.push(d),c||(c=!0,Promise.resolve().then(()=>{for(;u.length;)u.shift()();c=!1}).catch(p=>setTimeout(()=>{throw p})))},reset:()=>{s.setState(s.initialState)},setOptions:d=>{const p=ci(d,s.options);s.options=o(p)},getState:()=>s.options.state,setState:d=>{s.options.onStateChange==null||s.options.onStateChange(d)},_getRowId:(d,p,g)=>{var m;return(m=s.options.getRowId==null?void 0:s.options.getRowId(d,p,g))!=null?m:`${g?[g.id,p].join("."):p}`},getCoreRowModel:()=>(s._getCoreRowModel||(s._getCoreRowModel=s.options.getCoreRowModel(s)),s._getCoreRowModel()),getRowModel:()=>s.getPaginationRowModel(),getRow:(d,p)=>{let g=(p?s.getPrePaginationRowModel():s.getRowModel()).rowsById[d];if(!g&&(g=s.getCoreRowModel().rowsById[d],!g))throw process.env.NODE_ENV!=="production"?new Error(`getRow could not find row with ID: ${d}`):new Error;return g},_getDefaultColumnDef:Y(()=>[s.options.defaultColumn],d=>{var p;return d=(p=d)!=null?p:{},{header:g=>{const m=g.header.column.columnDef;return m.accessorKey?m.accessorKey:m.accessorFn?m.id:null},cell:g=>{var m,x;return(m=(x=g.renderValue())==null||x.toString==null?void 0:x.toString())!=null?m:null},...s._features.reduce((g,m)=>Object.assign(g,m.getDefaultColumnDef==null?void 0:m.getDefaultColumnDef()),{}),...d}},X(i,"debugColumns","_getDefaultColumnDef")),_getColumnDefs:()=>s.options.columns,getAllColumns:Y(()=>[s._getColumnDefs()],d=>{const p=function(g,m,x){return x===void 0&&(x=0),g.map(y=>{const b=Vm(s,y,x,m),v=y;return b.columns=v.columns?p(v.columns,b,x+1):[],b})};return p(d)},X(i,"debugColumns","getAllColumns")),getAllFlatColumns:Y(()=>[s.getAllColumns()],d=>d.flatMap(p=>p.getFlatColumns()),X(i,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:Y(()=>[s.getAllFlatColumns()],d=>d.reduce((p,g)=>(p[g.id]=g,p),{}),X(i,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:Y(()=>[s.getAllColumns(),s._getOrderColumnsFn()],(d,p)=>{let g=d.flatMap(m=>m.getLeafColumns());return p(g)},X(i,"debugColumns","getAllLeafColumns")),getColumn:d=>{const p=s._getAllFlatColumnsById()[d];return process.env.NODE_ENV!=="production"&&!p&&console.error(`[Table] Column with id '${d}' does not exist.`),p}};Object.assign(s,h);for(let d=0;d<s._features.length;d++){const p=s._features[d];p==null||p.createTable==null||p.createTable(s)}return s}function S0(){return i=>Y(()=>[i.options.data],e=>{const t={rows:[],flatRows:[],rowsById:{}},n=function(s,r,o){r===void 0&&(r=0);const l=[];for(let u=0;u<s.length;u++){const c=Gr(i,i._getRowId(s[u],u,o),s[u],u,r,void 0,o==null?void 0:o.id);if(t.flatRows.push(c),t.rowsById[c.id]=c,l.push(c),i.options.getSubRows){var a;c.originalSubRows=i.options.getSubRows(s[u],u),(a=c.originalSubRows)!=null&&a.length&&(c.subRows=n(c.originalSubRows,r+1,c))}}return l};return t.rows=n(e),t},X(i.options,"debugTable","getRowModel",()=>i._autoResetPageIndex()))}function wu(){return i=>Y(()=>[i.getState().expanded,i.getPreExpandedRowModel(),i.options.paginateExpandedRows],(e,t,n)=>!t.rows.length||e!==!0&&!Object.keys(e??{}).length||!n?t:Yh(t),X(i.options,"debugTable","getExpandedRowModel"))}function Yh(i){const e=[],t=n=>{var s;e.push(n),(s=n.subRows)!=null&&s.length&&n.getIsExpanded()&&n.subRows.forEach(t)};return i.rows.forEach(t),{rows:e,flatRows:i.flatRows,rowsById:i.rowsById}}function C0(i,e,t){return t.options.filterFromLeafRows?w0(i,e,t):E0(i,e,t)}function w0(i,e,t){var n;const s=[],r={},o=(n=t.options.maxLeafRowFilterDepth)!=null?n:100,l=function(a,u){u===void 0&&(u=0);const c=[];for(let d=0;d<a.length;d++){var h;let p=a[d];const g=Gr(t,p.id,p.original,p.index,p.depth,void 0,p.parentId);if(g.columnFilters=p.columnFilters,(h=p.subRows)!=null&&h.length&&u<o){if(g.subRows=l(p.subRows,u+1),p=g,e(p)&&!g.subRows.length){c.push(p),r[p.id]=p,s.push(p);continue}if(e(p)||g.subRows.length){c.push(p),r[p.id]=p,s.push(p);continue}}else p=g,e(p)&&(c.push(p),r[p.id]=p,s.push(p))}return c};return{rows:l(i),flatRows:s,rowsById:r}}function E0(i,e,t){var n;const s=[],r={},o=(n=t.options.maxLeafRowFilterDepth)!=null?n:100,l=function(a,u){u===void 0&&(u=0);const c=[];for(let d=0;d<a.length;d++){let p=a[d];if(e(p)){var h;if((h=p.subRows)!=null&&h.length&&u<o){const m=Gr(t,p.id,p.original,p.index,p.depth,void 0,p.parentId);m.subRows=l(p.subRows,u+1),p=m}c.push(p),s.push(p),r[p.id]=p}}return c};return{rows:l(i),flatRows:s,rowsById:r}}function R0(){return i=>Y(()=>[i.getPreFilteredRowModel(),i.getState().columnFilters,i.getState().globalFilter],(e,t,n)=>{if(!e.rows.length||!(t!=null&&t.length)&&!n){for(let d=0;d<e.flatRows.length;d++)e.flatRows[d].columnFilters={},e.flatRows[d].columnFiltersMeta={};return e}const s=[],r=[];(t??[]).forEach(d=>{var p;const g=i.getColumn(d.id);if(!g)return;const m=g.getFilterFn();if(!m){process.env.NODE_ENV!=="production"&&console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${g.id}.`);return}s.push({id:d.id,filterFn:m,resolvedValue:(p=m.resolveFilterValue==null?void 0:m.resolveFilterValue(d.value))!=null?p:d.value})});const o=(t??[]).map(d=>d.id),l=i.getGlobalFilterFn(),a=i.getAllLeafColumns().filter(d=>d.getCanGlobalFilter());n&&l&&a.length&&(o.push("__global__"),a.forEach(d=>{var p;r.push({id:d.id,filterFn:l,resolvedValue:(p=l.resolveFilterValue==null?void 0:l.resolveFilterValue(n))!=null?p:n})}));let u,c;for(let d=0;d<e.flatRows.length;d++){const p=e.flatRows[d];if(p.columnFilters={},s.length)for(let g=0;g<s.length;g++){u=s[g];const m=u.id;p.columnFilters[m]=u.filterFn(p,m,u.resolvedValue,x=>{p.columnFiltersMeta[m]=x})}if(r.length){for(let g=0;g<r.length;g++){c=r[g];const m=c.id;if(c.filterFn(p,m,c.resolvedValue,x=>{p.columnFiltersMeta[m]=x})){p.columnFilters.__global__=!0;break}}p.columnFilters.__global__!==!0&&(p.columnFilters.__global__=!1)}}const h=d=>{for(let p=0;p<o.length;p++)if(d.columnFilters[o[p]]===!1)return!1;return!0};return C0(e.rows,h,i)},X(i.options,"debugTable","getFilteredRowModel",()=>i._autoResetPageIndex()))}function k0(){return i=>Y(()=>[i.getState().grouping,i.getPreGroupedRowModel()],(e,t)=>{if(!t.rows.length||!e.length)return t.rows.forEach(a=>{a.depth=0,a.parentId=void 0}),t;const n=e.filter(a=>i.getColumn(a)),s=[],r={},o=function(a,u,c){if(u===void 0&&(u=0),u>=n.length)return a.map(g=>(g.depth=u,s.push(g),r[g.id]=g,g.subRows&&(g.subRows=o(g.subRows,u+1,g.id)),g));const h=n[u],d=A0(a,h);return Array.from(d.entries()).map((g,m)=>{let[x,y]=g,b=`${h}:${x}`;b=c?`${c}>${b}`:b;const v=o(y,u+1,b);v.forEach(E=>{E.parentId=b});const C=u?Vh(y,E=>E.subRows):y,S=Gr(i,b,C[0].original,m,u,void 0,c);return Object.assign(S,{groupingColumnId:h,groupingValue:x,subRows:v,leafRows:C,getValue:E=>{if(n.includes(E)){if(S._valuesCache.hasOwnProperty(E))return S._valuesCache[E];if(y[0]){var A;S._valuesCache[E]=(A=y[0].getValue(E))!=null?A:void 0}return S._valuesCache[E]}if(S._groupingValuesCache.hasOwnProperty(E))return S._groupingValuesCache[E];const I=i.getColumn(E),R=I==null?void 0:I.getAggregationFn();if(R)return S._groupingValuesCache[E]=R(E,C,y),S._groupingValuesCache[E]}}),v.forEach(E=>{s.push(E),r[E.id]=E}),S})},l=o(t.rows,0);return l.forEach(a=>{s.push(a),r[a.id]=a}),{rows:l,flatRows:s,rowsById:r}},X(i.options,"debugTable","getGroupedRowModel",()=>{i._queue(()=>{i._autoResetExpanded(),i._autoResetPageIndex()})}))}function A0(i,e){const t=new Map;return i.reduce((n,s)=>{const r=`${s.getGroupingValue(e)}`,o=n.get(r);return o?o.push(s):n.set(r,[s]),n},t)}function T0(i){return e=>Y(()=>[e.getState().pagination,e.getPrePaginationRowModel(),e.options.paginateExpandedRows?void 0:e.getState().expanded],(t,n)=>{if(!n.rows.length)return n;const{pageSize:s,pageIndex:r}=t;let{rows:o,flatRows:l,rowsById:a}=n;const u=s*r,c=u+s;o=o.slice(u,c);let h;e.options.paginateExpandedRows?h={rows:o,flatRows:l,rowsById:a}:h=Yh({rows:o,flatRows:l,rowsById:a}),h.flatRows=[];const d=p=>{h.flatRows.push(p),p.subRows.length&&p.subRows.forEach(d)};return h.rows.forEach(d),h},X(e.options,"debugTable","getPaginationRowModel"))}function M0(){return i=>Y(()=>[i.getState().sorting,i.getPreSortedRowModel()],(e,t)=>{if(!t.rows.length||!(e!=null&&e.length))return t;const n=i.getState().sorting,s=[],r=n.filter(a=>{var u;return(u=i.getColumn(a.id))==null?void 0:u.getCanSort()}),o={};r.forEach(a=>{const u=i.getColumn(a.id);u&&(o[a.id]={sortUndefined:u.columnDef.sortUndefined,invertSorting:u.columnDef.invertSorting,sortingFn:u.getSortingFn()})});const l=a=>{const u=a.map(c=>({...c}));return u.sort((c,h)=>{for(let p=0;p<r.length;p+=1){var d;const g=r[p],m=o[g.id],x=m.sortUndefined,y=(d=g==null?void 0:g.desc)!=null?d:!1;let b=0;if(x){const v=c.getValue(g.id),C=h.getValue(g.id),S=v===void 0,E=C===void 0;if(S||E){if(x==="first")return S?-1:1;if(x==="last")return S?1:-1;b=S&&E?0:S?x:-x}}if(b===0&&(b=m.sortingFn(c,h,g.id)),b!==0)return y&&(b*=-1),m.invertSorting&&(b*=-1),b}return c.index-h.index}),u.forEach(c=>{var h;s.push(c),(h=c.subRows)!=null&&h.length&&(c.subRows=l(c.subRows))}),u};return{rows:l(t.rows),flatRows:s,rowsById:t.rowsById}},X(i.options,"debugTable","getSortedRowModel",()=>i._autoResetPageIndex()))}/**
14
14
  * react-table
15
15
  *
16
16
  * Copyright (c) TanStack
@@ -19,16 +19,16 @@
19
19
  * LICENSE.md file in the root directory of this source tree.
20
20
  *
21
21
  * @license MIT
22
- */function go(i,e){return i?l0(i)?Se.createElement(i,e):i:null}function l0(i){return a0(i)||typeof i=="function"||u0(i)}function a0(i){return typeof i=="function"&&(()=>{const e=Object.getPrototypeOf(i);return e.prototype&&e.prototype.isReactComponent})()}function u0(i){return typeof i=="object"&&typeof i.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(i.$$typeof.description)}function c0(i){const e={state:{},onStateChange:()=>{},renderFallbackValue:null,...i},[t]=Se.useState(()=>({current:Qm(e)})),[n,s]=Se.useState(()=>t.current.initialState);return t.current.setOptions(r=>({...r,...i,state:{...n,...i.state},onStateChange:o=>{s(o),i.onStateChange==null||i.onStateChange(o)}})),t.current}function h0(i){const[e,t]=j.useState(-1),n=j.useRef(null),s=()=>{const r=n.current;if(!r)return;const{scrollWidth:o,clientWidth:l,scrollLeft:a}=r,u=o-l;t(u===0?-1:Math.round(a)/u)};return j.useEffect(()=>{const r=n.current;if(!r)return;s();const o=new ResizeObserver(s);return o.observe(r),()=>o.disconnect()},[i]),{scrollRatio:e,tableRef:n,handleScrollRatioUpdate:s}}var $r=(i=>(i.NONE="none",i.CLIENT="client",i.SERVER="server",i))($r||{});const f0=15,cu=15,d0=[{id:cu,label:String(cu)},{id:25,label:String(25)},{id:50,label:String(50)}],nl="__JOIN__",ni={globalFilter:"",columnFilters:[],pagination:{pageSize:f0},sorting:[],grouping:[],columnOrder:[],columnVisibility:{},rowSelectionEnabled:!1},Lh="ma-studio-table-settings";function aa(i,e){var n;const t=((n=e==null?void 0:e.typeMeta)==null?void 0:n.kind)??"";return t in i?{...d.lodashExports.omit(i,t),...i[t]}:i}function ua(i,e,t){const n="original"in e?e.original:e.record,s=aa(i,n),r=s.id||t,o=e.getValue(r)??"";return"items"in s?typeof o!="string"?(console.warn(`Expected string from normalizeColumnAccessor for multi-cell column ${r}, got:`,typeof o,o),d.safeStringify(o).split(nl).at(0)??""):o.split(nl).at(0)??"":o}function p0({preFilteredRows:i,column:e}){const t=d.useCellToString();return j.useMemo(()=>{const n={},s={};return i.forEach(r=>{const o=ua(e,r,e.id);if(o==null)return;const l=t({value:o,record:r.record,column:e}),a=l==null&&o===""?"":l;if(a==null||a in n)return;const u=d.safeStringify(o);n[a]=o,s[u]=a}),[s,n]},[i,t,e])}function g0({column:i,close:e,getFilterValue:t,setFilterValue:n,preFilteredRows:s}){const r=sa.CategoricalColumn({title:"",mapDataToValue:()=>""}).renderFilter,[o,l]=p0({preFilteredRows:s,column:i}),a=Object.keys(l),u=(t()??[]).map(f=>o[d.safeStringify(f)]).filter(Boolean),c=a.sort((f,p)=>{const g=u.includes(f),m=u.includes(p);return g===m?f.localeCompare(p):g?-1:1}),h=({selection:f,exclude:p})=>{const m=(p?a.filter(x=>!f.has(x)):Array.from(f)).map(x=>l[x]);n(m.length>0?m:void 0),e()};return d.jsxRuntimeExports.jsx(r,{data:c,setFilter:h,close:e,filterParams:{description:"",selection:new Set(u),exclude:!1}})}const m0=new Date("2022-01-01T00:00:00"),x0=i=>{var e;return i?{...i,range:((e=i==null?void 0:i.range)==null?void 0:e.map(t=>new Date(t)))??[]}:{operation:"",range:[],selection:[],description:"",exclude:!1}};function y0({close:i,getFilterValue:e,setFilterValue:t}){const n=sa.DatetimeColumn({title:"",mapDataToValue:()=>new Date}).renderFilter,s=[m0,new Date],r=x0(e());return d.jsxRuntimeExports.jsx(n,{data:s,setFilter:t,close:i,filterParams:r})}function Fh(i){switch(i){case d.CellType.DATE:return y0;default:return g0}}function b0(){const i=d.useCellToString();return e=>{const t=o=>!(o!=null&&o.length);return{isFilterInactive:t,getActiveFilter:o=>!Array.isArray(o)||!(o!=null&&o.length)?"":o.map(l=>i({record:{},value:l,column:e})).join(", "),getFilterSummary:o=>!Array.isArray(o)||!(o!=null&&o.length)?"":`(${o.length}) ${e.label?`${e.label}: `:""}${o.map(l=>i({record:{},value:l,column:e})).join(", ")}`,buildTableFilterFn:()=>{const o=(l,a,u)=>t(u)?!0:u.includes(ua(e,l,a));return o.autoRemove=t,o}}}}function v0(){return i=>{const e=o=>{var l;return{...o,range:((l=o==null?void 0:o.range)==null?void 0:l.map(a=>new Date(a)))||[]}},t=o=>{var l,a;return!((l=o==null?void 0:o.range)!=null&&l.length)&&!((a=o==null?void 0:o.selection)!=null&&a.length)},n=o=>t(o)?"":(o==null?void 0:o.description)??"";return{isFilterInactive:t,getActiveFilter:n,getFilterSummary:o=>t(o)?"":`${i.label?`${i.label}: `:""}${n(o)}`,buildTableFilterFn:()=>{const o=(l,a,u)=>{if(t(u)||u.range.length===1)return!0;const c=u.range.some(p=>typeof p=="string")?e(u):u,h=ua(i,l,a),f=d.getDateFromEpochSeconds(typeof h=="number"?h:parseFloat(String(h)));return sa.DatetimeColumn({title:"",mapDataToValue:()=>new Date}).buildFilter(c)(f)};return o.autoRemove=t,o}}}}function Nh(){const i=b0(),e=v0();return t=>t.type===d.CellType.DATE?e(t):i(t)}function S0(i){const{column:e,preFilteredRows:t}=i,[n,s]=D.useStyletron(),[r,o]=j.useState(!1),[l,a]=j.useState(!1),[u,c]=j.useState(null),f=Nh()({id:e.id,type:e.type,label:e.label}),p=()=>{c(setTimeout(()=>a(!0),1e3))},g=()=>{u&&clearTimeout(u),a(!1)},m=Fh(e.type);return d.jsxRuntimeExports.jsx(Nt.StatefulPopover,{placement:Nt.PLACEMENT.bottomLeft,content:({close:x})=>d.jsxRuntimeExports.jsx(m,{column:e,close:x,getFilterValue:e.getFilterValue,setFilterValue:e.setFilterValue,preFilteredRows:t}),onOpen:()=>o(!0),onClose:()=>o(!1),children:d.jsxRuntimeExports.jsx(sr.Tag,{kind:sr.KIND.blue,overrides:r?{Root:{style:({$theme:x})=>({borderColor:x.colors.accent,borderWidth:"2px"})}}:{},onActionClick:()=>e.setFilterValue(void 0),children:d.jsxRuntimeExports.jsx(Oi.Tooltip,{content:()=>d.jsxRuntimeExports.jsx("div",{className:n({maxWidth:s.sizing.scale4800,overflowWrap:"break-word"}),children:f.getActiveFilter(e.getFilterValue())}),placement:Nt.PLACEMENT.top,isOpen:l,onMouseEnter:p,onMouseLeave:g,showArrow:!0,children:d.jsxRuntimeExports.jsx(d.TruncatedText,{children:f.getFilterSummary(e.getFilterValue())})})})})}function C0(i){const{filterableColumns:e,preFilteredRows:t}=i,[n,s]=D.useStyletron(),r=e.filter(o=>{const l=o.getFilterValue();return l!=null});return r.length===0?null:d.jsxRuntimeExports.jsx("div",{className:n({display:"flex",flexWrap:"wrap",gap:s.sizing.scale300}),children:r.map(o=>d.jsxRuntimeExports.jsx(S0,{column:o,preFilteredRows:t},o.id))})}const w0=D.styled("li",({$theme:i})=>({...i.typography.ParagraphSmall,display:"flex",justifyContent:"space-between",alignItems:"center",paddingTop:i.sizing.scale500,paddingBottom:i.sizing.scale500,paddingLeft:i.sizing.scale600,paddingRight:i.sizing.scale800,cursor:"pointer",position:"relative",":hover":{backgroundColor:i.colors.menuFillHover},":before":E0(i.colors.borderOpaque)}));function E0(i){return{position:"absolute",width:"85%",content:'""',borderTop:"1px solid",borderColor:i,top:0,left:"7.5%"}}function R0({label:i,onClick:e}){return d.jsxRuntimeExports.jsxs(w0,{onClick:e,role:"option","aria-label":i,"data-testid":`filter-option-${i}`,children:[i,d.jsxRuntimeExports.jsx(d.Icon,{name:"chevronRight"})]})}const k0=D.styled("ul",{margin:0,padding:0,listStyle:"none",maxHeight:"340px",overflowY:"auto"});function A0({filterableColumns:i,setSelectedColumn:e}){const[t,n]=D.useStyletron();return d.jsxRuntimeExports.jsxs("div",{className:t({backgroundColor:n.colors.backgroundPrimary,borderRadius:n.borders.radius300,width:"214px",display:"flex",flexDirection:"column"}),children:[d.jsxRuntimeExports.jsx("div",{className:t({...n.typography.LabelSmall,paddingBottom:n.sizing.scale300,paddingTop:n.sizing.scale500,paddingLeft:n.sizing.scale500,paddingRight:n.sizing.scale500}),children:"Select column to filter"}),d.jsxRuntimeExports.jsx(k0,{role:"listbox",children:i.map(s=>d.jsxRuntimeExports.jsx(R0,{label:s.label,onClick:()=>e(s)},s.id))})]})}function T0(i){const{columnFilters:e,filterableColumns:t,onClose:n,preFilteredRows:s,selectedColumn:r,setColumnFilters:o,setSelectedColumn:l}=i,[a,u]=D.useStyletron();if(r){const c=Fh(r.type);return d.jsxRuntimeExports.jsxs("div",{className:a({backgroundColor:u.colors.backgroundPrimary}),children:[d.jsxRuntimeExports.jsx(_.Button,{onClick:()=>l(void 0),kind:_.KIND.tertiary,size:_.SIZE.compact,children:d.jsxRuntimeExports.jsx(d.Icon,{name:"arrowLeft",size:u.sizing.scale650})}),d.jsxRuntimeExports.jsx(c,{column:r,close:n,getFilterValue:()=>{const h=e.find(f=>f.id===r.id);return h==null?void 0:h.value},setFilterValue:h=>{const f=e.filter(p=>p.id!==r.id);h!==void 0&&f.push({id:r.id,value:h}),o(f)},preFilteredRows:s})]})}return d.jsxRuntimeExports.jsx(A0,{filterableColumns:t,setSelectedColumn:l})}function M0(i){const{filterableColumns:e,columnFilters:t,setColumnFilters:n,preFilteredRows:s}=i,[r,o]=j.useState(),[l,a]=j.useState(!1),u=j.useCallback(()=>{o(void 0),a(!1)},[]);return d.jsxRuntimeExports.jsx(Nt.StatefulPopover,{placement:Nt.PLACEMENT.rightTop,onClose:u,onOpen:()=>a(!0),overrides:{Body:{style:{overflow:"hidden"}}},content:({close:c})=>d.jsxRuntimeExports.jsx(T0,{columnFilters:t,filterableColumns:e,onClose:()=>{u(),c()},preFilteredRows:s,selectedColumn:r,setColumnFilters:n,setSelectedColumn:o}),children:d.jsxRuntimeExports.jsx(_.Button,{shape:_.SHAPE.pill,size:_.SIZE.compact,kind:l||t.length>0?_.KIND.primary:_.KIND.secondary,startEnhancer:d.jsxRuntimeExports.jsx(d.Icon,{name:"plus"}),overrides:{BaseButton:{style:{textWrap:"nowrap"}}},children:"Add filter"})})}function j0({value:i,onChange:e}){const[t,n]=j.useState(i);j.useEffect(()=>{n(o=>o===i?o:i)},[i]);const s=j.useMemo(()=>{let o;return l=>{clearTimeout(o),o=setTimeout(()=>e(l),500)}},[e]),r=o=>{const l=o.target.value;n(l),s(l)};return d.jsxRuntimeExports.jsx(ht.Input,{clearable:!0,type:"search",value:t,onChange:r,size:ht.SIZE.compact,overrides:{Root:{style:{width:"250px"}}},placeholder:"Search...",startEnhancer:d.jsxRuntimeExports.jsx(d.Icon,{name:"search"})})}const O0=D.styled("div",({$theme:i})=>({display:"flex",flexDirection:"column",gap:i.sizing.scale300})),I0=D.styled("div",({$theme:i})=>({alignItems:"center",display:"flex",gap:i.sizing.scale300})),P0=D.styled("div",({$theme:i})=>({display:"flex",alignItems:"center",gap:i.sizing.scale300,marginLeft:"auto"}));function D0({globalFilter:i,setGlobalFilter:e,columnFilters:t,setColumnFilters:n,preFilteredRows:s,configuration:r,filterableColumns:o=[]}){return d.jsxRuntimeExports.jsxs(O0,{children:[d.jsxRuntimeExports.jsxs(I0,{children:[r.enableSearch&&d.jsxRuntimeExports.jsx(j0,{value:i,onChange:e}),r.enableFilters&&o.length>0&&d.jsxRuntimeExports.jsx(M0,{filterableColumns:o,columnFilters:t,setColumnFilters:n,preFilteredRows:s}),r.middle,r.trailing&&d.jsxRuntimeExports.jsx(P0,{children:r.trailing})]}),r.enableFilters&&o.length>0&&d.jsxRuntimeExports.jsx(C0,{filterableColumns:o,preFilteredRows:s})]})}function L0({expanded:i}){const[,e]=D.useStyletron(),t=i?"chevronDown":"chevronRight",n=i?"Collapse":"Expand";return d.jsxRuntimeExports.jsx(d.Icon,{name:t,title:n,size:e.sizing.scale600})}function F0({cell:i,row:e,columnIndex:t}){const[n,s]=D.useStyletron();return i.getIsGrouped()||e.getCanExpand()&&t===0?d.jsxRuntimeExports.jsxs("div",{className:n({display:"flex",alignItems:"center",cursor:"pointer",gap:s.sizing.scale600}),onClick:e.getToggleExpandedHandler(),children:[d.jsxRuntimeExports.jsx(L0,{expanded:e.getIsExpanded()}),go(i.column.columnDef.cell,i.getContext())]}):i.getIsAggregated()?go(i.column.columnDef.aggregatedCell??i.column.columnDef.cell,i.getContext()):i.getIsPlaceholder()?null:go(i.column.columnDef.cell,i.getContext())}function ar(i){return i.map(e=>({id:e.id,cells:e.getAllCells().map((t,n)=>({id:t.id,content:j.createElement(F0,{cell:t,row:e,columnIndex:n}),column:t.column.columnDef.meta,value:t.getValue(),isVisible:t.column.getIsVisible()})),record:e.original,canSelect:e.getCanSelect(),isSelected:e.getIsSelected(),onToggleSelection:t=>e.toggleSelected(t),canExpand:e.getCanExpand(),isExpanded:e.getIsExpanded(),onToggleExpanded:()=>e.toggleExpanded()}))}const N0=D.styled("div",({$theme:i})=>({textAlign:"center",margin:"90px auto",maxWidth:"450px",display:"flex",flexDirection:"column",alignItems:"center",gap:i.sizing.scale600}));function Yt(i){const[e]=D.useStyletron(),{illustration:t,title:n,description:s,buttonConfig:r}=i;return d.jsxRuntimeExports.jsxs(N0,{children:[t,d.jsxRuntimeExports.jsx(bt.HeadingXSmall,{className:e({margin:0}),children:n}),s&&d.jsxRuntimeExports.jsx(bt.ParagraphMedium,{className:e({margin:0}),children:s}),r&&d.jsxRuntimeExports.jsx(_.Button,{...d.lodashExports.omit(r,"content"),kind:_.KIND.secondary,shape:_.SHAPE.pill,children:r.content})]})}const B0=zt.StyledTable,ca=D.withStyle(zt.StyledTableBody,({$theme:i})=>({backgroundColor:i.colors.tableHeadBackgroundColor})),Bh=zt.StyledTableBodyRow,Ui=D.withStyle(zt.StyledTableBodyCell,({$columnNumber:i,$enableRowSelection:e})=>({fontWeight:i===(e?1:0)?500:"normal",verticalAlign:"middle"})),Vh=D.styled("div",{display:"flex",justifyContent:"center"});function ur({children:i}){const[e,t]=D.useStyletron();return d.jsxRuntimeExports.jsx(ca,{children:d.jsxRuntimeExports.jsx(Bh,{children:d.jsxRuntimeExports.jsx(Ui,{colSpan:100,children:d.jsxRuntimeExports.jsx("div",{className:e({padding:t.sizing.scale600}),children:i})})})})}function V0({emptyState:i}){return d.jsxRuntimeExports.jsx(ur,{children:d.jsxRuntimeExports.jsx(Yt,{illustration:i.icon,title:i.title,description:i.content})})}var vt=(i=>(i[i.ERROR=0]="ERROR",i[i.PRIMARY=1]="PRIMARY",i))(vt||{});function pi({width:i="64",height:e="64",kind:t=vt.ERROR}){const[,n]=D.useStyletron(),s=t===vt.ERROR?n.colors.contentNegative:n.colors.contentStateDisabled;return d.jsxRuntimeExports.jsxs("svg",{role:"img","aria-label":"Circle Exclamation Mark icon",viewBox:"0 0 38 38",width:i,height:e,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[d.jsxRuntimeExports.jsx("path",{d:"M19 37.8891C29.4321 37.8891 37.8889 29.4323 37.8889 19.0002C37.8889 8.56817 29.4321 0.111328 19 0.111328C8.56796 0.111328 0.111115 8.56817 0.111115 19.0002C0.111115 29.4323 8.56796 37.8891 19 37.8891Z",fill:s}),d.jsxRuntimeExports.jsx("path",{d:"M18.9999 35.3133C28.0094 35.3133 35.3131 28.0096 35.3131 19.0001C35.3131 9.99065 28.0094 2.68701 18.9999 2.68701C9.99044 2.68701 2.6868 9.99065 2.6868 19.0001C2.6868 28.0096 9.99044 35.3133 18.9999 35.3133Z",fill:"black"}),d.jsxRuntimeExports.jsx("path",{d:"M20.3652 24.5036C20.3652 25.2677 19.7728 25.8601 19.0087 25.8601C18.2446 25.8601 17.635 25.2677 17.635 24.5036C17.635 23.7394 18.2531 23.147 19.0087 23.147C19.7643 23.147 20.3652 23.7394 20.3652 24.5036ZM17.9441 21.9536L17.7552 12.1313H20.2536L20.0647 21.9536H17.9441Z",fill:"white"})]})}function z0({error:i}){switch(i.code){case d.GrpcStatusCode.DEADLINE_EXCEEDED:return d.jsxRuntimeExports.jsx(ur,{children:d.jsxRuntimeExports.jsx(Yt,{illustration:d.jsxRuntimeExports.jsx(pi,{kind:vt.ERROR,height:"64px",width:"64px"}),title:"It took too long to fulfill the request",description:"Try modifying the table filters to reduce the request size."})});case d.GrpcStatusCode.INVALID_ARGUMENT:default:return d.jsxRuntimeExports.jsx(ur,{children:d.jsxRuntimeExports.jsx(Yt,{illustration:d.jsxRuntimeExports.jsx(pi,{kind:vt.ERROR,height:"64px",width:"64px"}),title:"Unable to fetch data for the table",description:"Try reloading the table and retrying the request."})})}}var cr=(i=>(i[i.DEFAULT=0]="DEFAULT",i[i.GREY=1]="GREY",i))(cr||{});const $0={[cr.DEFAULT]:{outlineColor:"safety",questionMarkColor:"white",backgroundColor:"black"},[cr.GREY]:{outlineColor:"tableFilter",questionMarkColor:"white",backgroundColor:"black"}};function _0(i){const[,e]=D.useStyletron(),{kind:t=cr.DEFAULT,height:n="64",width:s="64"}=i,{outlineColor:r,questionMarkColor:o,backgroundColor:l}=$0[t];return d.jsxRuntimeExports.jsxs("svg",{width:s,height:n,viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[d.jsxRuntimeExports.jsx("path",{d:"M9.22954 32.5703L1.11591 18.3516C0.961364 18.1172 0.961364 17.8047 1.11591 17.5703L9.22954 3.39062C9.38409 3.15625 9.61591 3 9.88636 3H26.1136C26.3841 3 26.6545 3.15625 26.7705 3.39062L34.8841 17.6094C35.0386 17.8437 35.0386 18.1562 34.8841 18.3906L26.7705 32.6094C26.6159 32.8437 26.3841 33 26.1136 33H9.88636C9.61591 32.9609 9.34545 32.8437 9.22954 32.5703Z",fill:e.colors[r]}),d.jsxRuntimeExports.jsx("path",{d:"M11.2 29.875L4.43863 18L11.2 6.125H24.8L31.5614 18L24.8 29.875H11.2Z",fill:e.colors[l]}),d.jsxRuntimeExports.jsx("path",{d:"M21.7864 15.3828C21.7864 15.8516 21.7091 16.2813 21.5545 16.6719C21.4 17.0625 21.1682 17.4531 20.8977 17.7656C20.6273 18.0781 20.2795 18.3516 19.8932 18.5469C19.5068 18.7422 19.0818 18.8984 18.6568 18.9375L18.5795 20.5781H16.8023L16.725 17.1797H17.6909C17.9227 17.1797 18.1932 17.1406 18.3864 17.0625C18.6182 16.9844 18.8114 16.8672 18.9659 16.7109C19.1205 16.5547 19.2364 16.3984 19.3523 16.1641C19.4682 15.9688 19.5068 15.7344 19.5068 15.5C19.5068 14.9922 19.3136 14.5625 18.9659 14.2109C18.6182 13.8984 18.1932 13.7031 17.6523 13.7031C17.1886 13.7031 16.7636 13.8203 16.4159 14.0156C16.0682 14.2109 15.7205 14.4844 15.4886 14.8359L13.8273 13.625C14.2909 13.0391 14.8318 12.5703 15.45 12.1797C16.0682 11.8281 16.8409 11.6328 17.7295 11.6328C18.3091 11.6328 18.85 11.7109 19.3136 11.9062C19.8159 12.1016 20.2409 12.375 20.5886 12.6875C20.9364 13 21.2455 13.3906 21.4386 13.8594C21.6705 14.3672 21.7864 14.875 21.7864 15.3828ZM17.6909 21.6719C18.0386 21.6719 18.3477 21.7891 18.5795 22.0234C18.8114 22.2578 18.9273 22.5703 18.9273 22.9219C18.9273 23.2734 18.8114 23.5859 18.5795 23.8203C18.3477 24.0547 18.0386 24.1719 17.6909 24.1719C17.3432 24.1719 17.0341 24.0547 16.8023 23.8203C16.5705 23.5859 16.4159 23.2734 16.4159 22.9219C16.4159 22.5703 16.5318 22.2578 16.8023 22.0234C17.0341 21.7891 17.3432 21.6719 17.6909 21.6719Z",fill:e.colors[o]})]})}function H0({clearFilters:i}){return d.jsxRuntimeExports.jsx(ur,{children:d.jsxRuntimeExports.jsx(Yt,{illustration:d.jsxRuntimeExports.jsx(_0,{}),title:"There is no information available for selected filters",description:"Please change or remove filters to see the information.",buttonConfig:{content:"Clear all filters",onClick:i}})})}function G0(i){if(typeof i.column.tooltip.content=="function"){const e=i.column.tooltip.content;return d.jsxRuntimeExports.jsx(e,{...i})}return d.jsxRuntimeExports.jsx(d.Markdown,{children:i.column.tooltip.content})}function W0(i,e){return i?Array.isArray(i)?i.length===1&&i[0]===e:i===e:!1}function U0(i,e,t,n){return function(r){const{column:o,value:l}=r,{action:a}=o.tooltip;if(a==="filter"&&W0(t,l))return d.jsxRuntimeExports.jsx(i,{...r});const u=()=>{a==="filter"&&n&&n([l])};return d.jsxRuntimeExports.jsx(d.CellTooltipWrapper,{actionHandler:u,content:d.jsxRuntimeExports.jsx(G0,{...r,row:e}),children:d.jsxRuntimeExports.jsx(i,{...r})})}}const q0=150;function K0(i){const e={},t=Object.entries(i.breakpoints);for(const[n,[,s]]of t.entries()){const r=`@media screen and (min-width: ${s}px)`;e[r]={maxWidth:`${q0*(n+1)}px`}}return e}const sl=i=>{const[e,t]=D.useStyletron(),{row:n,record:s,value:r,columnFilterValue:o,setColumnFilterValue:l}=i,u=d.useInterpolationResolver()(aa(i.column,s),{row:s}),c=d.useCellStyles({record:s,style:u.style}),f=d.useGetCellRenderer()({column:u,record:s,value:r}),p=u.tooltip?U0(f,n,o,l):f;return d.jsxRuntimeExports.jsxs(d.CellContainer,{children:[d.jsxRuntimeExports.jsx("div",{className:e({...K0(t),...c}),children:d.jsxRuntimeExports.jsx(p,{column:u,record:s,value:r,CellComponent:sl})}),d.jsxRuntimeExports.jsx(d.CellEnhancer,{endEnhancer:u.endEnhancer})]})};function Y0(i){return e=>{const t=aa(i,e);return"items"in t?t.items.map(n=>d.getObjectValue(e,n.accessor??n.id)).join(nl):d.getObjectValue(e,t.accessor??t.id)}}function X0(i){const e=Nh();return j.useMemo(()=>i.map(t=>{const n=e(t);return{id:t.id,meta:t,accessorFn:Y0(t),header:t.label,cell:s=>d.jsxRuntimeExports.jsx(sl,{column:s.column.columnDef.meta,row:ar([s.row])[0],record:s.row.original,value:s.getValue(),columnFilterValue:s.column.getFilterValue(),setColumnFilterValue:s.column.setFilterValue}),aggregatedCell:s=>t.aggregatedCell?d.jsxRuntimeExports.jsx(t.aggregatedCell,{column:s.column.columnDef.meta,record:s.row.original,value:s.getValue()}):d.jsxRuntimeExports.jsx(sl,{column:s.column.columnDef.meta,row:ar([s.row])[0],record:s.row.original,value:s.getValue(),columnFilterValue:s.column.getFilterValue(),setColumnFilterValue:s.column.setFilterValue}),filterFn:n.buildTableFilterFn(),enableColumnFilters:t.filterMode!==$r.NONE,enableSorting:t.enableSorting??!0,enableGrouping:t.enableGrouping??!1,aggregationFn:t.aggregationFn,sortingFn:t.sortingFn??"auto",sortUndefined:"last"}}),[i,e])}function Q0(i){const{paginationState:e,pageCount:t,gotoPage:n}=i,{pageIndex:s}=e,[r,o]=j.useState(!1);j.useEffect(()=>{const a=s+1>t;s!==0&&a&&(o(!0),n(0))},[s,t,n]),j.useEffect(()=>{r&&s===0&&o(!1)},[r,s]);const l=s+1>t&&s!==0;return{isResetting:r||l}}const zh=Se.createContext({selectedRows:[],selectionEnabled:!1,setSelectionEnabled:()=>null,toggleAllRowsSelected:()=>null,getIsAllRowsSelected:()=>!1,getIsSomeRowsSelected:()=>!1}),J0=()=>Se.useContext(zh);function Z0({children:i,value:e}){return d.jsxRuntimeExports.jsx(zh.Provider,{value:e,children:i})}function ex({state:i,initialState:e}){const[t,n]=j.useState(e.rowSelectionEnabled);return{enableRowSelection:(i.setRowSelectionEnabled?i.rowSelectionEnabled:t)??!1,setRowSelectionEnabled:i.setRowSelectionEnabled??n}}const $h=i=>({width:i.sizing.scale900,minWidth:i.sizing.scale900,maxWidth:i.sizing.scale900});function _h({canSelect:i,isSelected:e,onToggleSelection:t}){if(!i)return null;const n=s=>{s.stopPropagation(),t(s.target.checked)};return d.jsxRuntimeExports.jsx(Ti.Checkbox,{checked:e,onChange:n,overrides:{Root:{style:{alignItems:"center"}}}})}function tx(i){const[e,t]=j.useState(!1);return j.useEffect(()=>{const n=i.current;if(!n)return;const s=()=>t(!0),r=()=>t(!1);return n.addEventListener("mouseenter",s),n.addEventListener("mouseleave",r),()=>{n.removeEventListener("mouseenter",s),n.removeEventListener("mouseleave",r)}},[i]),e}const ix={left:{right:"auto",left:"-7px",getOpacity:i=>i===-1?0:1-i},right:{right:"-7px",left:"auto",getOpacity:i=>i===-1?0:i}};function nx(i,e){if(i==="none")return{};const{getOpacity:t,...n}=ix[i];return{"::before":{...n,content:'" "',position:"absolute",top:0,bottom:0,width:"7px",opacity:Math.ceil(t(e)),transition:"opacity 0.2s ease",background:`linear-gradient(to ${i}, rgba(0,0,0, 0.15), rgba(0, 0, 0, 0) 4px)`}}}const sx=56;function rx(i,e){const t={};return i?(t[0]={stickySide:"left",position:0,shadowSide:"none"},t[1]={stickySide:"left",position:sx,shadowSide:"right"}):t[1]={stickySide:"left",position:0,shadowSide:"right"},t[e]={stickySide:"right",position:0,shadowSide:"left"},t}function Hh(i){return function(t){const{enableStickySides:n,enableRowSelection:s,lastColumnIndex:r,scrollRatio:o=-1,role:l,children:a,...u}=t,[c,h]=D.useStyletron(),f=j.useRef(null),p=tx(f);if(!n)return d.jsxRuntimeExports.jsx(i,{...u,children:a});const m={position:"sticky !important",backgroundColor:`${p&&l==="row"?h.colors.tableStripedBackground:h.colors.tableHeadBackgroundColor} !important`},x=rx(s,r);return d.jsxRuntimeExports.jsx(i,{...u,ref:f,children:j.Children.map(a,(y,b)=>{const v=x[b];if(!v||!j.isValidElement(y))return y;const w={...m,[v.stickySide]:`${v.position}px !important`};return j.cloneElement(y,{className:`${c(w)} ${c(nx(v.shadowSide,o))}`,"data-testid":`sticky-cell-${v.stickySide}-sticky`})})})}}const ox=Hh(zt.StyledTableBodyRow),lx=({rows:i,enableRowSelection:e,enableStickySides:t,scrollRatio:n,subRow:s,actions:r})=>{const[o,l]=D.useStyletron(),a=i[0].cells.filter(u=>u.isVisible).length+1;return d.jsxRuntimeExports.jsx(ca,{children:i.map(u=>d.jsxRuntimeExports.jsxs(j.Fragment,{children:[d.jsxRuntimeExports.jsxs(ox,{enableStickySides:t,enableRowSelection:e,lastColumnIndex:a,scrollRatio:n,role:"row",children:[e&&d.jsxRuntimeExports.jsx(Ui,{className:o($h(l)),children:d.jsxRuntimeExports.jsx(_h,{canSelect:u.canSelect??!1,isSelected:u.isSelected??!1,onToggleSelection:u.onToggleSelection??(()=>{})})}),u.cells.filter(c=>c.isVisible).map((c,h)=>d.jsxRuntimeExports.jsx(Ui,{$columnNumber:h,$enableRowSelection:e,children:c.content},c.id)),d.jsxRuntimeExports.jsx(Ui,{children:d.jsxRuntimeExports.jsx(Vh,{children:r&&j.createElement(r,{row:u})})})]}),s&&u.isExpanded&&d.jsxRuntimeExports.jsx(zt.StyledTableBodyRow,{children:d.jsxRuntimeExports.jsx(Ui,{colSpan:u.cells.filter(c=>c.isVisible).length+(e?2:1),children:j.createElement(s,{row:u})})})]},u.id))})};function ax(i,e,t){return n=>{const s=n.newIndex===-1,r=n.oldIndex+1,o=n.newIndex+1;if(s){const l=i[r];t(a=>({...a,[l.id]:!l.isVisible}))}else e(Ws.arrayMove(i.map(l=>l.id),r,o))}}function ux({columns:i,setColumnOrder:e,setColumnVisibility:t}){const[n,s]=D.useStyletron(),r=ax(i,e,t);return d.jsxRuntimeExports.jsx(Nt.StatefulPopover,{placement:Nt.PLACEMENT.bottomRight,content:()=>d.jsxRuntimeExports.jsx("div",{className:n({backgroundColor:s.colors.backgroundPrimary,borderRadius:s.borders.radius300,width:"214px",display:"flex",flexDirection:"column"}),children:d.jsxRuntimeExports.jsx(Ws.List,{removable:!0,overrides:{Item:{style:{height:s.sizing.scale800}},Label:{component:o=>d.jsxRuntimeExports.jsx(Ws.StyledLabel,{...o,children:o.$value.label})},CloseHandle:{component:o=>d.jsxRuntimeExports.jsx(Ws.StyledCloseHandle,{...o,children:d.jsxRuntimeExports.jsx(Ti.Checkbox,{checked:o.$value.isVisible,disabled:!o.$value.canHide,title:`Toggle ${o.$value.label}`})})}},onChange:r,items:i.slice(1)})}),children:d.jsxRuntimeExports.jsx(_.Button,{title:"Configure columns",size:_.SIZE.mini,kind:_.KIND.tertiary,children:d.jsxRuntimeExports.jsx(d.Icon,{name:"settings"})})})}function cx(i){const{column:e}=i,t=e.getIsSorted(),n=t==="desc"?"sortDescending":"sortAscending",s=t?d.IconKind.ACCENT:d.IconKind.TERTIARY;return d.jsxRuntimeExports.jsx(d.Icon,{name:n,kind:s,title:"Toggle Sort"})}const rl=D.withStyle(zt.StyledTableHeadCell,({$theme:i})=>({zIndex:"unset",position:"inherit",...i.typography.LabelSmall})),hx=D.withStyle(zt.StyledTableHeadCellSortable,({$theme:i})=>({zIndex:"unset",position:"inherit",...i.typography.LabelSmall})),fx=D.withStyle(rl,{padding:0}),dx=Hh(zt.StyledTableHeadRow),px=({columns:i,setColumnOrder:e,setColumnVisibility:t,enableRowSelection:n,isSelected:s,onToggleSelection:r,enableStickySides:o,scrollRatio:l})=>{const[a,u]=D.useStyletron();return d.jsxRuntimeExports.jsx(zt.StyledTableHead,{children:d.jsxRuntimeExports.jsxs(dx,{enableStickySides:o,enableRowSelection:n,lastColumnIndex:i.filter(c=>c.isVisible).length+1,scrollRatio:l,role:"header",children:[n&&d.jsxRuntimeExports.jsx(rl,{role:"columnheader",className:a($h(u)),children:d.jsxRuntimeExports.jsx(_h,{canSelect:n,isSelected:s,onToggleSelection:r})}),i.filter(c=>c.isVisible).map(c=>c.canSort?d.jsxRuntimeExports.jsx(hx,{$isFocusVisible:!1,onClick:c.onToggleSort,role:"columnheader",children:d.jsxRuntimeExports.jsxs("div",{className:a({display:"flex",alignItems:"center",gap:u.sizing.scale300}),children:[d.jsxRuntimeExports.jsx("div",{children:c.label}),d.jsxRuntimeExports.jsx(cx,{column:{getIsSorted:()=>c.sortDirection??!1}})]})},c.id):d.jsxRuntimeExports.jsx(rl,{role:"columnheader",children:c.label},c.id)),e&&t&&d.jsxRuntimeExports.jsx(fx,{role:"columnheader",children:d.jsxRuntimeExports.jsx(Vh,{children:d.jsxRuntimeExports.jsx(ux,{columns:i,setColumnOrder:e,setColumnVisibility:t})})})]})})};function gx(){return d.jsxRuntimeExports.jsx(ca,{"aria-label":"Loading",children:[1,2,3].map(i=>d.jsxRuntimeExports.jsx(Bh,{children:d.jsxRuntimeExports.jsx(Ui,{colSpan:100,children:d.jsxRuntimeExports.jsx(Jg.Skeleton,{animation:!0,width:"100%",height:"22px"})})},i))})}function mx(i){const{pageSizes:e,state:t,setPageSize:n}=i,{pageSize:s}=t,[r,o]=D.useStyletron(),l=e.find(a=>a.id===s);return d.jsxRuntimeExports.jsxs("div",{className:r({...o.typography.LabelMedium,display:"flex",gap:o.sizing.scale600,alignItems:"center"}),children:[d.jsxRuntimeExports.jsx("div",{className:r({minWidth:"fit-content",paddingLeft:o.sizing.scale600}),children:"Rows per page"}),d.jsxRuntimeExports.jsx(Ji.Select,{placeholder:"","aria-label":"Select rows per page",clearable:!1,searchable:!1,options:e,value:l?[l]:[],onChange:({option:a})=>n(Number((a==null?void 0:a.id)??s)),overrides:{Root:{props:{"aria-label":"Select rows per page"}},ControlContainer:{style:({$theme:a})=>({borderColor:"transparent",backgroundColor:a.colors.buttonTertiaryFill,":hover":{backgroundColor:a.colors.buttonTertiaryHover}})},SingleValue:{style:({$theme:a})=>({color:a.colors.buttonTertiaryText,paddingLeft:a.sizing.scale200,paddingRight:a.sizing.scale500})}}})]})}function xx(i){const{state:e,pageCount:t,gotoPage:n,fetchPlugin:s}=i,{pageIndex:r}=e,[o]=D.useStyletron(),l=Math.min(r+1,t);return d.jsxRuntimeExports.jsxs("div",{className:o({display:"flex",justifyContent:"space-between",width:"100%",alignItems:"center"}),children:[d.jsxRuntimeExports.jsx(mx,{pageSizes:i.pageSizes,state:i.state,setPageSize:i.setPageSize}),d.jsxRuntimeExports.jsx(Zg.Pagination,{numPages:t,currentPage:l,onPageChange:({nextPage:a})=>{s&&a===t&&s.fetchNextPage(),n(Math.max(0,a-1))},overrides:{Root:{style:{display:"flex",justifyContent:"flex-end"}},MaxLabel:s?{component:()=>null}:{},NextButton:s!=null&&s.isFetchNextPageInProgress?{component:yx}:{}}})]})}function yx(){return d.jsxRuntimeExports.jsx(_.Button,{isLoading:!0,kind:_.KIND.tertiary,children:"Next"})}function bx(i,e){const t=e[0].id;return i==null||i<=t?t:(e.find(r=>i<=r.id)??e[e.length-1]).id}function vx(i){const e=i.disablePagination??!1,t=i.disableSorting??!1,n=i.pageSizes??d0;return{...i,emptyState:i.emptyState??{icon:d.jsxRuntimeExports.jsx(pi,{kind:vt.PRIMARY,height:"64px",width:"64px"}),title:"No data",content:"No data is present."},loading:i.loading??!1,loadingView:i.loadingView??gx,error:i.error??void 0,actionBarConfig:{enableSearch:!0,enableFilters:!0,...i.actionBarConfig},disablePagination:e,disableSorting:t,pageSizes:n,state:Sx(i.state,e,n),pagination:i.pagination??xx,enableStickySides:i.enableStickySides??!0,body:i.body??lx,header:i.header??px,unFilteredData:i.unFilteredData??i.data}}function Sx(i,e,t){var o;const n={...i,rowSelectionEnabled:(i==null?void 0:i.rowSelectionEnabled)??!1};if(e){const{pagination:l,setPagination:a,...u}=n;return u}const s=(o=n==null?void 0:n.pagination)==null?void 0:o.pageSize,r=bx(s,t);return{...n,pagination:{pageIndex:0,...n==null?void 0:n.pagination,pageSize:r}}}const hu={globalFilter:"setGlobalFilter",columnFilters:"setColumnFilters",pagination:"setPagination",sorting:"setSorting",columnOrder:"setColumnOrder",columnVisibility:"setColumnVisibility",rowSelection:"setRowSelection",rowSelectionEnabled:"setRowSelectionEnabled",grouping:"setGrouping"};function Cx(i){const e={},t={},n=Object.keys(hu);for(const s of n){const r=hu[s];r in i?(s in i||console.warn(`Controlled state setter ${r} must be accompanied by property ${s}`),e[s]=i[s],e[r]=i[r]):s in i&&(t[s]=i[s])}return{initialState:t,state:e}}function wx(i){const{loading:e,dataLength:t,error:n,hasFiltersApplied:s,filteredLength:r,columnsLength:o}=i;return e?"loading":n?"error":o===0?"no-columns":t===0?"empty":s&&r===0?"filtered-empty":"ready"}function Gh(i,e,t){return i.getValue(e)?d.safeStringify(i.getValue(e)).toLowerCase().includes(t.toLowerCase()):!1}Gh.autoRemove=i=>i==null;function Ex(i){return i.map(e=>{const t=e.columnDef.meta,n=t.label??e.id;return{...t,label:n,type:t.type??d.CellType.TEXT,canFilter:e.getCanFilter(),getFilterValue:e.getFilterValue,setFilterValue:e.setFilterValue,canSort:e.getCanSort(),onToggleSort:e.getToggleSortingHandler()??(()=>{}),sortDirection:e.getIsSorted(),canHide:e.getCanHide(),isVisible:e.getIsVisible()}})}function _r(i){var y,b,v,w;const e=vx(i),t=X0(e.columns),[n,s]=D.useStyletron(),{state:r,initialState:o}=Cx(e.state??{}),{enableRowSelection:l,setRowSelectionEnabled:a}=ex({state:r,initialState:o}),{scrollRatio:u,tableRef:c,handleScrollRatioUpdate:h}=h0(t),f=c0({data:e.data,columns:t,initialState:o,...Object.keys(r).length>0&&{state:r},...r.setGlobalFilter?{onGlobalFilterChange:r.setGlobalFilter}:{},...r.setColumnFilters?{onColumnFiltersChange:r.setColumnFilters}:{},...r.setPagination?{onPaginationChange:r.setPagination}:{},...r.setSorting?{onSortingChange:r.setSorting}:{},...r.setColumnOrder?{onColumnOrderChange:r.setColumnOrder}:{},...r.setColumnVisibility?{onColumnVisibilityChange:r.setColumnVisibility}:{},...r.setRowSelection?{onRowSelectionChange:r.setRowSelection}:{},getCoreRowModel:Jm(),getFilteredRowModel:i0(),...e.disableSorting?{enableSorting:!1}:{getSortedRowModel:o0()},...e.disablePagination?{}:{getPaginationRowModel:r0()},...(y=o.grouping)!=null&&y.length||(b=r.grouping)!=null&&b.length?{getGroupedRowModel:n0(),getExpandedRowModel:uu()}:{},...e.subRow?{getExpandedRowModel:uu(),getRowCanExpand:()=>!0}:{},enableRowSelection:l,getColumnCanGlobalFilter:()=>!0,globalFilterFn:Gh,autoResetPageIndex:!1}),p=Ex(f.getAllLeafColumns()),{isResetting:g}=Q0({gotoPage:f.setPageIndex,pageCount:f.getPageCount(),paginationState:f.getState().pagination}),m=wx({dataLength:e.data.length,error:e.error,loading:e.loading||g,hasFiltersApplied:((v=f.getState().globalFilter)==null?void 0:v.length)>0||(((w=f.getState().columnFilters)==null?void 0:w.length)??0)>0,filteredLength:f.getRowModel().rows.length,columnsLength:t.length}),x=e.unFilteredData.map(S=>({getValue:E=>{const A=t.find(O=>O.id===E);if(A)return A.accessorFn(S)},record:S}));return d.jsxRuntimeExports.jsx("div",{className:n({display:"flex",flexDirection:"column",gap:s.sizing.scale400}),children:d.jsxRuntimeExports.jsxs(Z0,{value:{selectedRows:ar(f.getSelectedRowModel().flatRows),selectionEnabled:l,setSelectionEnabled:a,toggleAllRowsSelected:S=>f.toggleAllRowsSelected(S),getIsAllRowsSelected:()=>f.getIsAllRowsSelected(),getIsSomeRowsSelected:()=>f.getIsSomeRowsSelected()},children:[d.jsxRuntimeExports.jsx(D0,{globalFilter:f.getState().globalFilter,setGlobalFilter:f.setGlobalFilter,columnFilters:f.getState().columnFilters,setColumnFilters:f.setColumnFilters,preFilteredRows:x,configuration:e.actionBarConfig,filterableColumns:p.filter(S=>S.canFilter&&S.filterMode!==$r.NONE)}),d.jsxRuntimeExports.jsx("div",{className:n({overflow:"auto",position:"relative"}),ref:c,onScroll:h,children:d.jsxRuntimeExports.jsxs(B0,{children:[m==="loading"&&d.jsxRuntimeExports.jsx(e.loadingView,{}),m==="error"&&d.jsxRuntimeExports.jsx(z0,{error:e.error}),(m==="empty"||m==="no-columns")&&d.jsxRuntimeExports.jsx(V0,{emptyState:e.emptyState}),m==="filtered-empty"&&d.jsxRuntimeExports.jsx(H0,{clearFilters:()=>{f.setGlobalFilter(""),f.setColumnFilters([])}}),m!=="error"&&m!=="no-columns"&&d.jsxRuntimeExports.jsx(e.header,{columns:p,setColumnOrder:f.setColumnOrder,setColumnVisibility:f.setColumnVisibility,enableRowSelection:l,isSelected:f.getIsAllRowsSelected(),onToggleSelection:S=>f.toggleAllRowsSelected(S),enableStickySides:e.enableStickySides,scrollRatio:u}),m==="ready"&&d.jsxRuntimeExports.jsx(e.body,{rows:ar(f.getRowModel().rows),enableRowSelection:l,enableStickySides:e.enableStickySides,scrollRatio:u,subRow:e.subRow,actions:e.actions})]})}),!e.disablePagination&&m==="ready"&&f.getPreFilteredRowModel().rows.length>Math.min(...e.pageSizes.map(S=>S.id))&&d.jsxRuntimeExports.jsx(e.pagination,{gotoPage:f.setPageIndex,pageCount:f.getPageCount(),setPageSize:f.setPageSize,state:f.getState().pagination,pageSizes:e.pageSizes,fetchPlugin:e.fetchPlugin})]})})}function Rx(){const[i,e]=D.useStyletron(),{data:t,isLoading:n}=d.useStudioQuery({queryName:"ListProject",serviceOptions:{namespace:""}});return d.jsxRuntimeExports.jsx("div",{className:i({marginTop:e.sizing.scale400}),children:d.jsxRuntimeExports.jsx(_r,{data:(t==null?void 0:t.projectList.items)??[],columns:wh,loading:n})})}const kx=({label:i,required:e,description:t})=>{const[n,s]=D.useStyletron();return d.jsxRuntimeExports.jsxs("span",{className:n({display:"flex",gap:s.sizing.scale200,minHeight:s.sizing.scale600,alignItems:"center"}),children:[i,e?d.jsxRuntimeExports.jsx("span",{className:n({color:s.colors.negative}),children:"*"}):null,t?d.jsxRuntimeExports.jsx(d.HelpTooltip,{text:t}):null]})},Ax=({counter:i,labelEndEnhancer:e})=>{const[t,n]=D.useStyletron();return d.jsxRuntimeExports.jsxs(d.jsxRuntimeExports.Fragment,{children:[i&&d.jsxRuntimeExports.jsxs("span",{className:t({...n.typography.font100,color:n.colors.contentPrimary}),children:[i.length,"/",i.maxLength]}),e]})},Je=({label:i,required:e,description:t,labelEndEnhancer:n,caption:s,error:r,counter:o,children:l})=>{const[a,u]=D.useStyletron(),c=o||n?d.jsxRuntimeExports.jsx(Ax,{counter:o,labelEndEnhancer:n}):void 0;return d.jsxRuntimeExports.jsx("div",{className:a({width:"100%"}),children:d.jsxRuntimeExports.jsx(em.FormControl,{label:i&&d.jsxRuntimeExports.jsx(kx,{label:i,required:e,description:t}),labelEndEnhancer:c,caption:s&&d.jsxRuntimeExports.jsx(d.TruncatedText,{children:d.jsxRuntimeExports.jsx(d.Markdown,{children:s})}),error:r,overrides:{ControlContainer:{style:{marginBottom:0}},LabelEndEnhancer:{style:{display:"flex",alignItems:"center",gap:u.sizing.scale300}},Caption:{style:({$error:h,$positive:f})=>({display:h||f?"flex":"block"})}},children:l})})};function be(){return be=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},be.apply(null,arguments)}function Hr(i,e){if(i==null)return{};var t={};for(var n in i)if({}.hasOwnProperty.call(i,n)){if(e.indexOf(n)!==-1)continue;t[n]=i[n]}return t}var Tx=46,Mx=/\\(\\)?/g,jx=RegExp(`[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,"g"),Ox=function(e){var t=[];return e.charCodeAt(0)===Tx&&t.push(""),e.replace(jx,function(n,s,r,o){var l=n;r?l=o.replace(Mx,"$1"):s&&(l=s.trim()),t.push(l)}),t},bs={},Ix=/[.[\]]+/,Wh=function(e){if(e==null||!e.length)return[];if(typeof e!="string")throw new Error("toPath() expects a string");return bs[e]==null&&(e.endsWith("[]")?bs[e]=e.split(Ix).filter(Boolean):bs[e]=Ox(e)),bs[e]},ge=function(e,t){for(var n=Wh(t),s=e,r=0;r<n.length;r++){var o=n[r];if(s==null||typeof s!="object"||Array.isArray(s)&&isNaN(o))return;s=s[o]}return s};function Px(i){var e=Dx(i,"string");return typeof e=="symbol"?e:String(e)}function Dx(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(i)}var Lx=function i(e,t,n,s,r){if(t>=n.length)return s;var o=n[t];if(isNaN(o)){var l;if(e==null){var a,u=i(void 0,t+1,n,s,r);return u===void 0?void 0:(a={},a[o]=u,a)}if(Array.isArray(e))throw new Error("Cannot set a non-numeric property on an array");var c=i(e[o],t+1,n,s,r);if(c===void 0){var h=Object.keys(e).length;if(e[o]===void 0&&h===0)return;if(e[o]!==void 0&&h<=1)return!isNaN(n[t-1])&&!r?{}:void 0;e[o];var f=Hr(e,[o].map(Px));return f}return be({},e,(l={},l[o]=c,l))}var p=Number(o);if(e==null){var g=i(void 0,t+1,n,s,r);if(g===void 0)return;var m=[];return m[p]=g,m}if(!Array.isArray(e))throw new Error("Cannot set a numeric property on an object");var x=e[p],y=i(x,t+1,n,s,r),b=[].concat(e);if(r&&y===void 0){if(b.splice(p,1),b.length===0)return}else b[p]=y;return b},lt=function(e,t,n,s){if(s===void 0&&(s=!1),e==null)throw new Error("Cannot call setIn() with "+String(e)+" state");if(t==null)throw new Error("Cannot call setIn() with "+String(t)+" key");return Lx(e,0,Wh(t),n,s)},_n="FINAL_FORM/form-error",Zi="FINAL_FORM/array-error";function fu(i,e){var t=i.errors,n=i.initialValues,s=i.lastSubmittedValues,r=i.submitErrors,o=i.submitFailed,l=i.submitSucceeded,a=i.submitting,u=i.values,c=e.active,h=e.blur,f=e.change,p=e.data,g=e.focus,m=e.modified,x=e.modifiedSinceLastSubmit,y=e.name,b=e.touched,v=e.validating,w=e.visited,S=ge(u,y),E=ge(t,y);E&&E[Zi]&&(E=E[Zi]);var A=r&&ge(r,y),O=n&&ge(n,y),R=e.isEqual(O,S),H=!!(s&&!e.isEqual(ge(s,y),S)),N=!E&&!A;return{active:c,blur:h,change:f,data:p,dirty:!R,dirtySinceLastSubmit:H,error:E,focus:g,initial:O,invalid:!N,length:Array.isArray(S)?S.length:void 0,modified:m,modifiedSinceLastSubmit:x,name:y,pristine:R,submitError:A,submitFailed:o,submitSucceeded:l,submitting:a,touched:b,valid:N,value:S,visited:w,validating:v}}var ha=["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","modified","modifiedSinceLastSubmit","pristine","submitError","submitFailed","submitSucceeded","submitting","touched","valid","value","visited","validating"],Ot=function(e,t){if(e===t)return!0;if(typeof e!="object"||!e||typeof t!="object"||!t)return!1;var n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(var r=Object.prototype.hasOwnProperty.bind(t),o=0;o<n.length;o++){var l=n[o];if(!r(l)||e[l]!==t[l])return!1}return!0};function Uh(i,e,t,n,s,r){var o=!1;return s.forEach(function(l){n[l]&&(i[l]=e[l],(!t||(~r.indexOf(l)?!Ot(e[l],t[l]):e[l]!==t[l]))&&(o=!0))}),o}var Fx=["data"],Nx=function(e,t,n,s){var r={blur:e.blur,change:e.change,focus:e.focus,name:e.name},o=Uh(r,e,t,n,ha,Fx)||!t;return o||s?r:void 0},qh=["active","dirty","dirtyFields","dirtyFieldsSinceLastSubmit","dirtySinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","modified","modifiedSinceLastSubmit","pristine","submitting","submitError","submitErrors","submitFailed","submitSucceeded","touched","valid","validating","values","visited"],Bx=["touched","visited"];function du(i,e,t,n){var s={},r=Uh(s,i,e,t,qh,Bx)||!e;return r||n?s:void 0}var pu=function(e){var t,n;return function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return(!t||r.length!==t.length||r.some(function(l,a){return!Ot(t[a],l)}))&&(t=r,n=e.apply(void 0,r)),n}},mo=(function(i){return!!i&&(typeof i=="object"||typeof i=="function")&&typeof i.then=="function"}),Vx="4.20.10",zx=function(e,t){return e===t},qi=function i(e){return Object.keys(e).some(function(t){var n=e[t];return n&&typeof n=="object"&&!(n instanceof Error)?i(n):typeof n<"u"})};function $x(i){var e=i.active,t=i.dirtySinceLastSubmit,n=i.modifiedSinceLastSubmit,s=i.error,r=i.errors,o=i.initialValues,l=i.pristine,a=i.submitting,u=i.submitFailed,c=i.submitSucceeded,h=i.submitError,f=i.submitErrors,p=i.valid,g=i.validating,m=i.values;return{active:e,dirty:!l,dirtySinceLastSubmit:t,modifiedSinceLastSubmit:n,error:s,errors:r,hasSubmitErrors:!!(h||f&&qi(f)),hasValidationErrors:!!(s||qi(r)),invalid:!p,initialValues:o,pristine:l,submitting:a,submitFailed:u,submitSucceeded:c,submitError:h,submitErrors:f,valid:p,validating:g>0,values:m}}function Kh(i,e,t,n,s,r){var o=s(t,n,e,r);return o?(i(o),!0):!1}function gu(i,e,t,n,s){var r=i.entries;Object.keys(r).forEach(function(o){var l=r[Number(o)];if(l){var a=l.subscription,u=l.subscriber,c=l.notified;Kh(u,a,e,t,n,s||!c)&&(l.notified=!0)}})}function _x(i){if(!i)throw new Error("No config specified");var e=i.debug,t=i.destroyOnUnregister,n=i.keepDirtyOnReinitialize,s=i.initialValues,r=i.mutators,o=i.onSubmit,l=i.validate,a=i.validateOnBlur;if(!o)throw new Error("No onSubmit function specified");var u={subscribers:{index:0,entries:{}},fieldSubscribers:{},fields:{},formState:{asyncErrors:{},dirtySinceLastSubmit:!1,modifiedSinceLastSubmit:!1,errors:{},initialValues:s&&be({},s),invalid:!1,pristine:!0,submitting:!1,submitFailed:!1,submitSucceeded:!1,resetWhileSubmitting:!1,valid:!0,validating:0,values:s?be({},s):{}},lastFormState:void 0},c=0,h=!1,f=!1,p=!1,g=0,m={},x=function(C){return function(M){return delete m[C],M}},y=function(C,M,L){var F=ge(C.formState.values,M),X=L(F);C.formState.values=lt(C.formState.values,M,X)||{}},b=function(C,M,L){if(C.fields[M]){var F,X;C.fields=be({},C.fields,(F={},F[L]=be({},C.fields[M],{name:L,blur:function(){return ee.blur(L)},change:function(ue){return ee.change(L,ue)},focus:function(){return ee.focus(L)},lastFieldState:void 0}),F)),delete C.fields[M],C.fieldSubscribers=be({},C.fieldSubscribers,(X={},X[L]=C.fieldSubscribers[M],X)),delete C.fieldSubscribers[M];var Z=ge(C.formState.values,M);C.formState.values=lt(C.formState.values,M,void 0)||{},C.formState.values=lt(C.formState.values,L,Z),delete C.lastFormState}},v=function(C){return function(){if(r){for(var M={formState:u.formState,fields:u.fields,fieldSubscribers:u.fieldSubscribers,lastFormState:u.lastFormState},L=arguments.length,F=new Array(L),X=0;X<L;X++)F[X]=arguments[X];var Z=r[C](F,M,{changeValue:y,getIn:ge,renameField:b,resetFieldState:ee.resetFieldState,setIn:lt,shallowEqual:Ot});return u.formState=M.formState,u.fields=M.fields,u.fieldSubscribers=M.fieldSubscribers,u.lastFormState=M.lastFormState,O(void 0,function(){R(),Q()}),Z}}},w=r?Object.keys(r).reduce(function(G,C){return G[C]=v(C),G},{}):{},S=function(C){var M=[];if(l){var L=l(be({},u.formState.values));mo(L)?M.push(L.then(function(F){return C(F,!0)})):C(L,!1)}return M},E=function(C){return Object.keys(C.validators).reduce(function(M,L){var F=C.validators[Number(L)]();return F&&M.push(F),M},[])},A=function(C,M){var L=[],F=E(C);if(F.length){var X;F.forEach(function(Z){var ae=Z(ge(u.formState.values,C.name),u.formState.values,Z.length===0||Z.length===3?fu(u.formState,u.fields[C.name]):void 0);if(ae&&mo(ae)){C.validating=!0;var ue=ae.then(function(le){u.fields[C.name]&&(u.fields[C.name].validating=!1,M(le))});L.push(ue)}else X||(X=ae)}),M(X)}return L},O=function(C,M){if(h){f=!0,M();return}var L=u.fields,F=u.formState,X=be({},L),Z=Object.keys(X);if(!l&&!Z.some(function(ti){return E(X[ti]).length})){M();return}var ae=!1;if(C){var ue=X[C];if(ue){var le=ue.validateFields;le&&(ae=!0,Z=le.length?le.concat(C):[C])}}var ke={},Be={},mt={},ei=[].concat(S(function(ti,Si){Si?Be=ti||{}:ke=ti||{}}),Z.reduce(function(ti,Si){return ti.concat(A(L[Si],function(Rt){mt[Si]=Rt}))},[])),je=ei.length>0,we=++g,zi=Promise.all(ei).then(x(we));je&&(m[we]=zi);var iu=function(Si){var Rt=be({},ae?F.errors:{},ke,Si?Be:F.asyncErrors),su=function(Ci){Z.forEach(function(ii){if(L[ii]){var Cn=ge(ke,ii),Ug=ge(Rt,ii),qg=E(X[ii]).length,Kg=mt[ii];Ci(ii,qg&&Kg||l&&Cn||(!Cn&&!ae?Ug:void 0))}})};su(function(Sn,Ci){Rt=lt(Rt,Sn,Ci)||{}}),su(function(Sn,Ci){if(Ci&&Ci[Zi]){var ii=ge(Rt,Sn),Cn=[].concat(ii);Cn[Zi]=Ci[Zi],Rt=lt(Rt,Sn,Cn)}}),Ot(F.errors,Rt)||(F.errors=Rt),Si&&(F.asyncErrors=Be),F.error=ke[_n]};if(je&&(u.formState.validating++,M()),iu(!1),M(),je){var nu=function(){u.formState.validating--,M(),u.formState.validating===0&&u.lastFormState.validating&&Q()};zi.then(function(){g>we||iu(!0)}).then(nu,nu)}},R=function(C){if(!c){var M=u.fields,L=u.fieldSubscribers,F=u.formState,X=be({},M),Z=function(ue){var le=X[ue],ke=fu(F,le),Be=le.lastFieldState;le.lastFieldState=ke;var mt=L[ue];mt&&gu(mt,ke,Be,Nx,Be===void 0)};C?Z(C):Object.keys(X).forEach(Z)}},H=function(){Object.keys(u.fields).forEach(function(C){u.fields[C].touched=!0})},N=function(){return!!(u.formState.error||qi(u.formState.errors))},I=function(){var C=u.fields,M=u.formState,L=u.lastFormState,F=be({},C),X=Object.keys(F),Z=!1,ae=X.reduce(function(je,we){var zi=!F[we].isEqual(ge(M.values,we),ge(M.initialValues||{},we));return zi&&(Z=!0,je[we]=!0),je},{}),ue=X.reduce(function(je,we){var zi=M.lastSubmittedValues||{};return F[we].isEqual(ge(M.values,we),ge(zi,we))||(je[we]=!0),je},{});M.pristine=!Z,M.dirtySinceLastSubmit=!!(M.lastSubmittedValues&&Object.values(ue).some(function(je){return je})),M.modifiedSinceLastSubmit=!!(M.lastSubmittedValues&&Object.keys(F).some(function(je){return F[je].modifiedSinceLastSubmit})),M.valid=!M.error&&!M.submitError&&!qi(M.errors)&&!(M.submitErrors&&qi(M.submitErrors));var le=$x(M),ke=X.reduce(function(je,we){return je.modified[we]=F[we].modified,je.touched[we]=F[we].touched,je.visited[we]=F[we].visited,je},{modified:{},touched:{},visited:{}}),Be=ke.modified,mt=ke.touched,ei=ke.visited;return le.dirtyFields=L&&Ot(L.dirtyFields,ae)?L.dirtyFields:ae,le.dirtyFieldsSinceLastSubmit=L&&Ot(L.dirtyFieldsSinceLastSubmit,ue)?L.dirtyFieldsSinceLastSubmit:ue,le.modified=L&&Ot(L.modified,Be)?L.modified:Be,le.touched=L&&Ot(L.touched,mt)?L.touched:mt,le.visited=L&&Ot(L.visited,ei)?L.visited:ei,L&&Ot(L,le)?L:le},W=function(){return e&&!0&&e(I(),Object.keys(u.fields).reduce(function(C,M){return C[M]=u.fields[M],C},{}))},P=!1,U=!1,Q=function G(){if(P)U=!0;else{if(P=!0,W(),!c&&!(h&&p)){var C=u.lastFormState,M=I();M!==C&&(u.lastFormState=M,gu(u.subscribers,M,C,du))}P=!1,U&&(U=!1,G())}},he=function(){return Object.keys(u.fields).some(function(C){return u.fields[C].beforeSubmit&&u.fields[C].beforeSubmit()===!1})},pe=function(){return Object.keys(u.fields).forEach(function(C){return u.fields[C].afterSubmit&&u.fields[C].afterSubmit()})},ie=function(){return Object.keys(u.fields).forEach(function(C){return u.fields[C].modifiedSinceLastSubmit=!1})};O(void 0,function(){Q()});var ee={batch:function(C){c++,C(),c--,R(),Q()},blur:function(C){var M=u.fields,L=u.formState,F=M[C];F&&(delete L.active,M[C]=be({},F,{active:!1,touched:!0}),a?O(C,function(){R(),Q()}):(R(),Q()))},change:function(C,M){var L=u.fields,F=u.formState;if(ge(F.values,C)!==M){y(u,C,function(){return M});var X=L[C];X&&(L[C]=be({},X,{modified:!0,modifiedSinceLastSubmit:!!F.lastSubmittedValues})),a?(R(),Q()):O(C,function(){R(),Q()})}},get destroyOnUnregister(){return!!t},set destroyOnUnregister(G){t=G},focus:function(C){var M=u.fields[C];M&&!M.active&&(u.formState.active=C,M.active=!0,M.visited=!0,R(),Q())},mutators:w,getFieldState:function(C){var M=u.fields[C];return M&&M.lastFieldState},getRegisteredFields:function(){return Object.keys(u.fields)},getState:function(){return I()},initialize:function(C){var M=u.fields,L=u.formState,F=be({},M),X=typeof C=="function"?C(L.values):C;n||(L.values=X);var Z=n?Object.keys(F).reduce(function(ae,ue){var le=F[ue],ke=le.isEqual(ge(L.values,ue),ge(L.initialValues||{},ue));return ke||(ae[ue]=ge(L.values,ue)),ae},{}):{};L.initialValues=X,L.values=X,Object.keys(Z).forEach(function(ae){L.values=lt(L.values,ae,Z[ae])||{}}),O(void 0,function(){R(),Q()})},isValidationPaused:function(){return h},pauseValidation:function(C){C===void 0&&(C=!0),h=!0,p=C},registerField:function(C,M,L,F){L===void 0&&(L={}),u.fieldSubscribers[C]||(u.fieldSubscribers[C]={index:0,entries:{}});var X=u.fieldSubscribers[C].index++;u.fieldSubscribers[C].entries[X]={subscriber:pu(M),subscription:L,notified:!1};var Z=u.fields[C]||{active:!1,afterSubmit:F&&F.afterSubmit,beforeSubmit:F&&F.beforeSubmit,data:F&&F.data||{},isEqual:F&&F.isEqual||zx,lastFieldState:void 0,modified:!1,modifiedSinceLastSubmit:!1,name:C,touched:!1,valid:!0,validateFields:F&&F.validateFields,validators:{},validating:!1,visited:!1};Z.blur=Z.blur||function(){return ee.blur(C)},Z.change=Z.change||function(Be){return ee.change(C,Be)},Z.focus=Z.focus||function(){return ee.focus(C)},u.fields[C]=Z;var ae=!1,ue=F&&F.silent,le=function(){ue&&u.fields[C]?R(C):(Q(),R())};if(F){ae=!!(F.getValidator&&F.getValidator()),F.getValidator&&(u.fields[C].validators[X]=F.getValidator);var ke=ge(u.formState.values,C)===void 0;F.initialValue!==void 0&&(ke||ge(u.formState.values,C)===ge(u.formState.initialValues,C))&&(u.formState.initialValues=lt(u.formState.initialValues||{},C,F.initialValue),u.formState.values=lt(u.formState.values,C,F.initialValue),O(void 0,le)),F.defaultValue!==void 0&&F.initialValue===void 0&&ge(u.formState.initialValues,C)===void 0&&ke&&(u.formState.values=lt(u.formState.values,C,F.defaultValue))}return ae?O(void 0,le):le(),function(){var Be=!1;u.fields[C]&&(Be=!!(u.fields[C].validators[X]&&u.fields[C].validators[X]()),delete u.fields[C].validators[X]);var mt=!!u.fieldSubscribers[C];mt&&delete u.fieldSubscribers[C].entries[X];var ei=mt&&!Object.keys(u.fieldSubscribers[C].entries).length;ei&&(delete u.fieldSubscribers[C],delete u.fields[C],Be&&(u.formState.errors=lt(u.formState.errors,C,void 0)||{}),t&&(u.formState.values=lt(u.formState.values,C,void 0,!0)||{})),ue||(Be?O(void 0,function(){Q(),R()}):ei&&Q())}},reset:function(C){C===void 0&&(C=u.formState.initialValues),u.formState.submitting&&(u.formState.resetWhileSubmitting=!0),u.formState.submitFailed=!1,u.formState.submitSucceeded=!1,delete u.formState.submitError,delete u.formState.submitErrors,delete u.formState.lastSubmittedValues,ee.initialize(C||{})},resetFieldState:function(C){u.fields[C]=be({},u.fields[C],{active:!1,lastFieldState:void 0,modified:!1,touched:!1,valid:!0,validating:!1,visited:!1}),O(void 0,function(){R(),Q()})},restart:function(C){C===void 0&&(C=u.formState.initialValues),ee.batch(function(){for(var M in u.fields)ee.resetFieldState(M),u.fields[M]=be({},u.fields[M],{active:!1,lastFieldState:void 0,modified:!1,modifiedSinceLastSubmit:!1,touched:!1,valid:!0,validating:!1,visited:!1});ee.reset(C)})},resumeValidation:function(){h=!1,p=!1,f&&O(void 0,function(){R(),Q()}),f=!1},setConfig:function(C,M){switch(C){case"debug":e=M;break;case"destroyOnUnregister":t=M;break;case"initialValues":ee.initialize(M);break;case"keepDirtyOnReinitialize":n=M;break;case"mutators":r=M,M?(Object.keys(w).forEach(function(L){L in M||delete w[L]}),Object.keys(M).forEach(function(L){w[L]=v(L)})):Object.keys(w).forEach(function(L){delete w[L]});break;case"onSubmit":o=M;break;case"validate":l=M,O(void 0,function(){R(),Q()});break;case"validateOnBlur":a=M;break;default:throw new Error("Unrecognised option "+C)}},submit:function(){var C=u.formState;if(!C.submitting){if(delete C.submitErrors,delete C.submitError,C.lastSubmittedValues=be({},C.values),N()){H(),ie(),u.formState.submitFailed=!0,Q(),R();return}var M=Object.keys(m);if(M.length){Promise.all(M.map(function(ue){return m[Number(ue)]})).then(ee.submit,console.error);return}var L=he();if(!L){var F,X=!1,Z=function(le){C.submitting=!1;var ke=C.resetWhileSubmitting;return ke&&(C.resetWhileSubmitting=!1),le&&qi(le)?(C.submitFailed=!0,C.submitSucceeded=!1,C.submitErrors=le,C.submitError=le[_n],H()):(ke||(C.submitFailed=!1,C.submitSucceeded=!0),pe()),Q(),R(),X=!0,F&&F(le),le};C.submitting=!0,C.submitFailed=!1,C.submitSucceeded=!1,C.lastSubmittedValues=be({},C.values),ie();var ae=o(C.values,ee,Z);if(!X){if(ae&&mo(ae))return Q(),R(),ae.then(Z,function(ue){throw Z(),ue});if(o.length>=3)return Q(),R(),new Promise(function(ue){F=ue});Z(ae)}}}},subscribe:function(C,M){if(!C)throw new Error("No callback given.");if(!M)throw new Error("No subscription provided. What values do you want to listen to?");var L=pu(C),F=u.subscribers,X=F.index++;F.entries[X]={subscriber:L,subscription:M,notified:!1};var Z=I();return Kh(L,M,Z,Z,du,!0),function(){delete F.entries[X]}}};return ee}var Hx=["render","children","component"];function Gx(i,e,t){var n=i.render,s=i.children,r=i.component,o=Hr(i,Hx);if(r)return Se.createElement(r,Object.assign(e,o,{children:s,render:n}));if(n)return n(s===void 0?Object.assign(e,o):Object.assign(e,o,{children:s}));if(typeof s!="function")throw new Error("Must specify either a render prop, a render function as children, or a component prop to "+t);return s(Object.assign(e,o))}function Ht(i,e,t){t===void 0&&(t=function(r,o){return r===o});var n=j.useRef(i);j.useEffect(function(){t(i,n.current)||(e(),n.current=i)})}function Wx(i){var e=j.useRef();return e.current||(e.current=i()),e.current}var xo=function(e,t){if(e===t)return!0;if(typeof e!="object"||!e||typeof t!="object"||!t)return!1;var n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(var r=Object.prototype.hasOwnProperty.bind(t),o=0;o<n.length;o++){var l=n[o];if(!r(l)||e[l]!==t[l])return!1}return!0},Ux=function(e){return!!(e&&typeof e.stopPropagation=="function")},Yh=Se.createContext();function Xh(i){var e=j.useRef(i);return j.useEffect(function(){e.current=i}),e}var qx="6.5.8",Qh=function(e,t,n){n.forEach(function(s){Object.defineProperty(e,s,{get:function(){return t[s]},enumerable:!0})})},Jh=function(e,t){return Qh(e,t,["active","dirty","dirtyFields","dirtySinceLastSubmit","dirtyFieldsSinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","modified","modifiedSinceLastSubmit","pristine","submitError","submitErrors","submitFailed","submitSucceeded","submitting","touched","valid","validating","values","visited"])},Kx=function(e,t){return Qh(e,t,["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","modified","modifiedSinceLastSubmit","pristine","submitError","submitFailed","submitSucceeded","submitting","touched","valid","validating","visited"])},Yx=["debug","decorators","destroyOnUnregister","form","initialValues","initialValuesEqual","keepDirtyOnReinitialize","mutators","onSubmit","subscription","validate","validateOnBlur"],Xx={"final-form":Vx,"react-final-form":qx},Zh=qh.reduce(function(i,e){return i[e]=!0,i},{});function Qx(i){var e=i.debug,t=i.decorators,n=t===void 0?[]:t,s=i.destroyOnUnregister,r=i.form,o=i.initialValues,l=i.initialValuesEqual,a=i.keepDirtyOnReinitialize,u=i.mutators,c=i.onSubmit,h=i.subscription,f=h===void 0?Zh:h,p=i.validate,g=i.validateOnBlur,m=Hr(i,Yx),x={debug:e,destroyOnUnregister:s,initialValues:o,keepDirtyOnReinitialize:a,mutators:u,onSubmit:c,validate:p,validateOnBlur:g},y=Wx(function(){var O=r||_x(x);return O.pauseValidation(),O}),b=Se.useState(function(){var O={};return y.subscribe(function(R){O=R},f)(),O}),v=b[0],w=b[1],S=Xh(v);Se.useEffect(function(){y.isValidationPaused()&&y.resumeValidation();var O=[y.subscribe(function(R){xo(R,S.current)||w(R)},f)].concat(n?n.map(function(R){return R(y)}):[]);return function(){y.pauseValidation(),O.reverse().forEach(function(R){return R()})}},n),process.env.NODE_ENV!=="production"&&Ht(n,function(){console.error("Form decorators should not change from one render to the next as new values will be ignored")},xo),Ht(e,function(){y.setConfig("debug",e)}),Ht(s,function(){y.destroyOnUnregister=!!s}),Ht(a,function(){y.setConfig("keepDirtyOnReinitialize",a)}),Ht(o,function(){y.setConfig("initialValues",o)},l||xo),Ht(u,function(){y.setConfig("mutators",u)}),Ht(c,function(){y.setConfig("onSubmit",c)}),Ht(p,function(){y.setConfig("validate",p)}),Ht(g,function(){y.setConfig("validateOnBlur",g)});var E=function(R){return R&&(typeof R.preventDefault=="function"&&R.preventDefault(),typeof R.stopPropagation=="function"&&R.stopPropagation()),y.submit()},A={form:be({},y,{reset:function(R){Ux(R)?y.reset():y.reset(R)}}),handleSubmit:E};return Jh(A,v),Se.createElement(Yh.Provider,{value:y},Gx(be({},m,{__versions:Xx}),A,"ReactFinalForm"))}function Gr(i){var e=Se.useContext(Yh);if(!e)throw new Error((i||"useForm")+" must be used inside of a <Form> component");return e}function Jx(i){var e=i===void 0?{}:i,t=e.onChange,n=e.subscription,s=n===void 0?Zh:n,r=Gr("useFormState"),o=Se.useRef(!0),l=Se.useRef(t);l.current=t;var a=Se.useState(function(){var f={};return r.subscribe(function(p){f=p},s)(),t&&t(f),f}),u=a[0],c=a[1];Se.useEffect(function(){return r.subscribe(function(f){o.current?o.current=!1:(c(f),l.current&&l.current(f))},s)},[]);var h={};return Jh(h,u),h}var Zx=typeof window<"u"&&window.navigator&&window.navigator.product&&window.navigator.product==="ReactNative",ey=function(e){var t=[];if(e)for(var n=0;n<e.length;n++){var s=e[n];s.selected&&t.push(s.value)}return t},ty=function(e,t,n,s){if(!s&&e.nativeEvent&&e.nativeEvent.text!==void 0||s&&e.nativeEvent)return e.nativeEvent.text;var r=e,o=r.target,l=o.type,a=o.value,u=o.checked;switch(l){case"checkbox":if(n!==void 0){if(u)return Array.isArray(t)?t.concat(n):[n];if(!Array.isArray(t))return t;var c=t.indexOf(n);return c<0?t:t.slice(0,c).concat(t.slice(c+1))}else return!!u;case"select-multiple":return ey(e.target.options);default:return a}};function yo(i){var e=Se.useRef(i);return Se.useEffect(function(){e.current=i}),Se.useCallback(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return e.current.apply(null,n)},[])}var iy=ha.reduce(function(i,e){return i[e]=!0,i},{}),bo=function(e,t){return e===void 0?"":e},ny=function(e,t){return e===""?void 0:e},sy=function(e,t){return e===t};function ef(i,e){e===void 0&&(e={});var t=e,n=t.afterSubmit,s=t.allowNull,r=t.component,o=t.data,l=t.defaultValue,a=t.format,u=a===void 0?bo:a,c=t.formatOnBlur,h=t.initialValue,f=t.multiple,p=t.parse,g=p===void 0?ny:p,m=t.subscription,x=m===void 0?iy:m,y=t.type,b=t.validateFields,v=t.value,w=Gr("useField"),S=Xh(e),E=function(U,Q){return w.registerField(i,U,x,{afterSubmit:n,beforeSubmit:function(){var pe=S.current,ie=pe.beforeSubmit,ee=pe.formatOnBlur,G=pe.format,C=G===void 0?bo:G;if(ee){var M=w.getFieldState(i),L=M.value,F=C(L,i);F!==L&&w.change(i,F)}return ie&&ie()},data:o,defaultValue:l,getValidator:function(){return S.current.validate},initialValue:h,isEqual:function(pe,ie){return(S.current.isEqual||sy)(pe,ie)},silent:Q,validateFields:b})},A=Se.useRef(!0),O=Se.useState(function(){var P={},U=w.destroyOnUnregister;return w.destroyOnUnregister=!1,E(function(Q){P=Q},!0)(),w.destroyOnUnregister=U,P}),R=O[0],H=O[1];Se.useEffect(function(){return E(function(P){A.current?A.current=!1:H(P)},!1)},[i,o,l,h]);var N={};Kx(N,R);var I={name:i,get value(){var P=R.value;return c?r==="input"&&(P=bo(P)):P=u(P,i),P===null&&!s&&(P=""),y==="checkbox"||y==="radio"?v:r==="select"&&f?P||[]:P},get checked(){var P=R.value;if(y==="checkbox")return P=u(P,i),v===void 0?!!P:!!(Array.isArray(P)&&~P.indexOf(v));if(y==="radio")return u(P,i)===v},onBlur:yo(function(P){if(R.blur(),c){var U=w.getFieldState(R.name);R.change(u(U.value,R.name))}}),onChange:yo(function(P){if(process.env.NODE_ENV!=="production"&&P&&P.target){var U=P.target.type,Q=~["checkbox","radio","select-multiple"].indexOf(U)&&!y&&r!=="select",he=U==="select-multiple"?R.value:v;Q&&console.error('You must pass `type="'+(U==="select-multiple"?"select":U)+'"` prop to your Field('+i+`) component.
23
- `+("Without it we don't know how to unpack your `value` prop - "+(Array.isArray(he)?"["+he+"]":'"'+he+'"')+"."))}var pe=P&&P.target?ty(P,R.value,v,Zx):P;R.change(g(pe,i))}),onFocus:yo(function(P){return R.focus()})};f&&(I.multiple=f),y!==void 0&&(I.type=y);var W={input:I,meta:N};return W}const tf=j.createContext(null);function fa(){const i=j.useContext(tf);if(!i)throw new Error("useFormContext must be used within a <Form>");return i}function ry(i,e){const{fieldRegistry:t}=fa();j.useEffect(()=>(e&&t.set(i,{label:e}),()=>{t.delete(i)}),[i,e,t])}const oy=(...i)=>e=>{for(const t of i){const n=t(e);if(n!==void 0)return n}},ly=i=>i==null?!0:typeof i=="string"?i.trim()==="":Array.isArray(i)?i.length===0:d.isRecord(i)?Object.keys(i).length===0:!1,ay=(i="This field is required.")=>e=>{if(!(typeof e=="boolean"||typeof e=="number"))return ly(e)?i:void 0};function ot(i,e){ry(i,e==null?void 0:e.label);const t=e!=null&&e.required?oy(ay(),...e.validate?[e.validate]:[]):e==null?void 0:e.validate,s=ef(i,{validate:t?l=>t(l):void 0,defaultValue:e==null?void 0:e.defaultValue,initialValue:e==null?void 0:e.initialValue,parse:e==null?void 0:e.parse,format:e==null?void 0:e.format}),r={value:s.input.value,name:s.input.name,onChange:s.input.onChange,onBlur:s.input.onBlur,onFocus:s.input.onFocus},o={error:typeof s.meta.error=="string"?s.meta.error:void 0,touched:!!s.meta.touched};return{input:r,meta:o}}function uy(i){const{closeable:e,index:t,onRemove:n,readOnly:s,updateValue:r,value:o}=i,[,l]=D.useStyletron(),[a,u]=j.useState(!1),[c,h]=j.useState(o),f={paddingTop:l.sizing.scale100,paddingRight:l.sizing.scale100,paddingBottom:l.sizing.scale100,paddingLeft:l.sizing.scale100},p=()=>{h(o),u(!1)},g=()=>{r(c,t),u(!1)},m=x=>{x.key==="Enter"&&g()};return a&&!s?d.jsxRuntimeExports.jsx(d.Tag,{contentMaxWidth:"100%",overrides:{ActionIcon:{component:d.Icon,props:{name:"check",onMouseDown:g,size:l.sizing.scale500}},Root:{style:f}},behavior:d.TAG_BEHAVIOR.selection,hierarchy:sr.HIERARCHY.secondary,children:d.jsxRuntimeExports.jsx(ht.StyledInput,{$adjoined:ht.ADJOINED.none,autoFocus:!0,onBlur:p,onChange:x=>h(x.target.value),onKeyDown:m,size:c.length+1,$size:ht.SIZE.compact,style:{padding:0},value:c})}):d.jsxRuntimeExports.jsx(d.Tag,{closeable:e,onActionClick:n,onClick:()=>u(!0),overrides:{Root:{style:f}},hierarchy:sr.HIERARCHY.primary,children:o})}const cy=j.forwardRef(function(e,t){const{clear:n,readOnly:s,removeValue:r,updateValue:o,value:l,valueList:a,...u}=e,[,c]=D.useStyletron(),h=()=>{var p;n(),t&&typeof t!="function"&&((p=t.current)==null||p.focus())},f=p=>{var g;p.target===p.currentTarget&&t&&typeof t!="function"&&((g=t.current)==null||g.focus())};return d.jsxRuntimeExports.jsxs(d.jsxRuntimeExports.Fragment,{children:[d.jsxRuntimeExports.jsxs(Ji.StyledValueContainer,{$multi:!0,$style:{gap:c.sizing.scale100},onClick:f,children:[a.map((p,g)=>d.jsxRuntimeExports.jsx(uy,{value:p,index:g,closeable:!s,onRemove:()=>r(g),readOnly:s,updateValue:o},g)),d.jsxRuntimeExports.jsx(ht.StyledInput,{...u,$adjoined:ht.ADJOINED.none,readOnly:s,ref:t,size:String(l??"").length+1,$size:ht.SIZE.compact,value:l})]}),a.length>0&&!s&&d.jsxRuntimeExports.jsx(Ji.StyledIconsContainer,{children:d.jsxRuntimeExports.jsx(Ji.StyledClearIcon,{onClick:h,children:d.jsxRuntimeExports.jsx(tm.DeleteAlt,{})})})]})});function hy({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:u,caption:c,labelEndEnhancer:h,format:f,parse:p}){const{input:g,meta:m}=ot(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p}),[x,y]=j.useState(""),b=Array.isArray(g.value)?g.value:[],v=R=>{g.onChange([...b,R]),y("")},w=R=>g.onChange(b.filter((H,N)=>N!==R)),S=(R,H)=>{const N=[...b];N[H]=R,g.onChange(N)},E=()=>{g.onChange([]),y("")},A=R=>{if(o)return;const H=R.key==="Enter"&&x,N=R.key==="Backspace"&&b.length>0&&!x;H?(R.preventDefault(),v(x)):N&&w(b.length-1)},O=()=>{g.onBlur(),x&&v(x)};return d.jsxRuntimeExports.jsx(Je,{label:e,required:s,description:u,labelEndEnhancer:h,caption:c,error:m.touched&&m.error?m.error:void 0,children:d.jsxRuntimeExports.jsx(ht.Input,{...g,id:i,value:x,onChange:R=>y(R.currentTarget.value),onBlur:O,placeholder:!l&&!o&&b.length===0?a:"",readOnly:o,disabled:l,overrides:{InputContainer:{style:({$theme:R})=>o&&!l?{backgroundColor:R.colors.backgroundPrimary}:{}},Input:{component:cy,props:{clear:E,onKeyDown:A,readOnly:o,removeValue:w,updateValue:S,valueList:b},style:{width:"auto",flexGrow:1,padding:0}}}})})}function fy({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:u,caption:c,labelEndEnhancer:h,format:f,parse:p}){const{input:g,meta:m}=ot(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p});return d.jsxRuntimeExports.jsx(Je,{label:e,required:s,description:u,labelEndEnhancer:h,caption:c,error:m.touched&&m.error?m.error:void 0,children:d.jsxRuntimeExports.jsx(ht.Input,{id:g.name,value:g.value??"",name:g.name,onChange:x=>g.onChange(x.currentTarget.value),onBlur:g.onBlur,onFocus:g.onFocus,placeholder:a,readOnly:o,disabled:l})})}function da(i){return i.multi?d.jsxRuntimeExports.jsx(hy,{...i}):d.jsxRuntimeExports.jsx(fy,{...i})}function un(){return un=Object.assign||function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},un.apply(this,arguments)}var nf=function(e,t,n){var s=e[0],r=e[1],o=e[2],l=n.changeValue;l(t,s,function(c){var h=[].concat(c||[]);return h.splice(r,0,o),h});var a=new RegExp("^"+s+"\\[(\\d+)\\](.*)"),u={};Object.keys(t.fields).forEach(function(c){var h=a.exec(c);if(h){var f=Number(h[1]);if(f>=r){var p=s+"["+(f+1)+"]"+h[2];u[p]=t.fields[c],u[p].name=p}f===r&&delete t.fields[c]}}),t.fields=un({},t.fields,u)},dy=function(e,t,n){var s=e[0],r=e[1],o=n.changeValue;o(t,s,function(l){return l?[].concat(l,r):r})},py=function(e,t,n){var s=e[0],r=e[1],o=e[2],l=n.changeValue;if(r===o)return;l(t,s,function(c){var h=[].concat(c||[]),f=h[r];return h.splice(r,1),h.splice(o,0,f),h});var a=s+"["+r+"]";Object.keys(t.fields).forEach(function(c){if(c.substring(0,a.length)===a){var h=c.substring(a.length),f=a+h,p=t.fields[f];if(r<o)for(var g=r;g<o;g++){var m=s+"["+g+"]"+h;u({destKey:m,source:t.fields[s+"["+(g+1)+"]"+h]})}else for(var x=r;x>o;x--){var y=s+"["+x+"]"+h;u({destKey:y,source:t.fields[s+"["+(x-1)+"]"+h]})}var b=s+"["+o+"]"+h;u({destKey:b,source:p})}});function u(c){var h=c.destKey,f=c.source;t.fields[h]=un({},f,{name:h,change:t.fields[h]&&t.fields[h].change,blur:t.fields[h]&&t.fields[h].blur,focus:t.fields[h]&&t.fields[h].focus,lastFieldState:void 0})}},gy=function(e,t,n){var s=e[0],r=n.changeValue,o;return r(t,s,function(l){if(l)return l.length?(o=l[l.length-1],l.slice(0,l.length-1)):[]}),o},my=function(e,t,n){var s=e[0],r=e[1],o=n.changeValue;o(t,s,function(l){return l?[].concat(l,[r]):[r]})},sf=function(e,t,n){var s=e[0],r=e[1],o=n.changeValue,l;o(t,s,function(c){var h=[].concat(c||[]);return l=h[r],h.splice(r,1),h});var a=new RegExp("^"+s+"\\[(\\d+)\\](.*)"),u=un({},t.fields);return Object.keys(t.fields).forEach(function(c){var h=a.exec(c);if(h){var f=Number(h[1]);if(f===r)delete t.fields[c];else if(f>r){delete t.fields[c];var p=s+"["+(f-1)+"]"+h[2];t.fields[p]=u[c],t.fields[p].name=p}}}),l},xy=function(e,t){return e.reduce(function(n,s){return s<t?n+1:n},0)},yy=function(e,t,n){var s=e[0],r=e[1],o=n.changeValue,l=[].concat(r);l.sort();for(var a=0;a<l.length;a++)a>0&&l[a]===l[a-1]&&l.splice(a--,1);var u=[];o(t,s,function(f){if(u=r.map(function(m){return f&&f[m]}),!f||!l.length)return f;var p=[].concat(f),g=[];return l.forEach(function(m){p.splice(m-g.length,1),g.push(f&&f[m])}),p});var c=new RegExp("^"+s+"\\[(\\d+)\\](.*)"),h={};return Object.keys(t.fields).forEach(function(f){var p=c.exec(f);if(p){var g=Number(p[1]);if(!~l.indexOf(g)){var m=s+"["+(g-xy(l,g))+"]"+p[2];h[m]=t.fields[f],h[m].name=m}}else h[f]=t.fields[f]}),t.fields=h,u},by=function(e,t,n){var s=e[0];return sf([s,0],t,n)},vy=function(e,t,n){var s=e[0],r=e[1],o=e[2],l=n.changeValue;if(r===o)return;l(t,s,function(h){var f=[].concat(h||[]),p=f[r];return f[r]=f[o],f[o]=p,f});var a=s+"["+r+"]",u=s+"["+o+"]";Object.keys(t.fields).forEach(function(h){if(h.substring(0,a.length)===a){var f=h.substring(a.length),p=a+f,g=u+f,m=t.fields[p];c({destKey:p,source:t.fields[g]}),c({destKey:g,source:m})}});function c(h){var f=h.destKey,p=h.source;t.fields[f]=un({},p,{name:f,change:t.fields[f].change,blur:t.fields[f].blur,focus:t.fields[f].focus,lastFieldState:void 0})}},Sy=function(e,t,n){var s=e[0],r=e[1];return nf([s,0,r],t,n)},Cy=function(e,t,n){var s=e[0],r=e[1],o=e[2],l=n.changeValue;l(t,s,function(a){var u=[].concat(a||[]);return u.splice(r,1,o),u})},wy={insert:nf,concat:dy,move:py,pop:gy,push:my,remove:sf,removeBatch:yy,shift:by,swap:vy,unshift:Sy,update:Cy},Ey=function(e){return!!(e&&typeof e.focus=="function")},Ry=function(){return typeof document>"u"?[]:Array.prototype.slice.call(document.forms).reduce(function(e,t){return e.concat(Array.prototype.slice.call(t).filter(Ey))},[])},ky=function(e,t){return e.find(function(n){return n.name&&ge(t,n.name)})},Ay=function(){},Ty=function(e,t){return function(n){var s=function(c){e||(e=Ry),t||(t=ky);var h=t(e(),c);h&&h.focus()},r=n.submit,o={},l=n.subscribe(function(u){o=u},{errors:!0,submitErrors:!0}),a=function(){var c=o,h=c.errors,f=c.submitErrors;h&&Object.keys(h).length?s(h):f&&Object.keys(f).length&&s(f)};return n.submit=function(){var u=r.call(n);return u&&typeof u.then=="function"?u.then(a,Ay):a(),u},function(){l(),n.submit=r}}};const My=D.styled("div",({$height:i})=>({height:`${i}px`,flexShrink:0})),jy=D.styled("footer",({$theme:i})=>({display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",position:"fixed",boxSizing:"border-box",left:0,bottom:0,boxShadow:i.lighting.shallowAbove,backgroundColor:i.colors.backgroundPrimary,paddingTop:i.sizing.scale600,paddingBottom:i.sizing.scale600,paddingLeft:i.sizing.scale900,paddingRight:i.sizing.scale900,gap:i.sizing.scale400})),mu=D.styled("div",({$theme:i})=>({display:"flex",alignItems:"center",gap:i.sizing.scale200}));function Oy({leftContent:i,rightContent:e}){const t=j.useRef(null),[n,s]=j.useState(0);return j.useEffect(()=>{const r=t.current;if(!r)return;const o=new ResizeObserver(()=>{s(r.offsetHeight)});return o.observe(r),()=>o.disconnect()},[]),d.jsxRuntimeExports.jsxs(d.jsxRuntimeExports.Fragment,{children:[d.jsxRuntimeExports.jsx(My,{$height:n}),d.jsxRuntimeExports.jsxs(jy,{ref:t,children:[d.jsxRuntimeExports.jsx(mu,{children:i}),d.jsxRuntimeExports.jsx(mu,{children:e})]})]})}const Iy=Ty(),pa=({onSubmit:i,initialValues:e,id:t,children:n,render:s,footer:r,focusOnError:o=!0})=>{const[l,a]=D.useStyletron(),u=j.useRef(new Map),c=j.useMemo(()=>({fieldRegistry:u.current}),[]);return d.jsxRuntimeExports.jsx(tf.Provider,{value:c,children:d.jsxRuntimeExports.jsx(Qx,{onSubmit:i,initialValues:e,mutators:{...wy},decorators:o?[Iy]:void 0,render:({handleSubmit:h})=>{const f=d.jsxRuntimeExports.jsxs("form",{className:l({display:"flex",flexDirection:"column",gap:a.sizing.scale600}),id:t,onSubmit:h,children:[n,Py(r)]});return s?s(f):f}})})};function Py(i){if(!i)return null;if(typeof i=="object"&&("left"in i||"right"in i)){const{left:e,right:t}=i;return d.jsxRuntimeExports.jsx(Oy,{leftContent:e,rightContent:t})}return i}function Dy(){return d.jsxRuntimeExports.jsxs(Hi,{children:[d.jsxRuntimeExports.jsx(bt.HeadingXXLarge,{children:"Component Sandbox"}),d.jsxRuntimeExports.jsx(ru.Block,{marginBottom:"24px",children:"This is a sandbox for testing WIP components and features."}),d.jsxRuntimeExports.jsx(ru.Block,{width:"400px",children:d.jsxRuntimeExports.jsx(pa,{onSubmit:()=>{},children:d.jsxRuntimeExports.jsx(da,{name:"tags",label:"Tags",multi:!0,placeholder:"Add a tag"})})})]})}var hi=(i=>(i.PRIMARY="primary",i.SECONDARY="secondary",i.TERTIARY="tertiary",i))(hi||{});function ga(i){const e=i?{submitting:i.submitting,submitError:i.submitError,values:i.values,submitFailed:i.submitFailed,hasValidationErrors:i.hasValidationErrors,errors:i.errors,submitErrors:i.submitErrors,touched:i.touched,modifiedSinceLastSubmit:i.modifiedSinceLastSubmit}:void 0,t=Jx({subscription:e});return{submitting:t.submitting,submitError:t.submitError,values:t.values,submitFailed:t.submitFailed,hasValidationErrors:t.hasValidationErrors,errors:t.errors,submitErrors:t.submitErrors,touched:t.touched,modifiedSinceLastSubmit:t.modifiedSinceLastSubmit}}function Ly(){var a;const{fieldRegistry:i}=fa(),{submitErrors:e,errors:t,touched:n}=ga({submitErrors:!0,errors:!0,touched:!0}),s=e==null?void 0:e[_n],r=s instanceof Error?s.message:s,o=r?[{fieldPath:_n,errorMessage:r}]:[];if(!t)return o;const l=[];for(const[u,c]of Object.entries(n??{})){if(!c)continue;const h=ge(t,u);typeof h=="string"&&l.push({fieldPath:u,fieldLabel:(a=i.get(u))==null?void 0:a.label,errorMessage:h,focus:()=>{var f;(f=document.querySelector(`[name="${u}"]`))==null||f.focus()}})}return[...o,...l]}function rf(){const[i,e]=D.useStyletron(),t=Ly();return t.length===0?null:d.jsxRuntimeExports.jsx(d.Banner,{kind:"negative",children:t.map(n=>d.jsxRuntimeExports.jsxs("div",{className:i({...e.typography.ParagraphSmall,textAlign:"left"}),children:[n.fieldLabel&&d.jsxRuntimeExports.jsx(im.StyledLink,{$as:"button",type:"button",onClick:n.focus,className:i({background:"none",border:"none",cursor:"pointer",padding:"0"}),children:n.fieldLabel}),n.fieldLabel&&n.errorMessage&&d.jsxRuntimeExports.jsx(d.jsxRuntimeExports.Fragment,{children:" "}),d.jsxRuntimeExports.jsx(d.Markdown,{children:n.errorMessage})]},n.fieldPath))})}const of=({children:i,formId:e,kind:t=_.KIND.primary,disabled:n,overrides:s,...r})=>{const{submitting:o}=ga({submitting:!0});return d.jsxRuntimeExports.jsx(_.Button,{type:"submit",kind:t,form:e,disabled:n,isLoading:o,overrides:nm.mergeOverrides({BaseButton:{style:{minWidth:"200px"}}},s),...r,children:i})},lf=({isOpen:i,onDismiss:e,heading:t,size:n=rr.SIZE.large,onSubmit:s,initialValues:r,submitLabel:o="Submit",children:l})=>{const a=j.useId(),u=async c=>{try{await s(c),e()}catch(h){return{[_n]:h instanceof Error?h:new Error(String(h))}}};return d.jsxRuntimeExports.jsxs(pa,{id:a,initialValues:r,onSubmit:u,render:c=>d.jsxRuntimeExports.jsx(d.Dialog,{isOpen:i,onDismiss:e,heading:t,size:n,placement:rr.PLACEMENT.topCenter,buttonDock:{primaryAction:d.jsxRuntimeExports.jsx(of,{formId:a,children:o}),dismissiveAction:d.jsxRuntimeExports.jsx(_.Button,{kind:_.KIND.tertiary,onClick:e,overrides:{BaseButton:{style:{minWidth:"150px"}}},children:"Cancel"})},children:c}),children:[l,d.jsxRuntimeExports.jsx(rf,{})]})},af=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:u,caption:c,labelEndEnhancer:h,format:f,parse:p,rows:g,maxLength:m})=>{var v;const{input:x,meta:y}=ot(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p}),b=((v=x.value)==null?void 0:v.length)??0;return d.jsxRuntimeExports.jsx(Je,{label:e,required:s,description:u,labelEndEnhancer:h,caption:c,error:y.touched&&y.error?y.error:void 0,counter:m?{length:b,maxLength:m}:void 0,children:d.jsxRuntimeExports.jsx(Ch.Textarea,{id:x.name,name:x.name,value:x.value??"",onChange:w=>x.onChange(w.currentTarget.value),onBlur:x.onBlur,onFocus:x.onFocus,placeholder:a,readOnly:o,disabled:l,rows:g,maxLength:m,overrides:{Input:{style:{resize:"vertical"}}}})})},xu="-",Fy=8,Ny=(i={withDate:!1})=>{const e=`${xu}${crypto.randomUUID().substring(0,Fy)}`;if(i.withDate){const t=new Date().toISOString(),n=d.parseIsoString(t);if(!n)return console.warn("Date.toISOString() returned an invalid ISO string",t),e;const{date:s,time:r}=n,o=s.replace(/-/g,""),l=r.replace(/\..*$/,"").replace(/:/g,"");return`${xu}${o}-${l}${e}`}return e},By=({record:i,onClose:e})=>{var o;const{projectId:t}=d.useStudioParams("base"),n=d.useStudioMutation({mutationName:"CreatePipelineRun"}),s=async l=>{n.isPending||await n.mutateAsync(l)},r={metadata:{name:`run${Ny({withDate:!0})}`,namespace:t},spec:{pipeline:{name:((o=i==null?void 0:i.metadata)==null?void 0:o.name)??"",namespace:t}}};return d.jsxRuntimeExports.jsxs(lf,{isOpen:!0,onDismiss:e,heading:"Start new pipeline run",onSubmit:s,submitLabel:"Run",initialValues:r,children:[d.jsxRuntimeExports.jsx(da,{name:"spec.pipeline.name",label:"Pipeline to run",readOnly:!0}),d.jsxRuntimeExports.jsx(af,{name:"spec.description",label:"Description",placeholder:"Enter a description for this run…",description:"Optional. Helps identify this run in the pipeline run list."})]})},Wr=[{id:"metadata.creationTimestamp.seconds",label:"Created",type:d.CellType.DATE},{id:"spec.pipeline.name",label:"Pipeline",items:[{id:"spec.pipeline.name",type:d.CellType.TEXT},{id:"spec.revision.name",type:d.CellType.DESCRIPTION}]},{id:"spec.actor.name",label:"Started by",type:d.CellType.TEXT},{id:"status.state",label:"State",type:d.CellType.STATE,stateTextMap:{0:"Queued",1:"Pending",2:"Running",3:"Succeeded",4:"Killed",5:"Failed",6:"Skipped"},stateColorMap:{0:"gray",1:"blue",2:"blue",3:"green",4:"red",5:"red",6:"gray"}}],uf={id:"status.state",label:"State",type:d.CellType.STATE,stateTextMap:{0:"Invalid",1:"Created",2:"Building",3:"Ready",4:"Error"},stateColorMap:{0:"red",1:"green",2:"yellow",3:"green",4:"red"}},cf={id:"spec.type",label:"Type",type:d.CellType.TYPE,typeTextMap:{0:"Invalid",1:"Train",2:"Evaluation",3:"Performance Evaluation",4:"Experiment",5:"Retrain",6:"Prediction",7:"Performance Monitoring",8:"Basis Feature",9:"Data Prep",10:"Online Offline Feature Consistency",11:"Feature Group Compute",12:"Online Offline Feature Consistency Orchestration",13:"Post Processing",14:"Optimization",15:"Scorer"}},Vy={type:"detail",metadata:[{id:"metadata.creationTimestamp.seconds",label:"Created",type:d.CellType.DATE},{id:"spec.owner.name",label:"Owner",type:d.CellType.TEXT},cf,{id:"spec.commit.branch",label:"Branch",type:d.CellType.TEXT},uf],pages:[{id:"runs",label:"Pipeline Runs",type:"table",queryConfig:{endpoint:"list",service:"pipelineRun",serviceOptions:{listOptions:{labelSelector:"pipeline.michelangelo/name=${page.metadata.name}"}}},tableConfig:{columns:[{id:"metadata.name",label:"Name",url:"/${studio.projectId}/${studio.phase}/runs/${row.metadata.name}"},...Wr]}}]},zy=[{id:"metadata.name",label:"Name",url:"/${studio.projectId}/${studio.phase}/pipelines/${data.metadata.name}",tooltip:{content:"Click to filter by this pipeline name",action:"filter"}},{id:"metadata.creationTimestamp.seconds",label:"Created",type:d.CellType.DATE},cf,{id:"spec.commit.branch",label:"Branch",type:d.CellType.TEXT},uf],$y={type:"list",tableConfig:{columns:zy}},hf={id:"pipelines",name:"Pipelines",service:"pipeline",state:"active",views:[$y,Vy],actions:[{display:{label:"Run",icon:"playerPlay"},hierarchy:hi.PRIMARY,modal:{type:"custom",component:By}}]},oe={ERROR:"ERROR",PENDING:"PENDING",RUNNING:"RUNNING",SUCCESS:"SUCCESS",SKIPPED:"SKIPPED"},ff={[oe.ERROR]:{borderColorName:"borderNegativeLight",backgroundColorName:"backgroundNegativeLight"},[oe.PENDING]:{borderColorName:"contentInverseTertiary",colorName:"contentInverseTertiary"},[oe.SKIPPED]:{borderColorName:"contentInverseTertiary",colorName:"contentInverseTertiary"},[oe.RUNNING]:{borderColorName:"borderAccent",backgroundColorName:"backgroundAccentLight"},[oe.SUCCESS]:{borderColorName:"borderPositive"}},_y={[oe.SUCCESS]:{name:"circleCheck",colorName:"eatsGreen400"},[oe.ERROR]:{name:"circleX",colorName:"contentNegative"},[oe.PENDING]:{name:"diamondEmpty",colorName:"contentInverseTertiary"},[oe.RUNNING]:{name:"arrowCircular",colorName:"contentAccent"},[oe.SKIPPED]:{name:"playerNext",colorName:"contentNegative"}},Hy={type:"detail",metadata:Wr,pages:[{id:"steps",label:"Steps",type:"execution",emptyState:{title:"No execution data",description:"No steps available for this pipeline run"},tasks:{accessor:"status.steps",subTasksAccessor:"subSteps",header:{heading:"displayName",metadata:[{id:"startTime.seconds",label:"Start time",type:d.CellType.DATE},{id:"endTime.seconds",label:"End time",type:d.CellType.DATE},{id:"duration",label:"Duration",type:d.CellType.TEXT,accessor:i=>{var e,t;if((e=i.startTime)!=null&&e.seconds&&((t=i.endTime)!=null&&t.seconds)){const n=parseInt(i.startTime.seconds)*1e3,r=parseInt(i.endTime.seconds)*1e3-n;return`${Math.round(r/1e3)}s`}return null}},{id:"logUrl",label:"Logs"},{id:"state",label:"Status",type:d.CellType.STATE,stateTextMap:{0:"Pending",1:"Pending",2:"Running",3:"Success",4:"Killed",5:"Failed",6:"Skipped"},stateColorMap:{0:"gray",1:"blue",2:"blue",3:"green",4:"red",5:"red",6:"gray"}},{id:"retry",label:"Actions",type:d.CellType.RETRY,accessor:"activityId",hideEmpty:!0}]},body:[{type:"struct",label:"Input Parameters",accessor:"input"},{type:"struct",label:"Output Results",accessor:"output"},{type:"textarea",label:"Task Message",accessor:"message",markdown:!1}],stateBuilder:i=>{switch(i.state){case 1:return oe.PENDING;case 2:return oe.RUNNING;case 3:return oe.SUCCESS;case 4:return oe.ERROR;case 5:return oe.ERROR;case 6:return oe.SKIPPED;default:return oe.PENDING}}}}]},Gy=[{id:"metadata.name",label:"Name",items:[{id:"metadata.name",url:"/${studio.projectId}/${studio.phase}/runs/${data.metadata.name}"},{id:"spec.description",type:d.CellType.DESCRIPTION}]},...Wr],Wy={type:"list",tableConfig:{columns:Gy}},df={id:"runs",name:"Pipeline Runs",service:"pipelineRun",state:"active",views:[Wy,Hy]},pf={id:"data",icon:"database",name:"Prepare & Analyze Data",description:"Create data pipelines and analyze your datasets",docUrl:"https://michelangelo-ai.org/docs/user-guides/getting-started/prepare-your-data",state:"disabled",entities:[{...hf,state:"disabled"},{...df,state:"disabled"},{id:"datasources",name:"data sources",state:"disabled",service:"datasource",views:[]}]},vo={UNKNOWN:0,TRUE:1,FALSE:2},it={INVALID:0,VALIDATION:1,PLACEMENT:2,RESOURCE_ACQUISITION:3,ROLLOUT_COMPLETE:4,ROLLOUT_FAILED:5,ROLLBACK_IN_PROGRESS:6,ROLLBACK_COMPLETE:7,ROLLBACK_FAILED:8,CLEAN_UP_IN_PROGRESS:9,CLEAN_UP_COMPLETE:10,CLEAN_UP_FAILED:11},kt={INVALID:0,INITIALIZING:1,HEALTHY:2,UNHEALTHY:3,EMPTY:4},gf={id:"status.stage",label:"Stage",type:d.CellType.TYPE,typeTextMap:{[it.INVALID]:"Invalid",[it.VALIDATION]:"Validation",[it.PLACEMENT]:"Placement",[it.RESOURCE_ACQUISITION]:"Resource acquisition",[it.ROLLOUT_COMPLETE]:"Rollout complete",[it.ROLLOUT_FAILED]:"Rollout failed",[it.ROLLBACK_IN_PROGRESS]:"Rollback in progress",[it.ROLLBACK_COMPLETE]:"Rollback complete",[it.ROLLBACK_FAILED]:"Rollback failed",[it.CLEAN_UP_IN_PROGRESS]:"Clean up in progress",[it.CLEAN_UP_COMPLETE]:"Clean up complete",[it.CLEAN_UP_FAILED]:"Clean up failed"}},mf={id:"status.state",label:"State",type:d.CellType.STATE,stateTextMap:{[kt.INVALID]:"Invalid",[kt.INITIALIZING]:"Initializing",[kt.HEALTHY]:"Healthy",[kt.UNHEALTHY]:"Unhealthy",[kt.EMPTY]:"Empty"},stateColorMap:{[kt.INVALID]:"gray",[kt.INITIALIZING]:"blue",[kt.HEALTHY]:"green",[kt.UNHEALTHY]:"red",[kt.EMPTY]:"gray"}},Uy={type:"detail",metadata:[{id:"metadata.creationTimestamp.seconds",label:"Created",type:d.CellType.DATE},{id:'metadata.labels["michelangelo/owner"]',label:"Owner",type:d.CellType.TEXT},gf,mf],pages:[{id:"stages",label:"Stages",type:"execution",emptyState:{title:"No deployment rollout in progress",description:"Stages will appear here when a deployment rollout is in progress"},tasks:{accessor:i=>{var t,n,s;return(((t=i==null?void 0:i.status)==null?void 0:t.stage)===it.ROLLOUT_FAILED?(n=i==null?void 0:i.status)==null?void 0:n.conditionsSnapshot:(s=i==null?void 0:i.status)==null?void 0:s.conditions)??[]},header:{heading:"type",metadata:[{id:"lastUpdatedTimestamp",label:"Last updated",type:d.CellType.DATE,accessor:i=>{const e=i.lastUpdatedTimestamp;return e?Math.floor(Number(e)/1e3):void 0}}]},body:[{type:"textarea",label:"Information",accessor:"message",markdown:!1},{type:"textarea",label:"Details",accessor:"reason",markdown:!1}],stateBuilder:i=>{switch(i.status){case vo.TRUE:return oe.SUCCESS;case vo.FALSE:return oe.ERROR;case vo.UNKNOWN:default:return oe.RUNNING}}}}]},qy=[{id:"metadata.name",label:"Name",type:d.CellType.TEXT,url:"/${studio.projectId}/${studio.phase}/deployments/${row.metadata.name}"},{id:"status.currentRevision.name",label:"Model",type:d.CellType.TEXT},{id:"spec.definition.type",label:"Type",type:d.CellType.TAG,accessor:i=>{var t,n;const e=(n=(t=i==null?void 0:i.spec)==null?void 0:t.definition)==null?void 0:n.type;return e?e==="TARGET_TYPE_OFFLINE"?"Offline":e==="TARGET_TYPE_MOBILE"?"Mobile":"Online":null}},gf,{id:"spec.inferenceServer.name",label:"Target",type:d.CellType.TEXT,accessor:i=>{var t,n;const e=(t=i==null?void 0:i.spec)==null?void 0:t.target;return(e==null?void 0:e.case)==="inferenceServer"?((n=e.value)==null?void 0:n.name)??null:null}},{id:"spec.owner.name",label:"Owner",type:d.CellType.TEXT},mf],Ky={type:"list",tableConfig:{columns:qy}},Yy={id:"deployments",name:"Deployments",service:"deployment",state:"active",views:[Ky,Uy]},Oe={INVALID:0,INITIALIZED:1,CREATE_PENDING:2,SERVING:3,FAILED:4,DELETE_PENDING:5,CREATING:6,DELETING:7,DELETED:8},So={UNKNOWN:0,TRUE:1,FALSE:2},xf={id:"status.state",label:"State",type:d.CellType.STATE,stateTextMap:{[Oe.INVALID]:"Invalid",[Oe.INITIALIZED]:"Initialized",[Oe.CREATE_PENDING]:"Create pending",[Oe.SERVING]:"Serving",[Oe.FAILED]:"Failed",[Oe.DELETE_PENDING]:"Delete pending",[Oe.CREATING]:"Initializing",[Oe.DELETING]:"Deleting",[Oe.DELETED]:"Deleted"},stateColorMap:{[Oe.INVALID]:"gray",[Oe.INITIALIZED]:"blue",[Oe.CREATE_PENDING]:"blue",[Oe.SERVING]:"green",[Oe.FAILED]:"red",[Oe.DELETE_PENDING]:"blue",[Oe.CREATING]:"blue",[Oe.DELETING]:"blue",[Oe.DELETED]:"gray"}},Xy={type:"detail",metadata:[{id:"status.createTime",label:"Created",type:d.CellType.DATE,accessor:i=>{var t;const e=(t=i==null?void 0:i.status)==null?void 0:t.createTime;return e?Math.floor(new Date(e).getTime()/1e3):void 0}},{id:"spec.owner.name",label:"Owner",type:d.CellType.TEXT},xf],pages:[{id:"stages",label:"Stages",type:"execution",emptyState:{title:"No stages reported",description:"Stages will appear here once the inference server is initialized"},tasks:{accessor:"status.conditions",header:{heading:"type",metadata:[{id:"lastUpdatedTimestamp",label:"Last updated",type:d.CellType.DATE,accessor:i=>{const e=i.lastUpdatedTimestamp;return e?Math.floor(Number(e)/1e3):void 0}}]},body:[{type:"textarea",label:"Information",accessor:"message",markdown:!1},{type:"textarea",label:"Details",accessor:"reason",markdown:!1}],stateBuilder:i=>{switch(i.status){case So.TRUE:return oe.SUCCESS;case So.FALSE:return oe.ERROR;case So.UNKNOWN:default:return oe.RUNNING}}}}]},Qy=[{id:"metadata.name",label:"Target name",type:d.CellType.TEXT,url:"/${studio.projectId}/${studio.phase}/targets/${row.metadata.name}"},{id:"status.updateTime",label:"Last updated",type:d.CellType.DATE,accessor:i=>{var t;const e=(t=i==null?void 0:i.status)==null?void 0:t.updateTime;return e?Math.floor(new Date(e).getTime()/1e3):void 0}},{id:"type",label:"Type",type:d.CellType.TAG,accessor:()=>"Inference Server"},xf],Jy={type:"list",tableConfig:{columns:Qy}},Zy={id:"targets",name:"Targets",service:"inferenceServer",state:"active",views:[Jy,Xy]},yf={id:"deploy",icon:"deploy",name:"Deploy & Predict",description:"Deploy your models and predict new data",state:"comingSoon",entities:[Zy,Yy]},eb=[{id:"metadata.name",label:"Name",tooltip:{content:"Click to view model details",action:"filter"}},{id:"metadata.creationTimestamp.seconds",label:"Created",type:d.CellType.DATE},{id:"spec.modelFamily.name",label:"Model Family",type:d.CellType.TEXT},{id:"spec.environment",label:"Environment",type:d.CellType.TYPE,typeTextMap:{0:"Development",1:"Production"}},{id:"spec.deployed",label:"Deployed",type:d.CellType.BOOLEAN},{id:"spec.trainingFramework",label:"Framework",type:d.CellType.TAG},{id:"status.state",label:"State",type:d.CellType.STATE,stateTextMap:{0:"Draft",1:"Training",2:"Completed",3:"Failed",4:"Deployed"},stateColorMap:{0:"gray",1:"blue",2:"green",3:"red",4:"green"}}],tb={type:"list",tableConfig:{columns:eb}},ib={id:"models",name:"Trained Models",service:"model",state:"active",views:[tb]};class bf extends d.Interpolation{execute(e){return this.interpolator(e)}}function Us(i){return typeof i=="function"?new bf(i):new d.StringInterpolation(i)}const vf={id:"status.state",label:"State",type:d.CellType.STATE,stateTextMap:{0:"Queued",1:"Running",2:"Killed",3:"Failed",4:"Succeeded",5:"Pending Kill"},stateColorMap:{0:"gray",1:"blue",2:"gray",3:"red",4:"green",6:"yellow"}},Sf={id:"spec.pipeline.name",label:"Pipeline",items:[{id:"spec.pipeline.name",type:d.CellType.TEXT},{id:"spec.revision.name",type:d.CellType.DESCRIPTION}]},nb={type:"detail",metadata:[{id:"metadata.creationTimestamp.seconds",label:"Created",type:d.CellType.DATE},{id:"spec.actor.name",label:"Started by",type:d.CellType.TEXT},Sf,vf],pages:[{id:"runs",label:"Recent Runs",type:"table",queryConfig:{endpoint:"list",service:"pipelineRun",serviceOptions:{listOptions:{labelSelector:"pipelinerun.michelangelo/triggered-by=${page.metadata.name}"}}},tableConfig:{columns:[{id:"metadata.name",label:"Name",url:"/${studio.projectId}/${studio.phase}/runs/${row.metadata.name}"},...Wr]}}]},sb={type:"list",tableConfig:{columns:[{id:"metadata.name",label:"Name",url:"/${studio.projectId}/${studio.phase}/triggers/${data.metadata.name}"},{id:"metadata.creationTimestamp.seconds",label:"Created",type:d.CellType.DATE},{id:"spec.actor.name",label:"Started by",type:d.CellType.TEXT},Sf,vf]}};var Cf=(i=>(i[i.NO_ACTION=0]="NO_ACTION",i[i.KILL=1]="KILL",i[i.PAUSE=2]="PAUSE",i[i.RESUME=3]="RESUME",i))(Cf||{}),ol=(i=>(i[i.INVALID=0]="INVALID",i[i.RUNNING=1]="RUNNING",i[i.KILLED=2]="KILLED",i[i.FAILED=3]="FAILED",i[i.SUCCEEDED=4]="SUCCEEDED",i[i.PENDING_KILL=5]="PENDING_KILL",i[i.PAUSED=6]="PAUSED",i))(ol||{});const yu=i=>{var t;const e=(t=i.status)==null?void 0:t.state;return e===ol.RUNNING||e===ol.PAUSED},rb={id:"triggers",name:"Triggers",service:"triggerRun",state:"active",views:[sb,nb],actions:[{display:{label:"Kill",icon:"stopCircle"},hierarchy:Us(({data:i})=>yu(i)?hi.SECONDARY:hi.TERTIARY),disabled:[{condition:Us(({data:i})=>!yu(i)),message:"Only running or paused trigger runs can be killed"}],operation:{type:"mutation",mutation:{mutationName:"UpdateTriggerRun",successOperations:[{type:"invalidate",targets:["GetTriggerRun","ListTriggerRun"],delayMs:2e3}],middleware:{operations:[{destination:"spec.action",default:Cf.KILL}]}}},modal:{type:"confirm",header:{title:"Kill Trigger Run"},body:Us(({data:i})=>`Kill run **${i.metadata.name}** in pipeline **${i.spec.pipeline.name}**? This action cannot be undone.`),button:{label:"Kill"}}}]},wf={id:"train",icon:"chartLine",name:"Train & Evaluate",description:"Train machine learning models and evaluate their performance",docUrl:"https://michelangelo-ai.org/docs/user-guides/train-and-deploy-models/train-and-register-a-model",state:"active",entities:[hf,df,rb,ib,{id:"evaluations",name:"evaluations",state:"disabled",service:"evaluationReport",views:[]},{id:"notebooks",name:"notebooks",state:"disabled",service:"notebook",views:[]}]},ma={data:pf,train:wf,deploy:yf},ob=[{id:"core-ml",name:"Core ML",phases:Object.values(ma)}],xa=({children:i,title:e,description:t,expanded:n,defaultExpanded:s=!1,onToggle:r,disabled:o=!1,overrides:l={}})=>{const[a,u]=j.useState(s),c=n!==void 0,h=c?n:a;j.useEffect(()=>{c&&!r&&console.warn("CollapsibleBox: `expanded` prop provided without `onToggle`. This will make the component unresponsive to user interaction. Either provide `onToggle` or use `defaultExpanded` instead.")},[c,r]);const f=()=>{if(o)return;const x=!h;c||u(x),r==null||r(x)},[p,g]=D.getOverrides(l.HeaderTitle,d.StyledBoxTitle),m=e?d.jsxRuntimeExports.jsxs("div",{children:[d.jsxRuntimeExports.jsx(p,{...g,children:e}),t&&d.jsxRuntimeExports.jsx(d.DescriptionText,{children:t})]}):void 0;return d.jsxRuntimeExports.jsx(sm.Panel,{expanded:h,onChange:f,title:m,overrides:D.mergeOverrides({PanelContainer:{component:d.StyledBoxContainer,style:({$expanded:x,$theme:y})=>({...!x&&{gap:0},transitionProperty:"gap",transitionDuration:y.animation.timing500})},Header:{style:{padding:0}},Content:{style:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0}},ToggleIcon:{style:{alignSelf:"flex-start"}}},{...l.Container&&{PanelContainer:l.Container},...l.Header&&{Header:l.Header},...l.Content&&{Content:l.Content},...l.ToggleIcon&&{ToggleIcon:l.ToggleIcon}}),children:i})},lb=D.styled("hr",({$theme:i})=>({border:"none",borderBottom:`2px dashed ${i.colors.contentInverseTertiary}`,margin:`${i.sizing.scale200} 0`})),Dn=D.styled("div",({$theme:i})=>({display:"flex",flexDirection:"column",gap:i.sizing.scale800}));function Ef(i){const{id:e,defaultExpanded:t,state:n,overrides:s,...r}=i,o={Container:{props:{id:e,onClick:l=>l.stopPropagation()},...n&&{style:({$theme:l})=>({borderColor:l.colors[ff[n].borderColorName]})}},Content:{style:({$theme:l})=>({paddingTop:l.sizing.scale300})},...s};return d.jsxRuntimeExports.jsx(xa,{...r,defaultExpanded:t??!1,overrides:o})}function Rf(i){return`task-${i.name}`}function kf(i){const e=document.getElementById(Rf(i));if(!e)return;const t=e.getBoundingClientRect();window.scrollTo({top:window.scrollY+t.top-16,behavior:"smooth"})}function ya(i,e){if(!i.length)return[];const t=i.find(n=>n.focused)??i[i.length-1];return t.subTasks.length===0?[{parent:e,taskList:i}]:[{parent:e,taskList:i},...ya(t.subTasks,t)]}const ab=D.styled("div",({$theme:i})=>({display:"flex",flex:"auto",gap:i.sizing.scale300,flexWrap:"wrap",alignItems:"center"})),Af=D.styled("div",({$theme:i,$color:e,$direction:t})=>{const n=t==="up";return{width:0,height:0,borderLeft:n?"10px solid transparent":`8px solid ${i.colors[e]}`,borderRight:n?"10px solid transparent":"0px solid transparent",borderTop:n?"8px solid transparent":"10px solid transparent",borderBottom:n?`8px solid ${i.colors[e]}`:"10px solid transparent"}});function ba(i){const{state:e}=i,[,{colors:t,sizing:n}]=D.useStyletron(),s=_y[e];return d.jsxRuntimeExports.jsx(d.Icon,{name:s.name,color:t[s.colorName],size:n.scale700})}const Tf={overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},ub=D.styled("div",({$theme:{colors:i,sizing:e},$state:t,role:n})=>{const{colorName:s="contentPrimary",backgroundColorName:r="backgroundPrimary",borderColorName:o}=ff[t];return{flex:"1 1 0",position:"relative",display:"flex",alignItems:"center",gap:e.scale300,height:"44px",padding:"0 16px",boxSizing:"border-box",border:`2px solid ${i[o]}`,borderRadius:"12px",backgroundColor:i[r],color:i[s],cursor:n==="button"?"pointer":"default"}}),cb=D.styled("div",({$theme:{typography:i}})=>({...i.LabelSmall,...Tf}));function Mf(i){const{task:e,onClick:t}=i,{focused:n,name:s,state:r,subTasks:o}=e,l=!!(o!=null&&o.length),[a]=D.useStyletron();return d.jsxRuntimeExports.jsxs(ub,{$state:r,tabIndex:0,...t?{role:"button",onClick:t}:{},children:[d.jsxRuntimeExports.jsx(ba,{state:r}),d.jsxRuntimeExports.jsx(cb,{children:s}),l&&n?d.jsxRuntimeExports.jsx("div",{className:a({position:"absolute",bottom:"-25px",left:"50%",transform:"translate(-50%, 0)"}),children:d.jsxRuntimeExports.jsx(Af,{$color:"contentInverseTertiary",$direction:"up"})}):null]})}function ll({taskList:i,onTaskClick:e}){return d.jsxRuntimeExports.jsx(d.jsxRuntimeExports.Fragment,{children:i.map((t,n)=>d.jsxRuntimeExports.jsxs(j.Fragment,{children:[n>0&&d.jsxRuntimeExports.jsx(Af,{$color:"contentInverseSecondary",$direction:"right"}),d.jsxRuntimeExports.jsx(Mf,{task:t,...e?{onClick:()=>e(t)}:{}})]},n))})}function jf({matrix:i,onTaskClick:e,overrides:t}){const[n,s]=D.getOverrides(t==null?void 0:t.TaskListRenderer,ll),[r,o]=D.getOverrides((t==null?void 0:t.SubTaskListRenderer)??(t==null?void 0:t.TaskListRenderer),ll);return d.jsxRuntimeExports.jsx(d.jsxRuntimeExports.Fragment,{children:i.map((l,a)=>{const u=l.parent?r:n,c=l.parent?o:s;return d.jsxRuntimeExports.jsxs(j.Fragment,{children:[a>0&&d.jsxRuntimeExports.jsx(lb,{}),d.jsxRuntimeExports.jsx(ab,{children:d.jsxRuntimeExports.jsx(u,{taskList:l.taskList,onTaskClick:e,parent:l.parent,...c})})]},a)})})}function hb(i){const{label:e,cells:t,value:n}=i;return d.jsxRuntimeExports.jsx(Ef,{title:d.jsxRuntimeExports.jsx(bt.LabelSmall,{children:e}),children:d.jsxRuntimeExports.jsx(d.Row,{items:t,record:n??void 0})})}const Of=1024;let fb=0,Co=class{constructor(e,t){this.from=e,this.to=t}};class te{constructor(e={}){this.id=fb++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Ze.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}}te.closedBy=new te({deserialize:i=>i.split(" ")});te.openedBy=new te({deserialize:i=>i.split(" ")});te.group=new te({deserialize:i=>i.split(" ")});te.isolate=new te({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});te.contextHash=new te({perNode:!0});te.lookAhead=new te({perNode:!0});te.mounted=new te({perNode:!0});class hr{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[te.mounted.id]}}const db=Object.create(null);class Ze{constructor(e,t,n,s=0){this.name=e,this.props=t,this.id=n,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):db,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new Ze(e.name||"",t,e.id,n);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(te.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let s of n.split(" "))t[s]=e[n];return n=>{for(let s=n.prop(te.group),r=-1;r<(s?s.length:0);r++){let o=t[r<0?n.name:s[r]];if(o)return o}}}}Ze.none=new Ze("",Object.create(null),0,8);class va{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let s=null;for(let r of e){let o=r(n);if(o){s||(s=Object.assign({},n.props));let l=o[1],a=o[0];a.combine&&a.id in s&&(l=a.combine(s[a.id],l)),s[a.id]=l}}t.push(s?new Ze(n.name,s,n.id,n.flags):n)}return new va(t)}}const vs=new WeakMap,bu=new WeakMap;var Ie;(function(i){i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays"})(Ie||(Ie={}));class Re{constructor(e,t,n,s,r){if(this.type=e,this.children=t,this.positions=n,this.length=s,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=hr.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let s=n.toString();s&&(t&&(t+=","),t+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new ul(this.topNode,e)}cursorAt(e,t=0,n=0){let s=vs.get(this)||this.topNode,r=new ul(s);return r.moveTo(e,t),vs.set(this,r._tree),r}get topNode(){return new ft(this,0,0,null)}resolve(e,t=0){let n=Hn(vs.get(this)||this.topNode,e,t,!1);return vs.set(this,n),n}resolveInner(e,t=0){let n=Hn(bu.get(this)||this.topNode,e,t,!0);return bu.set(this,n),n}resolveStack(e,t=0){return mb(this,e,t)}iterate(e){let{enter:t,leave:n,from:s=0,to:r=this.length}=e,o=e.mode||0,l=(o&Ie.IncludeAnonymous)>0;for(let a=this.cursor(o|Ie.IncludeAnonymous);;){let u=!1;if(a.from<=r&&a.to>=s&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;u=!0}for(;u&&n&&(l||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:wa(Ze.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,s)=>new Re(this.type,t,n,s,this.propValues),e.makeTree||((t,n,s)=>new Re(Ze.none,t,n,s)))}static build(e){return xb(e)}}Re.empty=new Re(Ze.none,[],[],0);class Sa{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Sa(this.buffer,this.index)}}class gi{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Ze.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],s=this.set.types[t],r=s.name;if(/\W/.test(r)&&!s.isError&&(r=JSON.stringify(r)),e+=4,n==e)return r;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,n,s,r){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(If(r,s,o[a+1],o[a+2])&&(l=a,n>0));a=o[a+3]);return l}slice(e,t,n){let s=this.buffer,r=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){r[a++]=s[l++],r[a++]=s[l++]-n;let u=r[a++]=s[l++]-n;r[a++]=s[l++]-e,o=Math.max(o,u)}return new gi(r,o,this.set)}}function If(i,e,t,n){switch(i){case-2:return t<e;case-1:return n>=e&&t<e;case 0:return t<e&&n>e;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function Hn(i,e,t,n){for(var s;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to<e);){let o=!n&&i instanceof ft&&i.index<0?null:i.parent;if(!o)return i;i=o}let r=n?0:Ie.IgnoreOverlays;if(n)for(let o=i,l=o.parent;l;o=l,l=o.parent)o instanceof ft&&o.index<0&&((s=l.enter(e,t,r))===null||s===void 0?void 0:s.from)!=o.from&&(i=l);for(;;){let o=i.enter(e,t,r);if(!o)return i;i=o}}class Pf{cursor(e=0){return new ul(this,e)}getChild(e,t=null,n=null){let s=vu(this,e,t,n);return s.length?s[0]:null}getChildren(e,t=null,n=null){return vu(this,e,t,n)}resolve(e,t=0){return Hn(this,e,t,!1)}resolveInner(e,t=0){return Hn(this,e,t,!0)}matchContext(e){return al(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let s=t.lastChild;if(!s||s.to!=t.to)break;s.type.isError&&s.from==s.to?(n=t,t=s.prevSibling):t=s}return n}get node(){return this}get next(){return this.parent}}class ft extends Pf{constructor(e,t,n,s){super(),this._tree=e,this.from=t,this.index=n,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,s,r=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,u=t>0?l.length:-1;e!=u;e+=t){let c=l[e],h=a[e]+o.from;if(If(s,n,h,h+c.length)){if(c instanceof gi){if(r&Ie.ExcludeBuffers)continue;let f=c.findChild(0,c.buffer.length,t,n-h,s);if(f>-1)return new ai(new pb(o,c,e,h),null,f)}else if(r&Ie.IncludeAnonymous||!c.type.isAnonymous||Ca(c)){let f;if(!(r&Ie.IgnoreMounts)&&(f=hr.get(c))&&!f.overlay)return new ft(f.tree,h,e,o);let p=new ft(c,h,e,o);return r&Ie.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,n,s)}}}if(r&Ie.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let s;if(!(n&Ie.IgnoreOverlays)&&(s=hr.get(this._tree))&&s.overlay){let r=e-this.from;for(let{from:o,to:l}of s.overlay)if((t>0?o<=r:o<r)&&(t<0?l>=r:l>r))return new ft(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function vu(i,e,t,n){let s=i.cursor(),r=[];if(!s.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=s.type.is(t),!s.nextSibling())return r}for(;;){if(n!=null&&s.type.is(n))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return n==null?r:[]}}function al(i,e,t=e.length-1){for(let n=i;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}class pb{constructor(e,t,n,s){this.parent=e,this.buffer=t,this.index=n,this.start=s}}class ai extends Pf{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,n);return r<0?null:new ai(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&Ie.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new ai(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new ai(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new ai(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,s=this.index+4,r=n.buffer[this.index+3];if(r>s){let o=n.buffer[this.index+1];e.push(n.slice(s,r,o)),t.push(0)}return new Re(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Df(i){if(!i.length)return null;let e=0,t=i[0];for(let r=1;r<i.length;r++){let o=i[r];(o.from>t.from||o.to<t.to)&&(t=o,e=r)}let n=t instanceof ft&&t.index<0?null:t.parent,s=i.slice();return n?s[e]=n:s.splice(e,1),new gb(s,t)}class gb{constructor(e,t){this.heads=e,this.node=t}get next(){return Df(this.heads)}}function mb(i,e,t){let n=i.resolveInner(e,t),s=null;for(let r=n instanceof ft?n:n.context.parent;r;r=r.parent)if(r.index<0){let o=r.parent;(s||(s=[n])).push(o.resolve(e,t)),r=o}else{let o=hr.get(r.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new ft(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[n])).push(Hn(l,e,t,!1))}}return s?Df(s):n}class ul{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof ft)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=n+s.buffer[e+1],this.to=n+s.buffer[e+2],!0}yield(e){return e?e instanceof ft?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,n);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&Ie.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Ie.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Ie.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let s=n<0?0:this.stack[n]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(s)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:s}=this;if(s){if(e>0){if(this.index<s.buffer.buffer.length)return!1}else for(let r=0;r<this.index;r++)if(s.buffer.buffer[r+3]<this.index)return!1;({index:t,parent:n}=s)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,o=e<0?-1:n._tree.children.length;r!=o;r+=e){let l=n._tree.children[r];if(this.mode&Ie.IncludeAnonymous||l instanceof gi||!l.type.isAnonymous||Ca(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let s=this.index,r=this.stack.length;r>=0;){for(let o=e;o;o=o._parent)if(o.index==s){if(s==this.index)return o;t=o,n=r+1;break e}s=this.stack[--r]}for(let s=n;s<this.stack.length;s++)t=new ai(this.buffer,t,this.stack[s]);return this.bufferNode=new ai(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let s=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(s=!0)}for(;;){if(s&&t&&t(this),s=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,s=!0}}}matchContext(e){if(!this.buffer)return al(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let s=e.length-1,r=this.stack.length-1;s>=0;r--){if(r<0)return al(this._tree,e,s);let o=n[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[s]&&e[s]!=o.name)return!1;s--}}return!0}}function Ca(i){return i.children.some(e=>e instanceof gi||!e.type.isAnonymous||Ca(e))}function xb(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:s=Of,reused:r=[],minRepeatType:o=n.types.length}=i,l=Array.isArray(t)?new Sa(t,t.length):t,a=n.types,u=0,c=0;function h(S,E,A,O,R,H){let{id:N,start:I,end:W,size:P}=l,U=c,Q=u;if(P<0)if(l.next(),P==-1){let G=r[N];A.push(G),O.push(I-S);return}else if(P==-3){u=N;return}else if(P==-4){c=N;return}else throw new RangeError(`Unrecognized record size: ${P}`);let he=a[N],pe,ie,ee=I-S;if(W-I<=s&&(ie=x(l.pos-E,R))){let G=new Uint16Array(ie.size-ie.skip),C=l.pos-ie.size,M=G.length;for(;l.pos>C;)M=y(ie.start,G,M);pe=new gi(G,W-ie.start,n),ee=ie.start-S}else{let G=l.pos-P;l.next();let C=[],M=[],L=N>=o?N:-1,F=0,X=W;for(;l.pos>G;)L>=0&&l.id==L&&l.size>=0?(l.end<=X-s&&(g(C,M,I,F,l.end,X,L,U,Q),F=C.length,X=l.end),l.next()):H>2500?f(I,G,C,M):h(I,G,C,M,L,H+1);if(L>=0&&F>0&&F<C.length&&g(C,M,I,F,I,X,L,U,Q),C.reverse(),M.reverse(),L>-1&&F>0){let Z=p(he,Q);pe=wa(he,C,M,0,C.length,0,W-I,Z,Z)}else pe=m(he,C,M,W-I,U-W,Q)}A.push(pe),O.push(ee)}function f(S,E,A,O){let R=[],H=0,N=-1;for(;l.pos>E;){let{id:I,start:W,end:P,size:U}=l;if(U>4)l.next();else{if(N>-1&&W<N)break;N<0&&(N=P-s),R.push(I,W,P),H++,l.next()}}if(H){let I=new Uint16Array(H*4),W=R[R.length-2];for(let P=R.length-3,U=0;P>=0;P-=3)I[U++]=R[P],I[U++]=R[P+1]-W,I[U++]=R[P+2]-W,I[U++]=U;A.push(new gi(I,R[2]-W,n)),O.push(W-S)}}function p(S,E){return(A,O,R)=>{let H=0,N=A.length-1,I,W;if(N>=0&&(I=A[N])instanceof Re){if(!N&&I.type==S&&I.length==R)return I;(W=I.prop(te.lookAhead))&&(H=O[N]+I.length+W)}return m(S,A,O,R,H,E)}}function g(S,E,A,O,R,H,N,I,W){let P=[],U=[];for(;S.length>O;)P.push(S.pop()),U.push(E.pop()+A-R);S.push(m(n.types[N],P,U,H-R,I-H,W)),E.push(R-A)}function m(S,E,A,O,R,H,N){if(H){let I=[te.contextHash,H];N=N?[I].concat(N):[I]}if(R>25){let I=[te.lookAhead,R];N=N?[I].concat(N):[I]}return new Re(S,E,A,O,N)}function x(S,E){let A=l.fork(),O=0,R=0,H=0,N=A.end-s,I={size:0,start:0,skip:0};e:for(let W=A.pos-S;A.pos>W;){let P=A.size;if(A.id==E&&P>=0){I.size=O,I.start=R,I.skip=H,H+=4,O+=4,A.next();continue}let U=A.pos-P;if(P<0||U<W||A.start<N)break;let Q=A.id>=o?4:0,he=A.start;for(A.next();A.pos>U;){if(A.size<0)if(A.size==-3)Q+=4;else break e;else A.id>=o&&(Q+=4);A.next()}R=he,O+=P,H+=Q}return(E<0||O==S)&&(I.size=O,I.start=R,I.skip=H),I.size>4?I:void 0}function y(S,E,A){let{id:O,start:R,end:H,size:N}=l;if(l.next(),N>=0&&O<o){let I=A;if(N>4){let W=l.pos-(N-4);for(;l.pos>W;)A=y(S,E,A)}E[--A]=I,E[--A]=H-S,E[--A]=R-S,E[--A]=O}else N==-3?u=O:N==-4&&(c=O);return A}let b=[],v=[];for(;l.pos>0;)h(i.start||0,i.bufferStart||0,b,v,-1,0);let w=(e=i.length)!==null&&e!==void 0?e:b.length?v[0]+b[0].length:0;return new Re(a[i.topID],b.reverse(),v.reverse(),w)}const Su=new WeakMap;function qs(i,e){if(!i.isAnonymous||e instanceof gi||e.type!=i)return 1;let t=Su.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof Re)){t=1;break}t+=qs(i,n)}Su.set(e,t)}return t}function wa(i,e,t,n,s,r,o,l,a){let u=0;for(let g=n;g<s;g++)u+=qs(i,e[g]);let c=Math.ceil(u*1.5/8),h=[],f=[];function p(g,m,x,y,b){for(let v=x;v<y;){let w=v,S=m[v],E=qs(i,g[v]);for(v++;v<y;v++){let A=qs(i,g[v]);if(E+A>=c)break;E+=A}if(v==w+1){if(E>c){let A=g[w];p(A.children,A.positions,0,A.children.length,m[w]+b);continue}h.push(g[w])}else{let A=m[v-1]+g[v-1].length-S;h.push(wa(i,g,m,w,v,S,A,null,a))}f.push(S+b-r)}}return p(e,t,n,s,0),(l||a)(h,f,o)}class Ii{constructor(e,t,n,s,r=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=s,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let s=[new Ii(0,e.length,e,0,!1,n)];for(let r of t)r.to>e.length&&s.push(r);return s}static applyChanges(e,t,n=128){if(!t.length)return e;let s=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,u=0;;l++){let c=l<t.length?t[l]:null,h=c?c.fromA:1e9;if(h-a>=n)for(;o&&o.from<h;){let f=o;if(a>=f.from||h<=f.to||u){let p=Math.max(f.from,a)-u,g=Math.min(f.to,h)-u;f=p>=g?null:new Ii(p,g,f.tree,f.offset+u,l>0,!!c)}if(f&&s.push(f),o.to>h)break;o=r<e.length?e[r++]:null}if(!c)break;a=c.toA,u=c.toA-c.toB}return s}}class Lf{startParse(e,t,n){return typeof e=="string"&&(e=new yb(e)),n=n?n.length?n.map(s=>new Co(s.from,s.to)):[new Co(0,0)]:[new Co(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let s=this.startParse(e,t,n);for(;;){let r=s.advance();if(r)return r}}}class yb{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new te({perNode:!0});class fr{constructor(e,t,n,s,r,o,l,a,u,c=0,h){this.p=e,this.stack=t,this.state=n,this.reducePos=s,this.pos=r,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=u,this.lookAhead=c,this.parent=h}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let s=e.parser.context;return new fr(e,[],t,n,n,0,[],0,s?new Cu(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,s=e&65535,{parser:r}=this.p,o=this.reducePos<this.pos-25;o&&this.setLookAhead(this.pos);let l=r.dynamicPrecedence(s);if(l&&(this.score+=l),n==0){this.pushState(r.getGoto(this.state,s,!0),this.reducePos),s<r.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(s,this.reducePos);return}let a=this.stack.length-(n-1)*3-(e&262144?6:0),u=a?this.stack[a-2]:this.p.ranges[0].from,c=this.reducePos-u;c>=2e3&&!(!((t=this.p.parser.nodeSet.types[s])===null||t===void 0)&&t.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=u,this.p.lastBigReductionSize=c));let h=a?this.stack[a-1]:0,f=this.bufferBase+this.buffer.length-h;if(s<r.minRepeatTerm||e&131072){let p=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,u,p,f+4,!0)}if(e&262144)this.state=this.stack[a];else{let p=this.stack[a-3];this.state=r.getGoto(p,s,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(s,u)}storeNode(e,t,n,s=4,r=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,l=this.buffer.length;if(l==0&&o.parent&&(l=o.bufferBase-o.parent.bufferBase,o=o.parent),l>0&&o.buffer[l-4]==0&&o.buffer[l-1]>-1){if(t==n)return;if(o.buffer[l-2]>=t){o.buffer[l-2]=n;return}}}if(!r||this.pos==n)this.buffer.push(e,t,n,s);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>n;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>n;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=n,this.buffer[o+3]=s}}shift(e,t,n,s){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let r=e,{parser:o}=this.p;(s>this.pos||t<=o.maxNode)&&(this.pos=s,o.stateFlag(r,1)||(this.reducePos=s)),this.pushState(r,n),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,s,4)}else this.pos=s,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,s,4)}apply(e,t,n,s){e&65536?this.reduce(e):this.shift(e,t,n,s)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(n,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new fr(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,s,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new bb(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if((n&65536)==0)return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let s=[];for(let r=0,o;r<t.length;r+=2)(o=t[r+1])!=this.state&&this.p.parser.hasAction(o,e)&&s.push(t[r],o);if(this.stack.length<120)for(let r=0;s.length<8&&r<t.length;r+=2){let o=t[r+1];s.some((l,a)=>a&1&&l==o)||s.push(t[r],o)}t=s}let n=[];for(let s=0;s<t.length&&n.length<4;s+=2){let r=t[s+1];if(r==this.state)continue;let o=this.split();o.pushState(r,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[s],this.pos),o.reducePos=this.pos,o.score-=200,n.push(o)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if((t&65536)==0)return!1;if(!e.validAction(this.state,t)){let n=t>>19,s=t&65535,r=this.stack.length-n*3;if(r<0||e.getGoto(this.stack[r],s,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(s,r)=>{if(!t.includes(s))return t.push(s),e.allActions(s,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-r;if(l>1){let a=o&65535,u=this.stack.length-l*3;if(u>=0&&e.getGoto(this.stack[u],a,!1)>=0)return l<<19|65536|a}}else{let l=n(o,r+1);if(l!=null)return l}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new Cu(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class Cu{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class bb{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=s}}class dr{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new dr(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new dr(this.stack,this.pos,this.index)}}function Ss(i,e=Uint16Array){if(typeof i!="string")return i;let t=null;for(let n=0,s=0;n<i.length;){let r=0;for(;;){let o=i.charCodeAt(n++),l=!1;if(o==126){r=65535;break}o>=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),r+=a,l)break;r*=46}t?t[s++]=r:t=new e(r)}return t}class Ks{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const wu=new Ks;class vb{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=wu,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,s=this.rangeIndex,r=this.pos+e;for(;r<n.from;){if(!s)return null;let o=this.ranges[--s];r-=n.from-o.to,n=o}for(;t<0?r>n.to:r>=n.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];r+=o.from-n.to,n=o}return r}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,s;if(t>=0&&t<this.chunk.length)n=this.pos+e,s=this.chunk.charCodeAt(t);else{let r=this.resolveOffset(e,1);if(r==null)return-1;if(n=r,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)s=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=n;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-n)),s=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),s}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=wu,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let s of this.ranges){if(s.from>=t)break;s.to>e&&(n+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return n}}class en{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;Sb(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}en.prototype.contextual=en.prototype.fallback=en.prototype.extend=!1;en.prototype.fallback=en.prototype.extend=!1;function Sb(i,e,t,n,s,r){let o=0,l=1<<n,{dialect:a}=t.p.parser;e:for(;(l&i[o])!=0;){let u=i[o+1];for(let p=o+3;p<u;p+=2)if((i[p+1]&l)>0){let g=i[p];if(a.allows(g)&&(e.token.value==-1||e.token.value==g||Cb(g,e.token.value,s,r))){e.acceptToken(g);break}}let c=e.next,h=0,f=i[o+2];if(e.next<0&&f>h&&i[u+f*3-3]==65535){o=i[u+f*3-1];continue e}for(;h<f;){let p=h+f>>1,g=u+p+(p<<1),m=i[g],x=i[g+1]||65536;if(c<m)f=p;else if(c>=x)h=p+1;else{o=i[g+2],e.advance();continue e}}break}}function Eu(i,e,t){for(let n=e,s;(s=i[n])!=65535;n++)if(s==t)return n-e;return-1}function Cb(i,e,t,n){let s=Eu(t,n,e);return s<0||Eu(t,n,i)<s}const et=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG);let wo=null;function Ru(i,e,t){let n=i.cursor(Ie.IncludeAnonymous);for(n.moveTo(e);;)if(!(t<0?n.childBefore(e):n.childAfter(e)))for(;;){if((t<0?n.to<e:n.from>e)&&!n.type.isError)return t<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(i.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:i.length}}class wb{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Ru(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Ru(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],s=this.index[t];if(s==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=n.children[s],o=this.start[t]+n.positions[s];if(o>e)return this.nextStart=o,null;if(r instanceof Re){if(o==e){if(o<this.safeFrom)return null;let l=o+r.length;if(l<=this.safeTo){let a=r.prop(te.lookAhead);if(!a||l+a<this.fragment.to)return r}}this.index[t]++,o+r.length>=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class Eb{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new Ks)}getActions(e){let t=0,n=null,{parser:s}=e.p,{tokenizers:r}=s,o=s.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let u=0;u<r.length;u++){if((1<<u&o)==0)continue;let c=r[u],h=this.tokens[u];if(!(n&&!c.fallback)&&((c.contextual||h.start!=e.pos||h.mask!=o||h.context!=l)&&(this.updateCachedToken(h,c,e),h.mask=o,h.context=l),h.lookAhead>h.end+25&&(a=Math.max(h.lookAhead,a)),h.value!=0)){let f=t;if(h.extended>-1&&(t=this.addActions(e,h.extended,h.end,t)),t=this.addActions(e,h.value,h.end,t),!c.extend&&(n=h,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!n&&e.pos==this.stream.end&&(n=new Ks,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Ks,{pos:n,p:s}=e;return t.start=n,t.end=Math.min(n+1,s.stream.end),t.value=n==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,n){let s=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(s,e),n),e.value>-1){let{parser:r}=n.p;for(let o=0;o<r.specialized.length;o++)if(r.specialized[o]==e.value){let l=r.specializers[o](this.stream.read(e.start,e.end),n);if(l>=0&&n.p.parser.dialect.allows(l>>1)){(l&1)==0?e.value=l>>1:e.extended=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(s+1)}putAction(e,t,n,s){for(let r=0;r<s;r+=3)if(this.actions[r]==e)return s;return this.actions[s++]=e,this.actions[s++]=t,this.actions[s++]=n,s}addActions(e,t,n,s){let{state:r}=e,{parser:o}=e.p,{data:l}=o;for(let a=0;a<2;a++)for(let u=o.stateSlot(r,a?2:1);;u+=3){if(l[u]==65535)if(l[u+1]==1)u=Wt(l,u+2);else{s==0&&l[u+1]==2&&(s=this.putAction(Wt(l,u+2),t,n,s));break}l[u]==t&&(s=this.putAction(Wt(l,u+1),t,n,s))}return s}}class Rb{constructor(e,t,n,s){this.parser=e,this.input=t,this.ranges=s,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new vb(t,s),this.tokens=new Eb(e,this.stream),this.topTerm=e.top[1];let{from:r}=s[0];this.stacks=[fr.start(this,e.top[0],r)],this.fragments=n.length&&this.stream.end-r>e.bufferLength*4?new wb(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],s,r;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let l=e[o];for(;;){if(this.tokens.mainToken=null,l.pos>t)n.push(l);else{if(this.advanceStack(l,n,e))continue;{s||(s=[],r=[]),s.push(l);let a=this.tokens.getMainToken(l);r.push(a.value,a.end)}}break}}if(!n.length){let o=s&&Ab(s);if(o)return et&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw et&&s&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,r,n);if(o)return et&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(n.length>o)for(n.sort((l,a)=>a.score-l.score);n.length>o;)n.pop();n.some(l=>l.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let o=0;o<n.length-1;o++){let l=n[o];for(let a=o+1;a<n.length;a++){let u=n[a];if(l.sameState(u)||l.buffer.length>500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)n.splice(a--,1);else{n.splice(o--,1);continue e}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let o=1;o<n.length;o++)n[o].pos<this.minStackPos&&(this.minStackPos=n[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let s=e.pos,{parser:r}=this,o=et?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let h=this.fragments.nodeAt(s);h;){let f=this.parser.nodeSet.types[h.type.id]==h.type?r.getGoto(e.state,h.type.id):-1;if(f>-1&&h.length&&(!u||(h.prop(te.contextHash)||0)==c))return e.useNode(h,f),et&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(h.type.id)})`),!0;if(!(h instanceof Re)||h.children.length==0||h.positions[0]>0)break;let p=h.children[0];if(p instanceof Re&&h.positions[0]==0)h=p;else break}}let l=r.stateSlot(e.state,4);if(l>0)return e.reduce(l),et&&console.log(o+this.stackID(e)+` (via always-reduce ${r.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let u=0;u<a.length;){let c=a[u++],h=a[u++],f=a[u++],p=u==a.length||!n,g=p?e:e.split(),m=this.tokens.mainToken;if(g.apply(c,h,m?m.start:g.pos,f),et&&console.log(o+this.stackID(g)+` (via ${(c&65536)==0?"shift":`reduce of ${r.getName(c&65535)}`} for ${r.getName(h)} @ ${s}${g==e?"":", split"})`),p)return!0;g.pos>s?t.push(g):n.push(g)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return ku(e,t),!0}}runRecovery(e,t,n){let s=null,r=!1;for(let o=0;o<e.length;o++){let l=e[o],a=t[o<<1],u=t[(o<<1)+1],c=et?this.stackID(l)+" -> ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),et&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,n))))continue;let h=l.split(),f=c;for(let p=0;p<10&&h.forceReduce()&&(et&&console.log(f+this.stackID(h)+" (via force-reduce)"),!this.advanceFully(h,n));p++)et&&(f=this.stackID(h)+" -> ");for(let p of l.recoverByInsert(a))et&&console.log(c+this.stackID(p)+" (via recover-insert)"),this.advanceFully(p,n);this.stream.end>l.pos?(u==l.pos&&(u++,a=0),l.recoverByDelete(a,u),et&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),ku(l,n)):(!s||s.score<l.score)&&(s=l)}return s}stackToTree(e){return e.close(),Re.build({buffer:dr.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(wo||(wo=new WeakMap)).get(e);return t||wo.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function ku(i,e){for(let t=0;t<e.length;t++){let n=e[t];if(n.pos==i.pos&&n.sameState(i)){e[t].score<i.score&&(e[t]=i);return}}e.push(i)}class kb{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}}class pr extends Lf{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;l<e.repeatNodeCount;l++)t.push("");let n=Object.keys(e.topRules).map(l=>e.topRules[l][1]),s=[];for(let l=0;l<t.length;l++)s.push([]);function r(l,a,u){s[l].push([a,a.deserialize(String(u))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=te[a]);for(let u=1;u<l.length;){let c=l[u++];if(c>=0)r(c,a,l[u++]);else{let h=l[u+-c];for(let f=-c;f>0;f--)r(l[u++],a,h);u++}}}this.nodeSet=new va(t.map((l,a)=>Ze.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:s[a],top:n.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Of;let o=Ss(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(Au),this.states=Ss(e.states,Uint32Array),this.data=Ss(e.stateData),this.goto=Ss(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new en(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let s=new Rb(this,e,t,n);for(let r of this.wrappers)s=r(s,e,t,n);return s}getGoto(e,t,n=!1){let s=this.goto;if(t>=s[0])return-1;for(let r=s[t+1];;){let o=s[r++],l=o&1,a=s[r++];if(l&&n)return a;for(let u=r+(o>>1);r<u;r++)if(s[r]==e)return a;if(l)return-1}}hasAction(e,t){let n=this.data;for(let s=0;s<2;s++)for(let r=this.stateSlot(e,s?2:1),o;;r+=3){if((o=n[r])==65535)if(n[r+1]==1)o=n[r=Wt(n,r+2)];else{if(n[r+1]==2)return Wt(n,r+2);break}if(o==t||o==0)return Wt(n,r+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,n=>n==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),s=n?t(n):void 0;for(let r=this.stateSlot(e,1);s==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Wt(this.data,r+2);else break;s=t(Wt(this.data,r+1))}return s}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=Wt(this.data,n+2);else break;if((this.data[n+2]&1)==0){let s=this.data[n+1];t.some((r,o)=>o&1&&r==s)||t.push(this.data[n],s)}}return t}configure(e){let t=Object.assign(Object.create(pr.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(n=>{let s=e.tokenizers.find(r=>r.from==n);return s?s.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,s)=>{let r=e.specializers.find(l=>l.from==n.external);if(!r)return n;let o=Object.assign(Object.assign({},n),{external:r.to});return t.specializers[s]=Au(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(" ")){let o=t.indexOf(r);o>=0&&(n[o]=!0)}let s=null;for(let r=0;r<t.length;r++)if(!n[r])for(let o=this.dialects[t[r]],l;(l=this.data[o++])!=65535;)(s||(s=new Uint8Array(this.maxTerm+1)))[l]=1;return new kb(e,n,s)}static deserialize(e){return new pr(e)}}function Wt(i,e){return i[e]|i[e+1]<<16}function Ab(i){let e=null;for(let t of i){let n=t.p.stoppedAt;(t.pos==t.p.stream.end||n!=null&&t.pos>n)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function Au(i){if(i.external){let e=i.extend?1:0;return(t,n)=>i.external(t,n)<<1|e}return i.get}let Tb=0;class at{constructor(e,t,n,s){this.name=e,this.set=t,this.base=n,this.modified=s,this.id=Tb++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e=="string"?e:"?";if(e instanceof at&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let s=new at(n,[],null,[]);if(s.set.push(s),t)for(let r of t.set)s.set.push(r);return s}static defineModifier(e){let t=new gr(e);return n=>n.modified.indexOf(t)>-1?n:gr.get(n.base||n,n.modified.concat(t).sort((s,r)=>s.id-r.id))}}let Mb=0;class gr{constructor(e){this.name=e,this.instances=[],this.id=Mb++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(l=>l.base==e&&jb(t,l.modified));if(n)return n;let s=[],r=new at(e.name,s,e,t);for(let l of t)l.instances.push(r);let o=Ob(t);for(let l of e.set)if(!l.modified.length)for(let a of o)s.push(gr.get(l,a));return r}}function jb(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function Ob(i){let e=[[]];for(let t=0;t<i.length;t++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(i[t]));return e.sort((t,n)=>n.length-t.length)}function Ff(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let s of t.split(" "))if(s){let r=[],o=2,l=s;for(let h=0;;){if(l=="..."&&h>0&&h+3==s.length){o=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!f)throw new RangeError("Invalid path: "+s);if(r.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),h+=f[0].length,h==s.length)break;let p=s[h++];if(h==s.length&&p=="!"){o=0;break}if(p!="/")throw new RangeError("Invalid path: "+s);l=s.slice(h)}let a=r.length-1,u=r[a];if(!u)throw new RangeError("Invalid path: "+s);let c=new Gn(n,o,a>0?r.slice(0,a):null);e[u]=c.sort(e[u])}}return Nf.add(e)}const Nf=new te({combine(i,e){let t,n,s;for(;i||e;){if(!i||e&&i.depth>=e.depth?(s=e,e=e.next):(s=i,i=i.next),t&&t.mode==s.mode&&!s.context&&!t.context)continue;let r=new Gn(s.tags,s.mode,s.context);t?t.next=r:n=r,t=r}return n}});class Gn{constructor(e,t,n,s){this.tags=e,this.mode=t,this.context=n,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Gn.empty=new Gn([],2,null);function Bf(i,e){let t=Object.create(null);for(let r of i)if(!Array.isArray(r.tag))t[r.tag.id]=r.class;else for(let o of r.tag)t[o.id]=r.class;let{scope:n,all:s=null}=e||{};return{style:r=>{let o=s;for(let l of r)for(let a of l.set){let u=t[a.id];if(u){o=o?o+" "+u:u;break}}return o},scope:n}}function Ib(i,e){let t=null;for(let n of i){let s=n.style(e);s&&(t=t?t+" "+s:s)}return t}function Pb(i,e,t,n=0,s=i.length){let r=new Db(n,Array.isArray(e)?e:[e],t);r.highlightRange(i.cursor(),n,s,"",r.highlighters),r.flush(s)}class Db{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,s,r){let{type:o,from:l,to:a}=e;if(l>=n||a<=t)return;o.isTop&&(r=this.highlighters.filter(p=>!p.scope||p.scope(o)));let u=s,c=Lb(e)||Gn.empty,h=Ib(r,c.tags);if(h&&(u&&(u+=" "),u+=h,c.mode==1&&(s+=(s?" ":"")+h)),this.startSpan(Math.max(t,l),u),c.opaque)return;let f=e.tree&&e.tree.prop(te.mounted);if(f&&f.overlay){let p=e.node.enter(f.overlay[0].from+l,1),g=this.highlighters.filter(x=>!x.scope||x.scope(f.tree.type)),m=e.firstChild();for(let x=0,y=l;;x++){let b=x<f.overlay.length?f.overlay[x]:null,v=b?b.from+l:a,w=Math.max(t,y),S=Math.min(n,v);if(w<S&&m)for(;e.from<S&&(this.highlightRange(e,w,S,s,r),this.startSpan(Math.min(S,e.to),u),!(e.to>=v||!e.nextSibling())););if(!b||v>n)break;y=b.to+l,y>t&&(this.highlightRange(p.cursor(),Math.max(t,b.from+l),Math.min(n,y),"",g),this.startSpan(Math.min(n,y),u))}m&&e.parent()}else if(e.firstChild()){f&&(s="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,s,r),this.startSpan(Math.min(n,e.to),u)}while(e.nextSibling());e.parent()}}}function Lb(i){let e=i.type.prop(Nf);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}const B=at.define,Cs=B(),si=B(),Tu=B(si),Mu=B(si),ri=B(),ws=B(ri),Eo=B(ri),jt=B(),Ei=B(jt),At=B(),Tt=B(),cl=B(),En=B(cl),Es=B(),k={comment:Cs,lineComment:B(Cs),blockComment:B(Cs),docComment:B(Cs),name:si,variableName:B(si),typeName:Tu,tagName:B(Tu),propertyName:Mu,attributeName:B(Mu),className:B(si),labelName:B(si),namespace:B(si),macroName:B(si),literal:ri,string:ws,docString:B(ws),character:B(ws),attributeValue:B(ws),number:Eo,integer:B(Eo),float:B(Eo),bool:B(ri),regexp:B(ri),escape:B(ri),color:B(ri),url:B(ri),keyword:At,self:B(At),null:B(At),atom:B(At),unit:B(At),modifier:B(At),operatorKeyword:B(At),controlKeyword:B(At),definitionKeyword:B(At),moduleKeyword:B(At),operator:Tt,derefOperator:B(Tt),arithmeticOperator:B(Tt),logicOperator:B(Tt),bitwiseOperator:B(Tt),compareOperator:B(Tt),updateOperator:B(Tt),definitionOperator:B(Tt),typeOperator:B(Tt),controlOperator:B(Tt),punctuation:cl,separator:B(cl),bracket:En,angleBracket:B(En),squareBracket:B(En),paren:B(En),brace:B(En),content:jt,heading:Ei,heading1:B(Ei),heading2:B(Ei),heading3:B(Ei),heading4:B(Ei),heading5:B(Ei),heading6:B(Ei),contentSeparator:B(jt),list:B(jt),quote:B(jt),emphasis:B(jt),strong:B(jt),link:B(jt),monospace:B(jt),strikethrough:B(jt),inserted:B(),deleted:B(),changed:B(),invalid:B(),meta:Es,documentMeta:B(Es),annotation:B(Es),processingInstruction:B(Es),definition:at.defineModifier("definition"),constant:at.defineModifier("constant"),function:at.defineModifier("function"),standard:at.defineModifier("standard"),local:at.defineModifier("local"),special:at.defineModifier("special")};for(let i in k){let e=k[i];e instanceof at&&(e.name=i)}Bf([{tag:k.link,class:"tok-link"},{tag:k.heading,class:"tok-heading"},{tag:k.emphasis,class:"tok-emphasis"},{tag:k.strong,class:"tok-strong"},{tag:k.keyword,class:"tok-keyword"},{tag:k.atom,class:"tok-atom"},{tag:k.bool,class:"tok-bool"},{tag:k.url,class:"tok-url"},{tag:k.labelName,class:"tok-labelName"},{tag:k.inserted,class:"tok-inserted"},{tag:k.deleted,class:"tok-deleted"},{tag:k.literal,class:"tok-literal"},{tag:k.string,class:"tok-string"},{tag:k.number,class:"tok-number"},{tag:[k.regexp,k.escape,k.special(k.string)],class:"tok-string2"},{tag:k.variableName,class:"tok-variableName"},{tag:k.local(k.variableName),class:"tok-variableName tok-local"},{tag:k.definition(k.variableName),class:"tok-variableName tok-definition"},{tag:k.special(k.variableName),class:"tok-variableName2"},{tag:k.definition(k.propertyName),class:"tok-propertyName tok-definition"},{tag:k.typeName,class:"tok-typeName"},{tag:k.namespace,class:"tok-namespace"},{tag:k.className,class:"tok-className"},{tag:k.macroName,class:"tok-macroName"},{tag:k.propertyName,class:"tok-propertyName"},{tag:k.operator,class:"tok-operator"},{tag:k.comment,class:"tok-comment"},{tag:k.meta,class:"tok-meta"},{tag:k.invalid,class:"tok-invalid"},{tag:k.punctuation,class:"tok-punctuation"}]);const Fb=Ff({String:k.string,Number:k.number,"True False":k.bool,PropertyName:k.propertyName,Null:k.null,", :":k.separator,"[ ]":k.squareBracket,"{ }":k.brace}),Nb=pr.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[Fb],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});let hl=[],Vf=[];(()=>{let i="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<i.length;e++)(e%2?Vf:hl).push(t=t+i[e])})();function Bb(i){if(i<768)return!1;for(let e=0,t=hl.length;;){let n=e+t>>1;if(i<hl[n])t=n;else if(i>=Vf[n])e=n+1;else return!0;if(e==t)return!1}}function ju(i){return i>=127462&&i<=127487}const Ou=8205;function Vb(i,e,t=!0,n=!0){return(t?zf:zb)(i,e,n)}function zf(i,e,t){if(e==i.length)return e;e&&$f(i.charCodeAt(e))&&_f(i.charCodeAt(e-1))&&e--;let n=Ro(i,e);for(e+=Iu(n);e<i.length;){let s=Ro(i,e);if(n==Ou||s==Ou||t&&Bb(s))e+=Iu(s),n=s;else if(ju(s)){let r=0,o=e-2;for(;o>=0&&ju(Ro(i,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function zb(i,e,t){for(;e>0;){let n=zf(i,e-2,t);if(n<e)return n;e--}return 0}function Ro(i,e){let t=i.charCodeAt(e);if(!_f(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return $f(n)?(t-55296<<10)+(n-56320)+65536:t}function $f(i){return i>=56320&&i<57344}function _f(i){return i>=55296&&i<56320}function Iu(i){return i<65536?1:2}class re{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=cn(this,e,t);let s=[];return this.decompose(0,e,s,2),n.length&&n.decompose(0,n.length,s,3),this.decompose(t,this.length,s,1),It.from(s,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=cn(this,e,t);let n=[];return this.decompose(e,t,n,0),It.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),s=new Ln(this),r=new Ln(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=n)return!0}}iter(e=1){return new Ln(this,e)}iterRange(e,t=this.length){return new Hf(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;n=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Gf(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?re.empty:e.length<=32?new ve(e):It.from(ve.split(e,[]))}}class ve extends re{constructor(e,t=$b(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?n:l)>=e)return new _b(s,l,n,o);s=l+1,n++}}decompose(e,t,n,s){let r=e<=0&&t>=this.length?this:new ve(Pu(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=n.pop(),l=Ys(r.text,o.text.slice(),0,r.length);if(l.length<=32)n.push(new ve(l,o.length+r.length));else{let a=l.length>>1;n.push(new ve(l.slice(0,a)),new ve(l.slice(a)))}}else n.push(r)}replace(e,t,n){if(!(n instanceof ve))return super.replace(e,t,n);[e,t]=cn(this,e,t);let s=Ys(this.text,Ys(n.text,Pu(this.text,0,e)),t),r=this.length+n.length-(t-e);return s.length<=32?new ve(s,r):It.from(ve.split(s,[]),r)}sliceString(e,t=this.length,n=`
24
- `){[e,t]=cn(this,e,t);let s="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(s+=n),e<a&&t>r&&(s+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],s=-1;for(let r of e)n.push(r),s+=r.length+1,n.length==32&&(t.push(new ve(n,s)),n=[],s=-1);return s>-1&&t.push(new ve(n,s)),t}}class It extends re{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,s){for(let r=0;;r++){let o=this.children[r],l=s+o.length,a=n+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,n,s);s=l+1,n=a+1}}decompose(e,t,n,s){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=o){let u=s&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!u?n.push(l):l.decompose(e-o,t-o,n,u)}o=a+1}}replace(e,t,n){if([e,t]=cn(this,e,t),n.lines<this.lines)for(let s=0,r=0;s<this.children.length;s++){let o=this.children[s],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,n),u=this.lines-o.lines+a.lines;if(a.lines<u>>4&&a.lines>u>>6){let c=this.children.slice();return c[s]=a,new It(c,this.length-(t-e)+n.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=`
25
- `){[e,t]=cn(this,e,t);let s="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(s+=n),e<a&&t>o&&(s+=l.sliceString(e-o,t-o,n)),o=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof It))return 0;let n=0,[s,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==l)return n;let a=this.children[s],u=e.children[r];if(a!=u)return n+a.scanIdentical(u,t);n+=a.length+1}}static from(e,t=e.reduce((n,s)=>n+s.length+1,-1)){let n=0;for(let p of e)n+=p.lines;if(n<32){let p=[];for(let g of e)g.flatten(p);return new ve(p,t)}let s=Math.max(32,n>>5),r=s<<1,o=s>>1,l=[],a=0,u=-1,c=[];function h(p){let g;if(p.lines>r&&p instanceof It)for(let m of p.children)h(m);else p.lines>o&&(a>o||!a)?(f(),l.push(p)):p instanceof ve&&a&&(g=c[c.length-1])instanceof ve&&p.lines+g.lines<=32?(a+=p.lines,u+=p.length+1,c[c.length-1]=new ve(g.text.concat(p.text),g.length+1+p.length)):(a+p.lines>s&&f(),a+=p.lines,u+=p.length+1,c.push(p))}function f(){a!=0&&(l.push(c.length==1?c[0]:It.from(c,u)),u=-1,a=c.length=0)}for(let p of e)h(p);return f(),l.length==1?l[0]:new It(l,t)}}re.empty=new ve([""],0);function $b(i){let e=-1;for(let t of i)e+=t.length+1;return e}function Ys(i,e,t=0,n=1e9){for(let s=0,r=0,o=!0;r<i.length&&s<=n;r++){let l=i[r],a=s+l.length;a>=t&&(a>n&&(l=l.slice(0,n-s)),s<t&&(l=l.slice(t-s)),o?(e[e.length-1]+=l,o=!1):e.push(l)),s=a+1}return e}function Pu(i,e,t){return Ys(i,[""],e,t)}class Ln{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof ve?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,s=this.nodes[n],r=this.offsets[n],o=r>>1,l=s instanceof ve?s.text.length:s.children.length;if(o==(t>0?l:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
26
- `,this;e--}else if(s instanceof ve){let a=s.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof ve?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Hf{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Ln(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=n?s:t<0?s.slice(s.length-n):s.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Gf{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(re.prototype[Symbol.iterator]=function(){return this.iter()},Ln.prototype[Symbol.iterator]=Hf.prototype[Symbol.iterator]=Gf.prototype[Symbol.iterator]=function(){return this});class _b{constructor(e,t,n,s){this.from=e,this.to=t,this.number=n,this.text=s}get length(){return this.to-this.from}}function cn(i,e,t){return e=Math.max(0,Math.min(i.length,e)),[e,Math.max(e,Math.min(i.length,t))]}function Fe(i,e,t=!0,n=!0){return Vb(i,e,t,n)}function Hb(i){return i>=56320&&i<57344}function Gb(i){return i>=55296&&i<56320}function Ke(i,e){let t=i.charCodeAt(e);if(!Gb(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return Hb(n)?(t-55296<<10)+(n-56320)+65536:t}function Ea(i){return i<=65535?String.fromCharCode(i):(i-=65536,String.fromCharCode((i>>10)+55296,(i&1023)+56320))}function Pt(i){return i<65536?1:2}const fl=/\r\n?|\n/;var We=(function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i})(We||(We={}));class Bt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,s=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(n,s,r),s+=r):s+=o,n+=r}}iterChangedRanges(e,t=!1){dl(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],s=this.sections[t++];s<0?e.push(n,s):e.push(s,n)}return new Bt(e)}composeDesc(e){return this.empty?e:e.empty?this:Wf(this,e)}mapDesc(e,t=!1){return e.empty?this:pl(this,e,t)}mapPos(e,t=-1,n=We.Simple){let s=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],u=s+l;if(a<0){if(u>e)return r+(e-s);r+=l}else{if(n!=We.Simple&&u>=e&&(n==We.TrackDel&&s<e&&u>e||n==We.TrackBefore&&s<e||n==We.TrackAfter&&u>e))return null;if(u>e||u==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=u}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let n=0,s=0;n<this.sections.length&&s<=t;){let r=this.sections[n++],o=this.sections[n++],l=s+r;if(o>=0&&s<=t&&l>=e)return s<e&&l>t?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],s=this.sections[t++];e+=(e?" ":"")+n+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Bt(e)}static create(e){return new Bt(e)}}class Te extends Bt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return dl(this,(t,n,s,r,o)=>e=e.replace(s,s+(n-t),o),!1),e}mapDesc(e,t=!1){return pl(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let s=0,r=0;s<t.length;s+=2){let o=t[s],l=t[s+1];if(l>=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;n.length<a;)n.push(re.empty);n.push(o?e.slice(r,r+o):re.empty)}r+=o}return new Te(t,n)}compose(e){return this.empty?e:e.empty?this:Wf(this,e,!0)}map(e,t=!1){return e.empty?this:pl(this,e,t,!0)}iterChanges(e,t=!1){dl(this,e,t)}get desc(){return Bt.create(this.sections)}filter(e){let t=[],n=[],s=[],r=new Wn(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,a-l);ze(s,c,-1);let h=r.ins==-1?-1:r.off==0?r.ins:0;ze(t,c,h),h>0&&ui(n,t,r.text),r.forward(c),l+=c}let u=e[o++];for(;l<u;){if(r.done)break e;let c=Math.min(r.len,u-l);ze(t,c,-1),ze(s,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),l+=c}}return{changes:new Te(t,n),filtered:Bt.create(s)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],s=this.sections[t+1];s<0?e.push(n):s==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let s=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!s.length)return;o<t&&ze(s,t-o,-1);let h=new Te(s,r);l=l?l.compose(h.map(l)):h,s=[],r=[],o=0}function u(c){if(Array.isArray(c))for(let h of c)u(h);else if(c instanceof Te){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:h,to:f=h,insert:p}=c;if(h>f||h<0||f>t)throw new RangeError(`Invalid change range ${h} to ${f} (in doc of length ${t})`);let g=p?typeof p=="string"?re.of(p.split(n||fl)):p:re.empty,m=g.length;if(h==f&&m==0)return;h<o&&a(),h>o&&ze(s,h-o,-1),ze(s,f-h,m),ui(r,s,g),o=f}}return u(e),a(!l),l}static empty(e){return new Te(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let s=0;s<e.length;s++){let r=e[s];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;n.length<s;)n.push(re.empty);n[s]=re.of(r.slice(1)),t.push(r[0],n[s].length)}}}return new Te(t,n)}static createSet(e,t){return new Te(e,t)}}function ze(i,e,t,n=!1){if(e==0&&t<=0)return;let s=i.length-2;s>=0&&t<=0&&t==i[s+1]?i[s]+=e:s>=0&&e==0&&i[s]==0?i[s+1]+=t:n?(i[s]+=e,i[s+1]+=t):i.push(e,t)}function ui(i,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n<i.length)i[i.length-1]=i[i.length-1].append(t);else{for(;i.length<n;)i.push(re.empty);i.push(t)}}function dl(i,e,t){let n=i.inserted;for(let s=0,r=0,o=0;o<i.sections.length;){let l=i.sections[o++],a=i.sections[o++];if(a<0)s+=l,r+=l;else{let u=s,c=r,h=re.empty;for(;u+=l,c+=a,a&&n&&(h=h.append(n[o-2>>1])),!(t||o==i.sections.length||i.sections[o+1]<0);)l=i.sections[o++],a=i.sections[o++];e(s,u,r,c,h),s=u,r=c}}}function pl(i,e,t,n=!1){let s=[],r=n?[]:null,o=new Wn(i),l=new Wn(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);ze(s,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let u=l.len;for(ze(s,l.ins,-1);u;){let c=Math.min(o.len,u);o.ins>=0&&a<o.i&&o.len<=c&&(ze(s,0,o.ins),r&&ui(r,s,o.text),a=o.i),o.forward(c),u-=c}l.next()}else if(o.ins>=0){let u=0,c=o.len;for(;c;)if(l.ins==-1){let h=Math.min(c,l.len);u+=h,c-=h,l.forward(h)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;ze(s,u,a<o.i?o.ins:0),r&&a<o.i&&ui(r,s,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?Te.createSet(s,r):Bt.create(s);throw new Error("Mismatched change set lengths")}}}function Wf(i,e,t=!1){let n=[],s=t?[]:null,r=new Wn(i),o=new Wn(e);for(let l=!1;;){if(r.done&&o.done)return s?Te.createSet(n,s):Bt.create(n);if(r.ins==0)ze(n,r.len,0,l),r.next();else if(o.len==0&&!o.done)ze(n,0,o.ins,l),s&&ui(s,n,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),u=n.length;if(r.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;ze(n,a,c,l),s&&c&&ui(s,n,o.text)}else o.ins==-1?(ze(n,r.off?0:r.len,a,l),s&&ui(s,n,r.textBit(a))):(ze(n,r.off?0:r.len,o.off?0:o.ins,l),s&&!o.off&&ui(s,n,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||n.length>u),r.forward2(a),o.forward(a)}}}}class Wn{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?re.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?re.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Mi{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let n,s;return this.empty?n=s=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),n==this.from&&s==this.to?this:new Mi(n,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return T.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return T.range(this.anchor,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return T.range(e.anchor,e.head)}static create(e,t,n){return new Mi(e,t,n)}}class T{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:T.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new T([this.main],0)}addRange(e,t=!0){return T.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,T.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new T(e.ranges.map(t=>Mi.fromJSON(t)),e.main)}static single(e,t=e){return new T([T.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,s=0;s<e.length;s++){let r=e[s];if(r.empty?r.from<=n:r.from<n)return T.normalized(e.slice(),t);n=r.to}return new T(e,t)}static cursor(e,t=0,n,s){return Mi.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(s??16777215)<<6)}static range(e,t,n,s){let r=(n??16777215)<<6|(s==null?7:Math.min(6,s));return t<e?Mi.create(t,e,48|r):Mi.create(e,t,(t>e?8:0)|r)}static normalized(e,t=0){let n=e[t];e.sort((s,r)=>s.from-r.from),t=e.indexOf(n);for(let s=1;s<e.length;s++){let r=e[s],o=e[s-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);s<=t&&t--,e.splice(--s,2,r.anchor>r.head?T.range(a,l):T.range(l,a))}}return new T(e,t)}}function Uf(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Ra=0;class ${constructor(e,t,n,s,r){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=s,this.id=Ra++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new $(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:ka),!!e.static,e.enables)}of(e){return new Xs([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xs(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Xs(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}}function ka(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}class Xs{constructor(e,t,n,s){this.dependencies=e,this.facet=t,this.type=n,this.value=s,this.id=Ra++}dynamicSlot(e){var t;let n=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,u=!1,c=[];for(let h of this.dependencies)h=="doc"?a=!0:h=="selection"?u=!0:(((t=e[h.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[h.id]);return{create(h){return h.values[o]=n(h),1},update(h,f){if(a&&f.docChanged||u&&(f.docChanged||f.selection)||gl(h,c)){let p=n(h);if(l?!Du(p,h.values[o],s):!s(p,h.values[o]))return h.values[o]=p,1}return 0},reconfigure:(h,f)=>{let p,g=f.config.address[r];if(g!=null){let m=xr(f,g);if(this.dependencies.every(x=>x instanceof $?f.facet(x)===h.facet(x):x instanceof Ne?f.field(x,!1)==h.field(x,!1):!0)||(l?Du(p=n(h),m,s):s(p=n(h),m)))return h.values[o]=m,0}else p=n(h);return h.values[o]=p,1}}}}function Du(i,e,t){if(i.length!=e.length)return!1;for(let n=0;n<i.length;n++)if(!t(i[n],e[n]))return!1;return!0}function gl(i,e){let t=!1;for(let n of e)Fn(i,n)&1&&(t=!0);return t}function Wb(i,e,t){let n=t.map(a=>i[a.id]),s=t.map(a=>a.type),r=n.filter(a=>!(a&1)),o=i[e.id]>>1;function l(a){let u=[];for(let c=0;c<n.length;c++){let h=xr(a,n[c]);if(s[c]==2)for(let f of h)u.push(f);else u.push(h)}return e.combine(u)}return{create(a){for(let u of n)Fn(a,u);return a.values[o]=l(a),1},update(a,u){if(!gl(a,r))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,u){let c=gl(a,n),h=u.config.facets[e.id],f=u.facet(e);if(h&&!c&&ka(t,h))return a.values[o]=f,0;let p=l(a);return e.compare(p,f)?(a.values[o]=f,0):(a.values[o]=p,1)}}}const Rs=$.define({static:!0});class Ne{constructor(e,t,n,s,r){this.id=e,this.createF=t,this.updateF=n,this.compareF=s,this.spec=r,this.provides=void 0}static define(e){let t=new Ne(Ra++,e.create,e.update,e.compare||((n,s)=>n===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Rs).find(n=>n.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,s)=>{let r=n.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(n.values[t]=o,1)},reconfigure:(n,s)=>{let r=n.facet(Rs),o=s.facet(Rs),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(n.values[t]=l.create(n),1):s.config.address[this.id]!=null?(n.values[t]=s.field(this),0):(n.values[t]=this.create(n),1)}}}init(e){return[this,Rs.of({field:this,create:e})]}get extension(){return this}}const ki={lowest:4,low:3,default:2,high:1,highest:0};function Rn(i){return e=>new qf(e,i)}const Vi={highest:Rn(ki.highest),high:Rn(ki.high),default:Rn(ki.default),low:Rn(ki.low),lowest:Rn(ki.lowest)};class qf{constructor(e,t){this.inner=e,this.prec=t}}class Ur{of(e){return new ml(this,e)}reconfigure(e){return Ur.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class ml{constructor(e,t){this.compartment=e,this.inner=t}}class mr{constructor(e,t,n,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let s=[],r=Object.create(null),o=new Map;for(let f of Ub(e,t,o))f instanceof Ne?s.push(f):(r[f.facet.id]||(r[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],u=[];for(let f of s)l[f.id]=u.length<<1,u.push(p=>f.slot(p));let c=n==null?void 0:n.config.facets;for(let f in r){let p=r[f],g=p[0].facet,m=c&&c[f]||[];if(p.every(x=>x.type==0))if(l[g.id]=a.length<<1|1,ka(m,p))a.push(n.facet(g));else{let x=g.combine(p.map(y=>y.value));a.push(n&&g.compare(x,n.facet(g))?n.facet(g):x)}else{for(let x of p)x.type==0?(l[x.id]=a.length<<1|1,a.push(x.value)):(l[x.id]=u.length<<1,u.push(y=>x.dynamicSlot(y)));l[g.id]=u.length<<1,u.push(x=>Wb(x,g,p))}}let h=u.map(f=>f(l));return new mr(e,o,h,l,a,r)}}function Ub(i,e,t){let n=[[],[],[],[],[]],s=new Map;function r(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let u=n[a].indexOf(o);u>-1&&n[a].splice(u,1),o instanceof ml&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let u of o)r(u,l);else if(o instanceof ml){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;t.set(o.compartment,u),r(u,l)}else if(o instanceof qf)r(o.inner,o.prec);else if(o instanceof Ne)n[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof Xs)n[l].push(o),o.facet.extensions&&r(o.facet.extensions,ki.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(u,l)}}return r(i,ki.default),n.reduce((o,l)=>o.concat(l))}function Fn(i,e){if(e&1)return 2;let t=e>>1,n=i.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;i.status[t]=4;let s=i.computeSlot(i,i.config.dynamicSlots[t]);return i.status[t]=2|s}function xr(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}const Kf=$.define(),xl=$.define({combine:i=>i.some(e=>e),static:!0}),Yf=$.define({combine:i=>i.length?i[0]:void 0,static:!0}),Xf=$.define(),Qf=$.define(),Jf=$.define(),Zf=$.define({combine:i=>i.length?i[0]:!1});class $t{constructor(e,t){this.type=e,this.value=t}static define(){return new qb}}class qb{of(e){return new $t(this,e)}}class Kb{constructor(e){this.map=e}of(e){return new J(this,e)}}class J{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new J(this.type,t)}is(e){return this.type==e}static define(e={}){return new Kb(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let s of e){let r=s.map(t);r&&n.push(r)}return n}}J.reconfigure=J.define();J.appendConfig=J.define();class Me{constructor(e,t,n,s,r,o){this.startState=e,this.changes=t,this.selection=n,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,n&&Uf(n,t.newLength),r.some(l=>l.type==Me.time)||(this.annotations=r.concat(Me.time.of(Date.now())))}static create(e,t,n,s,r,o){return new Me(e,t,n,s,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Me.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Me.time=$t.define();Me.userEvent=$t.define();Me.addToHistory=$t.define();Me.remote=$t.define();function Yb(i,e){let t=[];for(let n=0,s=0;;){let r,o;if(n<i.length&&(s==e.length||e[s]>=i[n]))r=i[n++],o=i[n++];else if(s<e.length)r=e[s++],o=e[s++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function ed(i,e,t){var n;let s,r,o;return t?(s=e.changes,r=Te.empty(e.changes.length),o=i.changes.compose(e.changes)):(s=e.changes.map(i.changes),r=i.changes.mapDesc(e.changes,!0),o=i.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):(n=i.selection)===null||n===void 0?void 0:n.map(s),effects:J.mapEffects(i.effects,s).concat(J.mapEffects(e.effects,r)),annotations:i.annotations.length?i.annotations.concat(e.annotations):e.annotations,scrollIntoView:i.scrollIntoView||e.scrollIntoView}}function yl(i,e,t){let n=e.selection,s=tn(e.annotations);return e.userEvent&&(s=s.concat(Me.userEvent.of(e.userEvent))),{changes:e.changes instanceof Te?e.changes:Te.of(e.changes||[],t,i.facet(Yf)),selection:n&&(n instanceof T?n:T.single(n.anchor,n.head)),effects:tn(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function td(i,e,t){let n=yl(i,e.length?e[0]:{},i.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;n=ed(n,yl(i,e[r],o?n.changes.newLength:i.doc.length),o)}let s=Me.create(i,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return Qb(t?Xb(s):s)}function Xb(i){let e=i.startState,t=!0;for(let s of e.facet(Xf)){let r=s(i);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:Yb(t,r))}if(t!==!0){let s,r;if(t===!1)r=i.changes.invertedDesc,s=Te.empty(e.doc.length);else{let o=i.changes.filter(t);s=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}i=Me.create(e,s,i.selection&&i.selection.map(r),J.mapEffects(i.effects,r),i.annotations,i.scrollIntoView)}let n=e.facet(Qf);for(let s=n.length-1;s>=0;s--){let r=n[s](i);r instanceof Me?i=r:Array.isArray(r)&&r.length==1&&r[0]instanceof Me?i=r[0]:i=td(e,tn(r),!1)}return i}function Qb(i){let e=i.startState,t=e.facet(Jf),n=i;for(let s=t.length-1;s>=0;s--){let r=t[s](i);r&&Object.keys(r).length&&(n=ed(n,yl(e,r,i.changes.newLength),!0))}return n==i?i:Me.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}const Jb=[];function tn(i){return i==null?Jb:Array.isArray(i)?i:[i]}var ye=(function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i})(ye||(ye={}));const Zb=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let bl;try{bl=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function ev(i){if(bl)return bl.test(i);for(let e=0;e<i.length;e++){let t=i[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||Zb.test(t)))return!0}return!1}function tv(i){return e=>{if(!/\S/.test(e))return ye.Space;if(ev(e))return ye.Word;for(let t=0;t<i.length;t++)if(e.indexOf(i[t])>-1)return ye.Word;return ye.Other}}class ne{constructor(e,t,n,s,r,o){this.config=e,this.doc=t,this.selection=n,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Fn(this,l<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return Fn(this,n),xr(this,n)}update(...e){return td(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:s}=t;for(let l of e.effects)l.is(Ur.reconfigure)?(t&&(s=new Map,t.compartments.forEach((a,u)=>s.set(u,a)),t=null),s.set(l.value.compartment,l.value.extension)):l.is(J.reconfigure)?(t=null,n=l.value):l.is(J.appendConfig)&&(t=null,n=tn(n).concat(l.value));let r;t?r=e.startState.values.slice():(t=mr.resolve(n,s,this),r=new ne(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,u)=>u.reconfigure(a,this),null).values);let o=e.startState.facet(xl)?e.newSelection:e.newSelection.asSingle();new ne(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:T.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),s=this.changes(n.changes),r=[n.range],o=tn(n.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),u=this.changes(a.changes),c=u.map(s);for(let f=0;f<l;f++)r[f]=r[f].map(c);let h=s.mapDesc(u,!0);r.push(a.range.map(h)),s=s.compose(c),o=J.mapEffects(o,c).concat(J.mapEffects(tn(a.effects),h))}return{changes:s,selection:T.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Te?e:Te.of(e,this.doc.length,this.facet(ne.lineSeparator))}toText(e){return re.of(e.split(this.facet(ne.lineSeparator)||fl))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Fn(this,t),xr(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let s=e[n];s instanceof Ne&&this.config.address[s.id]!=null&&(t[n]=s.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(n){for(let r in n)if(Object.prototype.hasOwnProperty.call(e,r)){let o=n[r],l=e[r];s.push(o.init(a=>o.spec.fromJSON(l,a)))}}return ne.create({doc:e.doc,selection:T.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=mr.resolve(e.extensions||[],new Map),n=e.doc instanceof re?e.doc:re.of((e.doc||"").split(t.staticFacet(ne.lineSeparator)||fl)),s=e.selection?e.selection instanceof T?e.selection:T.single(e.selection.anchor,e.selection.head):T.single(0);return Uf(s,n.length),t.staticFacet(xl)||(s=s.asSingle()),new ne(t,n,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(ne.tabSize)}get lineBreak(){return this.facet(ne.lineSeparator)||`
27
- `}get readOnly(){return this.facet(Zf)}phrase(e,...t){for(let n of this.facet(ne.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,s)=>{if(s=="$")return"$";let r=+(s||1);return!r||r>t.length?n:t[r-1]})),e}languageDataAt(e,t,n=-1){let s=[];for(let r of this.facet(Kf))for(let o of r(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){return tv(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:s}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-n,l=e-n;for(;o>0;){let a=Fe(t,o,!1);if(r(t.slice(a,o))!=ye.Word)break;o=a}for(;l<s;){let a=Fe(t,l);if(r(t.slice(l,a))!=ye.Word)break;l=a}return o==l?null:T.range(o+n,l+n)}}ne.allowMultipleSelections=xl;ne.tabSize=$.define({combine:i=>i.length?i[0]:4});ne.lineSeparator=Yf;ne.readOnly=Zf;ne.phrases=$.define({compare(i,e){let t=Object.keys(i),n=Object.keys(e);return t.length==n.length&&t.every(s=>i[s]==e[s])}});ne.languageData=Kf;ne.changeFilter=Xf;ne.transactionFilter=Qf;ne.transactionExtender=Jf;Ur.reconfigure=J.define();function _t(i,e,t={}){let n={};for(let s of i)for(let r of Object.keys(s)){let o=s[r],l=n[r];if(l===void 0)n[r]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,r))n[r]=t[r](l,o);else throw new Error("Config merge conflict for field "+r)}for(let s in e)n[s]===void 0&&(n[s]=e[s]);return n}class Di{eq(e){return this==e}range(e,t=e){return Un.create(e,t,this)}}Di.prototype.startSide=Di.prototype.endSide=0;Di.prototype.point=!1;Di.prototype.mapMode=We.TrackDel;class Un{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new Un(e,t,n)}}function vl(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}class Aa{constructor(e,t,n,s){this.from=e,this.to=t,this.value=n,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,s=0){let r=n?this.to:this.from;for(let o=s,l=r.length;;){if(o==l)return o;let a=o+l>>1,u=r[a]-e||(n?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return u>=0?o:l;u>=0?l=a:o=a+1}}between(e,t,n,s){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,r);r<o;r++)if(s(this.from[r]+e,this.to[r]+e,this.value[r])===!1)return!1}map(e,t){let n=[],s=[],r=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let u=this.value[a],c=this.from[a]+e,h=this.to[a]+e,f,p;if(c==h){let g=t.mapPos(c,u.startSide,u.mapMode);if(g==null||(f=p=g,u.startSide!=u.endSide&&(p=t.mapPos(c,u.endSide),p<f)))continue}else if(f=t.mapPos(c,u.startSide),p=t.mapPos(h,u.endSide),f>p||f==p&&u.startSide>0&&u.endSide<=0)continue;(p-f||u.endSide-u.startSide)<0||(o<0&&(o=f),u.point&&(l=Math.max(l,p-f)),n.push(u),s.push(f-o),r.push(p-o))}return{mapped:n.length?new Aa(s,r,n,l):null,pos:o}}}class se{constructor(e,t,n,s){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=s}static create(e,t,n,s){return new se(e,t,n,s)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:s=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(n&&(t=t.slice().sort(vl)),this.isEmpty)return t.length?se.of(t):this;let l=new id(this,null,-1).goto(0),a=0,u=[],c=new Xt;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let h=t[a++];c.addInner(h.from,h.to,h.value)||u.push(h)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||s>this.chunkEnd(l.chunkIndex)||r<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||s>l.to||r<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value)||u.push(Un.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!u.length?se.empty:this.nextLayer.update({add:u,filter:o,filterFrom:s,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],s=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],u=e.touchesRange(l,l+a.length);if(u===!1)s=Math.max(s,a.maxPoint),t.push(a),n.push(e.mapPos(l));else if(u===!0){let{mapped:c,pos:h}=a.map(l,e);c&&(s=Math.max(s,c.maxPoint),t.push(c),n.push(h))}}let r=this.nextLayer.map(e);return t.length==0?r:new se(n,t,r||se.empty,s)}between(e,t,n){if(!this.isEmpty){for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s];if(t>=r&&e<=r+o.length&&o.between(r,e-r,t-r,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return qn.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return qn.from(e).goto(t)}static compare(e,t,n,s,r=-1){let o=e.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=r),l=t.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=r),a=Lu(o,l,n),u=new kn(o,a,r),c=new kn(l,a,r);n.iterGaps((h,f,p)=>Fu(u,h,c,f,p,s)),n.empty&&n.length==0&&Fu(u,0,c,0,0,s)}static eq(e,t,n=0,s){s==null&&(s=999999999);let r=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=Lu(r,o),a=new kn(r,l,0).goto(n),u=new kn(o,l,0).goto(n);for(;;){if(a.to!=u.to||!Sl(a.active,u.active)||a.point&&(!u.point||!a.point.eq(u.point)))return!1;if(a.to>s)return!0;a.next(),u.next()}}static spans(e,t,n,s,r=-1){let o=new kn(e,null,r).goto(t),l=t,a=o.openStart;for(;;){let u=Math.min(o.to,n);if(o.point){let c=o.activeForPoint(o.to),h=o.pointFrom<t?c.length+1:o.point.startSide<0?c.length:Math.min(c.length,a);s.point(l,u,o.point,c,h,o.pointRank),a=Math.min(o.openEnd(u),c.length)}else u>l&&(s.span(l,u,o.active,a),a=o.openEnd(u));if(o.to>n)return a+(o.point&&o.to>n?1:0);l=o.to,o.next()}}static of(e,t=!1){let n=new Xt;for(let s of e instanceof Un?[e]:t?iv(e):e)n.add(s.from,s.to,s.value);return n.finish()}static join(e){if(!e.length)return se.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let s=e[n];s!=se.empty;s=s.nextLayer)t=new se(s.chunkPos,s.chunk,t,Math.max(s.maxPoint,t.maxPoint));return t}}se.empty=new se([],[],null,-1);function iv(i){if(i.length>1)for(let e=i[0],t=1;t<i.length;t++){let n=i[t];if(vl(e,n)>0)return i.slice().sort(vl);e=n}return i}se.empty.nextLayer=se.empty;class Xt{finishChunk(e){this.chunks.push(new Aa(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new Xt)).add(e,t,n)}addInner(e,t,n){let s=e-this.lastTo||n.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(se.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=se.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Lu(i,e,t){let n=new Map;for(let r of i)for(let o=0;o<r.chunk.length;o++)r.chunk[o].maxPoint<=0&&n.set(r.chunk[o],r.chunkPos[o]);let s=new Set;for(let r of e)for(let o=0;o<r.chunk.length;o++){let l=n.get(r.chunk[o]);l!=null&&(t?t.mapPos(l):l)==r.chunkPos[o]&&!(t!=null&&t.touchesRange(l,l+r.chunk[o].length))&&s.add(r.chunk[o])}return s}class id{constructor(e,t,n,s=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=s}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let s=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(s)||this.layer.chunkEnd(this.chunkIndex)<e||s.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let s=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<s)&&this.setRangeIndex(s)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class qn{constructor(e){this.heap=e}static from(e,t=null,n=-1){let s=[];for(let r=0;r<e.length;r++)for(let o=e[r];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&s.push(new id(o,t,n,r));return s.length==1?s[0]:new qn(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)ko(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)ko(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),ko(this.heap,0)}}}function ko(i,e){for(let t=i[e];;){let n=(e<<1)+1;if(n>=i.length)break;let s=i[n];if(n+1<i.length&&s.compare(i[n+1])>=0&&(s=i[n+1],n++),t.compare(s)<0)break;i[n]=t,i[e]=s,e=n}}class kn{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=qn.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){ks(this.active,e),ks(this.activeTo,e),ks(this.activeRank,e),this.minActive=Nu(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:s,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||s-this.activeTo[t])>0;)t++;As(this.active,t,n),As(this.activeTo,t,s),As(this.activeRank,t,r),e&&As(e,t,this.cursor.from),this.minActive=Nu(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),n&&ks(n,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=r,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=r.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let s=n.length-1;s>=0&&n[s]<e;s--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function Fu(i,e,t,n,s,r){i.goto(e),t.goto(n);let o=n+s,l=n,a=n-e;for(;;){let u=i.to+a-t.to,c=u||i.endSide-t.endSide,h=c<0?i.to+a:t.to,f=Math.min(h,o);if(i.point||t.point?i.point&&t.point&&(i.point==t.point||i.point.eq(t.point))&&Sl(i.activeForPoint(i.to),t.activeForPoint(t.to))||r.comparePoint(l,f,i.point,t.point):f>l&&!Sl(i.active,t.active)&&r.compareRange(l,f,i.active,t.active),h>o)break;(u||i.openEnd!=t.openEnd)&&r.boundChange&&r.boundChange(h),l=h,c<=0&&i.next(),c>=0&&t.next()}}function Sl(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(i[t]!=e[t]&&!i[t].eq(e[t]))return!1;return!0}function ks(i,e){for(let t=e,n=i.length-1;t<n;t++)i[t]=i[t+1];i.pop()}function As(i,e,t){for(let n=i.length-1;n>=e;n--)i[n+1]=i[n];i[e]=t}function Nu(i,e){let t=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||i[s].endSide-i[t].endSide)<0&&(t=s,n=e[s]);return t}function yn(i,e,t=i.length){let n=0;for(let s=0;s<t&&s<i.length;)i.charCodeAt(s)==9?(n+=e-n%e,s++):(n++,s=Fe(i,s));return n}function Cl(i,e,t,n){for(let s=0,r=0;;){if(r>=e)return s;if(s==i.length)break;r+=i.charCodeAt(s)==9?t-r%t:1,s=Fe(i,s)}return n===!0?-1:i.length}const wl="ͼ",Bu=typeof Symbol>"u"?"__"+wl:Symbol.for(wl),El=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Vu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class mi{constructor(e,t){this.rules=[];let{finish:n}=t||{};function s(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,a,u){let c=[],h=/^@(\w+)\b/.exec(o[0]),f=h&&h[1]=="keyframes";if(h&&l==null)return a.push(o[0]+";");for(let p in l){let g=l[p];if(/&/.test(p))r(p.split(/,\s*/).map(m=>o.map(x=>m.replace(/&/,x))).reduce((m,x)=>m.concat(x)),g,a);else if(g&&typeof g=="object"){if(!h)throw new RangeError("The value of a property ("+p+") should be a primitive value.");r(s(p),g,c,f)}else g!=null&&c.push(p.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+g+";")}(c.length||f)&&a.push((n&&!h&&!u?o.map(n):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)r(s(o),e[o],this.rules)}getRules(){return this.rules.join(`
28
- `)}static newName(){let e=Vu[Bu]||1;return Vu[Bu]=e+1,wl+e.toString(36)}static mount(e,t,n){let s=e[El],r=n&&n.nonce;s?r&&s.setNonce(r):s=new nv(e,r),s.mount(Array.isArray(t)?t:[t],e)}}let zu=new Map;class nv{constructor(e,t){let n=e.ownerDocument||e,s=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let r=zu.get(n);if(r)return e[El]=r;this.sheet=new s.CSSStyleSheet,zu.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[El]=this}mount(e,t){let n=this.sheet,s=0,r=0;for(let o=0;o<e.length;o++){let l=e[o],a=this.modules.indexOf(l);if(a<r&&a>-1&&(this.modules.splice(a,1),r--,a=-1),a==-1){if(this.modules.splice(r++,0,l),n)for(let u=0;u<l.rules.length;u++)n.insertRule(l.rules[u],s++)}else{for(;r<a;)s+=this.modules[r++].rules.length;s+=l.rules.length,r++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
29
- `;this.styleTag.textContent=o;let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var xi={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Kn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},sv=typeof navigator<"u"&&/Mac/.test(navigator.platform),rv=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Le=0;Le<10;Le++)xi[48+Le]=xi[96+Le]=String(Le);for(var Le=1;Le<=24;Le++)xi[Le+111]="F"+Le;for(var Le=65;Le<=90;Le++)xi[Le]=String.fromCharCode(Le+32),Kn[Le]=String.fromCharCode(Le);for(var Ao in xi)Kn.hasOwnProperty(Ao)||(Kn[Ao]=xi[Ao]);function ov(i){var e=sv&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||rv&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?Kn:xi)[i.keyCode]||i.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function fe(){var i=arguments[0];typeof i=="string"&&(i=document.createElement(i));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var s=t[n];typeof s=="string"?i.setAttribute(n,s):s!=null&&(i[n]=s)}e++}for(;e<arguments.length;e++)nd(i,arguments[e]);return i}function nd(i,e){if(typeof e=="string")i.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)i.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)nd(i,e[t]);else throw new RangeError("Unsupported child node: "+e)}let Ge=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Rl=typeof document<"u"?document:{documentElement:{style:{}}};const kl=/Edge\/(\d+)/.exec(Ge.userAgent),sd=/MSIE \d/.test(Ge.userAgent),Al=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ge.userAgent),qr=!!(sd||Al||kl),$u=!qr&&/gecko\/(\d+)/i.test(Ge.userAgent),To=!qr&&/Chrome\/(\d+)/.exec(Ge.userAgent),lv="webkitFontSmoothing"in Rl.documentElement.style,Tl=!qr&&/Apple Computer/.test(Ge.vendor),_u=Tl&&(/Mobile\/\w+/.test(Ge.userAgent)||Ge.maxTouchPoints>2);var z={mac:_u||/Mac/.test(Ge.platform),windows:/Win/.test(Ge.platform),linux:/Linux|X11/.test(Ge.platform),ie:qr,ie_version:sd?Rl.documentMode||6:Al?+Al[1]:kl?+kl[1]:0,gecko:$u,gecko_version:$u?+(/Firefox\/(\d+)/.exec(Ge.userAgent)||[0,0])[1]:0,chrome:!!To,chrome_version:To?+To[1]:0,ios:_u,android:/Android\b/.test(Ge.userAgent),webkit_version:lv?+(/\bAppleWebKit\/(\d+)/.exec(Ge.userAgent)||[0,0])[1]:0,safari:Tl,safari_version:Tl?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Ge.userAgent)||[0,0])[1]:0,tabSize:Rl.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yn(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function Ml(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function Qs(i,e){if(!e.anchorNode)return!1;try{return Ml(i,e.anchorNode)}catch{return!1}}function hn(i){return i.nodeType==3?Fi(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function Nn(i,e,t,n){return t?Hu(i,e,t,n,-1)||Hu(i,e,t,n,1):!1}function Li(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function yr(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function Hu(i,e,t,n,s){for(;;){if(i==t&&e==n)return!0;if(e==(s<0?0:Vt(i))){if(i.nodeName=="DIV")return!1;let r=i.parentNode;if(!r||r.nodeType!=1)return!1;e=Li(i)+(s<0?0:1),i=r}else if(i.nodeType==1){if(i=i.childNodes[e+(s<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;e=s<0?Vt(i):0}else return!1}}function Vt(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function os(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function av(i){let e=i.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function rd(i,e){let t=e.width/i.offsetWidth,n=e.height/i.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-i.offsetWidth)<1)&&(t=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-i.offsetHeight)<1)&&(n=1),{scaleX:t,scaleY:n}}function uv(i,e,t,n,s,r,o,l){let a=i.ownerDocument,u=a.defaultView||window;for(let c=i,h=!1;c&&!h;)if(c.nodeType==1){let f,p=c==a.body,g=1,m=1;if(p)f=av(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(h=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let b=c.getBoundingClientRect();({scaleX:g,scaleY:m}=rd(c,b)),f={left:b.left,right:b.left+c.clientWidth*g,top:b.top,bottom:b.top+c.clientHeight*m}}let x=0,y=0;if(s=="nearest")e.top<f.top?(y=e.top-(f.top+o),t>0&&e.bottom>f.bottom+y&&(y=e.bottom-f.bottom+o)):e.bottom>f.bottom&&(y=e.bottom-f.bottom+o,t<0&&e.top-y<f.top&&(y=e.top-(f.top+o)));else{let b=e.bottom-e.top,v=f.bottom-f.top;y=(s=="center"&&b<=v?e.top+b/2-v/2:s=="start"||s=="center"&&t<0?e.top-o:e.bottom-v+o)-f.top}if(n=="nearest"?e.left<f.left?(x=e.left-(f.left+r),t>0&&e.right>f.right+x&&(x=e.right-f.right+r)):e.right>f.right&&(x=e.right-f.right+r,t<0&&e.left<f.left+x&&(x=e.left-(f.left+r))):x=(n=="center"?e.left+(e.right-e.left)/2-(f.right-f.left)/2:n=="start"==l?e.left-r:e.right-(f.right-f.left)+r)-f.left,x||y)if(p)u.scrollBy(x,y);else{let b=0,v=0;if(y){let w=c.scrollTop;c.scrollTop+=y/m,v=(c.scrollTop-w)*m}if(x){let w=c.scrollLeft;c.scrollLeft+=x/g,b=(c.scrollLeft-w)*g}e={left:e.left-b,top:e.top-v,right:e.right-b,bottom:e.bottom-v},b&&Math.abs(b-x)<1&&(n="nearest"),v&&Math.abs(v-y)<1&&(s="nearest")}if(p)break;(e.top<f.top||e.bottom>f.bottom||e.left<f.left||e.right>f.right)&&(e={left:Math.max(e.left,f.left),right:Math.min(e.right,f.right),top:Math.max(e.top,f.top),bottom:Math.min(e.bottom,f.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function cv(i){let e=i.ownerDocument,t,n;for(let s=i.parentNode;s&&!(s==e.body||t&&n);)if(s.nodeType==1)!n&&s.scrollHeight>s.clientHeight&&(n=s),!t&&s.scrollWidth>s.clientWidth&&(t=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:t,y:n}}class hv{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?Vt(t):0),n,Math.min(e.focusOffset,n?Vt(n):0))}set(e,t,n,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=s}}let Ri=null;z.safari&&z.safari_version>=26&&(Ri=!1);function od(i){if(i.setActive)return i.setActive();if(Ri)return i.focus(Ri);let e=[];for(let t=i;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(i.focus(Ri==null?{get preventScroll(){return Ri={preventScroll:!0},!0}}:void 0),!Ri){Ri=!1;for(let t=0;t<e.length;){let n=e[t++],s=e[t++],r=e[t++];n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}}}let Gu;function Fi(i,e,t=e){let n=Gu||(Gu=document.createRange());return n.setEnd(i,t),n.setStart(i,e),n}function nn(i,e,t,n){let s={key:e,code:e,keyCode:t,which:t,cancelable:!0};n&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=n);let r=new KeyboardEvent("keydown",s);r.synthetic=!0,i.dispatchEvent(r);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,i.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function fv(i){for(;i;){if(i&&(i.nodeType==9||i.nodeType==11&&i.host))return i;i=i.assignedSlot||i.parentNode}return null}function ld(i){for(;i.attributes.length;)i.removeAttributeNode(i.attributes[0])}function dv(i,e){let t=e.focusNode,n=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=n)return!1;for(n=Math.min(n,Vt(t));;)if(n){if(t.nodeType!=1)return!1;let s=t.childNodes[n-1];s.contentEditable=="false"?n--:(t=s,n=Vt(t))}else{if(t==i)return!0;n=Li(t),t=t.parentNode}}function ad(i){return i.scrollTop>Math.max(1,i.scrollHeight-i.clientHeight-4)}function ud(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&n>0)return{node:t,offset:n};if(t.nodeType==1&&n>0){if(t.contentEditable=="false")return null;t=t.childNodes[n-1],n=Vt(t)}else if(t.parentNode&&!yr(t))n=Li(t),t=t.parentNode;else return null}}function cd(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&n<t.nodeValue.length)return{node:t,offset:n};if(t.nodeType==1&&n<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[n],n=0}else if(t.parentNode&&!yr(t))n=Li(t)+1,t=t.parentNode;else return null}}class $e{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new $e(e.parentNode,Li(e),t)}static after(e,t){return new $e(e.parentNode,Li(e)+1,t)}}const Ta=[];class ce{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let n=this.dom,s=null,r;for(let o of this.children){if(o.flags&7){if(!o.dom&&(r=s?s.nextSibling:n.firstChild)){let l=ce.get(r);(!l||!l.parent&&l.canReuseDOM(o))&&o.reuseDOM(r)}o.sync(e,t),o.flags&=-8}if(r=s?s.nextSibling:n.firstChild,t&&!t.written&&t.node==n&&r!=o.dom&&(t.written=!0),o.dom.parentNode==n)for(;r&&r!=o.dom;)r=Wu(r);else n.insertBefore(o.dom,r);s=o.dom}for(r=s?s.nextSibling:n.firstChild,r&&t&&t.node==n&&(t.written=!0);r;)r=Wu(r)}else if(this.flags&1)for(let n of this.children)n.flags&7&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let s=Vt(e)==0?0:t==0?-1:1;for(;;){let r=e.parentNode;if(r==this.dom)break;s==0&&r.firstChild!=r.lastChild&&(e==r.firstChild?s=-1:s=1),e=r}s<0?n=e:n=e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!ce.get(n);)n=n.nextSibling;if(!n)return this.length;for(let s=0,r=0;;s++){let o=this.children[s];if(o.dom==n)return r;r+=o.length+o.breakAfter}}domBoundsAround(e,t,n=0){let s=-1,r=-1,o=-1,l=-1;for(let a=0,u=n,c=n;a<this.children.length;a++){let h=this.children[a],f=u+h.length;if(u<e&&f>t)return h.domBoundsAround(e,t,u);if(f>=e&&s==-1&&(s=a,r=u),u>t&&h.dom.parentNode==this.dom){o=a,l=c;break}c=f,u=f+h.breakAfter}return{from:r,to:l<0?n+this.length:l,startDOM:(s?this.children[s-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=Ta){this.markDirty();for(let s=e;s<t;s++){let r=this.children[s];r.parent==this&&n.indexOf(r)<0&&r.destroy()}n.length<250?this.children.splice(e,t-e,...n):this.children=[].concat(this.children.slice(0,e),n,this.children.slice(t));for(let s=0;s<n.length;s++)n[s].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new hd(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,n,s,r,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}}ce.prototype.breakAfter=0;function Wu(i){let e=i.nextSibling;return i.parentNode.removeChild(i),e}class hd{constructor(e,t,n){this.children=e,this.pos=t,this.i=n,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}}function fd(i,e,t,n,s,r,o,l,a){let{children:u}=i,c=u.length?u[e]:null,h=r.length?r[r.length-1]:null,f=h?h.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(t,s,r.length?h:null,t==0,l,a))){if(n<u.length){let p=u[n];p&&(s<p.length||p.breakAfter&&(h!=null&&h.breakAfter))?(e==n&&(p=p.split(s),s=0),!f&&h&&p.merge(0,s,h,!0,0,a)?r[r.length-1]=p:((s||p.children.length&&!p.children[0].length)&&p.merge(0,s,null,!1,0,a),r.push(p))):p!=null&&p.breakAfter&&(h?h.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,t>0&&(!o&&r.length&&c.merge(t,c.length,r[0],!1,l,0)?c.breakAfter=r.shift().breakAfter:(t<c.length||c.children.length&&c.children[c.children.length-1].length==0)&&c.merge(t,c.length,null,!1,l,0),e++));e<n&&r.length;)if(u[n-1].become(r[r.length-1]))n--,r.pop(),a=r.length?0:l;else if(u[e].become(r[0]))e++,r.shift(),l=r.length?0:a;else break;!r.length&&e&&n<u.length&&!u[e-1].breakAfter&&u[n].merge(0,0,u[e-1],!1,l,a)&&e--,(e<n||r.length)&&i.replaceChildren(e,n,r)}}function dd(i,e,t,n,s,r){let o=i.childCursor(),{i:l,off:a}=o.findPos(t,1),{i:u,off:c}=o.findPos(e,-1),h=e-t;for(let f of n)h+=f.length;i.length+=h,fd(i,u,c,l,a,n,0,s,r)}const pv=256;class St extends ce{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,n){return this.flags&8||n&&(!(n instanceof St)||this.length-(t-e)+n.length>pv||n.flags&8)?!1:(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new St(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new $e(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return gv(this.dom,e,t)}}class Qt extends ce{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let s of t)s.setParent(this)}setAttrs(e){if(ld(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,s,r,o){return n&&(!(n instanceof Qt&&n.mark.eq(this.mark))||e&&r<=0||t<this.length&&o<=0)?!1:(dd(this,e,t,n?n.children.slice():[],r-1,o-1),this.markDirty(),!0)}split(e){let t=[],n=0,s=-1,r=0;for(let l of this.children){let a=n+l.length;a>e&&t.push(n<e?l.split(e-n):l),s<0&&n>=e&&(s=r),n=a,r++}let o=this.length-e;return this.length=e,s>-1&&(this.children.length=s,this.markDirty()),new Qt(this.mark,t,o)}domAtPos(e){return pd(this,e)}coordsAt(e,t){return md(this,e,t)}}function gv(i,e,t){let n=i.nodeValue.length;e>n&&(e=n);let s=e,r=e,o=0;e==0&&t<0||e==n&&t>=0?z.chrome||z.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):t<0?s--:r<n&&r++;let l=Fi(i,s,r).getClientRects();if(!l.length)return null;let a=l[(o?o<0:t>=0)?0:l.length-1];return z.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,u=>u.width)||a),o?os(a,o<0):a||null}class qt extends ce{static create(e,t,n){return new qt(e,t,n)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}split(e){let t=qt.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,n,s,r,o){return n&&(!(n instanceof qt)||!this.widget.compare(n.widget)||e>0&&r<=0||t<this.length&&o<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}become(e){return e instanceof qt&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return re.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,n=t&&t.state.doc,s=this.posAtStart;return n?n.slice(s,s+this.length):re.empty}domAtPos(e){return(this.length?e==0:this.side>0)?$e.before(this.dom):$e.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let s=this.dom.getClientRects(),r=null;if(!s.length)return null;let o=this.side?this.side<0:e>0;for(let l=o?s.length-1:0;r=s[l],!(e>0?l==0:l==s.length-1||r.top<r.bottom);l+=o?-1:1);return os(r,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class fn extends ce{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof fn&&e.side==this.side}split(){return new fn(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?$e.before(this.dom):$e.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return re.empty}get isHidden(){return!0}}St.prototype.children=qt.prototype.children=fn.prototype.children=Ta;function pd(i,e){let t=i.dom,{children:n}=i,s=0;for(let r=0;s<n.length;s++){let o=n[s],l=r+o.length;if(!(l==r&&o.getSide()<=0)){if(e>r&&e<l&&o.dom.parentNode==t)return o.domAtPos(e-r);if(e<=r)break;r=l}}for(let r=s;r>0;r--){let o=n[r-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let r=s;r<n.length;r++){let o=n[r];if(o.dom.parentNode==t)return o.domAtPos(0)}return new $e(t,0)}function gd(i,e,t){let n,{children:s}=i;t>0&&e instanceof Qt&&s.length&&(n=s[s.length-1])instanceof Qt&&n.mark.eq(e.mark)?gd(n,e.children[0],t-1):(s.push(e),e.setParent(i)),i.length+=e.length}function md(i,e,t){let n=null,s=-1,r=null,o=-1;function l(u,c){for(let h=0,f=0;h<u.children.length&&f<=c;h++){let p=u.children[h],g=f+p.length;g>=c&&(p.children.length?l(p,c-f):(!r||r.isHidden&&(t>0||xv(r,p)))&&(g>c||f==g&&p.getSide()>0)?(r=p,o=c-f):(f<c||f==g&&p.getSide()<0&&!p.isHidden)&&(n=p,s=c-f)),f=g}}l(i,e);let a=(t<0?n:r)||n||r;return a?a.coordsAt(Math.max(0,a==n?s:o),t):mv(i)}function mv(i){let e=i.dom.lastChild;if(!e)return i.dom.getBoundingClientRect();let t=hn(e);return t[t.length-1]||null}function xv(i,e){let t=i.coordsAt(0,1),n=e.coordsAt(0,1);return t&&n&&n.top<t.bottom}function jl(i,e){for(let t in i)t=="class"&&e.class?e.class+=" "+i.class:t=="style"&&e.style?e.style+=";"+i.style:e[t]=i[t];return e}const Uu=Object.create(null);function br(i,e,t){if(i==e)return!0;i||(i=Uu),e||(e=Uu);let n=Object.keys(i),s=Object.keys(e);if(n.length-(t&&n.indexOf(t)>-1?1:0)!=s.length-(t&&s.indexOf(t)>-1?1:0))return!1;for(let r of n)if(r!=t&&(s.indexOf(r)==-1||i[r]!==e[r]))return!1;return!0}function Ol(i,e,t){let n=!1;if(e)for(let s in e)t&&s in t||(n=!0,s=="style"?i.style.cssText="":i.removeAttribute(s));if(t)for(let s in t)e&&e[s]==t[s]||(n=!0,s=="style"?i.style.cssText=t[s]:i.setAttribute(s,t[s]));return n}function yv(i){let e=Object.create(null);for(let t=0;t<i.attributes.length;t++){let n=i.attributes[t];e[n.name]=n.value}return e}class Zt{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var Ue=(function(i){return i[i.Text=0]="Text",i[i.WidgetBefore=1]="WidgetBefore",i[i.WidgetAfter=2]="WidgetAfter",i[i.WidgetRange=3]="WidgetRange",i})(Ue||(Ue={}));class q extends Di{constructor(e,t,n,s){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=s}get heightRelevant(){return!1}static mark(e){return new ls(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new yi(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,s;if(e.isBlockGap)n=-5e8,s=4e8;else{let{start:r,end:o}=xd(e,t);n=(r?t?-3e8:-1:5e8)-1,s=(o?t?2e8:1:-6e8)+1}return new yi(e,n,s,t,e.widget||null,!0)}static line(e){return new as(e)}static set(e,t=!1){return se.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}q.none=se.empty;class ls extends q{constructor(e){let{start:t,end:n}=xd(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof ls&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((n=e.attrs)===null||n===void 0?void 0:n.class))&&br(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}ls.prototype.point=!1;class as extends q{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof as&&this.spec.class==e.spec.class&&br(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}as.prototype.mapMode=We.TrackBefore;as.prototype.point=!0;class yi extends q{constructor(e,t,n,s,r,o){super(t,n,r,e),this.block=s,this.isReplace=o,this.mapMode=s?t<=0?We.TrackBefore:We.TrackAfter:We.TrackDel}get type(){return this.startSide!=this.endSide?Ue.WidgetRange:this.startSide<=0?Ue.WidgetBefore:Ue.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof yi&&bv(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}yi.prototype.point=!0;function xd(i,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=i;return t==null&&(t=i.inclusive),n==null&&(n=i.inclusive),{start:t??e,end:n??e}}function bv(i,e){return i==e||!!(i&&e&&i.compare(e))}function Js(i,e,t,n=0){let s=t.length-1;s>=0&&t[s]+n>=i?t[s]=Math.max(t[s],e):t.push(i,e)}class Ee extends ce{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,s,r,o){if(n){if(!(n instanceof Ee))return!1;this.dom||n.transferDOM(this)}return s&&this.setDeco(n?n.attrs:null),dd(this,e,t,n?n.children.slice():[],r,o),!0}split(e){let t=new Ee;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i:n,off:s}=this.childPos(e);s&&(t.append(this.children[n].split(s),0),this.children[n].merge(s,this.children[n].length,null,!1,0,0),n++);for(let r=n;r<this.children.length;r++)t.append(this.children[r],0);for(;n>0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){br(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){gd(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=jl(t,this.attrs||{})),n&&(this.attrs=jl({class:n},this.attrs||{}))}domAtPos(e){return pd(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(ld(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(Ol(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let s=this.dom.lastChild;for(;s&&ce.get(s)instanceof Qt;)s=s.lastChild;if(!s||!this.length||s.nodeName!="BR"&&((n=ce.get(s))===null||n===void 0?void 0:n.isEditable)==!1&&(!z.ios||!this.children.some(r=>r instanceof St))){let r=document.createElement("BR");r.cmIgnore=!0,this.dom.appendChild(r)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let n of this.children){if(!(n instanceof St)||/[^ -~]/.test(n.text))return null;let s=hn(n.dom);if(s.length!=1)return null;e+=s[0].width,t=s[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=md(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:s}=this.parent.view.viewState,r=n.bottom-n.top;if(Math.abs(r-s.lineHeight)<2&&s.textHeight<r){let o=(r-s.textHeight)/2;return{top:n.top+o,bottom:n.bottom-o,left:n.left,right:n.left}}}return n}become(e){return e instanceof Ee&&this.children.length==0&&e.children.length==0&&br(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,t){for(let n=0,s=0;n<e.children.length;n++){let r=e.children[n],o=s+r.length;if(o>=t){if(r instanceof Ee)return r;if(o>t)break}s=o+r.breakAfter}return null}}class Kt extends ce{constructor(e,t,n){super(),this.widget=e,this.length=t,this.deco=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,s,r,o){return n&&(!(n instanceof Kt)||!this.widget.compare(n.widget)||e>0&&r<=0||t<this.length&&o<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?$e.before(this.dom):$e.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new Kt(this.widget,t,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return Ta}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):re.empty}domBoundsAround(){return null}become(e){return e instanceof Kt&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);return n||(this.widget instanceof Il?null:os(this.dom.getBoundingClientRect(),this.length?e==0:t<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:n}=this.deco;return t==n?!1:e<0?t<0:n>0}}class Il extends Zt{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class Bn{constructor(e,t,n,s){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=s,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof Kt&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ee),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Ts(new fn(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof Kt)&&this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:o,lineBreak:l,done:a}=this.cursor.next(this.skip);if(this.skip=0,a)throw new Error("Ran out of text content when drawing inline views");if(l){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=o,this.textOff=0}let s=Math.min(this.text.length-this.textOff,e),r=Math.min(s,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(Ts(new St(this.text.slice(this.textOff,this.textOff+r)),t),n),this.atCursorPos=!0,this.textOff+=r,e-=r,n=s<=r?0:t.length}}span(e,t,n,s){this.buildText(t-e,n,s),this.pos=t,this.openStart<0&&(this.openStart=s)}point(e,t,n,s,r,o){if(this.disallowBlockEffectsFor[o]&&n instanceof yi){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(n instanceof yi)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Kt(n.widget||dn.block,l,n));else{let a=qt.create(n.widget||dn.inline,l,l?0:n.startSide),u=this.atCursorPos&&!a.isEditable&&r<=s.length&&(e<t||n.startSide>0),c=!a.isEditable&&(e<t||r>s.length||n.startSide<=0),h=this.getLine();this.pendingBuffer==2&&!u&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(s),u&&(h.append(Ts(new fn(1),s),r),r=s.length+Math.max(0,r-s.length)),h.append(Ts(a,s),r),this.atCursorPos=c,this.pendingBuffer=c?e<t||r>s.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=s.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=r)}static build(e,t,n,s,r){let o=new Bn(e,t,n,r);return o.openEnd=se.spans(s,t,n,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function Ts(i,e){for(let t of e)i=new Qt(t,[i],i.length);return i}class dn extends Zt{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}dn.inline=new dn("span");dn.block=new dn("div");var xe=(function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i})(xe||(xe={}));const Ni=xe.LTR,Ma=xe.RTL;function yd(i){let e=[];for(let t=0;t<i.length;t++)e.push(1<<+i[t]);return e}const vv=yd("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Sv=yd("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Pl=Object.create(null),Mt=[];for(let i of["()","[]","{}"]){let e=i.charCodeAt(0),t=i.charCodeAt(1);Pl[e]=t,Pl[t]=-e}function bd(i){return i<=247?vv[i]:1424<=i&&i<=1524?2:1536<=i&&i<=1785?Sv[i-1536]:1774<=i&&i<=2220?4:8192<=i&&i<=8204?256:64336<=i&&i<=65023?4:1}const Cv=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class ci{get dir(){return this.level%2?Ma:Ni}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,s){let r=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==n)return o;(r<0||(s!=0?s<0?l.from<t:l.to>t:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function vd(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++){let n=i[t],s=e[t];if(n.from!=s.from||n.to!=s.to||n.direction!=s.direction||!vd(n.inner,s.inner))return!1}return!0}const de=[];function wv(i,e,t,n,s){for(let r=0;r<=n.length;r++){let o=r?n[r-1].to:e,l=r<n.length?n[r].from:t,a=r?256:s;for(let u=o,c=a,h=a;u<l;u++){let f=bd(i.charCodeAt(u));f==512?f=c:f==8&&h==4&&(f=16),de[u]=f==4?2:f,f&7&&(h=f),c=f}for(let u=o,c=a,h=a;u<l;u++){let f=de[u];if(f==128)u<l-1&&c==de[u+1]&&c&24?f=de[u]=c:de[u]=256;else if(f==64){let p=u+1;for(;p<l&&de[p]==64;)p++;let g=u&&c==8||p<t&&de[p]==8?h==1?1:8:256;for(let m=u;m<p;m++)de[m]=g;u=p-1}else f==8&&h==1&&(de[u]=1);c=f,f&7&&(h=f)}}}function Ev(i,e,t,n,s){let r=s==1?2:1;for(let o=0,l=0,a=0;o<=n.length;o++){let u=o?n[o-1].to:e,c=o<n.length?n[o].from:t;for(let h=u,f,p,g;h<c;h++)if(p=Pl[f=i.charCodeAt(h)])if(p<0){for(let m=l-3;m>=0;m-=3)if(Mt[m+1]==-p){let x=Mt[m+2],y=x&2?s:x&4?x&1?r:s:0;y&&(de[h]=de[Mt[m]]=y),l=m;break}}else{if(Mt.length==189)break;Mt[l++]=h,Mt[l++]=f,Mt[l++]=a}else if((g=de[h])==2||g==1){let m=g==s;a=m?0:1;for(let x=l-3;x>=0;x-=3){let y=Mt[x+2];if(y&2)break;if(m)Mt[x+2]|=2;else{if(y&4)break;Mt[x+2]|=4}}}}}function Rv(i,e,t,n){for(let s=0,r=n;s<=t.length;s++){let o=s?t[s-1].to:i,l=s<t.length?t[s].from:e;for(let a=o;a<l;){let u=de[a];if(u==256){let c=a+1;for(;;)if(c==l){if(s==t.length)break;c=t[s++].to,l=s<t.length?t[s].from:e}else if(de[c]==256)c++;else break;let h=r==1,f=(c<e?de[c]:n)==1,p=h==f?h?1:2:n;for(let g=c,m=s,x=m?t[m-1].to:i;g>a;)g==x&&(g=t[--m].from,x=m?t[m-1].to:i),de[--g]=p;a=c}else r=u,a++}}}function Dl(i,e,t,n,s,r,o){let l=n%2?2:1;if(n%2==s%2)for(let a=e,u=0;a<t;){let c=!0,h=!1;if(u==r.length||a<r[u].from){let m=de[a];m!=l&&(c=!1,h=m==16)}let f=!c&&l==1?[]:null,p=c?n:n+1,g=a;e:for(;;)if(u<r.length&&g==r[u].from){if(h)break e;let m=r[u];if(!c)for(let x=m.to,y=u+1;;){if(x==t)break e;if(y<r.length&&r[y].from==x)x=r[y++].to;else{if(de[x]==l)break e;break}}if(u++,f)f.push(m);else{m.from>a&&o.push(new ci(a,m.from,p));let x=m.direction==Ni!=!(p%2);Ll(i,x?n+1:n,s,m.inner,m.from,m.to,o),a=m.to}g=m.to}else{if(g==t||(c?de[g]!=l:de[g]==l))break;g++}f?Dl(i,a,g,n+1,s,f,o):a<g&&o.push(new ci(a,g,p)),a=g}else for(let a=t,u=r.length;a>e;){let c=!0,h=!1;if(!u||a>r[u-1].to){let m=de[a-1];m!=l&&(c=!1,h=m==16)}let f=!c&&l==1?[]:null,p=c?n:n+1,g=a;e:for(;;)if(u&&g==r[u-1].to){if(h)break e;let m=r[--u];if(!c)for(let x=m.from,y=u;;){if(x==e)break e;if(y&&r[y-1].to==x)x=r[--y].from;else{if(de[x-1]==l)break e;break}}if(f)f.push(m);else{m.to<a&&o.push(new ci(m.to,a,p));let x=m.direction==Ni!=!(p%2);Ll(i,x?n+1:n,s,m.inner,m.from,m.to,o),a=m.from}g=m.from}else{if(g==e||(c?de[g-1]!=l:de[g-1]==l))break;g--}f?Dl(i,g,a,n+1,s,f,o):g<a&&o.push(new ci(g,a,p)),a=g}}function Ll(i,e,t,n,s,r,o){let l=e%2?2:1;wv(i,s,r,n,l),Ev(i,s,r,n,l),Rv(s,r,n,l),Dl(i,s,r,e,t,n,o)}function kv(i,e,t){if(!i)return[new ci(0,0,e==Ma?1:0)];if(e==Ni&&!t.length&&!Cv.test(i))return Sd(i.length);if(t.length)for(;i.length>de.length;)de[de.length]=256;let n=[],s=e==Ni?0:1;return Ll(i,s,s,t,0,i.length,n),n}function Sd(i){return[new ci(0,i,0)]}let Cd="";function Av(i,e,t,n,s){var r;let o=n.head-i.from,l=ci.find(e,o,(r=n.bidiLevel)!==null&&r!==void 0?r:-1,n.assoc),a=e[l],u=a.side(s,t);if(o==u){let f=l+=s?1:-1;if(f<0||f>=e.length)return null;a=e[l=f],o=a.side(!s,t),u=a.side(s,t)}let c=Fe(i.text,o,a.forward(s,t));(c<a.from||c>a.to)&&(c=u),Cd=i.text.slice(Math.min(o,c),Math.max(o,c));let h=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return h&&c==u&&h.level+(s?0:1)<a.level?T.cursor(h.side(!s,t)+i.from,h.forward(s,t)?1:-1,h.level):T.cursor(c+i.from,a.forward(s,t)?-1:1,a.level)}function Tv(i,e,t){for(let n=e;n<t;n++){let s=bd(i.charCodeAt(n));if(s==1)return Ni;if(s==2||s==4)return Ma}return Ni}const wd=$.define(),Ed=$.define(),Rd=$.define(),kd=$.define(),Fl=$.define(),Ad=$.define(),Td=$.define(),ja=$.define(),Oa=$.define(),Md=$.define({combine:i=>i.some(e=>e)}),jd=$.define({combine:i=>i.some(e=>e)}),Od=$.define();class sn{constructor(e,t="nearest",n="nearest",s=5,r=5,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=s,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new sn(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new sn(T.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Ms=J.define({map:(i,e)=>i.map(e)}),Id=J.define();function Xe(i,e,t){let n=i.facet(kd);n.length?n[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const Ut=$.define({combine:i=>i.length?i[0]:!0});let Mv=0;const Ki=$.define({combine(i){return i.filter((e,t)=>{for(let n=0;n<t;n++)if(i[n].plugin==e.plugin)return!1;return!0})}});class Ce{constructor(e,t,n,s,r){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=s,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(Ki.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Ki.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:s,provide:r,decorations:o}=t||{};return new Ce(Mv++,e,n,s,l=>{let a=[];return o&&a.push(Xn.of(u=>{let c=u.plugin(l);return c?o(c):q.none})),r&&a.push(r(l)),a})}static fromClass(e,t){return Ce.define((n,s)=>new e(n,s),t)}}class Mo{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Xe(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Xe(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Xe(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Pd=$.define(),Ia=$.define(),Xn=$.define(),Dd=$.define(),us=$.define(),Ld=$.define();function qu(i,e){let t=i.state.facet(Ld);if(!t.length)return t;let n=t.map(r=>r instanceof Function?r(i):r),s=[];return se.spans(n,e.from,e.to,{point(){},span(r,o,l,a){let u=r-e.from,c=o-e.from,h=s;for(let f=l.length-1;f>=0;f--,a--){let p=l[f].spec.bidiIsolate,g;if(p==null&&(p=Tv(e.text,u,c)),a>0&&h.length&&(g=h[h.length-1]).to==u&&g.direction==p)g.to=c,h=g.inner;else{let m={from:u,to:c,direction:p,inner:[]};h.push(m),h=m.inner}}}}),s}const Fd=$.define();function Pa(i){let e=0,t=0,n=0,s=0;for(let r of i.state.facet(Fd)){let o=r(i);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:e,right:t,top:n,bottom:s}}const Mn=$.define();class dt{constructor(e,t,n,s){this.fromA=e,this.toA=t,this.fromB=n,this.toB=s}join(e){return new dt(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let s=e[t-1];if(!(s.fromA>n.toA)){if(s.toA<n.fromA)break;n=n.join(s),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(t.length==0)return e;let n=[];for(let s=0,r=0,o=0,l=0;;s++){let a=s==e.length?null:e[s],u=o-l,c=a?a.fromB:1e9;for(;r<t.length&&t[r]<c;){let h=t[r],f=t[r+1],p=Math.max(l,h),g=Math.min(c,f);if(p<=g&&new dt(p+u,g+u,p,g).addToSet(n),f>c)break;r+=2}if(!a)return n;new dt(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),o=a.toA,l=a.toB}}}class vr{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=Te.empty(this.startState.doc.length);for(let r of n)this.changes=this.changes.compose(r.changes);let s=[];this.changes.iterChangedRanges((r,o,l,a)=>s.push(new dt(r,o,l,a))),this.changedRanges=s}static create(e,t,n){return new vr(e,t,n)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}class Ku extends ce{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=q.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new Ee],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new dt(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:u,toA:c})=>c<this.minWidthFrom||u>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?s=this.domChanged.newSel.head:!Fv(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let r=s>-1?Ov(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:u,to:c}=this.hasComposition;n=new dt(u,c,e.changes.mapPos(u,-1),e.changes.mapPos(c,1)).addToSet(n.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(z.ie||z.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=Dv(o,l,e.changes);return n=dt.extendWithRanges(n,a),!(this.flags&7)&&n.length==0?!1:(this.updateInner(n,e.startState.doc.length,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:s}=this.view;s.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=z.chrome||z.ios?{node:s.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||s.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let o of this.children)o instanceof Kt&&o.widget instanceof Il&&r.push(o.dom);s.updateGaps(r)}updateChildren(e,t,n){let s=n?n.range.addToSet(e.slice()):e,r=this.childCursor(t);for(let o=s.length-1;;o--){let l=o>=0?s[o]:null;if(!l)break;let{fromA:a,toA:u,fromB:c,toB:h}=l,f,p,g,m;if(n&&n.range.fromB<h&&n.range.toB>c){let w=Bn.build(this.view.state.doc,c,n.range.fromB,this.decorations,this.dynamicDecorationMap),S=Bn.build(this.view.state.doc,n.range.toB,h,this.decorations,this.dynamicDecorationMap);p=w.breakAtStart,g=w.openStart,m=S.openEnd;let E=this.compositionView(n);S.breakAtStart?E.breakAfter=1:S.content.length&&E.merge(E.length,E.length,S.content[0],!1,S.openStart,0)&&(E.breakAfter=S.content[0].breakAfter,S.content.shift()),w.content.length&&E.merge(0,0,w.content[w.content.length-1],!0,0,w.openEnd)&&w.content.pop(),f=w.content.concat(E).concat(S.content)}else({content:f,breakAtStart:p,openStart:g,openEnd:m}=Bn.build(this.view.state.doc,c,h,this.decorations,this.dynamicDecorationMap));let{i:x,off:y}=r.findPos(u,1),{i:b,off:v}=r.findPos(a,-1);fd(this,b,v,x,y,f,p,g,m)}n&&this.fixCompositionDOM(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let n of t.effects)n.is(Id)&&(this.editContextFormatting=n.value)}compositionView(e){let t=new St(e.text.nodeValue);t.flags|=8;for(let{deco:s}of e.marks)t=new Qt(s,[t],t.length);let n=new Ee;return n.append(t,0),n}fixCompositionDOM(e){let t=(r,o)=>{o.flags|=8|(o.children.some(a=>a.flags&7)?1:0),this.markedForComposition.add(o);let l=ce.get(r);l&&l!=o&&(l.dom=null),o.setDOM(r)},n=this.childPos(e.range.fromB,1),s=this.children[n.i];t(e.line,s);for(let r=e.marks.length-1;r>=-1;r--)n=s.childPos(n.off,1),s=s.children[n.i],t(r>=0?e.marks[r].node:e.text,s)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let n=this.view.root.activeElement,s=n==this.dom,r=!s&&!(this.view.state.facet(Ut)||this.dom.tabIndex>-1)&&Qs(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(s||t||r))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(l.anchor)),u=l.empty?a:this.moveToLine(this.domAtPos(l.head));if(z.gecko&&l.empty&&!this.hasComposition&&jv(a)){let h=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(h,a.node.childNodes[a.offset]||null)),a=u=new $e(h,0),o=!0}let c=this.view.observer.selectionRange;(o||!c.focusNode||(!Nn(a.node,a.offset,c.anchorNode,c.anchorOffset)||!Nn(u.node,u.offset,c.focusNode,c.focusOffset))&&!this.suppressWidgetCursorChange(c,l))&&(this.view.observer.ignore(()=>{z.android&&z.chrome&&this.dom.contains(c.focusNode)&&Lv(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let h=Yn(this.view.root);if(h)if(l.empty){if(z.gecko){let f=Iv(a.node,a.offset);if(f&&f!=3){let p=(f==1?ud:cd)(a.node,a.offset);p&&(a=new $e(p.node,p.offset))}}h.collapse(a.node,a.offset),l.bidiLevel!=null&&h.caretBidiLevel!==void 0&&(h.caretBidiLevel=l.bidiLevel)}else if(h.extend){h.collapse(a.node,a.offset);try{h.extend(u.node,u.offset)}catch{}}else{let f=document.createRange();l.anchor>l.head&&([a,u]=[u,a]),f.setEnd(u.node,u.offset),f.setStart(a.node,a.offset),h.removeAllRanges(),h.addRange(f)}r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(a,u)),this.impreciseAnchor=a.precise?null:new $e(c.anchorNode,c.anchorOffset),this.impreciseHead=u.precise?null:new $e(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Nn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Yn(e.root),{anchorNode:s,anchorOffset:r}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let o=Ee.find(this,t.head);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),u=this.coordsAt(t.head,1);if(!a||!u||a.bottom>u.top)return;let c=this.domAtPos(t.head+t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(s,r)}moveToLine(e){let t=this.dom,n;if(e.node!=t)return e;for(let s=e.offset;!n&&s<t.childNodes.length;s++){let r=ce.get(t.childNodes[s]);r instanceof Ee&&(n=r.domAtPos(0))}for(let s=e.offset-1;!n&&s>=0;s--){let r=ce.get(t.childNodes[s]);r instanceof Ee&&(n=r.domAtPos(r.length))}return n?new $e(n.node,n.offset,!0):e}nearest(e){for(let t=e;t;){let n=ce.get(t);if(n&&n.rootView==this)return n;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let s=this.children[t];if(n<s.length||s instanceof Ee)break;t++,n=0}return this.children[t].domAtPos(n)}coordsAt(e,t){let n=null,s=0;for(let r=this.length,o=this.children.length-1;o>=0;o--){let l=this.children[o],a=r-l.breakAfter,u=a-l.length;if(a<e)break;if(u<=e&&(u<e||l.covers(-1))&&(a>e||l.covers(1))&&(!n||l instanceof Ee&&!(n instanceof Ee&&t>=0)))n=l,s=u;else if(n&&u==e&&a==e&&l instanceof Kt&&Math.abs(t)<2){if(l.deco.startSide<0)break;o&&(n=null)}r=u}return n?n.coordsAt(e-s,t):null}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),s=this.children[t];if(!(s instanceof Ee))return null;for(;s.children.length;){let{i:l,off:a}=s.childPos(n,1);for(;;l++){if(l==s.children.length)return null;if((s=s.children[l]).length)break}n=a}if(!(s instanceof St))return null;let r=Fe(s.text,n);if(r==n)return null;let o=Fi(s.dom,n,r).getClientRects();for(let l=0;l<o.length;l++){let a=o[l];if(l==o.length-1||a.top<a.bottom&&a.left<a.right)return a}return null}measureVisibleLineHeights(e){let t=[],{from:n,to:s}=e,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==xe.LTR;for(let u=0,c=0;c<this.children.length;c++){let h=this.children[c],f=u+h.length;if(f>s)break;if(u>=n){let p=h.dom.getBoundingClientRect();if(t.push(p.height),o){let g=h.dom.lastChild,m=g?hn(g):[];if(m.length){let x=m[m.length-1],y=a?x.right-p.left:p.right-x.left;y>l&&(l=y,this.minWidth=r,this.minWidthFrom=u,this.minWidthTo=f)}}}u=f+h.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?xe.RTL:xe.LTR}measureTextSize(){for(let r of this.children)if(r instanceof Ee){let o=r.measureTextSize();if(o)return o}let e=document.createElement("div"),t,n,s;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let r=hn(e.firstChild)[0];t=e.getBoundingClientRect().height,n=r?r.width/27:7,s=r?r.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:s}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new hd(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,s=0;;s++){let r=s==t.viewports.length?null:t.viewports[s],o=r?r.from-1:this.length;if(o>n){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(q.replace({widget:new Il(l),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!r)break;n=r.to+1}return q.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Xn).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),n=!1,s=this.view.state.facet(Dd).map((r,o)=>{let l=typeof r=="function";return l&&(n=!0),l?r(this.view):r});for(s.length&&(this.dynamicDecorationMap[e++]=n,t.push(se.join(s))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}scrollIntoView(e){if(e.isSnapshot){let u=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=u.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let u of this.view.state.facet(Od))try{if(u(this.view,e.range,e))return!0}catch(c){Xe(this.view.state,c,"scroll handler")}let{range:t}=e,n=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),s;if(!n)return;!t.empty&&(s=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,s.left),top:Math.min(n.top,s.top),right:Math.max(n.right,s.right),bottom:Math.max(n.bottom,s.bottom)});let r=Pa(this.view),o={left:n.left-r.left,top:n.top-r.top,right:n.right+r.right,bottom:n.bottom+r.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;uv(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==xe.LTR)}lineHasWidget(e){let{i:t}=this.childCursor().findPos(e);if(t==this.children.length)return!1;let n=s=>s instanceof qt||s.children.some(n);return n(this.children[t])}}function jv(i){return i.node.nodeType==1&&i.node.firstChild&&(i.offset==0||i.node.childNodes[i.offset-1].contentEditable=="false")&&(i.offset==i.node.childNodes.length||i.node.childNodes[i.offset].contentEditable=="false")}function Nd(i,e){let t=i.observer.selectionRange;if(!t.focusNode)return null;let n=ud(t.focusNode,t.focusOffset),s=cd(t.focusNode,t.focusOffset),r=n||s;if(s&&n&&s.node!=n.node){let l=ce.get(s.node);if(!l||l instanceof St&&l.text!=s.node.nodeValue)r=s;else if(i.docView.lastCompositionAfterCursor){let a=ce.get(n.node);!a||a instanceof St&&a.text!=n.node.nodeValue||(r=s)}}if(i.docView.lastCompositionAfterCursor=r!=n,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function Ov(i,e,t){let n=Nd(i,t);if(!n)return null;let{node:s,from:r,to:o}=n,l=s.nodeValue;if(/[\n\r]/.test(l)||i.state.doc.sliceString(n.from,n.to)!=l)return null;let a=e.invertedDesc,u=new dt(a.mapPos(r),a.mapPos(o),r,o),c=[];for(let h=s.parentNode;;h=h.parentNode){let f=ce.get(h);if(f instanceof Qt)c.push({node:h,deco:f.mark});else{if(f instanceof Ee||h.nodeName=="DIV"&&h.parentNode==i.contentDOM)return{range:u,text:s,marks:c,line:h};if(h!=i.contentDOM)c.push({node:h,deco:new ls({inclusive:!0,attributes:yv(h),tagName:h.tagName.toLowerCase()})});else return null}}}function Iv(i,e){return i.nodeType!=1?0:(e&&i.childNodes[e-1].contentEditable=="false"?1:0)|(e<i.childNodes.length&&i.childNodes[e].contentEditable=="false"?2:0)}let Pv=class{constructor(){this.changes=[]}compareRange(e,t){Js(e,t,this.changes)}comparePoint(e,t){Js(e,t,this.changes)}boundChange(e){Js(e,e,this.changes)}};function Dv(i,e,t){let n=new Pv;return se.compare(i,e,t,n),n.changes}function Lv(i,e){for(let t=i;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function Fv(i,e){let t=!1;return e&&i.iterChangedRanges((n,s)=>{n<e.to&&s>e.from&&(t=!0)}),t}function Nv(i,e,t=1){let n=i.charCategorizer(e),s=i.doc.lineAt(e),r=e-s.from;if(s.length==0)return T.cursor(e);r==0?t=1:r==s.length&&(t=-1);let o=r,l=r;t<0?o=Fe(s.text,r,!1):l=Fe(s.text,r);let a=n(s.text.slice(o,l));for(;o>0;){let u=Fe(s.text,o,!1);if(n(s.text.slice(u,o))!=a)break;o=u}for(;l<s.length;){let u=Fe(s.text,l);if(n(s.text.slice(l,u))!=a)break;l=u}return T.range(o+s.from,l+s.from)}function Bv(i,e){return e.left>i?e.left-i:Math.max(0,i-e.right)}function Vv(i,e){return e.top>i?e.top-i:Math.max(0,i-e.bottom)}function jo(i,e){return i.top<e.bottom-1&&i.bottom>e.top+1}function Yu(i,e){return e<i.top?{top:e,left:i.left,right:i.right,bottom:i.bottom}:i}function Xu(i,e){return e>i.bottom?{top:i.top,left:i.left,right:i.right,bottom:e}:i}function Nl(i,e,t){let n,s,r,o,l=!1,a,u,c,h;for(let g=i.firstChild;g;g=g.nextSibling){let m=hn(g);for(let x=0;x<m.length;x++){let y=m[x];s&&jo(s,y)&&(y=Yu(Xu(y,s.bottom),s.top));let b=Bv(e,y),v=Vv(t,y);if(b==0&&v==0)return g.nodeType==3?Qu(g,e,t):Nl(g,e,t);(!n||o>v||o==v&&r>b)&&(n=g,s=y,r=b,o=v,l=b?e<y.left?x>0:x<m.length-1:!0),b==0?t>y.bottom&&(!c||c.bottom<y.bottom)?(a=g,c=y):t<y.top&&(!h||h.top>y.top)&&(u=g,h=y):c&&jo(c,y)?c=Xu(c,y.bottom):h&&jo(h,y)&&(h=Yu(h,y.top))}}if(c&&c.bottom>=t?(n=a,s=c):h&&h.top<=t&&(n=u,s=h),!n)return{node:i,offset:0};let f=Math.max(s.left,Math.min(s.right,e));if(n.nodeType==3)return Qu(n,f,t);if(l&&n.contentEditable!="false")return Nl(n,f,t);let p=Array.prototype.indexOf.call(i.childNodes,n)+(e>=(s.left+s.right)/2?1:0);return{node:i,offset:p}}function Qu(i,e,t){let n=i.nodeValue.length,s=-1,r=1e9,o=0;for(let l=0;l<n;l++){let a=Fi(i,l,l+1).getClientRects();for(let u=0;u<a.length;u++){let c=a[u];if(c.top==c.bottom)continue;o||(o=e-c.left);let h=(c.top>t?c.top-t:t-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&h<r){let f=e>=(c.left+c.right)/2,p=f;if((z.chrome||z.gecko)&&Fi(i,l).getBoundingClientRect().left==c.right&&(p=!f),h<=0)return{node:i,offset:l+(p?1:0)};s=l+(p?1:0),r=h}}}return{node:i,offset:s>-1?s:o>0?i.nodeValue.length:0}}function Bd(i,e,t,n=-1){var s,r;let o=i.contentDOM.getBoundingClientRect(),l=o.top+i.viewState.paddingTop,a,{docHeight:u}=i.viewState,{x:c,y:h}=e,f=h-l;if(f<0)return 0;if(f>u)return i.state.doc.length;for(let w=i.viewState.heightOracle.textHeight/2,S=!1;a=i.elementAtHeight(f),a.type!=Ue.Text;)for(;f=n>0?a.bottom+w:a.top-w,!(f>=0&&f<=u);){if(S)return t?null:0;S=!0,n=-n}h=l+f;let p=a.from;if(p<i.viewport.from)return i.viewport.from==0?0:t?null:Ju(i,o,a,c,h);if(p>i.viewport.to)return i.viewport.to==i.state.doc.length?i.state.doc.length:t?null:Ju(i,o,a,c,h);let g=i.dom.ownerDocument,m=i.root.elementFromPoint?i.root:g,x=m.elementFromPoint(c,h);x&&!i.contentDOM.contains(x)&&(x=null),x||(c=Math.max(o.left+1,Math.min(o.right-1,c)),x=m.elementFromPoint(c,h),x&&!i.contentDOM.contains(x)&&(x=null));let y,b=-1;if(x&&((s=i.docView.nearest(x))===null||s===void 0?void 0:s.isEditable)!=!1){if(g.caretPositionFromPoint){let w=g.caretPositionFromPoint(c,h);w&&({offsetNode:y,offset:b}=w)}else if(g.caretRangeFromPoint){let w=g.caretRangeFromPoint(c,h);w&&({startContainer:y,startOffset:b}=w)}y&&(!i.contentDOM.contains(y)||z.safari&&zv(y,b,c)||z.chrome&&$v(y,b,c))&&(y=void 0),y&&(b=Math.min(Vt(y),b))}if(!y||!i.docView.dom.contains(y)){let w=Ee.find(i.docView,p);if(!w)return f>a.top+a.height/2?a.to:a.from;({node:y,offset:b}=Nl(w.dom,c,h))}let v=i.docView.nearest(y);if(!v)return null;if(v.isWidget&&((r=v.dom)===null||r===void 0?void 0:r.nodeType)==1){let w=v.dom.getBoundingClientRect();return e.y<w.top||e.y<=w.bottom&&e.x<=(w.left+w.right)/2?v.posAtStart:v.posAtEnd}else return v.localPosFromDOM(y,b)+v.posAtStart}function Ju(i,e,t,n,s){let r=Math.round((n-e.left)*i.defaultCharacterWidth);if(i.lineWrapping&&t.height>i.defaultLineHeight*1.5){let l=i.viewState.heightOracle.textHeight,a=Math.floor((s-t.top-(i.defaultLineHeight-l)*.5)/l);r+=a*i.viewState.heightOracle.lineLength}let o=i.state.sliceDoc(t.from,t.to);return t.from+Cl(o,r,i.state.tabSize)}function Vd(i,e,t){let n,s=i;if(i.nodeType!=3||e!=(n=i.nodeValue.length))return!1;for(;;){let r=s.nextSibling;if(r){if(r.nodeName=="BR")break;return!1}else{let o=s.parentNode;if(!o||o.nodeName=="DIV")break;s=o}}return Fi(i,n-1,n).getBoundingClientRect().right>t}function zv(i,e,t){return Vd(i,e,t)}function $v(i,e,t){if(e!=0)return Vd(i,e,t);for(let s=i;;){let r=s.parentNode;if(!r||r.nodeType!=1||r.firstChild!=s)return!1;if(r.classList.contains("cm-line"))break;s=r}let n=i.nodeType==1?i.getBoundingClientRect():Fi(i,0,Math.max(i.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function Bl(i,e,t){let n=i.lineBlockAt(e);if(Array.isArray(n.type)){let s;for(let r of n.type){if(r.from>e)break;if(!(r.to<e)){if(r.from<e&&r.to>e)return r;(!s||r.type==Ue.Text&&(s.type!=r.type||(t<0?r.from<e:r.to>e)))&&(s=r)}}return s||n}return n}function _v(i,e,t,n){let s=Bl(i,e.head,e.assoc||-1),r=!n||s.type!=Ue.Text||!(i.lineWrapping||s.widgetLineBreaks)?null:i.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(r){let o=i.dom.getBoundingClientRect(),l=i.textDirectionAt(s.from),a=i.posAtCoords({x:t==(l==xe.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return T.cursor(a,t?-1:1)}return T.cursor(t?s.to:s.from,t?-1:1)}function Zu(i,e,t,n){let s=i.state.doc.lineAt(e.head),r=i.bidiSpans(s),o=i.textDirectionAt(s.from);for(let l=e,a=null;;){let u=Av(s,r,o,l,t),c=Cd;if(!u){if(s.number==(t?i.state.doc.lines:1))return l;c=`
30
- `,s=i.state.doc.line(s.number+(t?1:-1)),r=i.bidiSpans(s),u=i.visualLineSide(s,!t)}if(a){if(!a(c))return l}else{if(!n)return u;a=n(c)}l=u}}function Hv(i,e,t){let n=i.state.charCategorizer(e),s=n(t);return r=>{let o=n(r);return s==ye.Space&&(s=o),s==o}}function Gv(i,e,t,n){let s=e.head,r=t?1:-1;if(s==(t?i.state.doc.length:0))return T.cursor(s,e.assoc);let o=e.goalColumn,l,a=i.contentDOM.getBoundingClientRect(),u=i.coordsAtPos(s,e.assoc||-1),c=i.documentTop;if(u)o==null&&(o=u.left-a.left),l=r<0?u.top:u.bottom;else{let p=i.viewState.lineBlockAt(s);o==null&&(o=Math.min(a.right-a.left,i.defaultCharacterWidth*(s-p.from))),l=(r<0?p.top:p.bottom)+c}let h=a.left+o,f=n??i.viewState.heightOracle.textHeight>>1;for(let p=0;;p+=10){let g=l+(f+p)*r,m=Bd(i,{x:h,y:g},!1,r);if(g<a.top||g>a.bottom||(r<0?m<s:m>s)){let x=i.docView.coordsForChar(m),y=!x||g<x.top?-1:1;return T.cursor(m,y,void 0,o)}}}function Vn(i,e,t){for(;;){let n=0;for(let s of i)s.between(e-1,e+1,(r,o,l)=>{if(e>r&&e<o){let a=n||t||(e-r<o-e?-1:1);e=a<0?r:o,n=a}});if(!n)return e}}function zd(i,e){let t=null;for(let n=0;n<e.ranges.length;n++){let s=e.ranges[n],r=null;if(s.empty){let o=Vn(i,s.from,0);o!=s.from&&(r=T.cursor(o,-1))}else{let o=Vn(i,s.from,-1),l=Vn(i,s.to,1);(o!=s.from||l!=s.to)&&(r=T.range(s.from==s.anchor?o:l,s.from==s.head?o:l))}r&&(t||(t=e.ranges.slice()),t[n]=r)}return t?T.create(t,e.mainIndex):e}function Oo(i,e,t){let n=Vn(i.state.facet(us).map(s=>s(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:T.cursor(n,n<t.from?1:-1)}const jn="￿";class Wv{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(ne.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=jn}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let s=e;;){this.findPointBefore(n,s);let r=this.text.length;this.readNode(s);let o=s.nextSibling;if(o==t)break;let l=ce.get(s),a=ce.get(o);(l&&a?l.breakAfter:(l?l.breakAfter:yr(s))||yr(o)&&(s.nodeName!="BR"||s.cmIgnore)&&this.text.length>r)&&!qv(o,t)&&this.lineBreak(),s=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(l=s.exec(t))&&(r=l.index,o=l[0].length),this.append(t.slice(n,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);n=r+o}}readNode(e){if(e.cmIgnore)return;let t=ce.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let s=n.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(Uv(e,n.node,n.offset)?t:0))}}function Uv(i,e,t){for(;;){if(!e||t<Vt(e))return!1;if(e==i)return!0;t=Li(e)+1,e=e.parentNode}}function qv(i,e){let t;for(;!(i==e||!i);i=i.nextSibling){let n=ce.get(i);if(!(n!=null&&n.isWidget||i.cmIgnore))return!1;n&&(t||(t=[])).push(n)}if(t)for(let n of t){let s=n.overrideDOMText;if(s!=null&&s.length)return!1}return!0}class ec{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class Kv{constructor(e,t,n,s){this.typeOver=s,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let l=r||o?[]:Xv(e),a=new Wv(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Qv(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!Ml(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),u=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!Ml(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),c=e.viewport;if((z.ios||z.chrome)&&e.state.selection.main.empty&&a!=u&&(c.from>0||c.to<e.state.doc.length)){let h=Math.min(a,u),f=Math.max(a,u),p=c.from-h,g=c.to-f;(p==0||p==1||h==0)&&(g==0||g==-1||f==e.state.doc.length)&&(a=0,u=e.state.doc.length)}this.newSel=T.single(u,a)}}}function $d(i,e){let t,{newSel:n}=e,s=i.state.selection.main,r=i.inputState.lastKeyTime>Date.now()-100?i.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=s.from,u=null;(r===8||z.android&&e.text.length<l-o)&&(a=s.to,u="end");let c=_d(i.state.doc.sliceString(o,l,jn),e.text,a-o,u);c&&(z.chrome&&r==13&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==jn+jn&&c.toB--,t={from:o+c.from,to:o+c.toA,insert:re.of(e.text.slice(c.from,c.toB).split(jn))})}else n&&(!i.hasFocus&&i.state.facet(Ut)||n.main.eq(s))&&(n=null);if(!t&&!n)return!1;if(!t&&e.typeOver&&!s.empty&&n&&n.main.empty?t={from:s.from,to:s.to,insert:i.state.doc.slice(s.from,s.to)}:(z.mac||z.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())&&i.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=T.single(n.main.anchor-1,n.main.head-1)),t={from:t.from,to:t.to,insert:re.of([t.insert.toString().replace("."," ")])}):t&&t.from>=s.from&&t.to<=s.to&&(t.from!=s.from||t.to!=s.to)&&s.to-s.from-(t.to-t.from)<=4?t={from:s.from,to:s.to,insert:i.state.doc.slice(s.from,t.from).append(t.insert).append(i.state.doc.slice(t.to,s.to))}:i.state.doc.lineAt(s.from).to<s.to&&i.docView.lineHasWidget(s.to)&&i.inputState.insertingTextAt>Date.now()-50?t={from:s.from,to:s.to,insert:i.state.toText(i.inputState.insertingText)}:z.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==`
31
- `&&i.lineWrapping&&(n&&(n=T.single(n.main.anchor-1,n.main.head-1)),t={from:s.from,to:s.to,insert:re.of([" "])}),t)return Da(i,t,n,r);if(n&&!n.main.eq(s)){let o=!1,l="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(o=!0),l=i.inputState.lastSelectionOrigin,l=="select.pointer"&&(n=zd(i.state.facet(us).map(a=>a(i)),n))),i.dispatch({selection:n,scrollIntoView:o,userEvent:l}),!0}else return!1}function Da(i,e,t,n=-1){if(z.ios&&i.inputState.flushIOSKey(e))return!0;let s=i.state.selection.main;if(z.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&i.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&nn(i.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||n==8&&e.insert.length<e.to-e.from&&e.to>s.head)&&nn(i.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&nn(i.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let o,l=()=>o||(o=Yv(i,e,t));return i.state.facet(Ad).some(a=>a(i,e.from,e.to,r,l))||i.dispatch(l()),!0}function Yv(i,e,t){let n,s=i.state,r=s.selection.main,o=-1;if(e.from==e.to&&e.from<r.from||e.from>r.to){let a=e.from<r.from?-1:1,u=a<0?r.from:r.to,c=Vn(s.facet(us).map(h=>h(i)),u,a);e.from==c&&(o=c)}if(o>-1)n={changes:e,selection:T.cursor(e.from+e.insert.length,-1)};else if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&i.inputState.composing<0){let a=r.from<e.from?s.sliceDoc(r.from,e.from):"",u=r.to>e.to?s.sliceDoc(e.to,r.to):"";n=s.replaceSelection(i.state.toText(a+e.insert.sliceString(0,void 0,i.state.lineBreak)+u))}else{let a=s.changes(e),u=t&&t.main.to<=a.newLength?t.main:void 0;if(s.selection.ranges.length>1&&i.inputState.composing>=0&&e.to<=r.to+10&&e.to>=r.to-10){let c=i.state.sliceDoc(e.from,e.to),h,f=t&&Nd(i,t.main.head);if(f){let m=e.insert.length-(e.to-e.from);h={from:f.from,to:f.to-m}}else h=i.state.doc.lineAt(r.head);let p=r.to-e.to,g=r.to-r.from;n=s.changeByRange(m=>{if(m.from==r.from&&m.to==r.to)return{changes:a,range:u||m.map(a)};let x=m.to-p,y=x-c.length;if(m.to-m.from!=g||i.state.sliceDoc(y,x)!=c||m.to>=h.from&&m.from<=h.to)return{range:m};let b=s.changes({from:y,to:x,insert:e.insert}),v=m.to-r.to;return{changes:b,range:u?T.range(Math.max(0,u.anchor+v),Math.max(0,u.head+v)):m.map(b)}})}else n={changes:a,selection:u&&s.selection.replaceRange(u)}}let l="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,l+=".compose",i.inputState.compositionFirstChange&&(l+=".start",i.inputState.compositionFirstChange=!1)),s.update(n,{userEvent:l,scrollIntoView:!0})}function _d(i,e,t,n){let s=Math.min(i.length,e.length),r=0;for(;r<s&&i.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&i.length==e.length)return null;let o=i.length,l=e.length;for(;o>0&&l>0&&i.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(n=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o<r&&i.length<e.length){let a=t<=r&&t>=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l<r){let a=t<=r&&t>=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function Xv(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:s,focusOffset:r}=i.observer.selectionRange;return t&&(e.push(new ec(t,n)),(s!=t||r!=n)&&e.push(new ec(s,r))),e}function Qv(i,e){if(i.length==0)return null;let t=i[0].pos,n=i.length==2?i[1].pos:t;return t>-1&&n>-1?T.single(t+e,n+e):null}class Jv{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,z.safari&&e.contentDOM.addEventListener("input",()=>null),z.gecko&&pS(e.contentDOM.ownerDocument)}handleEvent(e){!oS(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let s of n.observers)s(this.view,t);for(let s of n.handlers){if(t.defaultPrevented)break;if(s(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Zv(e),n=this.handlers,s=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,l=n[r];l&&o!=!l.handlers.length&&(s.removeEventListener(r,this.handleEvent),l=null),l||s.addEventListener(r,this.handleEvent,{passive:o})}for(let r in n)r!="scroll"&&!t[r]&&s.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Gd.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),z.android&&z.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return z.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=Hd.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||eS.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,nn(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:z.safari&&!z.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function tc(i,e){return(t,n)=>{try{return e.call(i,n,t)}catch(s){Xe(t.state,s)}}}function Zv(i){let e=Object.create(null);function t(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of i){let s=n.spec,r=s&&s.plugin.domEventHandlers,o=s&&s.plugin.domEventObservers;if(r)for(let l in r){let a=r[l];a&&t(l).handlers.push(tc(n.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(tc(n.value,a))}}for(let n in Ct)t(n).handlers.push(Ct[n]);for(let n in pt)t(n).observers.push(pt[n]);return e}const Hd=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],eS="dthko",Gd=[16,17,18,20,91,92,224,225],js=6;function Os(i){return Math.max(0,i)*.7+8}function tS(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}class iS{constructor(e,t,n,s){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=cv(e.contentDOM),this.atoms=e.state.facet(us).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(ne.allowMultipleSelections)&&nS(e,t),this.dragging=rS(e,t)&&qd(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&tS(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,s=0,r=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Pa(this.view);e.clientX-a.left<=s+js?t=-Os(s-e.clientX):e.clientX+a.right>=o-js&&(t=Os(e.clientX-o)),e.clientY-a.top<=r+js?n=-Os(r-e.clientY):e.clientY+a.bottom>=l-js&&(n=Os(e.clientY-l)),this.setScrollSpeed(t,n)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=zd(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function nS(i,e){let t=i.state.facet(wd);return t.length?t[0](e):z.mac?e.metaKey:e.ctrlKey}function sS(i,e){let t=i.state.facet(Ed);return t.length?t[0](e):z.mac?!e.altKey:!e.ctrlKey}function rS(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let n=Yn(i.root);if(!n||n.rangeCount==0)return!0;let s=n.getRangeAt(0).getClientRects();for(let r=0;r<s.length;r++){let o=s[r];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function oS(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=i.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=ce.get(t))&&n.ignoreEvent(e))return!1;return!0}const Ct=Object.create(null),pt=Object.create(null),Wd=z.ie&&z.ie_version<15||z.ios&&z.webkit_version<604;function lS(i){let e=i.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{i.focus(),t.remove(),Ud(i,t.value)},50)}function Kr(i,e,t){for(let n of i.facet(e))t=n(t,i);return t}function Ud(i,e){e=Kr(i.state,ja,e);let{state:t}=i,n,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(Vl!=null&&t.selection.ranges.every(a=>a.empty)&&Vl==r.toString()){let a=-1;n=t.changeByRange(u=>{let c=t.doc.lineAt(u.from);if(c.from==a)return{range:u};a=c.from;let h=t.toText((o?r.line(s++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:h},range:T.cursor(u.from+h.length)}})}else o?n=t.changeByRange(a=>{let u=r.line(s++);return{changes:{from:a.from,to:a.to,insert:u.text},range:T.cursor(a.from+u.length)}}):n=t.replaceSelection(r);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}pt.scroll=i=>{i.inputState.lastScrollTop=i.scrollDOM.scrollTop,i.inputState.lastScrollLeft=i.scrollDOM.scrollLeft};Ct.keydown=(i,e)=>(i.inputState.setSelectionOrigin("select"),e.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);pt.touchstart=(i,e)=>{i.inputState.lastTouchTime=Date.now(),i.inputState.setSelectionOrigin("select.pointer")};pt.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};Ct.mousedown=(i,e)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let n of i.state.facet(Rd))if(t=n(i,e),t)break;if(!t&&e.button==0&&(t=cS(i,e)),t){let n=!i.hasFocus;i.inputState.startMouseSelection(new iS(i,e,t,n)),n&&i.observer.ignore(()=>{od(i.contentDOM);let r=i.root.activeElement;r&&!r.contains(i.contentDOM)&&r.blur()});let s=i.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else i.inputState.setSelectionOrigin("select.pointer");return!1};function ic(i,e,t,n){if(n==1)return T.cursor(e,t);if(n==2)return Nv(i.state,e,t);{let s=Ee.find(i.docView,e),r=i.state.doc.lineAt(s?s.posAtEnd:e),o=s?s.posAtStart:r.from,l=s?s.posAtEnd:r.to;return l<i.state.doc.length&&l==r.to&&l++,T.range(o,l)}}let nc=(i,e,t)=>e>=t.top&&e<=t.bottom&&i>=t.left&&i<=t.right;function aS(i,e,t,n){let s=Ee.find(i.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(r==0)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&nc(t,n,o))return-1;let l=s.coordsAt(r,1);return l&&nc(t,n,l)?1:o&&o.bottom>=n?-1:1}function sc(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:aS(i,t,e.clientX,e.clientY)}}const uS=z.ie&&z.ie_version<=11;let rc=null,oc=0,lc=0;function qd(i){if(!uS)return i.detail;let e=rc,t=lc;return rc=i,lc=Date.now(),oc=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(oc+1)%3:1}function cS(i,e){let t=sc(i,e),n=qd(e),s=i.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),s=s.map(r.changes))},get(r,o,l){let a=sc(i,r),u,c=ic(i,a.pos,a.bias,n);if(t.pos!=a.pos&&!o){let h=ic(i,t.pos,t.bias,n),f=Math.min(h.from,c.from),p=Math.max(h.to,c.to);c=f<c.from?T.range(f,p):T.range(p,f)}return o?s.replaceRange(s.main.extend(c.from,c.to)):l&&n==1&&s.ranges.length>1&&(u=hS(s,a.pos))?u:l?s.addRange(c):T.create([c])}}}function hS(i,e){for(let t=0;t<i.ranges.length;t++){let{from:n,to:s}=i.ranges[t];if(n<=e&&s>=e)return T.create(i.ranges.slice(0,t).concat(i.ranges.slice(t+1)),i.mainIndex==t?0:i.mainIndex-(i.mainIndex>t?1:0))}return null}Ct.dragstart=(i,e)=>{let{selection:{main:t}}=i.state;if(e.target.draggable){let s=i.docView.nearest(e.target);if(s&&s.isWidget){let r=s.posAtStart,o=r+s.length;(r>=t.to||o<=t.from)&&(t=T.range(r,o))}}let{inputState:n}=i;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",Kr(i.state,Oa,i.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Ct.dragend=i=>(i.inputState.draggedContent=null,!1);function ac(i,e,t,n){if(t=Kr(i.state,ja,t),!t)return;let s=i.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=i.inputState,o=n&&r&&sS(i,e)?{from:r.from,to:r.to}:null,l={from:s,insert:t},a=i.state.changes(o?[o,l]:l);i.focus(),i.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),i.inputState.draggedContent=null}Ct.drop=(i,e)=>{if(!e.dataTransfer)return!1;if(i.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let n=Array(t.length),s=0,r=()=>{++s==t.length&&ac(i,e,n.filter(o=>o!=null).join(i.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=r,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(n[o]=l.result),r()},l.readAsText(t[o])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return ac(i,e,n,!0),!0}return!1};Ct.paste=(i,e)=>{if(i.state.readOnly)return!0;i.observer.flush();let t=Wd?null:e.clipboardData;return t?(Ud(i,t.getData("text/plain")||t.getData("text/uri-list")),!0):(lS(i),!1)};function fS(i,e){let t=i.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),i.focus()},50)}function dS(i){let e=[],t=[],n=!1;for(let s of i.selection.ranges)s.empty||(e.push(i.sliceDoc(s.from,s.to)),t.push(s));if(!e.length){let s=-1;for(let{from:r}of i.selection.ranges){let o=i.doc.lineAt(r);o.number>s&&(e.push(o.text),t.push({from:o.from,to:Math.min(i.doc.length,o.to+1)})),s=o.number}n=!0}return{text:Kr(i,Oa,e.join(i.lineBreak)),ranges:t,linewise:n}}let Vl=null;Ct.copy=Ct.cut=(i,e)=>{let{text:t,ranges:n,linewise:s}=dS(i.state);if(!t&&!s)return!1;Vl=s?t:null,e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=Wd?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(fS(i,t),!1)};const Kd=$t.define();function Yd(i,e){let t=[];for(let n of i.facet(Td)){let s=n(i,e);s&&t.push(s)}return t.length?i.update({effects:t,annotations:Kd.of(!0)}):null}function Xd(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=Yd(i.state,e);t?i.dispatch(t):i.update([])}},10)}pt.focus=i=>{i.inputState.lastFocusTime=Date.now(),!i.scrollDOM.scrollTop&&(i.inputState.lastScrollTop||i.inputState.lastScrollLeft)&&(i.scrollDOM.scrollTop=i.inputState.lastScrollTop,i.scrollDOM.scrollLeft=i.inputState.lastScrollLeft),Xd(i)};pt.blur=i=>{i.observer.clearSelectionRange(),Xd(i)};pt.compositionstart=pt.compositionupdate=i=>{i.observer.editContext||(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0))};pt.compositionend=i=>{i.observer.editContext||(i.inputState.composing=-1,i.inputState.compositionEndedAt=Date.now(),i.inputState.compositionPendingKey=!0,i.inputState.compositionPendingChange=i.observer.pendingRecords().length>0,i.inputState.compositionFirstChange=null,z.chrome&&z.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50))};pt.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};Ct.beforeinput=(i,e)=>{var t,n;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(i.inputState.insertingText=e.data,i.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&i.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let l=o[0],a=i.posAtDOM(l.startContainer,l.startOffset),u=i.posAtDOM(l.endContainer,l.endOffset);return Da(i,{from:a,to:u,insert:i.state.toText(r)},null),!0}}let s;if(z.chrome&&z.android&&(s=Hd.find(r=>r.inputType==e.inputType))&&(i.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let r=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}return z.ios&&e.inputType=="deleteContentForward"&&i.observer.flushSoon(),z.safari&&e.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>pt.compositionend(i,e),20),!1};const uc=new Set;function pS(i){uc.has(i)||(uc.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}const cc=["pre-wrap","normal","pre-line","break-spaces"];let pn=!1;function hc(){pn=!1}class gS{constructor(e){this.lineWrapping=e,this.doc=re.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return cc.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let s=e[n];s<0?n++:this.heightSamples[Math.floor(s*10)]||(t=!0,this.heightSamples[Math.floor(s*10)]=!0)}return t}refresh(e,t,n,s,r,o){let l=cc.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=n,this.textHeight=s,this.lineLength=r,a){this.heightSamples={};for(let u=0;u<o.length;u++){let c=o[u];c<0?u++:this.heightSamples[Math.floor(c*10)]=!0}}return a}}class mS{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Dt{constructor(e,t,n,s,r){this.from=e,this.length=t,this.top=n,this.height=s,this._content=r}get type(){return typeof this._content=="number"?Ue.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof yi?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Dt(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var me=(function(i){return i[i.ByPos=0]="ByPos",i[i.ByHeight=1]="ByHeight",i[i.ByPosNoHeight=2]="ByPosNoHeight",i})(me||(me={}));const Zs=.001;class qe{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Zs&&(pn=!0),this.height=e)}replace(e,t,n){return qe.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,s){let r=this,o=n.doc;for(let l=s.length-1;l>=0;l--){let{fromA:a,toA:u,fromB:c,toB:h}=s[l],f=r.lineAt(a,me.ByPosNoHeight,n.setDoc(t),0,0),p=f.to>=u?f:r.lineAt(u,me.ByPosNoHeight,n,0,0);for(h+=p.to-u,u=p.to;l>0&&f.from<=s[l-1].toA;)a=s[l-1].fromA,c=s[l-1].fromB,l--,a<f.from&&(f=r.lineAt(a,me.ByPosNoHeight,n,0,0));c+=f.from-a,a=f.from;let g=La.build(n.setDoc(o),e,c,h);r=Sr(r,r.replace(a,u,g))}return r.updateHeight(n,0)}static empty(){return new nt(0,0)}static of(e){if(e.length==1)return e[0];let t=0,n=e.length,s=0,r=0;for(;;)if(t==n)if(s>r*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),n+=1+l.break,s-=l.size}else if(r>s*2){let l=e[n];l.break?e.splice(n,1,l.left,null,l.right):e.splice(n,1,l.left,l.right),n+=2+l.break,r-=l.size}else break;else if(s<r){let l=e[t++];l&&(s+=l.size)}else{let l=e[--n];l&&(r+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,n++),new xS(qe.of(e.slice(0,t)),o,qe.of(e.slice(n)))}}function Sr(i,e){return i==e?i:(i.constructor!=e.constructor&&(pn=!0),e)}qe.prototype.size=1;class Qd extends qe{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,s){return new Dt(s,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,s,r){return this.blockAt(0,n,s,r)}forEachLine(e,t,n,s,r,o){e<=r+this.length&&t>=r&&o(this.blockAt(0,n,s,r))}updateHeight(e,t=0,n=!1,s){return s&&s.from<=t&&s.more&&this.setHeight(s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class nt extends Qd{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,s){return new Dt(s,this.length,n,this.height,this.breaks)}replace(e,t,n){let s=n[0];return n.length==1&&(s instanceof nt||s instanceof De&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof De?s=new nt(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):qe.of(n)}updateHeight(e,t=0,n=!1,s){return s&&s.from<=t&&s.more?this.setHeight(s.heights[s.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class De extends qe{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,s=e.doc.lineAt(t+this.length).number,r=s-n+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:n,lastLine:s,perLine:o,perChar:l}}blockAt(e,t,n,s){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,s);if(t.lineWrapping){let u=s+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),c=t.doc.lineAt(u),h=l+c.length*a,f=Math.max(n,e-h/2);return new Dt(c.from,c.length,f,h,0)}else{let u=Math.max(0,Math.min(o-r,Math.floor((e-n)/l))),{from:c,length:h}=t.doc.line(r+u);return new Dt(c,h,n+l*u,l,0)}}lineAt(e,t,n,s,r){if(t==me.ByHeight)return this.blockAt(e,n,s,r);if(t==me.ByPosNoHeight){let{from:p,to:g}=n.doc.lineAt(e);return new Dt(p,g-p,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(n,r),u=n.doc.lineAt(e),c=l+u.length*a,h=u.number-o,f=s+l*h+a*(u.from-r-h);return new Dt(u.from,u.length,Math.max(s,Math.min(f,s+this.height-c)),c,0)}forEachLine(e,t,n,s,r,o){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:l,perLine:a,perChar:u}=this.heightMetrics(n,r);for(let c=e,h=s;c<=t;){let f=n.doc.lineAt(c);if(c==e){let g=f.number-l;h+=a*g+u*(e-r-g)}let p=a+u*f.length;o(new Dt(f.from,f.length,h,p,0)),h+=p,c=f.to+1}}replace(e,t,n){let s=this.length-t;if(s>0){let r=n[n.length-1];r instanceof De?n[n.length-1]=new De(r.length+s):n.push(null,new De(s-1))}if(e>0){let r=n[0];r instanceof De?n[0]=new De(e+r.length):n.unshift(new De(e-1),null)}return qe.of(n)}decomposeLeft(e,t){t.push(new De(e-1),null)}decomposeRight(e,t){t.push(null,new De(this.length-e-1))}updateHeight(e,t=0,n=!1,s){let r=t+this.length;if(s&&s.from<=t+this.length&&s.more){let o=[],l=Math.max(t,s.from),a=-1;for(s.from>t&&o.push(new De(s.from-t-1).updateHeight(e,t));l<=r&&s.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let h=s.heights[s.index++];a==-1?a=h:Math.abs(h-a)>=Zs&&(a=-2);let f=new nt(c,h);f.outdated=!1,o.push(f),l+=c+1}l<=r&&o.push(null,new De(r-l).updateHeight(e,l));let u=qe.of(o);return(a<0||Math.abs(u.height-this.height)>=Zs||Math.abs(a-this.heightMetrics(e,t).perLine)>=Zs)&&(pn=!0),Sr(this,u)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class xS extends qe{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,s){let r=n+this.left.height;return e<r?this.left.blockAt(e,t,n,s):this.right.blockAt(e,t,r,s+this.left.length+this.break)}lineAt(e,t,n,s,r){let o=s+this.left.height,l=r+this.left.length+this.break,a=t==me.ByHeight?e<o:e<l,u=a?this.left.lineAt(e,t,n,s,r):this.right.lineAt(e,t,n,o,l);if(this.break||(a?u.to<l:u.from>l))return u;let c=t==me.ByPosNoHeight?me.ByPosNoHeight:me.ByPos;return a?u.join(this.right.lineAt(l,c,n,o,l)):this.left.lineAt(l,c,n,s,r).join(u)}forEachLine(e,t,n,s,r,o){let l=s+this.left.height,a=r+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,s,r,o),t>=a&&this.right.forEachLine(e,t,n,l,a,o);else{let u=this.lineAt(a,me.ByPos,n,s,r);e<u.from&&this.left.forEachLine(e,u.from-1,n,s,r,o),u.to>=e&&u.from<=t&&o(u),t>u.to&&this.right.forEachLine(u.to+1,t,n,l,a,o)}}replace(e,t,n){let s=this.left.length+this.break;if(t<s)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-s,t-s,n));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of n)r.push(l);if(e>0&&fc(r,o-1),t<this.length){let l=r.length;this.decomposeRight(t,r),fc(r,l)}return qe.of(r)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,s=n+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<s&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?qe.of(this.break?[e,null,t]:[e,t]):(this.left=Sr(this.left,e),this.right=Sr(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,s){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return s&&s.from<=t+r.length&&s.more?a=r=r.updateHeight(e,t,n,s):r.updateHeight(e,t,n),s&&s.from<=l+o.length&&s.more?a=o=o.updateHeight(e,l,n,s):o.updateHeight(e,l,n),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function fc(i,e){let t,n;i[e]==null&&(t=i[e-1])instanceof De&&(n=i[e+1])instanceof De&&i.splice(e-1,3,new De(t.length+1+n.length))}const yS=5;class La{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof nt?s.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new nt(n-this.pos,-1)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let s=n.widget?n.widget.estimatedHeight:0,r=n.widget?n.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new Qd(o,s,n)):(o||r||s>=yS)&&this.addLineDeco(s,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new nt(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new De(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof nt)return e;let t=new nt(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let s=this.ensureLine();s.length+=n,s.collapsed+=n,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof nt)&&!this.isCovered?this.nodes.push(new nt(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let s of this.nodes)s instanceof nt&&s.updateHeight(this.oracle,n),n+=s?s.length:1;return this.nodes}static build(e,t,n,s){let r=new La(n,e);return se.spans(t,n,s,r,0),r.finish(n)}}function bS(i,e,t){let n=new vS;return se.compare(i,e,t,n,0),n.changes}class vS{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,s){(e<t||n&&n.heightRelevant||s&&s.heightRelevant)&&Js(e,t,this.changes,5)}}function SS(i,e){let t=i.getBoundingClientRect(),n=i.ownerDocument,s=n.defaultView||window,r=Math.max(0,t.left),o=Math.min(s.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(s.innerHeight,t.bottom);for(let u=i.parentNode;u&&u!=n.body;)if(u.nodeType==1){let c=u,h=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&h.overflow!="visible"){let f=c.getBoundingClientRect();r=Math.max(r,f.left),o=Math.min(o,f.right),l=Math.max(l,f.top),a=Math.min(u==i.parentNode?s.innerHeight:a,f.bottom)}u=h.position=="absolute"||h.position=="fixed"?c.offsetParent:c.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function CS(i){let e=i.getBoundingClientRect(),t=i.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function wS(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Io{constructor(e,t,n,s){this.from=e,this.to=t,this.size=n,this.displaySize=s}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let s=e[n],r=t[n];if(s.from!=r.from||s.to!=r.to||s.size!=r.size)return!1}return!0}draw(e,t){return q.replace({widget:new ES(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class ES extends Zt{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class dc{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=pc,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=xe.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Ia).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new gS(t),this.stateDeco=e.facet(Xn).filter(n=>typeof n!="function"),this.heightMap=qe.empty().applyChanges(this.stateDeco,re.empty,this.heightOracle.setDoc(e.doc),[new dt(0,0,0,e.doc.length)]);for(let n=0;n<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());n++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=q.set(this.lineGaps.map(n=>n.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let s=n?t.head:t.anchor;if(!e.some(({from:r,to:o})=>s>=r&&s<=o)){let{from:r,to:o}=this.lineBlockAt(s);e.push(new Is(r,o))}}return this.viewports=e.sort((n,s)=>n.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?pc:new Fa(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(On(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(Xn).filter(c=>typeof c!="function");let s=e.changedRanges,r=dt.extendWithRanges(s,bS(n,this.stateDeco,e?e.changes:Te.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);hc(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||pn)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let u=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(u||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(jd)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),s=this.heightOracle,r=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?xe.RTL:xe.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,c=0;if(l.width&&l.height){let{scaleX:w,scaleY:S}=rd(t,l);(w>.005&&Math.abs(this.scaleX-w)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=w,this.scaleY=S,u|=16,o=a=!0)}let h=(parseInt(n.paddingTop)||0)*this.scaleY,f=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=h||this.paddingBottom!=f)&&(this.paddingTop=h,this.paddingBottom=f,u|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=16);let p=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=p&&(this.scrollAnchorHeight=-1,this.scrollTop=p),this.scrolledToBottom=ad(e.scrollDOM);let g=(this.printing?wS:SS)(t,this.paddingTop),m=g.top-this.pixelViewport.top,x=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget&&!CS(e.dom))return 0;let b=l.width;if((this.contentDOMWidth!=b||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=16),a){let w=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(w)&&(o=!0),o||s.lineWrapping&&Math.abs(b-this.contentDOMWidth)>s.charWidth){let{lineHeight:S,charWidth:E,textHeight:A}=e.docView.measureTextSize();o=S>0&&s.refresh(r,S,E,A,Math.max(5,b/E),w),o&&(e.docView.minWidth=0,u|=16)}m>0&&x>0?c=Math.max(m,x):m<0&&x<0&&(c=Math.min(m,x)),hc();for(let S of this.viewports){let E=S.from==this.viewport.from?w:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?qe.empty().applyChanges(this.stateDeco,re.empty,this.heightOracle,[new dt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new mS(S.from,E))}pn&&(u|=2)}let v=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),u|=this.updateForViewport()),(u&2||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Is(s.lineAt(o-n*1e3,me.ByHeight,r,0,0).from,s.lineAt(l+(1-n)*1e3,me.ByHeight,r,0,0).to);if(t){let{head:u}=t.range;if(u<a.from||u>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),h=s.lineAt(u,me.ByPos,r,0,0),f;t.y=="center"?f=(h.top+h.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&u<a.from?f=h.top:f=h.bottom-c,a=new Is(s.lineAt(f-1e3/2,me.ByHeight,r,0,0).from,s.lineAt(f+c+1e3/2,me.ByHeight,r,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),s=t.mapPos(e.to,1);return new Is(this.heightMap.lineAt(n,me.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,me.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(e,me.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,me.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||s<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||r>=l+Math.max(10,Math.min(n,250)))&&s>o-2*1e3&&r<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let s of e)t.touchesRange(s.from,s.to)||n.push(new Io(t.mapPos(s.from),t.mapPos(s.to),s.size,s.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,s=n?1e4:2e3,r=s>>1,o=s<<1;if(this.defaultTextDirection!=xe.LTR&&!n)return[];let l=[],a=(c,h,f,p)=>{if(h-c<r)return;let g=this.state.selection.main,m=[g.from];g.empty||m.push(g.to);for(let y of m)if(y>c&&y<h){a(c,y-10,f,p),a(y+10,h,f,p);return}let x=kS(e,y=>y.from>=f.from&&y.to<=f.to&&Math.abs(y.from-c)<r&&Math.abs(y.to-h)<r&&!m.some(b=>y.from<b&&y.to>b));if(!x){if(h<f.to&&t&&n&&t.visibleRanges.some(v=>v.from<=h&&v.to>=h)){let v=t.moveToLineBoundary(T.cursor(h),!1,!0).head;v>c&&(h=v)}let y=this.gapSize(f,c,h,p),b=n||y<2e6?y:2e6;x=new Io(c,h,y,b)}l.push(x)},u=c=>{if(c.length<o||c.type!=Ue.Text)return;let h=RS(c.from,c.to,this.stateDeco);if(h.total<o)return;let f=this.scrollTarget?this.scrollTarget.range.head:null,p,g;if(n){let m=s/this.heightOracle.lineLength*this.heightOracle.lineHeight,x,y;if(f!=null){let b=Ds(h,f),v=((this.visibleBottom-this.visibleTop)/2+m)/c.height;x=b-v,y=b+v}else x=(this.visibleTop-c.top-m)/c.height,y=(this.visibleBottom-c.top+m)/c.height;p=Ps(h,x),g=Ps(h,y)}else{let m=h.total*this.heightOracle.charWidth,x=s*this.heightOracle.charWidth,y=0;if(m>2e6)for(let E of e)E.from>=c.from&&E.from<c.to&&E.size!=E.displaySize&&E.from*this.heightOracle.charWidth+y<this.pixelViewport.left&&(y=E.size-E.displaySize);let b=this.pixelViewport.left+y,v=this.pixelViewport.right+y,w,S;if(f!=null){let E=Ds(h,f),A=((v-b)/2+x)/m;w=E-A,S=E+A}else w=(b-x)/m,S=(v+x)/m;p=Ps(h,w),g=Ps(h,S)}p>c.from&&a(c.from,p,c,h),g<c.to&&a(g,c.to,c,h)};for(let c of this.viewportLines)Array.isArray(c.type)?c.type.forEach(u):u(c);return l}gapSize(e,t,n,s){let r=Ds(s,n)-Ds(s,t);return this.heightOracle.lineWrapping?e.height*r:s.total*this.heightOracle.charWidth*r}updateLineGaps(e){Io.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=q.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];se.spans(t,this.viewport.from,this.viewport.to,{span(r,o){n.push({from:r,to:o})},point(){}},20);let s=0;if(n.length!=this.visibleRanges.length)s=12;else for(let r=0;r<n.length&&!(s&8);r++){let o=this.visibleRanges[r],l=n[r];(o.from!=l.from||o.to!=l.to)&&(s|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(s|=8))}return this.visibleRanges=n,s}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||On(this.heightMap.lineAt(e,me.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||On(this.heightMap.lineAt(this.scaler.fromDOM(e),me.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return On(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Is{constructor(e,t){this.from=e,this.to=t}}function RS(i,e,t){let n=[],s=i,r=0;return se.spans(t,i,e,{span(){},point(o,l){o>s&&(n.push({from:s,to:o}),r+=o-s),s=l}},20),s<e&&(n.push({from:s,to:e}),r+=e-s),{total:r,ranges:n}}function Ps({total:i,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let n=Math.floor(i*t);for(let s=0;;s++){let{from:r,to:o}=e[s],l=o-r;if(n<=l)return r+n;n-=l}}function Ds(i,e){let t=0;for(let{from:n,to:s}of i.ranges){if(e<=s){t+=e-n;break}t+=s-n}return t/i.total}function kS(i,e){for(let t of i)if(e(t))return t}const pc={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}};class Fa{constructor(e,t,n){let s=0,r=0,o=0;this.viewports=n.map(({from:l,to:a})=>{let u=t.lineAt(l,me.ByPos,e,0,0).top,c=t.lineAt(a,me.ByPos,e,0,0).bottom;return s+=c-u,{from:l,to:a,top:u,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(t.height-s);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(e){for(let t=0,n=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return s+(e-n)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);n=r.bottom,s=r.domBottom}}fromDOM(e){for(let t=0,n=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return n+(e-s)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);n=r.bottom,s=r.domBottom}}eq(e){return e instanceof Fa?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to):!1}}function On(i,e){if(e.scale==1)return i;let t=e.toDOM(i.top),n=e.toDOM(i.bottom);return new Dt(i.from,i.length,t,n-t,Array.isArray(i._content)?i._content.map(s=>On(s,e)):i._content)}const Ls=$.define({combine:i=>i.join(" ")}),zl=$.define({combine:i=>i.indexOf(!0)>-1}),$l=mi.newName(),Jd=mi.newName(),Zd=mi.newName(),ep={"&light":"."+Jd,"&dark":"."+Zd};function _l(i,e,t){return new mi(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,s=>{if(s=="&")return i;if(!t||!t[s])throw new RangeError(`Unsupported selector: ${s}`);return t[s]}):i+" "+n}})}const AS=_l("."+$l,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},ep),TS={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Po=z.ie&&z.ie_version<=11;class MS{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new hv,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(z.ie&&z.ie_version<=11||z.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&z.android&&e.constructor.EDIT_CONTEXT!==!1&&!(z.chrome&&z.chrome_version<126)&&(this.editContext=new OS(e),e.state.facet(Ut)&&(e.contentDOM.editContext=this.editContext.editContext)),Po&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,s=this.selectionRange;if(n.state.facet(Ut)?n.root.activeElement!=this.dom:!Qs(this.dom,s))return;let r=s.anchorNode&&n.docView.nearest(s.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(z.ie&&z.ie_version<=11||z.android&&z.chrome)&&!n.state.selection.main.empty&&s.focusNode&&Nn(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Yn(e.root);if(!t)return!1;let n=z.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&jS(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let s=Qs(this.dom,n);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&dv(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),s&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,TS),Po&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Po&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let s=()=>{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&nn(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,s=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(s=!0),t==-1?{from:t,to:n}=o:(t=Math.min(o.from,t),n=Math.max(o.to,n)))}return{from:t,to:n,typeOver:s}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),s=this.selectionChanged&&Qs(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new Kv(this.view,e,t,n);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,s=$d(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),s}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let n=gc(t,e.previousSibling||e.target.previousSibling,-1),s=gc(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:s?t.posBefore(s):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Ut)!=e.state.facet(Ut)&&(e.view.contentDOM.editContext=e.state.facet(Ut)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function gc(i,e,t){for(;e;){let n=ce.get(e);if(n&&n.parent==i)return n;let s=e.parentNode;e=s!=i.dom?s:t>0?e.nextSibling:e.previousSibling}return null}function mc(i,e){let t=e.startContainer,n=e.startOffset,s=e.endContainer,r=e.endOffset,o=i.docView.domAtPos(i.state.selection.main.anchor);return Nn(o.node,o.offset,s,r)&&([t,n,s,r]=[s,r,t,n]),{anchorNode:t,anchorOffset:n,focusNode:s,focusOffset:r}}function jS(i,e){if(e.getComposedRanges){let s=e.getComposedRanges(i.root)[0];if(s)return mc(i,s)}let t=null;function n(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return i.contentDOM.addEventListener("beforeinput",n,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",n,!0),t?mc(i,t):null}class OS{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let s=e.state.selection.main,{anchor:r,head:o}=s,l=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:l,drifted:!1});let u=a-l>n.text.length;l==this.from&&r<this.from?l=r:a==this.to&&r>this.to&&(a=r);let c=_d(e.state.sliceDoc(l,a),n.text,(u?s.from:s.to)-l,u?"end":null);if(!c){let f=T.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));f.main.eq(s)||e.dispatch({selection:f,userEvent:"select"});return}let h={from:c.from+l,to:c.toA+l,insert:re.of(n.text.slice(c.from,c.toB).split(`
32
- `))};if((z.mac||z.android)&&h.from==o-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(h={from:l,to:a,insert:re.of([n.text.replace("."," ")])}),this.pendingContextChange=h,!e.state.readOnly){let f=this.to-this.from+(h.to-h.from+h.insert.length);Da(e,h,T.single(this.toEditorPos(n.selectionStart,f),this.toEditorPos(n.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),h.from<h.to&&!h.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let s=[],r=null;for(let o=this.toEditorPos(n.rangeStart),l=this.toEditorPos(n.rangeEnd);o<l;o++){let a=e.coordsForChar(o);r=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||r||new DOMRect,s.push(r)}t.updateCharacterBounds(n.rangeStart,s)},this.handlers.textformatupdate=n=>{let s=[];for(let r of n.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);if(a<u){let c=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;s.push(q.mark({attributes:{style:c}}).range(a,u))}}}e.dispatch({effects:Id.of(q.set(s))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:n}=this.composing;this.composing=null,n&&this.reset(e.state)}};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let s=Yn(n.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,s=this.pendingContextChange;return e.changes.iterChanges((r,o,l,a,u)=>{if(n)return;let c=u.length-(o-r);if(s&&o>=s.to)if(s.from==r&&s.to==o&&s.insert.eq(u)){s=this.pendingContextChange=null,t+=c,this.to+=c;return}else s=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=c,this.to+=c;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+u.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),u.toString()),this.to+=c}t+=c}),s&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),s=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(n,s)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class V{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(s=>s.forEach(r=>n(r,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||fv(e.parent)||document,this.viewState=new dc(e.state||ne.create(e)),e.scrollTo&&e.scrollTo.is(Ms)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ki).map(s=>new Mo(s));for(let s of this.plugins)s.update(this);this.observer=new MS(this),this.inputState=new Jv(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Ku(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof Me?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,s,r=this.state;for(let f of e){if(f.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=f.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;e.some(f=>f.annotation(Kd))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Yd(r,o),a||(l=1));let u=this.observer.delayedAndroidKey,c=null;if(u?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(ne.phrases)!=this.state.facet(ne.phrases))return this.setState(r);s=vr.create(this,r,e),s.flags|=l;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(h&&(h=h.map(f.changes)),f.scrollIntoView){let{main:p}=f.state.selection;h=new sn(p.empty?p:T.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of f.effects)p.is(Ms)&&(h=p.value.clip(this.state))}this.viewState.update(s,h),this.bidiCache=Cr.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(Mn)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Ls)!=s.state.facet(Ls)&&(this.viewState.mustMeasureContent=!0),(t||n||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let f of this.state.facet(Fl))try{f(s)}catch(p){Xe(this.state,p,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!$d(this,c)&&u.force&&nn(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new dc(e),this.plugins=e.facet(Ki).map(n=>new Mo(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new Ku(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Ki),n=e.state.facet(Ki);if(t!=n){let s=[];for(let r of n){let o=t.indexOf(r);if(o<0)s.push(new Mo(r));else{let l=this.plugins[o];l.mustUpdate=e,s.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s<this.plugins.length;s++)this.plugins[s].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(n){Xe(this.state,n,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,s=n.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(s-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(ad(n))r=-1,o=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(s);r=p.from,o=p.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];a&4||([this.measureRequests,u]=[u,this.measureRequests]);let c=u.map(p=>{try{return p.read(this)}catch(g){return Xe(this.state,g),xc}}),h=vr.create(this,this.state,[]),f=!1;h.flags|=a,t?t.flags|=a:t=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),f=this.docView.update(h),f&&this.docViewUpdate());for(let p=0;p<u.length;p++)if(c[p]!=xc)try{let g=u[p];g.write&&g.write(c[p],this)}catch(g){Xe(this.state,g)}if(f&&this.docView.updateSelection(!0),!h.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let g=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-o;if(g>1||g<-1){s=s+g,n.scrollTop=s/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(Fl))l(t)}get themeClasses(){return $l+" "+(this.state.facet(zl)?Zd:Jd)+" "+this.state.facet(Ls)}updateAttrs(){let e=yc(this,Pd,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Ut)?"true":"false",class:"cm-content",style:`${z.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),yc(this,Ia,t);let n=this.observer.ignore(()=>{let s=Ol(this.contentDOM,this.contentAttrs,t),r=Ol(this.dom,this.editorAttrs,e);return s||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let s of n.effects)if(s.is(V.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Mn);let e=this.state.facet(V.cspNonce);mi.mount(this.root,this.styleModules.concat(AS).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(n=>n.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return Oo(this,e,Zu(this,e,t,n))}moveByGroup(e,t){return Oo(this,e,Zu(this,e,t,n=>Hv(this,e.head,n)))}visualLineSide(e,t){let n=this.bidiSpans(e),s=this.textDirectionAt(e.from),r=n[t?n.length-1:0];return T.cursor(r.side(t,s)+e.from,r.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,n=!0){return _v(this,e,t,n)}moveVertically(e,t,n){return Oo(this,e,Gv(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),Bd(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let s=this.state.doc.lineAt(e),r=this.bidiSpans(s),o=r[ci.find(r,e-s.from,-1,t)];return os(n,o.dir==xe.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Md)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>IS)return Sd(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||vd(r.isolates,n=qu(this,e))))return r.order;n||(n=qu(this,e));let s=kv(e.text,t,n);return this.bidiCache.push(new Cr(e.from,e.to,t,n,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||z.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{od(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Ms.of(new sn(typeof e=="number"?T.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Ms.of(new sn(T.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Ce.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Ce.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=mi.newName(),s=[Ls.of(n),Mn.of(_l(`.${n}`,e))];return t&&t.dark&&s.push(zl.of(!0)),s}static baseTheme(e){return Vi.lowest(Mn.of(_l("."+$l,e,ep)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),s=n&&ce.get(n)||ce.get(e);return((t=s==null?void 0:s.rootView)===null||t===void 0?void 0:t.view)||null}}V.styleModule=Mn;V.inputHandler=Ad;V.clipboardInputFilter=ja;V.clipboardOutputFilter=Oa;V.scrollHandler=Od;V.focusChangeEffect=Td;V.perLineTextDirection=Md;V.exceptionSink=kd;V.updateListener=Fl;V.editable=Ut;V.mouseSelectionStyle=Rd;V.dragMovesSelection=Ed;V.clickAddsSelectionRange=wd;V.decorations=Xn;V.outerDecorations=Dd;V.atomicRanges=us;V.bidiIsolatedRanges=Ld;V.scrollMargins=Fd;V.darkTheme=zl;V.cspNonce=$.define({combine:i=>i.length?i[0]:""});V.contentAttributes=Ia;V.editorAttributes=Pd;V.lineWrapping=V.contentAttributes.of({class:"cm-lineWrapping"});V.announce=J.define();const IS=4096,xc={};class Cr{constructor(e,t,n,s,r,o){this.from=e,this.to=t,this.dir=n,this.isolates=s,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let n=[],s=e.length?e[e.length-1].dir:xe.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let o=e[r];o.dir==s&&!t.touchesRange(o.from,o.to)&&n.push(new Cr(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function yc(i,e,t){for(let n=i.state.facet(e),s=n.length-1;s>=0;s--){let r=n[s],o=typeof r=="function"?r(i):r;o&&jl(o,t)}return t}const PS=z.mac?"mac":z.windows?"win":z.linux?"linux":"key";function DS(i,e){const t=i.split(/-(?!$)/);let n=t[t.length-1];n=="Space"&&(n=" ");let s,r,o,l;for(let a=0;a<t.length-1;++a){const u=t[a];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))s=!0;else if(/^(c|ctrl|control)$/i.test(u))r=!0;else if(/^s(hift)?$/i.test(u))o=!0;else if(/^mod$/i.test(u))e=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+u)}return s&&(n="Alt-"+n),r&&(n="Ctrl-"+n),l&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function Fs(i,e,t){return e.altKey&&(i="Alt-"+i),e.ctrlKey&&(i="Ctrl-"+i),e.metaKey&&(i="Meta-"+i),t!==!1&&e.shiftKey&&(i="Shift-"+i),i}const LS=Vi.default(V.domEventHandlers({keydown(i,e){return ip(tp(e.state),i,e,"editor")}})),Yr=$.define({enables:LS}),bc=new WeakMap;function tp(i){let e=i.facet(Yr),t=bc.get(e);return t||bc.set(e,t=BS(e.reduce((n,s)=>n.concat(s),[]))),t}function FS(i,e,t){return ip(tp(i.state),e,i,t)}let oi=null;const NS=4e3;function BS(i,e=PS){let t=Object.create(null),n=Object.create(null),s=(o,l)=>{let a=n[o];if(a==null)n[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,a,u,c)=>{var h,f;let p=t[o]||(t[o]=Object.create(null)),g=l.split(/ (?!$)/).map(y=>DS(y,e));for(let y=1;y<g.length;y++){let b=g.slice(0,y).join(" ");s(b,!0),p[b]||(p[b]={preventDefault:!0,stopPropagation:!1,run:[v=>{let w=oi={view:v,prefix:b,scope:o};return setTimeout(()=>{oi==w&&(oi=null)},NS),!0}]})}let m=g.join(" ");s(m,!1);let x=p[m]||(p[m]={preventDefault:!1,stopPropagation:!1,run:((f=(h=p._any)===null||h===void 0?void 0:h.run)===null||f===void 0?void 0:f.slice())||[]});a&&x.run.push(a),u&&(x.preventDefault=!0),c&&(x.stopPropagation=!0)};for(let o of i){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of l){let c=t[u]||(t[u]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:h}=o;for(let f in c)c[f].run.push(p=>h(p,Hl))}let a=o[e]||o.key;if(a)for(let u of l)r(u,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(u,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}let Hl=null;function ip(i,e,t,n){Hl=e;let s=ov(e),r=Ke(s,0),o=Pt(r)==s.length&&s!=" ",l="",a=!1,u=!1,c=!1;oi&&oi.view==t&&oi.scope==n&&(l=oi.prefix+" ",Gd.indexOf(e.keyCode)<0&&(u=!0,oi=null));let h=new Set,f=x=>{if(x){for(let y of x.run)if(!h.has(y)&&(h.add(y),y(t)))return x.stopPropagation&&(c=!0),!0;x.preventDefault&&(x.stopPropagation&&(c=!0),u=!0)}return!1},p=i[n],g,m;return p&&(f(p[l+Fs(s,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(z.windows&&e.ctrlKey&&e.altKey)&&!(z.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(g=xi[e.keyCode])&&g!=s?(f(p[l+Fs(g,e,!0)])||e.shiftKey&&(m=Kn[e.keyCode])!=s&&m!=g&&f(p[l+Fs(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&f(p[l+Fs(s,e,!0)])&&(a=!0),!a&&f(p._any)&&(a=!0)),u&&(a=!0),a&&c&&e.stopPropagation(),Hl=null,a}class cs{constructor(e,t,n,s,r){this.className=e,this.left=t,this.top=n,this.width=s,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let s=e.coordsAtPos(n.head,n.assoc||1);if(!s)return[];let r=np(e);return[new cs(t,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return VS(e,t,n)}}function np(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==xe.LTR?e.left:e.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:e.top-i.scrollDOM.scrollTop*i.scaleY}}function vc(i,e,t,n){let s=i.coordsAtPos(e,t*2);if(!s)return n;let r=i.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,l=i.posAtCoords({x:r.left+1,y:o}),a=i.posAtCoords({x:r.right-1,y:o});return l==null||a==null?n:{from:Math.max(n.from,Math.min(l,a)),to:Math.min(n.to,Math.max(l,a))}}function VS(i,e,t){if(t.to<=i.viewport.from||t.from>=i.viewport.to)return[];let n=Math.max(t.from,i.viewport.from),s=Math.min(t.to,i.viewport.to),r=i.textDirection==xe.LTR,o=i.contentDOM,l=o.getBoundingClientRect(),a=np(i),u=o.querySelector(".cm-line"),c=u&&window.getComputedStyle(u),h=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),f=l.right-(c?parseInt(c.paddingRight):0),p=Bl(i,n,1),g=Bl(i,s,-1),m=p.type==Ue.Text?p:null,x=g.type==Ue.Text?g:null;if(m&&(i.lineWrapping||p.widgetLineBreaks)&&(m=vc(i,n,1,m)),x&&(i.lineWrapping||g.widgetLineBreaks)&&(x=vc(i,s,-1,x)),m&&x&&m.from==x.from&&m.to==x.to)return b(v(t.from,t.to,m));{let S=m?v(t.from,null,m):w(p,!1),E=x?v(null,t.to,x):w(g,!0),A=[];return(m||p).to<(x||g).from-(m&&x?1:0)||p.widgetLineBreaks>1&&S.bottom+i.defaultLineHeight/2<E.top?A.push(y(h,S.bottom,f,E.top)):S.bottom<E.top&&i.elementAtHeight((S.bottom+E.top)/2).type==Ue.Text&&(S.bottom=E.top=(S.bottom+E.top)/2),b(S).concat(A).concat(b(E))}function y(S,E,A,O){return new cs(e,S-a.left,E-a.top,A-S,O-E)}function b({top:S,bottom:E,horizontal:A}){let O=[];for(let R=0;R<A.length;R+=2)O.push(y(A[R],S,A[R+1],E));return O}function v(S,E,A){let O=1e9,R=-1e9,H=[];function N(P,U,Q,he,pe){let ie=i.coordsAtPos(P,P==A.to?-2:2),ee=i.coordsAtPos(Q,Q==A.from?2:-2);!ie||!ee||(O=Math.min(ie.top,ee.top,O),R=Math.max(ie.bottom,ee.bottom,R),pe==xe.LTR?H.push(r&&U?h:ie.left,r&&he?f:ee.right):H.push(!r&&he?h:ee.left,!r&&U?f:ie.right))}let I=S??A.from,W=E??A.to;for(let P of i.visibleRanges)if(P.to>I&&P.from<W)for(let U=Math.max(P.from,I),Q=Math.min(P.to,W);;){let he=i.state.doc.lineAt(U);for(let pe of i.bidiSpans(he)){let ie=pe.from+he.from,ee=pe.to+he.from;if(ie>=Q)break;ee>U&&N(Math.max(ie,U),S==null&&ie<=I,Math.min(ee,Q),E==null&&ee>=W,pe.dir)}if(U=he.to+1,U>=Q)break}return H.length==0&&N(I,S==null,W,E==null,i.textDirection),{top:O,bottom:R,horizontal:H}}function w(S,E){let A=l.top+(E?S.top:S.bottom);return{top:A,bottom:A,horizontal:[]}}}function zS(i,e){return i.constructor==e.constructor&&i.eq(e)}class $S{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(er)!=e.state.facet(er)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(er);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,n)=>!zS(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[n].constructor&&s.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(s.draw(),t);for(;t;){let s=t.nextSibling;t.remove(),t=s}this.drawn=e,z.safari&&z.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const er=$.define();function sp(i){return[Ce.define(e=>new $S(e,i)),er.of(i)]}const Qn=$.define({combine(i){return _t(i,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function _S(i={}){return[Qn.of(i),HS,GS,WS,jd.of(!0)]}function rp(i){return i.startState.facet(Qn)!=i.state.facet(Qn)}const HS=sp({above:!0,markers(i){let{state:e}=i,t=e.facet(Qn),n=[];for(let s of e.selection.ranges){let r=s==e.selection.main;if(s.empty||t.drawRangeCursor){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=s.empty?s:T.cursor(s.head,s.head>s.anchor?-1:1);for(let a of cs.forRange(i,o,l))n.push(a)}}return n},update(i,e){i.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=rp(i);return t&&Sc(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){Sc(e.state,i)},class:"cm-cursorLayer"});function Sc(i,e){e.style.animationDuration=i.facet(Qn).cursorBlinkRate+"ms"}const GS=sp({above:!1,markers(i){return i.state.selection.ranges.map(e=>e.empty?[]:cs.forRange(i,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||rp(i)},class:"cm-selectionLayer"}),WS=Vi.highest(V.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),op=J.define({map(i,e){return i==null?null:e.mapPos(i)}}),In=Ne.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(op)?n.value:t,i)}}),US=Ce.fromClass(class{constructor(i){this.view=i,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(i){var e;let t=i.state.field(In);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(i.startState.field(In)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:i}=this,e=i.state.field(In),t=e!=null&&i.coordsAtPos(e);if(!t)return null;let n=i.scrollDOM.getBoundingClientRect();return{left:t.left-n.left+i.scrollDOM.scrollLeft*i.scaleX,top:t.top-n.top+i.scrollDOM.scrollTop*i.scaleY,height:t.bottom-t.top}}drawCursor(i){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;i?(this.cursor.style.left=i.left/e+"px",this.cursor.style.top=i.top/t+"px",this.cursor.style.height=i.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(i){this.view.state.field(In)!=i&&this.view.dispatch({effects:op.of(i)})}},{eventObservers:{dragover(i){this.setDropPos(this.view.posAtCoords({x:i.clientX,y:i.clientY}))},dragleave(i){(i.target==this.view.contentDOM||!this.view.contentDOM.contains(i.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function qS(){return[In,US]}function Cc(i,e,t,n,s){e.lastIndex=0;for(let r=i.iterRange(t,n),o=t,l;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;l=e.exec(r.value);)s(o+l.index,l)}function KS(i,e){let t=i.visibleRanges;if(t.length==1&&t[0].from==i.viewport.from&&t[0].to==i.viewport.to)return t;let n=[];for(let{from:s,to:r}of t)s=Math.max(i.state.doc.lineAt(s).from,s-e),r=Math.min(i.state.doc.lineAt(r).to,r+e),n.length&&n[n.length-1].to>=s?n[n.length-1].to=r:n.push({from:s,to:r});return n}class YS{constructor(e){const{regexp:t,decoration:n,decorate:s,boundary:r,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,s)this.addMatch=(l,a,u,c)=>s(c,u,u+l[0].length,l,a);else if(typeof n=="function")this.addMatch=(l,a,u,c)=>{let h=n(l,a,u);h&&c(u,u+l[0].length,h)};else if(n)this.addMatch=(l,a,u,c)=>c(u,u+l[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(e){let t=new Xt,n=t.add.bind(t);for(let{from:s,to:r}of KS(e,this.maxLength))Cc(e.state.doc,this.regexp,s,r,(o,l)=>this.addMatch(l,e,o,n));return t.finish()}updateDeco(e,t){let n=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((r,o,l,a)=>{a>=e.view.viewport.from&&l<=e.view.viewport.to&&(n=Math.min(l,n),s=Math.max(a,s))}),e.viewportMoved||s-n>1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),n,s):t}updateRange(e,t,n,s){for(let r of e.visibleRanges){let o=Math.max(r.from,n),l=Math.min(r.to,s);if(l>=o){let a=e.state.doc.lineAt(o),u=a.to<l?e.state.doc.lineAt(l):a,c=Math.max(r.from,a.from),h=Math.min(r.to,u.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;l<u.to;l++)if(this.boundary.test(u.text[l-u.from])){h=l;break}}let f=[],p,g=(m,x,y)=>f.push(y.range(m,x));if(a==u)for(this.regexp.lastIndex=c-a.from;(p=this.regexp.exec(a.text))&&p.index<h-a.from;)this.addMatch(p,e,p.index+a.from,g);else Cc(e.state.doc,this.regexp,c,h,(m,x)=>this.addMatch(x,e,m,g));t=t.update({filterFrom:c,filterTo:h,filter:(m,x)=>m<c||x>h,add:f})}}return t}}const Gl=/x/.unicode!=null?"gu":"g",XS=new RegExp(`[\0-\b
33
- --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,Gl),QS={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Do=null;function JS(){var i;if(Do==null&&typeof document<"u"&&document.body){let e=document.body.style;Do=((i=e.tabSize)!==null&&i!==void 0?i:e.MozTabSize)!=null}return Do||!1}const tr=$.define({combine(i){let e=_t(i,{render:null,specialChars:XS,addSpecialChars:null});return(e.replaceTabs=!JS())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Gl)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Gl)),e}});function ZS(i={}){return[tr.of(i),e1()]}let wc=null;function e1(){return wc||(wc=Ce.fromClass(class{constructor(i){this.view=i,this.decorations=q.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(i.state.facet(tr)),this.decorations=this.decorator.createDeco(i)}makeDecorator(i){return new YS({regexp:i.specialChars,decoration:(e,t,n)=>{let{doc:s}=t.state,r=Ke(e[0],0);if(r==9){let o=s.lineAt(n),l=t.state.tabSize,a=yn(o.text,l,n-o.from);return q.replace({widget:new s1((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=q.replace({widget:new n1(i,r)}))},boundary:i.replaceTabs?void 0:/[^]/})}update(i){let e=i.state.facet(tr);i.startState.facet(tr)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(i.view)):this.decorations=this.decorator.updateDeco(i,this.decorations)}},{decorations:i=>i.decorations}))}const t1="•";function i1(i){return i>=32?t1:i==10?"␤":String.fromCharCode(9216+i)}class n1 extends Zt{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=i1(this.code),n=e.state.phrase("Control character")+" "+(QS[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,n,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=n,r.setAttribute("aria-label",n),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class s1 extends Zt{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function r1(){return l1}const o1=q.line({class:"cm-activeLine"}),l1=Ce.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.docChanged||i.selectionSet)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=-1,t=[];for(let n of i.state.selection.ranges){let s=i.lineBlockAt(n.head);s.from>e&&(t.push(o1.range(s.from)),e=s.from)}return q.set(t)}},{decorations:i=>i.decorations});class a1 extends Zt{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?hn(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),s=os(t[0],n.direction!="rtl"),r=parseInt(n.lineHeight);return s.bottom-s.top>r*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+r}:s}ignoreEvent(){return!1}}function u1(i){let e=Ce.fromClass(class{constructor(t){this.view=t,this.placeholder=i?q.set([q.widget({widget:new a1(i),side:1}).range(0)]):q.none}get decorations(){return this.view.state.doc.length?q.none:this.placeholder}},{decorations:t=>t.decorations});return typeof i=="string"?[e,V.contentAttributes.of({"aria-placeholder":i})]:e}const Wl=2e3;function c1(i,e,t){let n=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>Wl||t.off>Wl||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=n;a<=s;a++){let u=i.doc.line(a);u.length<=l&&r.push(T.range(u.from+o,u.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=n;a<=s;a++){let u=i.doc.line(a),c=Cl(u.text,o,i.tabSize,!0);if(c<0)r.push(T.cursor(u.to));else{let h=Cl(u.text,l,i.tabSize);r.push(T.range(u.from+c,u.from+h))}}}return r}function h1(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function Ec(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1),n=i.state.doc.lineAt(t),s=t-n.from,r=s>Wl?-1:s==n.length?h1(i,e.clientX):yn(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:r,off:s}}function f1(i,e){let t=Ec(i,e),n=i.state.selection;return t?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.doc.line(t.line).from),o=s.state.doc.lineAt(r);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},n=n.map(s.changes)}},get(s,r,o){let l=Ec(i,s);if(!l)return n;let a=c1(i.state,t,l);return a.length?o?T.create(a.concat(n.ranges)):T.create(a):n}}:null}function d1(i){let e=(t=>t.altKey&&t.button==0);return V.mouseSelectionStyle.of((t,n)=>e(n)?f1(t,n):null)}const p1={Alt:[18,i=>!!i.altKey],Control:[17,i=>!!i.ctrlKey],Shift:[16,i=>!!i.shiftKey],Meta:[91,i=>!!i.metaKey]},g1={style:"cursor: crosshair"};function m1(i={}){let[e,t]=p1[i.key||"Alt"],n=Ce.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventObservers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)},mousemove(s){this.set(t(s))}}});return[n,V.contentAttributes.of(s=>{var r;return!((r=s.plugin(n))===null||r===void 0)&&r.isDown?g1:null})]}const Ns="-10000px";class lp{constructor(e,t,n,s){this.facet=t,this.createTooltipView=n,this.removeTooltipView=s,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=n(o,r))}update(e,t){var n;let s=e.state.facet(this.facet),r=s.filter(a=>a);if(s===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;a<r.length;a++){let u=r[a],c=-1;if(u){for(let h=0;h<this.tooltips.length;h++){let f=this.tooltips[h];f&&f.create==u.create&&(c=h)}if(c<0)o[a]=this.createTooltipView(u,a?o[a-1]:null),l&&(l[a]=!!u.above);else{let h=o[a]=this.tooltipViews[c];l&&(l[a]=t[c]),h.update&&h.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(n=a.destroy)===null||n===void 0||n.call(a));return t&&(l.forEach((a,u)=>t[u]=a),t.length=l.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}}function x1(i){let e=i.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Lo=$.define({combine:i=>{var e,t,n;return{position:z.ios?"absolute":((e=i.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=i.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((n=i.find(s=>s.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||x1}}}),Rc=new WeakMap,Na=Ce.fromClass(class{constructor(i){this.view=i,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=i.state.facet(Lo);this.position=e.position,this.parent=e.parent,this.classes=i.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new lp(i,Ba,(t,n)=>this.createTooltip(t,n),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),i.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let i of this.manager.tooltipViews)this.intersectionObserver.observe(i.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(i){i.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(i,this.above);e&&this.observeIntersection();let t=e||i.geometryChanged,n=i.state.facet(Lo);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(i,e){let t=i.create(this.view),n=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),i.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",t.dom.appendChild(s)}return t.dom.style.position=this.position,t.dom.style.top=Ns,t.dom.style.left="0px",this.container.insertBefore(t.dom,n),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var i,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(i=n.destroy)===null||i===void 0||i.call(n);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let i=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(z.safari){let o=r.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else t=!!r.offsetParent&&r.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(i=r.width/this.parent.offsetWidth,e=r.height/this.parent.offsetHeight)}else({scaleX:i,scaleY:e}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),s=Pa(this.view);return{visible:{left:n.left+s.left,top:n.top+s.top,right:n.right-s.right,bottom:n.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((r,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(Lo).tooltipSpace(this.view),scaleX:i,scaleY:e,makeAbsolute:t}}writeMeasure(i){var e;if(i.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:t,space:n,scaleX:s,scaleY:r}=i,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],u=this.manager.tooltipViews[l],{dom:c}=u,h=i.pos[l],f=i.size[l];if(!h||a.clip!==!1&&(h.bottom<=Math.max(t.top,n.top)||h.top>=Math.min(t.bottom,n.bottom)||h.right<Math.max(t.left,n.left)-.1||h.left>Math.min(t.right,n.right)+.1)){c.style.top=Ns;continue}let p=a.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,g=p?7:0,m=f.right-f.left,x=(e=Rc.get(u))!==null&&e!==void 0?e:f.bottom-f.top,y=u.offset||b1,b=this.view.textDirection==xe.LTR,v=f.width>n.right-n.left?b?n.left:n.right-f.width:b?Math.max(n.left,Math.min(h.left-(p?14:0)+y.x,n.right-m)):Math.min(Math.max(n.left,h.left-m+(p?14:0)-y.x),n.right-m),w=this.above[l];!a.strictSide&&(w?h.top-x-g-y.y<n.top:h.bottom+x+g+y.y>n.bottom)&&w==n.bottom-h.bottom>h.top-n.top&&(w=this.above[l]=!w);let S=(w?h.top-n.top:n.bottom-h.bottom)-g;if(S<x&&u.resize!==!1){if(S<this.view.defaultLineHeight){c.style.top=Ns;continue}Rc.set(u,x),c.style.height=(x=S)/r+"px"}else c.style.height&&(c.style.height="");let E=w?h.top-x-g-y.y:h.bottom+g+y.y,A=v+m;if(u.overlap!==!0)for(let O of o)O.left<A&&O.right>v&&O.top<E+x&&O.bottom>E&&(E=w?O.top-x-2-g:O.bottom+g+2);if(this.position=="absolute"?(c.style.top=(E-i.parent.top)/r+"px",kc(c,(v-i.parent.left)/s)):(c.style.top=E/r+"px",kc(c,v/s)),p){let O=h.left+(b?y.x:-y.x)-(v+14-7);p.style.left=O/s+"px"}u.overlap!==!0&&o.push({left:v,top:E,right:A,bottom:E+x}),c.classList.toggle("cm-tooltip-above",w),c.classList.toggle("cm-tooltip-below",!w),u.positioned&&u.positioned(i.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let i of this.manager.tooltipViews)i.dom.style.top=Ns}},{eventObservers:{scroll(){this.maybeMeasure()}}});function kc(i,e){let t=parseInt(i.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(i.style.left=e+"px")}const y1=V.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),b1={x:0,y:0},Ba=$.define({enables:[Na,y1]}),wr=$.define({combine:i=>i.reduce((e,t)=>e.concat(t),[])});class Xr{static create(e){return new Xr(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new lp(e,wr,(t,n)=>this.createHostedView(t,n),t=>t.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let s=n[e];if(s!==void 0){if(t===void 0)t=s;else if(t!==s)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const v1=Ba.compute([wr],i=>{let e=i.facet(wr);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var n;return(n=t.end)!==null&&n!==void 0?n:t.pos})),create:Xr.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class S1{constructor(e,t,n,s,r){this.view=e,this.source=t,this.field=n,this.setHover=s,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.nearest(t.target);if(!n)return;let s,r=1;if(n instanceof qt)s=n.posAtStart;else{if(s=e.posAtCoords(t),s==null)return;let l=e.coordsAtPos(s);if(!l||t.y<l.top||t.y>l.bottom||t.x<l.left-e.defaultCharacterWidth||t.x>l.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(s)).find(c=>c.from<=s&&c.to>=s),u=a&&a.dir==xe.RTL?-1:1;r=t.x<l.left?-u:u}let o=this.source(e,s,r);if(o!=null&&o.then){let l=this.pending={pos:s};o.then(a=>{this.pending==l&&(this.pending=null,a&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])}))},a=>Xe(e.state,a,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(Na),t=e?e.manager.tooltips.findIndex(n=>n.create==Xr.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:r}=this;if(s.length&&r&&!C1(r.dom,e)||this.pending){let{pos:o}=s[0]||this.pending,l=(n=(t=s[0])===null||t===void 0?void 0:t.end)!==null&&n!==void 0?n:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!w1(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:n}=this;n&&n.dom.contains(e.relatedTarget)?this.watchTooltipLeave(n.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Bs=4;function C1(i,e){let{left:t,right:n,top:s,bottom:r}=i.getBoundingClientRect(),o;if(o=i.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();s=Math.min(l.top,s),r=Math.max(l.bottom,r)}return e.clientX>=t-Bs&&e.clientX<=n+Bs&&e.clientY>=s-Bs&&e.clientY<=r+Bs}function w1(i,e,t,n,s,r){let o=i.scrollDOM.getBoundingClientRect(),l=i.documentTop+i.documentPadding.top+i.contentHeight;if(o.left>n||o.right<n||o.top>s||Math.min(o.bottom,l)<s)return!1;let a=i.posAtCoords({x:n,y:s},!1);return a>=e&&a<=t}function E1(i,e={}){let t=J.define(),n=Ne.define({create(){return[]},update(s,r){if(s.length&&(e.hideOnChange&&(r.docChanged||r.selection)?s=[]:e.hideOn&&(s=s.filter(o=>!e.hideOn(r,o))),r.docChanged)){let o=[];for(let l of s){let a=r.changes.mapPos(l.pos,-1,We.TrackDel);if(a!=null){let u=Object.assign(Object.create(null),l);u.pos=a,u.end!=null&&(u.end=r.changes.mapPos(u.end)),o.push(u)}}s=o}for(let o of r.effects)o.is(t)&&(s=o.value),o.is(R1)&&(s=[]);return s},provide:s=>wr.from(s)});return{active:n,extension:[n,Ce.define(s=>new S1(s,i,n,t,e.hoverTime||300)),v1]}}function ap(i,e){let t=i.plugin(Na);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}const R1=J.define(),Ac=$.define({combine(i){let e,t;for(let n of i)e=e||n.topContainer,t=t||n.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Jn(i,e){let t=i.plugin(up),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}const up=Ce.fromClass(class{constructor(i){this.input=i.state.facet(Zn),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(Ac);this.top=new Vs(i,!0,e.topContainer),this.bottom=new Vs(i,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(i){let e=i.state.facet(Ac);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Vs(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Vs(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(Zn);if(t!=this.input){let n=t.filter(a=>a),s=[],r=[],o=[],l=[];for(let a of n){let u=this.specs.indexOf(a),c;u<0?(c=a(i.view),l.push(c)):(c=this.panels[u],c.update&&c.update(i)),s.push(c),(c.top?r:o).push(c)}this.specs=n,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let n of this.panels)n.update&&n.update(i)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i=>V.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Vs{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Tc(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Tc(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function Tc(i){let e=i.nextSibling;return i.remove(),e}const Zn=$.define({enables:up});class Jt extends Di{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Jt.prototype.elementClass="";Jt.prototype.toDOM=void 0;Jt.prototype.mapMode=We.TrackBefore;Jt.prototype.startSide=Jt.prototype.endSide=-1;Jt.prototype.point=!0;const ir=$.define(),k1=$.define(),A1={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>se.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},zn=$.define();function T1(i){return[cp(),zn.of({...A1,...i})]}const Mc=$.define({combine:i=>i.some(e=>e)});function cp(i){return[M1]}const M1=Ce.fromClass(class{constructor(i){this.view=i,this.domAfter=null,this.prevViewport=i.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=i.state.facet(zn).map(e=>new Oc(i,e)),this.fixed=!i.state.facet(Mc);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),i.scrollDOM.insertBefore(this.dom,i.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(i){if(this.updateGutters(i)){let e=this.prevViewport,t=i.view.viewport,n=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(n<(t.to-t.from)*.8)}if(i.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Mc)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=i.view.viewport}syncGutters(i){let e=this.dom.nextSibling;i&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=se.iter(this.view.state.facet(ir),this.view.viewport.from),n=[],s=this.gutters.map(r=>new j1(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==Ue.Text&&o){Ul(t,n,l.from);for(let a of s)a.line(this.view,l,n);o=!1}else if(l.widget)for(let a of s)a.widget(this.view,l)}else if(r.type==Ue.Text){Ul(t,n,r.from);for(let o of s)o.line(this.view,r,n)}else if(r.widget)for(let o of s)o.widget(this.view,r);for(let r of s)r.finish();i&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(i){let e=i.startState.facet(zn),t=i.state.facet(zn),n=i.docChanged||i.heightChanged||i.viewportChanged||!se.eq(i.startState.facet(ir),i.state.facet(ir),i.view.viewport.from,i.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(i)&&(n=!0);else{n=!0;let s=[];for(let r of t){let o=e.indexOf(r);o<0?s.push(new Oc(this.view,r)):(this.gutters[o].update(i),s.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=s}return n}destroy(){for(let i of this.gutters)i.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:i=>V.scrollMargins.of(e=>{let t=e.plugin(i);if(!t||t.gutters.length==0||!t.fixed)return null;let n=t.dom.offsetWidth*e.scaleX,s=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==xe.LTR?{left:n,right:s}:{right:n,left:s}})});function jc(i){return Array.isArray(i)?i:[i]}function Ul(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}class j1{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=se.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:s}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==s.elements.length){let l=new hp(e,o,r,n);s.elements.push(l),s.dom.appendChild(l.dom)}else s.elements[this.i].update(e,o,r,n);this.height=t.bottom,this.i++}line(e,t,n){let s=[];Ul(this.cursor,s,t.from),n.length&&(s=s.concat(n));let r=this.gutter.config.lineMarker(e,t,s);r&&s.unshift(r);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,s)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),s=n?[n]:null;for(let r of e.state.facet(k1)){let o=r(e,t.widget,t);o&&(s||(s=[])).push(o)}s&&this.addElement(e,t,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Oc{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,s=>{let r=s.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=s.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[n](e,l,s)&&s.preventDefault()});this.markers=jc(t.markers(e)),t.initialSpacer&&(this.spacer=new hp(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=jc(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let n=e.view.viewport;return!se.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class hp{constructor(e,t,n,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,s)}update(e,t,n,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),O1(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let n="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=r<t.length?t[r++]:null,u=!1;if(a){let c=a.elementClass;c&&(n+=" "+c);for(let h=o;h<this.markers.length;h++)if(this.markers[h].compare(a)){l=h,u=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(s);let h=s.nextSibling;s.remove(),s=h}}if(!a)break;a.toDOM&&(u?s=s.nextSibling:this.dom.insertBefore(a.toDOM(e),s)),u&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}}function O1(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(!i[t].compare(e[t]))return!1;return!0}const I1=$.define(),P1=$.define(),Yi=$.define({combine(i){return _t(i,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let s in t){let r=n[s],o=t[s];n[s]=r?(l,a,u)=>r(l,a,u)||o(l,a,u):o}return n}})}});class Fo extends Jt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function No(i,e){return i.state.facet(Yi).formatNumber(e,i.state)}const D1=zn.compute([Yi],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(I1)},lineMarker(e,t,n){return n.some(s=>s.toDOM)?null:new Fo(No(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let s of e.state.facet(P1)){let r=s(e,t,n);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(Yi)!=e.state.facet(Yi),initialSpacer(e){return new Fo(No(e,Ic(e.state.doc.lines)))},updateSpacer(e,t){let n=No(t.view,Ic(t.view.state.doc.lines));return n==e.number?e:new Fo(n)},domEventHandlers:i.facet(Yi).domEventHandlers,side:"before"}));function L1(i={}){return[Yi.of(i),cp(),D1]}function Ic(i){let e=9;for(;e<i;)e=e*10+9;return e}const F1=new class extends Jt{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},N1=ir.compute(["selection"],i=>{let e=[],t=-1;for(let n of i.selection.ranges){let s=i.doc.lineAt(n.head).from;s>t&&(t=s,e.push(F1.range(s)))}return se.of(e)});function B1(){return N1}var Bo;const Xi=new te;function V1(i){return $.define({combine:i?e=>e.concat(i):void 0})}const z1=new te;class xt{constructor(e,t,n=[],s=""){this.data=e,this.name=s,ne.prototype.hasOwnProperty("tree")||Object.defineProperty(ne.prototype,"tree",{get(){return _e(this)}}),this.parser=t,this.extension=[bi.of(this),ne.languageData.of((r,o,l)=>{let a=Pc(r,o,l),u=a.type.prop(Xi);if(!u)return[];let c=r.facet(u),h=a.type.prop(z1);if(h){let f=a.resolve(o-a.from,l);for(let p of h)if(p.test(f,r)){let g=r.facet(p.facet);return p.type=="replace"?g:g.concat(c)}}return c})].concat(n)}isActiveAt(e,t,n=-1){return Pc(e,t,n).type.prop(Xi)==this.data}findRegions(e){let t=e.facet(bi);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],s=(r,o)=>{if(r.prop(Xi)==this.data){n.push({from:o,to:o+r.length});return}let l=r.prop(te.mounted);if(l){if(l.tree.prop(Xi)==this.data){if(l.overlay)for(let a of l.overlay)n.push({from:a.from+o,to:a.to+o});else n.push({from:o,to:o+r.length});return}else if(l.overlay){let a=n.length;if(s(l.tree,l.overlay[0].from+o),n.length>a)return}}for(let a=0;a<r.children.length;a++){let u=r.children[a];u instanceof Re&&s(u,r.positions[a]+o)}};return s(_e(e),0),n}get allowsNesting(){return!0}}xt.setState=J.define();function Pc(i,e,t){let n=i.facet(bi),s=_e(i).topNode;if(!n||n.allowsNesting)for(let r=s;r;r=r.enter(e,t,Ie.ExcludeBuffers))r.type.isTop&&(s=r);return s}class Er extends xt{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=V1(e.languageData);return new Er(t,e.parser.configure({props:[Xi.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new Er(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function _e(i){let e=i.field(xt.state,!1);return e?e.tree:Re.empty}class $1{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let An=null;class Rr{constructor(e,t,n=[],s,r,o,l,a){this.parser=e,this.state=t,this.fragments=n,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Rr(e,t,[],Re.empty,0,n,[],null)}startParse(){return this.parser.startParse(new $1(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Re.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(Ii.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Ii.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=An;An=this;try{return e()}finally{An=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Dc(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((u,c,h,f)=>a.push({fromA:u,toA:c,fromB:h,toB:f})),n=Ii.applyChanges(n,a),s=Re.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let c=e.mapPos(u.from,1),h=e.mapPos(u.to,-1);c<h&&l.push({from:c,to:h})}}}return new Rr(this.parser,t,n,s,r,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:s,to:r}=this.skipped[n];s<e.to&&r>e.from&&(this.fragments=Dc(this.fragments,s,r),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Lf{createParse(t,n,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=An;if(a){for(let u of s)a.tempSkipped.push(u);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Re(Ze.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return An}}function Dc(i,e,t){return Ii.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}class gn{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new gn(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Rr.create(e.facet(bi).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new gn(n)}}xt.state=Ne.define({create:gn.init,update(i,e){for(let t of e.effects)if(t.is(xt.setState))return t.value;return e.startState.facet(bi)!=e.state.facet(bi)?gn.init(e.state):i.apply(e)}});let fp=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(fp=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Vo=typeof navigator<"u"&&(!((Bo=navigator.scheduling)===null||Bo===void 0)&&Bo.isInputPending)?()=>navigator.scheduling.isInputPending():null,_1=Ce.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(xt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(xt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=fp(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:s}}=this.view,r=n.field(xt.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Vo?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<s&&n.doc.length>s+1e3,a=r.context.work(()=>Vo&&Vo()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:xt.setState.of(new gn(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Xe(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),bi=$.define({combine(i){return i.length?i[0]:null},enables:i=>[xt.state,_1,V.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});class H1{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const G1=$.define(),Qr=$.define({combine:i=>{if(!i.length)return" ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function kr(i){let e=i.facet(Qr);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function es(i,e){let t="",n=i.tabSize,s=i.facet(Qr)[0];if(s==" "){for(;e>=n;)t+=" ",e-=n;s=" "}for(let r=0;r<e;r++)t+=s;return t}function Va(i,e){i instanceof ne&&(i=new Jr(i));for(let n of i.state.facet(G1)){let s=n(i,e);if(s!==void 0)return s}let t=_e(i.state);return t.length>=e?W1(i,t,e):null}class Jr{constructor(e,t={}){this.state=e,this.options=t,this.unit=kr(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=n.from&&s<=n.to?r&&s==e?{text:"",from:e}:(t<0?s<e:s<=e)?{text:n.text.slice(s-n.from),from:s}:{text:n.text.slice(0,s-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:s}=this.lineAt(e,t);return n.slice(e-s,Math.min(n.length,e+100-s))}column(e,t=1){let{text:n,from:s}=this.lineAt(e,t),r=this.countColumn(n,e-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(r+=o-this.countColumn(n,n.search(/\S|$/))),r}countColumn(e,t=e.length){return yn(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const dp=new te;function W1(i,e,t){let n=e.resolveStack(t),s=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(s!=n.node){let r=[];for(let o=s;o&&!(o.from<n.node.from||o.to>n.node.to||o.from==n.node.from&&o.type==n.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)n={node:r[o],next:n}}return pp(n,i,t)}function pp(i,e,t){for(let n=i;n;n=n.next){let s=q1(n.node);if(s)return s(za.create(e,t,n))}return 0}function U1(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function q1(i){let e=i.type.prop(dp);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(te.closedBy))){let s=i.lastChild,r=s&&n.indexOf(s.name)>-1;return o=>Q1(o,!0,1,void 0,r&&!U1(o)?s.from:void 0)}return i.parent==null?K1:null}function K1(){return 0}class za extends Jr{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new za(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(Y1(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return pp(this.context.next,this.base,this.pos)}}function Y1(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function X1(i){let e=i.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let s=i.options.simulateBreak,r=i.state.doc.lineAt(t.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==n)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let u=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+u}}l=a.to}}function Q1(i,e,t,n,s){let r=i.textAfter,o=r.match(/^\s*/)[0].length,l=n&&r.slice(o,o+n.length)==n||s==i.pos+o,a=X1(i);return a?l?i.column(a.from):i.column(a.to):i.baseIndent+(l?0:i.unit*t)}function Lc({except:i,units:e=1}={}){return t=>{let n=i&&i.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}const J1=200;function Z1(){return ne.transactionFilter.of(i=>{if(!i.docChanged||!i.isUserEvent("input.type")&&!i.isUserEvent("input.complete"))return i;let e=i.startState.languageDataAt("indentOnInput",i.startState.selection.main.head);if(!e.length)return i;let t=i.newDoc,{head:n}=i.newSelection.main,s=t.lineAt(n);if(n>s.from+J1)return i;let r=t.sliceString(s.from,n);if(!e.some(u=>u.test(r)))return i;let{state:o}=i,l=-1,a=[];for(let{head:u}of o.selection.ranges){let c=o.doc.lineAt(u);if(c.from==l)continue;l=c.from;let h=Va(o,c.from);if(h==null)continue;let f=/^\s*/.exec(c.text)[0],p=es(o,h);f!=p&&a.push({from:c.from,to:c.from+f.length,insert:p})}return a.length?[i,{changes:a,sequential:!0}]:i})}const eC=$.define(),gp=new te;function tC(i){let e=i.firstChild,t=i.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?i.to:t.from}:null}function iC(i,e,t){let n=_e(i);if(n.length<t)return null;let s=n.resolveStack(t,1),r=null;for(let o=s;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(r&&l.from<e)break;let a=l.type.prop(gp);if(a&&(l.to<n.length-50||n.length==i.doc.length||!nC(l))){let u=a(l,i);u&&u.from<=t&&u.from>=e&&u.to>t&&(r=u)}}return r}function nC(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function Ar(i,e,t){for(let n of i.facet(eC)){let s=n(i,e,t);if(s)return s}return iC(i,e,t)}function mp(i,e){let t=e.mapPos(i.from,1),n=e.mapPos(i.to,-1);return t>=n?void 0:{from:t,to:n}}const Zr=J.define({map:mp}),hs=J.define({map:mp});function xp(i){let e=[];for(let{head:t}of i.state.selection.ranges)e.some(n=>n.from<=t&&n.to>=t)||e.push(i.lineBlockAt(t));return e}const Bi=Ne.define({create(){return q.none},update(i,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((t,n)=>i=Fc(i,t,n)),i=i.map(e.changes);for(let t of e.effects)if(t.is(Zr)&&!sC(i,t.value.from,t.value.to)){let{preparePlaceholder:n}=e.state.facet(vp),s=n?q.replace({widget:new hC(n(e.state,t.value))}):Nc;i=i.update({add:[s.range(t.value.from,t.value.to)]})}else t.is(hs)&&(i=i.update({filter:(n,s)=>t.value.from!=n||t.value.to!=s,filterFrom:t.value.from,filterTo:t.value.to}));return e.selection&&(i=Fc(i,e.selection.main.head)),i},provide:i=>V.decorations.from(i),toJSON(i,e){let t=[];return i.between(0,e.doc.length,(n,s)=>{t.push(n,s)}),t},fromJSON(i){if(!Array.isArray(i)||i.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<i.length;){let n=i[t++],s=i[t++];if(typeof n!="number"||typeof s!="number")throw new RangeError("Invalid JSON for fold state");e.push(Nc.range(n,s))}return q.set(e,!0)}});function Fc(i,e,t=e){let n=!1;return i.between(e,t,(s,r)=>{s<t&&r>e&&(n=!0)}),n?i.update({filterFrom:e,filterTo:t,filter:(s,r)=>s>=t||r<=e}):i}function Tr(i,e,t){var n;let s=null;return(n=i.field(Bi,!1))===null||n===void 0||n.between(e,t,(r,o)=>{(!s||s.from>r)&&(s={from:r,to:o})}),s}function sC(i,e,t){let n=!1;return i.between(e,e,(s,r)=>{s==e&&r==t&&(n=!0)}),n}function yp(i,e){return i.field(Bi,!1)?e:e.concat(J.appendConfig.of(Sp()))}const rC=i=>{for(let e of xp(i)){let t=Ar(i.state,e.from,e.to);if(t)return i.dispatch({effects:yp(i.state,[Zr.of(t),bp(i,t)])}),!0}return!1},oC=i=>{if(!i.state.field(Bi,!1))return!1;let e=[];for(let t of xp(i)){let n=Tr(i.state,t.from,t.to);n&&e.push(hs.of(n),bp(i,n,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function bp(i,e,t=!0){let n=i.state.doc.lineAt(e.from).number,s=i.state.doc.lineAt(e.to).number;return V.announce.of(`${i.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${i.state.phrase("to")} ${s}.`)}const lC=i=>{let{state:e}=i,t=[];for(let n=0;n<e.doc.length;){let s=i.lineBlockAt(n),r=Ar(e,s.from,s.to);r&&t.push(Zr.of(r)),n=(r?i.lineBlockAt(r.to):s).to+1}return t.length&&i.dispatch({effects:yp(i.state,t)}),!!t.length},aC=i=>{let e=i.state.field(Bi,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,i.state.doc.length,(n,s)=>{t.push(hs.of({from:n,to:s}))}),i.dispatch({effects:t}),!0},uC=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:rC},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:oC},{key:"Ctrl-Alt-[",run:lC},{key:"Ctrl-Alt-]",run:aC}],cC={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},vp=$.define({combine(i){return _t(i,cC)}});function Sp(i){return[Bi,pC]}function Cp(i,e){let{state:t}=i,n=t.facet(vp),s=o=>{let l=i.lineBlockAt(i.posAtDOM(o.target)),a=Tr(i.state,l.from,l.to);a&&i.dispatch({effects:hs.of(a)}),o.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(i,s,e);let r=document.createElement("span");return r.textContent=n.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const Nc=q.replace({widget:new class extends Zt{toDOM(i){return Cp(i,null)}}});class hC extends Zt{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Cp(e,this.value)}}const fC={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class zo extends Jt{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function dC(i={}){let e={...fC,...i},t=new zo(e,!0),n=new zo(e,!1),s=Ce.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(bi)!=o.state.facet(bi)||o.startState.field(Bi,!1)!=o.state.field(Bi,!1)||_e(o.startState)!=_e(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new Xt;for(let a of o.viewportLineBlocks){let u=Tr(o.state,a.from,a.to)?n:Ar(o.state,a.from,a.to)?t:null;u&&l.add(a.from,a.from,u)}return l.finish()}}),{domEventHandlers:r}=e;return[s,T1({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(s))===null||l===void 0?void 0:l.markers)||se.empty},initialSpacer(){return new zo(e,!1)},domEventHandlers:{...r,click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let u=Tr(o.state,l.from,l.to);if(u)return o.dispatch({effects:hs.of(u)}),!0;let c=Ar(o.state,l.from,l.to);return c?(o.dispatch({effects:Zr.of(c)}),!0):!1}}}),Sp()]}const pC=V.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class fs{constructor(e,t){this.specs=e;let n;function s(l){let a=mi.newName();return(n||(n=Object.create(null)))["."+a]=l,a}const r=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,o=t.scope;this.scope=o instanceof xt?l=>l.prop(Xi)==o.data:o?l=>l==o:void 0,this.style=Bf(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=n?new mi(n):null,this.themeType=t.themeType}static define(e,t){return new fs(e,t||{})}}const ql=$.define(),wp=$.define({combine(i){return i.length?[i[0]]:null}});function $o(i){let e=i.facet(ql);return e.length?e:i.facet(wp)}function Ep(i,e){let t=[mC],n;return i instanceof fs&&(i.module&&t.push(V.styleModule.of(i.module)),n=i.themeType),e!=null&&e.fallback?t.push(wp.of(i)):n?t.push(ql.computeN([V.darkTheme],s=>s.facet(V.darkTheme)==(n=="dark")?[i]:[])):t.push(ql.of(i)),t}class gC{constructor(e){this.markCache=Object.create(null),this.tree=_e(e.state),this.decorations=this.buildDeco(e,$o(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=_e(e.state),n=$o(e.state),s=n!=$o(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!s&&t.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return q.none;let n=new Xt;for(let{from:s,to:r}of e.visibleRanges)Pb(this.tree,t,(o,l,a)=>{n.add(o,l,this.markCache[a]||(this.markCache[a]=q.mark({class:a})))},s,r);return n.finish()}}const mC=Vi.high(Ce.fromClass(gC,{decorations:i=>i.decorations})),xC=fs.define([{tag:k.meta,color:"#404740"},{tag:k.link,textDecoration:"underline"},{tag:k.heading,textDecoration:"underline",fontWeight:"bold"},{tag:k.emphasis,fontStyle:"italic"},{tag:k.strong,fontWeight:"bold"},{tag:k.strikethrough,textDecoration:"line-through"},{tag:k.keyword,color:"#708"},{tag:[k.atom,k.bool,k.url,k.contentSeparator,k.labelName],color:"#219"},{tag:[k.literal,k.inserted],color:"#164"},{tag:[k.string,k.deleted],color:"#a11"},{tag:[k.regexp,k.escape,k.special(k.string)],color:"#e40"},{tag:k.definition(k.variableName),color:"#00f"},{tag:k.local(k.variableName),color:"#30a"},{tag:[k.typeName,k.namespace],color:"#085"},{tag:k.className,color:"#167"},{tag:[k.special(k.variableName),k.macroName],color:"#256"},{tag:k.definition(k.propertyName),color:"#00c"},{tag:k.comment,color:"#940"},{tag:k.invalid,color:"#f00"}]),yC=V.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Rp=1e4,kp="()[]{}",Ap=$.define({combine(i){return _t(i,{afterCursor:!0,brackets:kp,maxScanDistance:Rp,renderMatch:SC})}}),bC=q.mark({class:"cm-matchingBracket"}),vC=q.mark({class:"cm-nonmatchingBracket"});function SC(i){let e=[],t=i.matched?bC:vC;return e.push(t.range(i.start.from,i.start.to)),i.end&&e.push(t.range(i.end.from,i.end.to)),e}const CC=Ne.define({create(){return q.none},update(i,e){if(!e.docChanged&&!e.selection)return i;let t=[],n=e.state.facet(Ap);for(let s of e.state.selection.ranges){if(!s.empty)continue;let r=Lt(e.state,s.head,-1,n)||s.head>0&&Lt(e.state,s.head-1,1,n)||n.afterCursor&&(Lt(e.state,s.head,1,n)||s.head<e.state.doc.length&&Lt(e.state,s.head+1,-1,n));r&&(t=t.concat(n.renderMatch(r,e.state)))}return q.set(t,!0)},provide:i=>V.decorations.from(i)}),wC=[CC,yC];function EC(i={}){return[Ap.of(i),wC]}const RC=new te;function Kl(i,e,t){let n=i.prop(e<0?te.openedBy:te.closedBy);if(n)return n;if(i.name.length==1){let s=t.indexOf(i.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function Yl(i){let e=i.type.prop(RC);return e?e(i.node):i}function Lt(i,e,t,n={}){let s=n.maxScanDistance||Rp,r=n.brackets||kp,o=_e(i),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let u=Kl(a.type,t,r);if(u&&a.from<a.to){let c=Yl(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return kC(i,e,t,a,c,u,r)}}return AC(i,e,t,o,l.type,s,r)}function kC(i,e,t,n,s,r,o){let l=n.parent,a={from:s.from,to:s.to},u=0,c=l==null?void 0:l.cursor();if(c&&(t<0?c.childBefore(n.from):c.childAfter(n.to)))do if(t<0?c.to<=n.from:c.from>=n.to){if(u==0&&r.indexOf(c.type.name)>-1&&c.from<c.to){let h=Yl(c);return{start:a,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}else if(Kl(c.type,t,o))u++;else if(Kl(c.type,-t,o)){if(u==0){let h=Yl(c);return{start:a,end:h&&h.from<h.to?{from:h.from,to:h.to}:void 0,matched:!1}}u--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function AC(i,e,t,n,s,r,o){let l=t<0?i.sliceDoc(e-1,e):i.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let u={from:t<0?e-1:e,to:t>0?e+1:e},c=i.doc.iterRange(e,t>0?i.doc.length:0),h=0;for(let f=0;!c.next().done&&f<=r;){let p=c.value;t<0&&(f+=p.length);let g=e+f*t;for(let m=t>0?0:p.length-1,x=t>0?p.length:-1;m!=x;m+=t){let y=o.indexOf(p[m]);if(!(y<0||n.resolveInner(g+m,1).type!=s))if(y%2==0==t>0)h++;else{if(h==1)return{start:u,end:{from:g+m,to:g+m+1},matched:y>>1==a>>1};h--}}t>0&&(f+=p.length)}return c.done?{start:u,matched:!1}:null}const TC=Object.create(null),Bc=[Ze.none],Vc=[],zc=Object.create(null),MC=Object.create(null);for(let[i,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])MC[i]=jC(TC,e);function _o(i,e){Vc.indexOf(i)>-1||(Vc.push(i),console.warn(e))}function jC(i,e){let t=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let c=i[u]||k[u];c?typeof c=="function"?a.length?a=a.map(c):_o(u,`Modifier ${u} used at start of tag`):a.length?_o(u,`Tag ${u} used as modifier`):a=Array.isArray(c)?c:[c]:_o(u,`Unknown highlighting tag ${u}`)}for(let u of a)t.push(u)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+t.map(l=>l.id),r=zc[s];if(r)return r.id;let o=zc[s]=Ze.define({id:Bc.length,name:n,props:[Ff({[n]:t})]});return Bc.push(o),o.id}xe.RTL,xe.LTR;const OC=Er.define({name:"json",parser:Nb.configure({props:[dp.add({Object:Lc({except:/^\s*\}/}),Array:Lc({except:/^\s*\]/})}),gp.add({"Object Array":tC})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function IC(){return new H1(OC)}const PC=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=_a(i.state,t.from);return n.line?DC(i):n.block?FC(i):!1};function $a(i,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let s=i(e,t);return s?(n(t.update(s)),!0):!1}}const DC=$a(VC,0),LC=$a(Tp,0),FC=$a((i,e)=>Tp(i,e,BC(e)),0);function _a(i,e){let t=i.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const Tn=50;function NC(i,{open:e,close:t},n,s){let r=i.sliceDoc(n-Tn,n),o=i.sliceDoc(s,s+Tn),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,u=r.length-l;if(r.slice(u-e.length,u)==e&&o.slice(a,a+t.length)==t)return{open:{pos:n-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let c,h;s-n<=2*Tn?c=h=i.sliceDoc(n,s):(c=i.sliceDoc(n,n+Tn),h=i.sliceDoc(s-Tn,s));let f=/^\s*/.exec(c)[0].length,p=/\s*$/.exec(h)[0].length,g=h.length-p-t.length;return c.slice(f,f+e.length)==e&&h.slice(g,g+t.length)==t?{open:{pos:n+f+e.length,margin:/\s/.test(c.charAt(f+e.length))?1:0},close:{pos:s-p-t.length,margin:/\s/.test(h.charAt(g-1))?1:0}}:null}function BC(i){let e=[];for(let t of i.selection.ranges){let n=i.doc.lineAt(t.from),s=t.to<=n.to?n:i.doc.lineAt(t.to);s.from>n.from&&s.from==t.to&&(s=t.to==n.to+1?n:i.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>n.from?e[r].to=s.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:s.to})}return e}function Tp(i,e,t=e.selection.ranges){let n=t.map(r=>_a(e,r.from).block);if(!n.every(r=>r))return null;let s=t.map((r,o)=>NC(e,n[o],r.from,r.to));if(i!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:n[o].open+" "},{from:r.to,insert:" "+n[o].close}]))};if(i!=1&&s.some(r=>r)){let r=[];for(let o=0,l;o<s.length;o++)if(l=s[o]){let a=n[o],{open:u,close:c}=l;r.push({from:u.pos-a.open.length,to:u.pos+u.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:r}}return null}function VC(i,e,t=e.selection.ranges){let n=[],s=-1;for(let{from:r,to:o}of t){let l=n.length,a=1e9,u=_a(e,r).line;if(u){for(let c=r;c<=o;){let h=e.doc.lineAt(c);if(h.from>s&&(r==o||o>h.from)){s=h.from;let f=/^\s*/.exec(h.text)[0].length,p=f==h.length,g=h.text.slice(f,f+u.length)==u?f:-1;f<h.text.length&&f<a&&(a=f),n.push({line:h,comment:g,token:u,indent:f,empty:p,single:!1})}c=h.to+1}if(a<1e9)for(let c=l;c<n.length;c++)n[c].indent<n[c].line.text.length&&(n[c].indent=a);n.length==l+1&&(n[l].single=!0)}}if(i!=2&&n.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:u,empty:c,single:h}of n)(h||!c)&&r.push({from:l.from+u,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(i!=1&&n.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of n)if(l>=0){let u=o.from+l,c=u+a.length;o.text[c-o.from]==" "&&c++,r.push({from:u,to:c})}return{changes:r}}return null}const Xl=$t.define(),zC=$t.define(),$C=$.define(),Mp=$.define({combine(i){return _t(i,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,s)=>e(n,s)||t(n,s)})}}),jp=Ne.define({create(){return Ft.empty},update(i,e){let t=e.state.facet(Mp),n=e.annotation(Xl);if(n){let a=Qe.fromTransaction(e,n.selection),u=n.side,c=u==0?i.undone:i.done;return a?c=Mr(c,c.length,t.minDepth,a):c=Pp(c,e.startState.selection),new Ft(u==0?n.rest:c,u==0?c:n.rest)}let s=e.annotation(zC);if((s=="full"||s=="before")&&(i=i.isolate()),e.annotation(Me.addToHistory)===!1)return e.changes.empty?i:i.addMapping(e.changes.desc);let r=Qe.fromTransaction(e),o=e.annotation(Me.time),l=e.annotation(Me.userEvent);return r?i=i.addChanges(r,o,l,t,e):e.selection&&(i=i.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(s=="full"||s=="after")&&(i=i.isolate()),i},toJSON(i){return{done:i.done.map(e=>e.toJSON()),undone:i.undone.map(e=>e.toJSON())}},fromJSON(i){return new Ft(i.done.map(Qe.fromJSON),i.undone.map(Qe.fromJSON))}});function _C(i={}){return[jp,Mp.of(i),V.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?Op:e.inputType=="historyRedo"?Ql:null;return n?(e.preventDefault(),n(t)):!1}})]}function eo(i,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let s=t.field(jp,!1);if(!s)return!1;let r=s.pop(i,t,e);return r?(n(r),!0):!1}}const Op=eo(0,!1),Ql=eo(1,!1),HC=eo(0,!0),GC=eo(1,!0);class Qe{constructor(e,t,n,s,r){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new Qe(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new Qe(e.changes&&Te.fromJSON(e.changes),[],e.mapped&&Bt.fromJSON(e.mapped),e.startSelection&&T.fromJSON(e.startSelection),e.selectionsAfter.map(T.fromJSON))}static fromTransaction(e,t){let n=ut;for(let s of e.startState.facet($C)){let r=s(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new Qe(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,ut)}static selection(e){return new Qe(void 0,ut,void 0,void 0,e)}}function Mr(i,e,t,n){let s=e+1>t+20?e-t-1:0,r=i.slice(s,e);return r.push(n),r}function WC(i,e){let t=[],n=!1;return i.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,l)=>{for(let a=0;a<t.length;){let u=t[a++],c=t[a++];l>=u&&o<=c&&(n=!0)}}),n}function UC(i,e){return i.ranges.length==e.ranges.length&&i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function Ip(i,e){return i.length?e.length?i.concat(e):i:e}const ut=[],qC=200;function Pp(i,e){if(i.length){let t=i[i.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-qC));return n.length&&n[n.length-1].eq(e)?i:(n.push(e),Mr(i,i.length-1,1e9,t.setSelAfter(n)))}else return[Qe.selection([e])]}function KC(i){let e=i[i.length-1],t=i.slice();return t[i.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Ho(i,e){if(!i.length)return i;let t=i.length,n=ut;for(;t;){let s=YC(i[t-1],e,n);if(s.changes&&!s.changes.empty||s.effects.length){let r=i.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,n=s.selectionsAfter}return n.length?[Qe.selection(n)]:ut}function YC(i,e,t){let n=Ip(i.selectionsAfter.length?i.selectionsAfter.map(l=>l.map(e)):ut,t);if(!i.changes)return Qe.selection(n);let s=i.changes.map(e),r=e.mapDesc(i.changes,!0),o=i.mapped?i.mapped.composeDesc(r):r;return new Qe(s,J.mapEffects(i.effects,e),o,i.startSelection.map(r),n)}const XC=/^(input\.type|delete)($|\.)/;class Ft{constructor(e,t,n=0,s=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=s}isolate(){return this.prevTime?new Ft(this.done,this.undone):this}addChanges(e,t,n,s,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!n||XC.test(n))&&(!l.selectionsAfter.length&&t-this.prevTime<s.newGroupDelay&&s.joinToEvent(r,WC(l.changes,e.changes))||n=="input.type.compose")?o=Mr(o,o.length-1,s.minDepth,new Qe(e.changes.compose(l.changes),Ip(J.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,ut)):o=Mr(o,o.length,s.minDepth,e),new Ft(o,ut,t,n)}addSelection(e,t,n,s){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:ut;return r.length>0&&t-this.prevTime<s&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&UC(r[r.length-1],e)?this:new Ft(Pp(this.done,e),this.undone,t,n)}addMapping(e){return new Ft(Ho(this.done,e),Ho(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let s=e==0?this.done:this.undone;if(s.length==0)return null;let r=s[s.length-1],o=r.selectionsAfter[0]||t.selection;if(n&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:Xl.of({side:e,rest:KC(s),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=s.length==1?ut:s.slice(0,s.length-1);return r.mapped&&(l=Ho(l,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:Xl.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}Ft.empty=new Ft(ut,ut);const QC=[{key:"Mod-z",run:Op,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Ql,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Ql,preventDefault:!0},{key:"Mod-u",run:HC,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:GC,preventDefault:!0}];function bn(i,e){return T.create(i.ranges.map(e),i.mainIndex)}function wt(i,e){return i.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Et({state:i,dispatch:e},t){let n=bn(i.selection,t);return n.eq(i.selection,!0)?!1:(e(wt(i,n)),!0)}function to(i,e){return T.cursor(e?i.to:i.from)}function Dp(i,e){return Et(i,t=>t.empty?i.moveByChar(t,e):to(t,e))}function He(i){return i.textDirectionAt(i.state.selection.main.head)==xe.LTR}const Lp=i=>Dp(i,!He(i)),Fp=i=>Dp(i,He(i));function Np(i,e){return Et(i,t=>t.empty?i.moveByGroup(t,e):to(t,e))}const JC=i=>Np(i,!He(i)),ZC=i=>Np(i,He(i));function ew(i,e,t){if(e.type.prop(t))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(i.sliceDoc(e.from,e.to)))||e.firstChild}function io(i,e,t){let n=_e(i).resolveInner(e.head),s=t?te.closedBy:te.openedBy;for(let a=e.head;;){let u=t?n.childAfter(a):n.childBefore(a);if(!u)break;ew(i,u,s)?n=u:a=t?u.to:u.from}let r=n.type.prop(s),o,l;return r&&(o=t?Lt(i,n.from,1):Lt(i,n.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?n.to:n.from,T.cursor(l,t?-1:1)}const tw=i=>Et(i,e=>io(i.state,e,!He(i))),iw=i=>Et(i,e=>io(i.state,e,He(i)));function Bp(i,e){return Et(i,t=>{if(!t.empty)return to(t,e);let n=i.moveVertically(t,e);return n.head!=t.head?n:i.moveToLineBoundary(t,e)})}const Vp=i=>Bp(i,!1),zp=i=>Bp(i,!0);function $p(i){let e=i.scrollDOM.clientHeight<i.scrollDOM.scrollHeight-2,t=0,n=0,s;if(e){for(let r of i.state.facet(V.scrollMargins)){let o=r(i);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(n=Math.max(o==null?void 0:o.bottom,n))}s=i.scrollDOM.clientHeight-t-n}else s=(i.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:n,selfScroll:e,height:Math.max(i.defaultLineHeight,s-5)}}function _p(i,e){let t=$p(i),{state:n}=i,s=bn(n.selection,o=>o.empty?i.moveVertically(o,e,t.height):to(o,e));if(s.eq(n.selection))return!1;let r;if(t.selfScroll){let o=i.coordsAtPos(n.selection.main.head),l=i.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,u=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<u&&(r=V.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-a}))}return i.dispatch(wt(n,s),{effects:r}),!0}const $c=i=>_p(i,!1),Jl=i=>_p(i,!0);function vi(i,e,t){let n=i.lineBlockAt(e.head),s=i.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?n.to:n.from)&&(s=i.moveToLineBoundary(e,t,!1)),!t&&s.head==n.from&&n.length){let r=/^\s*/.exec(i.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;r&&e.head!=n.from+r&&(s=T.cursor(n.from+r))}return s}const nw=i=>Et(i,e=>vi(i,e,!0)),sw=i=>Et(i,e=>vi(i,e,!1)),rw=i=>Et(i,e=>vi(i,e,!He(i))),ow=i=>Et(i,e=>vi(i,e,He(i))),lw=i=>Et(i,e=>T.cursor(i.lineBlockAt(e.head).from,1)),aw=i=>Et(i,e=>T.cursor(i.lineBlockAt(e.head).to,-1));function uw(i,e,t){let n=!1,s=bn(i.selection,r=>{let o=Lt(i,r.head,-1)||Lt(i,r.head,1)||r.head>0&&Lt(i,r.head-1,1)||r.head<i.doc.length&&Lt(i,r.head+1,-1);if(!o||!o.end)return r;n=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return T.cursor(l)});return n?(e(wt(i,s)),!0):!1}const cw=({state:i,dispatch:e})=>uw(i,e);function gt(i,e){let t=bn(i.state.selection,n=>{let s=e(n);return T.range(n.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return t.eq(i.state.selection)?!1:(i.dispatch(wt(i.state,t)),!0)}function Hp(i,e){return gt(i,t=>i.moveByChar(t,e))}const Gp=i=>Hp(i,!He(i)),Wp=i=>Hp(i,He(i));function Up(i,e){return gt(i,t=>i.moveByGroup(t,e))}const hw=i=>Up(i,!He(i)),fw=i=>Up(i,He(i)),dw=i=>gt(i,e=>io(i.state,e,!He(i))),pw=i=>gt(i,e=>io(i.state,e,He(i)));function qp(i,e){return gt(i,t=>i.moveVertically(t,e))}const Kp=i=>qp(i,!1),Yp=i=>qp(i,!0);function Xp(i,e){return gt(i,t=>i.moveVertically(t,e,$p(i).height))}const _c=i=>Xp(i,!1),Hc=i=>Xp(i,!0),gw=i=>gt(i,e=>vi(i,e,!0)),mw=i=>gt(i,e=>vi(i,e,!1)),xw=i=>gt(i,e=>vi(i,e,!He(i))),yw=i=>gt(i,e=>vi(i,e,He(i))),bw=i=>gt(i,e=>T.cursor(i.lineBlockAt(e.head).from)),vw=i=>gt(i,e=>T.cursor(i.lineBlockAt(e.head).to)),Gc=({state:i,dispatch:e})=>(e(wt(i,{anchor:0})),!0),Wc=({state:i,dispatch:e})=>(e(wt(i,{anchor:i.doc.length})),!0),Uc=({state:i,dispatch:e})=>(e(wt(i,{anchor:i.selection.main.anchor,head:0})),!0),qc=({state:i,dispatch:e})=>(e(wt(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),Sw=({state:i,dispatch:e})=>(e(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),Cw=({state:i,dispatch:e})=>{let t=no(i).map(({from:n,to:s})=>T.range(n,Math.min(s+1,i.doc.length)));return e(i.update({selection:T.create(t),userEvent:"select"})),!0},ww=({state:i,dispatch:e})=>{let t=bn(i.selection,n=>{let s=_e(i),r=s.resolveStack(n.from,1);if(n.empty){let o=s.resolveStack(n.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:l}=o;if((l.from<n.from&&l.to>=n.to||l.to>n.to&&l.from<=n.from)&&o.next)return T.range(l.to,l.from)}return n});return t.eq(i.selection)?!1:(e(wt(i,t)),!0)};function Qp(i,e){let{state:t}=i,n=t.selection,s=t.selection.ranges.slice();for(let r of t.selection.ranges){let o=t.doc.lineAt(r.head);if(e?o.to<i.state.doc.length:o.from>0)for(let l=r;;){let a=i.moveVertically(l,e);if(a.head<o.from||a.head>o.to){s.some(u=>u.head==a.head)||s.push(a);break}else{if(a.head==l.head)break;l=a}}}return s.length==n.ranges.length?!1:(i.dispatch(wt(t,T.create(s,s.length-1))),!0)}const Ew=i=>Qp(i,!1),Rw=i=>Qp(i,!0),kw=({state:i,dispatch:e})=>{let t=i.selection,n=null;return t.ranges.length>1?n=T.create([t.main]):t.main.empty||(n=T.create([T.cursor(t.main.head)])),n?(e(wt(i,n)),!0):!1};function ds(i,e){if(i.state.readOnly)return!1;let t="delete.selection",{state:n}=i,s=n.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);a<o?(t="delete.backward",a=zs(i,a,!1)):a>o&&(t="delete.forward",a=zs(i,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=zs(i,o,!1),l=zs(i,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:T.cursor(o,o<r.head?-1:1)}});return s.changes.empty?!1:(i.dispatch(n.update(s,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?V.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function zs(i,e,t){if(i instanceof V)for(let n of i.state.facet(V.atomicRanges).map(s=>s(i)))n.between(e,e,(s,r)=>{s<e&&r>e&&(e=t?r:s)});return e}const Jp=(i,e,t)=>ds(i,n=>{let s=n.from,{state:r}=i,o=r.doc.lineAt(s),l,a;if(t&&!e&&s>o.from&&s<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,s-o.from))){if(l[l.length-1]==" ")return s-1;let u=yn(l,r.tabSize),c=u%kr(r)||kr(r);for(let h=0;h<c&&l[l.length-1-h]==" ";h++)s--;a=s}else a=Fe(o.text,s-o.from,e,e)+o.from,a==s&&o.number!=(e?r.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,s-o.from))&&(a=Fe(o.text,a-o.from,!1,!1)+o.from);return a}),Zl=i=>Jp(i,!1,!0),Zp=i=>Jp(i,!0,!1),eg=(i,e)=>ds(i,t=>{let n=t.head,{state:s}=i,r=s.doc.lineAt(n),o=s.charCategorizer(n);for(let l=null;;){if(n==(e?r.to:r.from)){n==t.head&&r.number!=(e?s.doc.lines:1)&&(n+=e?1:-1);break}let a=Fe(r.text,n-r.from,e)+r.from,u=r.text.slice(Math.min(n,a)-r.from,Math.max(n,a)-r.from),c=o(u);if(l!=null&&c!=l)break;(u!=" "||n!=t.head)&&(l=c),n=a}return n}),tg=i=>eg(i,!1),Aw=i=>eg(i,!0),Tw=i=>ds(i,e=>{let t=i.lineBlockAt(e.head).to;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)}),Mw=i=>ds(i,e=>{let t=i.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),jw=i=>ds(i,e=>{let t=i.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)}),Ow=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:re.of(["",""])},range:T.cursor(n.from)}));return e(i.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Iw=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>{if(!n.empty||n.from==0||n.from==i.doc.length)return{range:n};let s=n.from,r=i.doc.lineAt(s),o=s==r.from?s-1:Fe(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:Fe(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:i.doc.slice(s,l).append(i.doc.slice(o,s))},range:T.cursor(l)}});return t.changes.empty?!1:(e(i.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function no(i){let e=[],t=-1;for(let n of i.selection.ranges){let s=i.doc.lineAt(n.from),r=i.doc.lineAt(n.to);if(!n.empty&&n.to==r.from&&(r=i.doc.lineAt(n.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(n)}else e.push({from:s.from,to:r.to,ranges:[n]});t=r.number+1}return e}function ig(i,e,t){if(i.readOnly)return!1;let n=[],s=[];for(let r of no(i)){if(t?r.to==i.doc.length:r.from==0)continue;let o=i.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){n.push({from:r.to,to:o.to},{from:r.from,insert:o.text+i.lineBreak});for(let a of r.ranges)s.push(T.range(Math.min(i.doc.length,a.anchor+l),Math.min(i.doc.length,a.head+l)))}else{n.push({from:o.from,to:r.from},{from:r.to,insert:i.lineBreak+o.text});for(let a of r.ranges)s.push(T.range(a.anchor-l,a.head-l))}}return n.length?(e(i.update({changes:n,scrollIntoView:!0,selection:T.create(s,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Pw=({state:i,dispatch:e})=>ig(i,e,!1),Dw=({state:i,dispatch:e})=>ig(i,e,!0);function ng(i,e,t){if(i.readOnly)return!1;let n=[];for(let s of no(i))t?n.push({from:s.from,insert:i.doc.slice(s.from,s.to)+i.lineBreak}):n.push({from:s.to,insert:i.lineBreak+i.doc.slice(s.from,s.to)});return e(i.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Lw=({state:i,dispatch:e})=>ng(i,e,!1),Fw=({state:i,dispatch:e})=>ng(i,e,!0),Nw=i=>{if(i.state.readOnly)return!1;let{state:e}=i,t=e.changes(no(e).map(({from:s,to:r})=>(s>0?s--:r<e.doc.length&&r++,{from:s,to:r}))),n=bn(e.selection,s=>{let r;if(i.lineWrapping){let o=i.lineBlockAt(s.head),l=i.coordsAtPos(s.head,s.assoc||1);l&&(r=o.bottom+i.documentTop-l.bottom+i.defaultLineHeight/2)}return i.moveVertically(s,!0,r)}).map(t);return i.dispatch({changes:t,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Bw(i,e){if(/\(\)|\[\]|\{\}/.test(i.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=_e(i).resolveInner(e),n=t.childBefore(e),s=t.childAfter(e),r;return n&&s&&n.to<=e&&s.from>=e&&(r=n.type.prop(te.closedBy))&&r.indexOf(s.name)>-1&&i.doc.lineAt(n.to).from==i.doc.lineAt(s.from).from&&!/\S/.test(i.sliceDoc(n.to,s.from))?{from:n.to,to:s.from}:null}const Kc=sg(!1),Vw=sg(!0);function sg(i){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(s=>{let{from:r,to:o}=s,l=e.doc.lineAt(r),a=!i&&r==o&&Bw(e,r);i&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new Jr(e,{simulateBreak:r,simulateDoubleBreak:!!a}),c=Va(u,r);for(c==null&&(c=yn(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let h=["",es(e,c)];return a&&h.push(es(e,u.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:re.of(h)},range:T.cursor(r+1+h[1].length)}});return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ha(i,e){let t=-1;return i.changeByRange(n=>{let s=[];for(let o=n.from;o<=n.to;){let l=i.doc.lineAt(o);l.number>t&&(n.empty||n.to>l.from)&&(e(l,s,n),t=l.number),o=l.to+1}let r=i.changes(s);return{changes:s,range:T.range(r.mapPos(n.anchor,1),r.mapPos(n.head,1))}})}const zw=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=Object.create(null),n=new Jr(i,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=Ha(i,(r,o,l)=>{let a=Va(n,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let u=/^\s*/.exec(r.text)[0],c=es(i,a);(u!=c||l.from<r.from+u.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+u.length,insert:c}))});return s.changes.empty||e(i.update(s,{userEvent:"indent"})),!0},rg=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(Ha(i,(t,n)=>{n.push({from:t.from,insert:i.facet(Qr)})}),{userEvent:"input.indent"})),!0),og=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(Ha(i,(t,n)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=yn(s,i.tabSize),o=0,l=es(i,Math.max(0,r-kr(i)));for(;o<s.length&&o<l.length&&s.charCodeAt(o)==l.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+s.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),$w=i=>(i.setTabFocusMode(),!0),_w=[{key:"Ctrl-b",run:Lp,shift:Gp,preventDefault:!0},{key:"Ctrl-f",run:Fp,shift:Wp},{key:"Ctrl-p",run:Vp,shift:Kp},{key:"Ctrl-n",run:zp,shift:Yp},{key:"Ctrl-a",run:lw,shift:bw},{key:"Ctrl-e",run:aw,shift:vw},{key:"Ctrl-d",run:Zp},{key:"Ctrl-h",run:Zl},{key:"Ctrl-k",run:Tw},{key:"Ctrl-Alt-h",run:tg},{key:"Ctrl-o",run:Ow},{key:"Ctrl-t",run:Iw},{key:"Ctrl-v",run:Jl}],Hw=[{key:"ArrowLeft",run:Lp,shift:Gp,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JC,shift:hw,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:rw,shift:xw,preventDefault:!0},{key:"ArrowRight",run:Fp,shift:Wp,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:ZC,shift:fw,preventDefault:!0},{mac:"Cmd-ArrowRight",run:ow,shift:yw,preventDefault:!0},{key:"ArrowUp",run:Vp,shift:Kp,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Gc,shift:Uc},{mac:"Ctrl-ArrowUp",run:$c,shift:_c},{key:"ArrowDown",run:zp,shift:Yp,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Wc,shift:qc},{mac:"Ctrl-ArrowDown",run:Jl,shift:Hc},{key:"PageUp",run:$c,shift:_c},{key:"PageDown",run:Jl,shift:Hc},{key:"Home",run:sw,shift:mw,preventDefault:!0},{key:"Mod-Home",run:Gc,shift:Uc},{key:"End",run:nw,shift:gw,preventDefault:!0},{key:"Mod-End",run:Wc,shift:qc},{key:"Enter",run:Kc,shift:Kc},{key:"Mod-a",run:Sw},{key:"Backspace",run:Zl,shift:Zl,preventDefault:!0},{key:"Delete",run:Zp,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:tg,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Aw,preventDefault:!0},{mac:"Mod-Backspace",run:Mw,preventDefault:!0},{mac:"Mod-Delete",run:jw,preventDefault:!0}].concat(_w.map(i=>({mac:i.key,run:i.run,shift:i.shift}))),Gw=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:tw,shift:dw},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:iw,shift:pw},{key:"Alt-ArrowUp",run:Pw},{key:"Shift-Alt-ArrowUp",run:Lw},{key:"Alt-ArrowDown",run:Dw},{key:"Shift-Alt-ArrowDown",run:Fw},{key:"Mod-Alt-ArrowUp",run:Ew},{key:"Mod-Alt-ArrowDown",run:Rw},{key:"Escape",run:kw},{key:"Mod-Enter",run:Vw},{key:"Alt-l",mac:"Ctrl-l",run:Cw},{key:"Mod-i",run:ww,preventDefault:!0},{key:"Mod-[",run:og},{key:"Mod-]",run:rg},{key:"Mod-Alt-\\",run:zw},{key:"Shift-Mod-k",run:Nw},{key:"Shift-Mod-\\",run:cw},{key:"Mod-/",run:PC},{key:"Alt-A",run:LC},{key:"Ctrl-m",mac:"Shift-Alt-m",run:$w}].concat(Hw),Ww={key:"Tab",run:rg,shift:og},Yc=typeof String.prototype.normalize=="function"?i=>i.normalize("NFKD"):i=>i;class mn{constructor(e,t,n=0,s=e.length,r,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,s),this.bufferStart=n,this.normalize=r?l=>r(Yc(l)):Yc,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Ke(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=Ea(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Pt(e);let s=this.normalize(t);if(s.length)for(let r=0,o=n;;r++){let l=s.charCodeAt(r),a=this.match(l,o,this.bufferPos+this.bufferStart);if(r==s.length-1){if(a)return this.value=a,this;break}o==n&&r<t.length&&t.charCodeAt(r)==l&&o++}}}match(e,t,n){let s=null;for(let r=0;r<this.matches.length;r+=2){let o=this.matches[r],l=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?s={from:this.matches[r+1],to:n}:(this.matches[r]++,l=!0)),l||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:t,to:n}:this.matches.push(1,t)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(mn.prototype[Symbol.iterator]=function(){return this});const lg={from:-1,to:-1,match:/.*/.exec("")},Ga="gm"+(/x/.unicode==null?"":"u");class ag{constructor(e,t,n,s=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=lg,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new ug(e,t,n,s,r);this.re=new RegExp(t,Ga+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.iter=e.iter();let o=e.lineAt(s);this.curLineStart=o.from,this.matchPos=jr(e,s),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,s=n+t[0].length;if(this.matchPos=jr(this.text,s+(n==s?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<s||n>this.value.to)&&(!this.test||this.test(n,s,t)))return this.value={from:n,to:s,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const Go=new WeakMap;class rn{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let s=Go.get(e);if(!s||s.from>=n||s.to<=t){let l=new rn(t,e.sliceString(t,n));return Go.set(e,l),l}if(s.from==t&&s.to==n)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.to<n&&(r+=e.sliceString(s.to,n)),Go.set(e,new rn(o,r)),new rn(t,r.slice(t-o,n-o))}}class ug{constructor(e,t,n,s,r){this.text=e,this.to=r,this.done=!1,this.value=lg,this.matchPos=jr(e,s),this.re=new RegExp(t,Ga+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.flat=rn.get(e,s,this.chunkEnd(s+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let n=this.flat.from+t.index,s=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,s,t)))return this.value={from:n,to:s,match:t},this.matchPos=jr(this.text,s+(n==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=rn.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(ag.prototype[Symbol.iterator]=ug.prototype[Symbol.iterator]=function(){return this});function Uw(i){try{return new RegExp(i,Ga),!0}catch{return!1}}function jr(i,e){if(e>=i.length)return e;let t=i.lineAt(e),n;for(;e<t.to&&(n=t.text.charCodeAt(e-t.from))>=56320&&n<57344;)e++;return e}function ea(i){let e=String(i.state.doc.lineAt(i.state.selection.main.head).number),t=fe("input",{class:"cm-textfield",name:"line",value:e}),n=fe("form",{class:"cm-gotoLine",onkeydown:r=>{r.keyCode==27?(r.preventDefault(),i.dispatch({effects:$n.of(!1)}),i.focus()):r.keyCode==13&&(r.preventDefault(),s())},onsubmit:r=>{r.preventDefault(),s()}},fe("label",i.state.phrase("Go to line"),": ",t)," ",fe("button",{class:"cm-button",type:"submit"},i.state.phrase("go")),fe("button",{name:"close",onclick:()=>{i.dispatch({effects:$n.of(!1)}),i.focus()},"aria-label":i.state.phrase("close"),type:"button"},["×"]));function s(){let r=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!r)return;let{state:o}=i,l=o.doc.lineAt(o.selection.main.head),[,a,u,c,h]=r,f=c?+c.slice(1):0,p=u?+u:l.number;if(u&&h){let x=p/100;a&&(x=x*(a=="-"?-1:1)+l.number/o.doc.lines),p=Math.round(o.doc.lines*x)}else u&&a&&(p=p*(a=="-"?-1:1)+l.number);let g=o.doc.line(Math.max(1,Math.min(o.doc.lines,p))),m=T.cursor(g.from+Math.max(0,Math.min(f,g.length)));i.dispatch({effects:[$n.of(!1),V.scrollIntoView(m.from,{y:"center"})],selection:m}),i.focus()}return{dom:n}}const $n=J.define(),Xc=Ne.define({create(){return!0},update(i,e){for(let t of e.effects)t.is($n)&&(i=t.value);return i},provide:i=>Zn.from(i,e=>e?ea:null)}),qw=i=>{let e=Jn(i,ea);if(!e){let t=[$n.of(!0)];i.state.field(Xc,!1)==null&&t.push(J.appendConfig.of([Xc,Kw])),i.dispatch({effects:t}),e=Jn(i,ea)}return e&&e.dom.querySelector("input").select(),!0},Kw=V.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),Yw={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Xw=$.define({combine(i){return _t(i,Yw,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Qw(i){return[iE,tE]}const Jw=q.mark({class:"cm-selectionMatch"}),Zw=q.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Qc(i,e,t,n){return(t==0||i(e.sliceDoc(t-1,t))!=ye.Word)&&(n==e.doc.length||i(e.sliceDoc(n,n+1))!=ye.Word)}function eE(i,e,t,n){return i(e.sliceDoc(t,t+1))==ye.Word&&i(e.sliceDoc(n-1,n))==ye.Word}const tE=Ce.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.selectionSet||i.docChanged||i.viewportChanged)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=i.state.facet(Xw),{state:t}=i,n=t.selection;if(n.ranges.length>1)return q.none;let s=n.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return q.none;let a=t.wordAt(s.head);if(!a)return q.none;o=t.charCategorizer(s.head),r=t.sliceDoc(a.from,a.to)}else{let a=s.to-s.from;if(a<e.minSelectionLength||a>200)return q.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(Qc(o,t,s.from,s.to)&&eE(o,t,s.from,s.to)))return q.none}else if(r=t.sliceDoc(s.from,s.to),!r)return q.none}let l=[];for(let a of i.visibleRanges){let u=new mn(t.doc,r,a.from,a.to);for(;!u.next().done;){let{from:c,to:h}=u.value;if((!o||Qc(o,t,c,h))&&(s.empty&&c<=s.from&&h>=s.to?l.push(Zw.range(c,h)):(c>=s.to||h<=s.from)&&l.push(Jw.range(c,h)),l.length>e.maxMatches))return q.none}}return q.set(l)}},{decorations:i=>i.decorations}),iE=V.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),nE=({state:i,dispatch:e})=>{let{selection:t}=i,n=T.create(t.ranges.map(s=>i.wordAt(s.head)||T.cursor(s.head)),t.mainIndex);return n.eq(t)?!1:(e(i.update({selection:n})),!0)};function sE(i,e){let{main:t,ranges:n}=i.selection,s=i.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=!1,l=new mn(i.doc,e,n[n.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new mn(i.doc,e,0,Math.max(0,n[n.length-1].from-1)),o=!0}else{if(o&&n.some(a=>a.from==l.value.from))continue;if(r){let a=i.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const rE=({state:i,dispatch:e})=>{let{ranges:t}=i.selection;if(t.some(r=>r.from===r.to))return nE({state:i,dispatch:e});let n=i.sliceDoc(t[0].from,t[0].to);if(i.selection.ranges.some(r=>i.sliceDoc(r.from,r.to)!=n))return!1;let s=sE(i,n);return s?(e(i.update({selection:i.selection.addRange(T.range(s.from,s.to),!1),effects:V.scrollIntoView(s.to)})),!0):!1},vn=$.define({combine(i){return _t(i,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new xE(e),scrollToMatch:e=>V.scrollIntoView(e)})}});class cg{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Uw(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,n)=>n=="n"?`
34
- `:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new uE(this):new lE(this)}getCursor(e,t=0,n){let s=e.doc?e:ne.create({doc:e});return n==null&&(n=s.doc.length),this.regexp?Wi(this,s,t,n):Gi(this,s,t,n)}}class hg{constructor(e){this.spec=e}}function Gi(i,e,t,n){return new mn(e.doc,i.unquoted,t,n,i.caseSensitive?void 0:s=>s.toLowerCase(),i.wholeWord?oE(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function oE(i,e){return(t,n,s,r)=>((r>t||r+s.length<n)&&(r=Math.max(0,t-2),s=i.sliceString(r,Math.min(i.length,n+2))),(e(Or(s,t-r))!=ye.Word||e(Ir(s,t-r))!=ye.Word)&&(e(Ir(s,n-r))!=ye.Word||e(Or(s,n-r))!=ye.Word))}class lE extends hg{constructor(e){super(e)}nextMatch(e,t,n){let s=Gi(this.spec,e,n,e.doc.length).nextOverlapping();if(s.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);s=Gi(this.spec,e,0,r).nextOverlapping()}return s.done||s.value.from==t&&s.value.to==n?null:s.value}prevMatchInRange(e,t,n){for(let s=n;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=Gi(this.spec,e,r,s),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;s-=1e4}}prevMatch(e,t,n){let s=this.prevMatchInRange(e,0,t);return s||(s=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),s&&(s.from!=t||s.to!=n)?s:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=Gi(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let r=Gi(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function Wi(i,e,t,n){return new ag(e.doc,i.search,{ignoreCase:!i.caseSensitive,test:i.wholeWord?aE(e.charCategorizer(e.selection.main.head)):void 0},t,n)}function Or(i,e){return i.slice(Fe(i,e,!1),e)}function Ir(i,e){return i.slice(e,Fe(i,e))}function aE(i){return(e,t,n)=>!n[0].length||(i(Or(n.input,n.index))!=ye.Word||i(Ir(n.input,n.index))!=ye.Word)&&(i(Ir(n.input,n.index+n[0].length))!=ye.Word||i(Or(n.input,n.index+n[0].length))!=ye.Word)}class uE extends hg{nextMatch(e,t,n){let s=Wi(this.spec,e,n,e.doc.length).next();return s.done&&(s=Wi(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,n){for(let s=1;;s++){let r=Math.max(t,n-s*1e4),o=Wi(this.spec,e,r,n),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let s=n.length;s>0;s--){let r=+n.slice(0,s);if(r>0&&r<e.match.length)return e.match[r]+n.slice(s)}return t})}matchAll(e,t){let n=Wi(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let r=Wi(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const ts=J.define(),Wa=J.define(),fi=Ne.define({create(i){return new Wo(ta(i).create(),null)},update(i,e){for(let t of e.effects)t.is(ts)?i=new Wo(t.value.create(),i.panel):t.is(Wa)&&(i=new Wo(i.query,t.value?Ua:null));return i},provide:i=>Zn.from(i,e=>e.panel)});class Wo{constructor(e,t){this.query=e,this.panel=t}}const cE=q.mark({class:"cm-searchMatch"}),hE=q.mark({class:"cm-searchMatch cm-searchMatch-selected"}),fE=Ce.fromClass(class{constructor(i){this.view=i,this.decorations=this.highlight(i.state.field(fi))}update(i){let e=i.state.field(fi);(e!=i.startState.field(fi)||i.docChanged||i.selectionSet||i.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:i,panel:e}){if(!e||!i.spec.valid)return q.none;let{view:t}=this,n=new Xt;for(let s=0,r=t.visibleRanges,o=r.length;s<o;s++){let{from:l,to:a}=r[s];for(;s<o-1&&a>r[s+1].from-500;)a=r[++s].to;i.highlight(t.state,l,a,(u,c)=>{let h=t.state.selection.ranges.some(f=>f.from==u&&f.to==c);n.add(u,c,h?hE:cE)})}return n.finish()}},{decorations:i=>i.decorations});function ps(i){return e=>{let t=e.state.field(fi,!1);return t&&t.query.spec.valid?i(e,t):pg(e)}}const Pr=ps((i,{query:e})=>{let{to:t}=i.state.selection.main,n=e.nextMatch(i.state,t,t);if(!n)return!1;let s=T.single(n.from,n.to),r=i.state.facet(vn);return i.dispatch({selection:s,effects:[qa(i,n),r.scrollToMatch(s.main,i)],userEvent:"select.search"}),dg(i),!0}),Dr=ps((i,{query:e})=>{let{state:t}=i,{from:n}=t.selection.main,s=e.prevMatch(t,n,n);if(!s)return!1;let r=T.single(s.from,s.to),o=i.state.facet(vn);return i.dispatch({selection:r,effects:[qa(i,s),o.scrollToMatch(r.main,i)],userEvent:"select.search"}),dg(i),!0}),dE=ps((i,{query:e})=>{let t=e.matchAll(i.state,1e3);return!t||!t.length?!1:(i.dispatch({selection:T.create(t.map(n=>T.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),pE=({state:i,dispatch:e})=>{let t=i.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:n,to:s}=t.main,r=[],o=0;for(let l=new mn(i.doc,i.sliceDoc(n,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==n&&(o=r.length),r.push(T.range(l.value.from,l.value.to))}return e(i.update({selection:T.create(r,o),userEvent:"select.search.matches"})),!0},Jc=ps((i,{query:e})=>{let{state:t}=i,{from:n,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,n,n);if(!r)return!1;let o=r,l=[],a,u,c=[];o.from==n&&o.to==s&&(u=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:u}),o=e.nextMatch(t,o.from,o.to),c.push(V.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(n).number)+".")));let h=i.state.changes(l);return o&&(a=T.single(o.from,o.to).map(h),c.push(qa(i,o)),c.push(t.facet(vn).scrollToMatch(a.main,i))),i.dispatch({changes:h,selection:a,effects:c,userEvent:"input.replace"}),!0}),gE=ps((i,{query:e})=>{if(i.state.readOnly)return!1;let t=e.matchAll(i.state,1e9).map(s=>{let{from:r,to:o}=s;return{from:r,to:o,insert:e.getReplacement(s)}});if(!t.length)return!1;let n=i.state.phrase("replaced $ matches",t.length)+".";return i.dispatch({changes:t,effects:V.announce.of(n),userEvent:"input.replace.all"}),!0});function Ua(i){return i.state.facet(vn).createPanel(i)}function ta(i,e){var t,n,s,r,o;let l=i.selection.main,a=l.empty||l.to>l.from+100?"":i.sliceDoc(l.from,l.to);if(e&&!a)return e;let u=i.facet(vn);return new cg({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:u.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:u.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:u.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:u.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:u.wholeWord})}function fg(i){let e=Jn(i,Ua);return e&&e.dom.querySelector("[main-field]")}function dg(i){let e=fg(i);e&&e==i.root.activeElement&&e.select()}const pg=i=>{let e=i.state.field(fi,!1);if(e&&e.panel){let t=fg(i);if(t&&t!=i.root.activeElement){let n=ta(i.state,e.query.spec);n.valid&&i.dispatch({effects:ts.of(n)}),t.focus(),t.select()}}else i.dispatch({effects:[Wa.of(!0),e?ts.of(ta(i.state,e.query.spec)):J.appendConfig.of(bE)]});return!0},gg=i=>{let e=i.state.field(fi,!1);if(!e||!e.panel)return!1;let t=Jn(i,Ua);return t&&t.dom.contains(i.root.activeElement)&&i.focus(),i.dispatch({effects:Wa.of(!1)}),!0},mE=[{key:"Mod-f",run:pg,scope:"editor search-panel"},{key:"F3",run:Pr,shift:Dr,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Pr,shift:Dr,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:gg,scope:"editor search-panel"},{key:"Mod-Shift-l",run:pE},{key:"Mod-Alt-g",run:qw},{key:"Mod-d",run:rE,preventDefault:!0}];class xE{constructor(e){this.view=e;let t=this.query=e.state.field(fi).query.spec;this.commit=this.commit.bind(this),this.searchField=fe("input",{value:t.search,placeholder:tt(e,"Find"),"aria-label":tt(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=fe("input",{value:t.replace,placeholder:tt(e,"Replace"),"aria-label":tt(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=fe("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=fe("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=fe("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(s,r,o){return fe("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=fe("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,n("next",()=>Pr(e),[tt(e,"next")]),n("prev",()=>Dr(e),[tt(e,"previous")]),n("select",()=>dE(e),[tt(e,"all")]),fe("label",null,[this.caseField,tt(e,"match case")]),fe("label",null,[this.reField,tt(e,"regexp")]),fe("label",null,[this.wordField,tt(e,"by word")]),...e.state.readOnly?[]:[fe("br"),this.replaceField,n("replace",()=>Jc(e),[tt(e,"replace")]),n("replaceAll",()=>gE(e),[tt(e,"replace all")])],fe("button",{name:"close",onclick:()=>gg(e),"aria-label":tt(e,"close"),type:"button"},["×"])])}commit(){let e=new cg({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:ts.of(e)}))}keydown(e){FS(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Dr:Pr)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Jc(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(ts)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(vn).top}}function tt(i,e){return i.state.phrase(e)}const $s=30,_s=/[\s\.,:;?!]/;function qa(i,{from:e,to:t}){let n=i.state.doc.lineAt(e),s=i.state.doc.lineAt(t).to,r=Math.max(n.from,e-$s),o=Math.min(s,t+$s),l=i.state.sliceDoc(r,o);if(r!=n.from){for(let a=0;a<$s;a++)if(!_s.test(l[a+1])&&_s.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-$s;a--)if(!_s.test(l[a-1])&&_s.test(l[a])){l=l.slice(0,a);break}}return V.announce.of(`${i.state.phrase("current match")}. ${l} ${i.state.phrase("on line")} ${n.number}.`)}const yE=V.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),bE=[fi,Vi.low(fE),yE];class mg{constructor(e,t,n,s){this.state=e,this.pos=t,this.explicit=n,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=_e(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),s=t.text.slice(n-t.from,this.pos-t.from),r=s.search(xg(e,!1));return r<0?null:{from:n+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function Zc(i){let e=Object.keys(i).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function vE(i){let e=Object.create(null),t=Object.create(null);for(let{label:s}of i){e[s[0]]=!0;for(let r=1;r<s.length;r++)t[s[r]]=!0}let n=Zc(e)+Zc(t)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function SE(i){let e=i.map(s=>typeof s=="string"?{label:s}:s),[t,n]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:vE(e);return s=>{let r=s.matchBefore(n);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}class eh{constructor(e,t,n,s){this.completion=e,this.source=t,this.match=n,this.score=s}}function Pi(i){return i.selection.main.from}function xg(i,e){var t;let{source:n}=i,s=e&&n[0]!="^",r=n[n.length-1]!="$";return!s&&!r?i:new RegExp(`${s?"^":""}(?:${n})${r?"$":""}`,(t=i.flags)!==null&&t!==void 0?t:i.ignoreCase?"i":"")}const yg=$t.define();function CE(i,e,t,n){let{main:s}=i.selection,r=t-s.from,o=n-s.from;return{...i.changeByRange(l=>{if(l!=s&&t!=n&&i.sliceDoc(l.from+r,l.from+o)!=i.sliceDoc(t,n))return{range:l};let a=i.toText(e);return{changes:{from:l.from+r,to:n==s.from?l.to:l.from+o,insert:a},range:T.cursor(l.from+r+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const th=new WeakMap;function wE(i){if(!Array.isArray(i))return i;let e=th.get(i);return e||th.set(i,e=SE(i)),e}const Lr=J.define(),is=J.define();class EE{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=Ke(e,t),s=Pt(n);this.chars.push(n);let r=e.slice(t,t+s),o=r.toUpperCase();this.folded.push(Ke(o==r?r.toLowerCase():o,0)),t+=s}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:s,precise:r,byWord:o}=this;if(t.length==1){let b=Ke(e,0),v=Pt(b),w=v==e.length?0:-100;if(b!=t[0])if(b==n[0])w+=-200;else return null;return this.ret(w,[0,v])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,u=0;if(l<0){for(let b=0,v=Math.min(e.length,200);b<v&&u<a;){let w=Ke(e,b);(w==t[u]||w==n[u])&&(s[u++]=b),b+=Pt(w)}if(u<a)return null}let c=0,h=0,f=!1,p=0,g=-1,m=-1,x=/[a-z]/.test(e),y=!0;for(let b=0,v=Math.min(e.length,200),w=0;b<v&&h<a;){let S=Ke(e,b);l<0&&(c<a&&S==t[c]&&(r[c++]=b),p<a&&(S==t[p]||S==n[p]?(p==0&&(g=b),m=b+1,p++):p=0));let E,A=S<255?S>=48&&S<=57||S>=97&&S<=122?2:S>=65&&S<=90?1:0:(E=Ea(S))!=E.toLowerCase()?1:E!=E.toUpperCase()?2:0;(!b||A==1&&x||w==0&&A!=0)&&(t[h]==S||n[h]==S&&(f=!0)?o[h++]=b:o.length&&(y=!1)),w=A,b+=Pt(S)}return h==a&&o[0]==0&&y?this.result(-100+(f?-200:0),o,e):p==a&&g==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):p==a?this.ret(-900-e.length,[g,m]):h==a?this.result(-100+(f?-200:0)+-700+(y?0:-1100),o,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,n){let s=[],r=0;for(let o of t){let l=o+(this.astral?Pt(Ke(n,o)):1);r&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return this.ret(e-n.length,s)}}class RE{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const Pe=$.define({combine(i){return _t(i,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:kE,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>ih(e(n),t(n)),optionClass:(e,t)=>n=>ih(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function ih(i,e){return i?e?i+" "+e:i:e}function kE(i,e,t,n,s,r){let o=i.textDirection==xe.RTL,l=o,a=!1,u="top",c,h,f=e.left-s.left,p=s.right-e.right,g=n.right-n.left,m=n.bottom-n.top;if(l&&f<Math.min(g,p)?l=!1:!l&&p<Math.min(g,f)&&(l=!0),g<=(l?f:p))c=Math.max(s.top,Math.min(t.top,s.bottom-m))-e.top,h=Math.min(400,l?f:p);else{a=!0,h=Math.min(400,(o?e.right:s.right-e.left)-30);let b=s.bottom-e.bottom;b>=m||b>e.top?c=t.bottom-e.top:(u="bottom",c=e.bottom-t.top)}let x=(e.bottom-e.top)/r.offsetHeight,y=(e.right-e.left)/r.offsetWidth;return{style:`${u}: ${c/x}px; max-width: ${h/y}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function AE(i){let e=i.addToOptions.slice();return i.icons&&e.push({render(t){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),t.type&&n.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(t,n,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let u=0;u<r.length;){let c=r[u++],h=r[u++];c>a&&o.appendChild(document.createTextNode(l.slice(a,c)));let f=o.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(l.slice(c,h))),f.className="cm-completionMatchedText",a=h}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let n=document.createElement("span");return n.className="cm-completionDetail",n.textContent=t.detail,n},position:80}),e.sort((t,n)=>t.position-n.position).map(t=>t.render)}function Uo(i,e,t){if(i<=t)return{from:0,to:i};if(e<0&&(e=0),e<=i>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let n=Math.floor((i-e)/t);return{from:i-(n+1)*t,to:i-n*t}}class TE{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:r,selected:o}=s.open,l=e.state.facet(Pe);this.optionContent=AE(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=Uo(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:u}=e.state.field(t).open;for(let c=a.target,h;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(h=/-(\d+)$/.exec(c.id))&&+h[1]<u.length){this.applyCompletion(e,u[+h[1]]),a.preventDefault();return}}),this.dom.addEventListener("focusout",a=>{let u=e.state.field(this.stateField,!1);u&&u.tooltip&&e.state.facet(Pe).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:is.of(null)})}),this.showOptions(r,s.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=s){let{options:r,selected:o,disabled:l}=n.open;(!s.open||s.open.options!=r)&&(this.range=Uo(r.length,o,e.state.facet(Pe).maxRenderedOptions),this.showOptions(r,n.id)),this.updateSel(),l!=((t=s.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of t.split(" "))n&&this.dom.classList.add(n);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Uo(t.options.length,t.selected,this.view.state.facet(Pe).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:s}=t.options[t.selected],{info:r}=s;if(!r)return;let o=typeof r=="string"?document.createTextNode(r):r(s);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,s)}).catch(l=>Xe(this.view.state,l,"completion info")):(this.addInfoPane(o,s),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;n.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,s=this.range.from;n;n=n.nextSibling,s++)n.nodeName!="LI"||!n.id?s--:s==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby"));return t&&jE(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return s.top>Math.min(r.bottom,t.bottom)-10||s.bottom<Math.max(r.top,t.top)+10?null:this.view.state.facet(Pe).positionInfo(this.view,t,s,n,r,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions")),s.addEventListener("mousedown",o=>{o.target==s&&o.preventDefault()});let r=null;for(let o=n.from;o<n.to;o++){let{completion:l,match:a}=e[o],{section:u}=l;if(u){let f=typeof u=="string"?u:u.name;if(f!=r&&(o>n.from||n.from==0))if(r=f,typeof u!="string"&&u.header)s.appendChild(u.header(u));else{let p=s.appendChild(document.createElement("completion-section"));p.textContent=f}}const c=s.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let h=this.optionClass(l);h&&(c.className=h);for(let f of this.optionContent){let p=f(l,this.view.state,this.view,a);p&&c.appendChild(p)}}return n.from&&s.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function ME(i,e){return t=>new TE(t,i,e)}function jE(i,e){let t=i.getBoundingClientRect(),n=e.getBoundingClientRect(),s=t.height/i.offsetHeight;n.top<t.top?i.scrollTop-=(t.top-n.top)/s:n.bottom>t.bottom&&(i.scrollTop+=(n.bottom-t.bottom)/s)}function nh(i){return(i.boost||0)*100+(i.apply?10:0)+(i.info?5:0)+(i.type?1:0)}function OE(i,e){let t=[],n=null,s=null,r=c=>{t.push(c);let{section:h}=c.completion;if(h){n||(n=[]);let f=typeof h=="string"?h:h.name;n.some(p=>p.name==f)||n.push(typeof h=="string"?{name:f}:h)}},o=e.facet(Pe);for(let c of i)if(c.hasResult()){let h=c.result.getMatch;if(c.result.filter===!1)for(let f of c.result.options)r(new eh(f,c.source,h?h(f):[],1e9-t.length));else{let f=e.sliceDoc(c.from,c.to),p,g=o.filterStrict?new RE(f):new EE(f);for(let m of c.result.options)if(p=g.match(m.label)){let x=m.displayLabel?h?h(m,p.matched):[]:p.matched,y=p.score+(m.boost||0);if(r(new eh(m,c.source,x,y)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:b}=m.section;s||(s=Object.create(null)),s[b]=Math.max(y,s[b]||-1e9)}}}}if(n){let c=Object.create(null),h=0,f=(p,g)=>(p.rank==="dynamic"&&g.rank==="dynamic"?s[g.name]-s[p.name]:0)||(typeof p.rank=="number"?p.rank:1e9)-(typeof g.rank=="number"?g.rank:1e9)||(p.name<g.name?-1:1);for(let p of n.sort(f))h-=1e5,c[p.name]=h;for(let p of t){let{section:g}=p.completion;g&&(p.score+=c[typeof g=="string"?g:g.name])}}let l=[],a=null,u=o.compareCompletions;for(let c of t.sort((h,f)=>f.score-h.score||u(h.completion,f.completion))){let h=c.completion;!a||a.label!=h.label||a.detail!=h.detail||a.type!=null&&h.type!=null&&a.type!=h.type||a.apply!=h.apply||a.boost!=h.boost?l.push(c):nh(c.completion)>nh(a)&&(l[l.length-1]=c),a=c.completion}return l}class Qi{constructor(e,t,n,s,r,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Qi(this.options,sh(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,s,r,o){if(s&&!o&&e.some(u=>u.isPending))return s.setDisabled();let l=OE(e,t);if(!l.length)return s&&e.some(u=>u.isPending)?s.setDisabled():null;let a=t.facet(Pe).selectOnOpen?0:-1;if(s&&s.selected!=a&&s.selected!=-1){let u=s.options[s.selected].completion;for(let c=0;c<l.length;c++)if(l[c].completion==u){a=c;break}}return new Qi(l,sh(n,a),{pos:e.reduce((u,c)=>c.hasResult()?Math.min(u,c.from):u,1e8),create:NE,above:r.aboveCursor},s?s.timestamp:Date.now(),a,!1)}map(e){return new Qi(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Qi(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Fr{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new Fr(LE,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(Pe),r=(n.override||t.languageDataAt("autocomplete",Pi(t)).map(wE)).map(a=>(this.active.find(c=>c.source==a)||new ct(a,this.active.some(c=>c.state!=0)?1:0)).update(e,n));r.length==this.active.length&&r.every((a,u)=>a==this.active[u])&&(r=this.active);let o=this.open,l=e.effects.some(a=>a.is(Ka));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!IE(r,this.active)||l?o=Qi.build(r,t,this.id,o,n,l):o&&o.disabled&&!r.some(a=>a.isPending)&&(o=null),!o&&r.every(a=>!a.isPending)&&r.some(a=>a.hasResult())&&(r=r.map(a=>a.hasResult()?new ct(a.source,0):a));for(let a of e.effects)a.is(vg)&&(o=o&&o.setSelected(a.value,this.id));return r==this.active&&o==this.open?this:new Fr(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?PE:DE}}function IE(i,e){if(i==e)return!0;for(let t=0,n=0;;){for(;t<i.length&&!i[t].hasResult();)t++;for(;n<e.length&&!e[n].hasResult();)n++;let s=t==i.length,r=n==e.length;if(s||r)return s==r;if(i[t++].result!=e[n++].result)return!1}}const PE={"aria-autocomplete":"list"},DE={};function sh(i,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":i};return e>-1&&(t["aria-activedescendant"]=i+"-"+e),t}const LE=[];function bg(i,e){if(i.isUserEvent("input.complete")){let n=i.annotation(yg);if(n&&e.activateOnCompletion(n))return 12}let t=i.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:i.isUserEvent("delete.backward")?2:i.selection?8:i.docChanged?16:0}class ct{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let n=bg(e,t),s=this;(n&8||n&16&&this.touches(e))&&(s=new ct(s.source,0)),n&4&&s.state==0&&(s=new ct(this.source,1)),s=s.updateFor(e,n);for(let r of e.effects)if(r.is(Lr))s=new ct(s.source,1,r.value);else if(r.is(is))s=new ct(s.source,0);else if(r.is(Ka))for(let o of r.value)o.source==s.source&&(s=o);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Pi(e.state))}}class on extends ct{constructor(e,t,n,s,r,o){super(e,3,t),this.limit=n,this.result=s,this.from=r,this.to=o}hasResult(){return!0}updateFor(e,t){var n;if(!(t&3))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=Pi(e.state);if(l>o||!s||t&2&&(Pi(e.startState)==this.from||l<this.limit))return new ct(this.source,t&4?1:0);let a=e.changes.mapPos(this.limit);return FE(s.validFor,e.state,r,o)?new on(this.source,this.explicit,a,s,r,o):s.update&&(s=s.update(s,r,o,new mg(e.state,l,!1)))?new on(this.source,this.explicit,a,s,s.from,(n=s.to)!==null&&n!==void 0?n:Pi(e.state)):new ct(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new on(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new ct(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function FE(i,e,t,n){if(!i)return!1;let s=e.sliceDoc(t,n);return typeof i=="function"?i(s,t,n,e):xg(i,!0).test(s)}const Ka=J.define({map(i,e){return i.map(t=>t.map(e))}}),vg=J.define(),Ye=Ne.define({create(){return Fr.start()},update(i,e){return i.update(e)},provide:i=>[Ba.from(i,e=>e.tooltip),V.contentAttributes.from(i,e=>e.attrs)]});function Ya(i,e){const t=e.completion.apply||e.completion.label;let n=i.state.field(Ye).active.find(s=>s.source==e.source);return n instanceof on?(typeof t=="string"?i.dispatch({...CE(i.state,t,n.from,n.to),annotations:yg.of(e.completion)}):t(i,e.completion,n.from,n.to),!0):!1}const NE=ME(Ye,Ya);function Hs(i,e="option"){return t=>{let n=t.state.field(Ye,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<t.state.facet(Pe).interactionDelay)return!1;let s=1,r;e=="page"&&(r=ap(t,n.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=n.open.options,l=n.open.selected>-1?n.open.selected+s*(i?1:-1):i?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:vg.of(l)}),!0}}const BE=i=>{let e=i.state.field(Ye,!1);return i.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<i.state.facet(Pe).interactionDelay?!1:Ya(i,e.open.options[e.open.selected])},qo=i=>i.state.field(Ye,!1)?(i.dispatch({effects:Lr.of(!0)}),!0):!1,VE=i=>{let e=i.state.field(Ye,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(i.dispatch({effects:is.of(null)}),!0)};class zE{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const $E=50,_E=1e3,HE=Ce.fromClass(class{constructor(i){this.view=i,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of i.state.field(Ye).active)e.isPending&&this.startQuery(e)}update(i){let e=i.state.field(Ye),t=i.state.facet(Pe);if(!i.selectionSet&&!i.docChanged&&i.startState.field(Ye)==e)return;let n=i.transactions.some(r=>{let o=bg(r,t);return o&8||(r.selection||r.docChanged)&&!(o&3)});for(let r=0;r<this.running.length;r++){let o=this.running[r];if(n||o.context.abortOnDocChange&&i.docChanged||o.updates.length+i.transactions.length>$E&&Date.now()-o.time>_E){for(let l of o.context.abortListeners)try{l()}catch(a){Xe(this.view.state,a)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...i.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),i.transactions.some(r=>r.effects.some(o=>o.is(Lr)))&&(this.pendingStart=!0);let s=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.isPending&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let r of i.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:i}=this.view,e=i.field(Ye);for(let t of e.active)t.isPending&&!this.running.some(n=>n.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Pe).updateSyncTime))}startQuery(i){let{state:e}=this.view,t=Pi(e),n=new mg(e,t,i.explicit,this.view),s=new zE(i,n);this.running.push(s),Promise.resolve(i.source(n)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:is.of(null)}),Xe(this.view.state,r)})}scheduleAccept(){this.running.every(i=>i.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Pe).updateSyncTime))}accept(){var i;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Pe),n=this.view.state.field(Ye);for(let s=0;s<this.running.length;s++){let r=this.running[s];if(r.done===void 0)continue;if(this.running.splice(s--,1),r.done){let l=Pi(r.updates.length?r.updates[0].startState:this.view.state),a=Math.min(l,r.done.from+(r.active.explicit?0:1)),u=new on(r.active.source,r.active.explicit,a,r.done,r.done.from,(i=r.done.to)!==null&&i!==void 0?i:l);for(let c of r.updates)u=u.update(c,t);if(u.hasResult()){e.push(u);continue}}let o=n.active.find(l=>l.source==r.active.source);if(o&&o.isPending)if(r.done==null){let l=new ct(r.active.source,0);for(let a of r.updates)l=l.update(a,t);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:Ka.of(e)})}},{eventHandlers:{blur(i){let e=this.view.state.field(Ye,!1);if(e&&e.tooltip&&this.view.state.facet(Pe).closeOnBlur){let t=e.open&&ap(this.view,e.open.tooltip);(!t||!t.dom.contains(i.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:is.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Lr.of(!1)}),20),this.composing=0}}}),GE=typeof navigator=="object"&&/Win/.test(navigator.platform),WE=Vi.highest(V.domEventHandlers({keydown(i,e){let t=e.state.field(Ye,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||i.key.length>1||i.ctrlKey&&!(GE&&i.altKey)||i.metaKey)return!1;let n=t.open.options[t.open.selected],s=t.active.find(o=>o.source==n.source),r=n.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(i.key)>-1&&Ya(e,n),!1}})),UE=V.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),ns={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},ji=J.define({map(i,e){let t=e.mapPos(i,-1,We.TrackAfter);return t??void 0}}),Xa=new class extends Di{};Xa.startSide=1;Xa.endSide=-1;const Sg=Ne.define({create(){return se.empty},update(i,e){if(i=i.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);i=i.update({filter:n=>n>=t.from&&n<=t.to})}for(let t of e.effects)t.is(ji)&&(i=i.update({add:[Xa.range(t.value,t.value+1)]}));return i}});function qE(){return[YE,Sg]}const Ko="()[]{}<>«»»«[]{}";function Cg(i){for(let e=0;e<Ko.length;e+=2)if(Ko.charCodeAt(e)==i)return Ko.charAt(e+1);return Ea(i<128?i:i+1)}function wg(i,e){return i.languageDataAt("closeBrackets",e)[0]||ns}const KE=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),YE=V.inputHandler.of((i,e,t,n)=>{if((KE?i.composing:i.compositionStarted)||i.state.readOnly)return!1;let s=i.state.selection.main;if(n.length>2||n.length==2&&Pt(Ke(n,0))==1||e!=s.from||t!=s.to)return!1;let r=JE(i.state,n);return r?(i.dispatch(r),!0):!1}),XE=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let n=wg(i,i.selection.main.head).brackets||ns.brackets,s=null,r=i.changeByRange(o=>{if(o.empty){let l=ZE(i.doc,o.head);for(let a of n)if(a==l&&so(i.doc,o.head)==Cg(Ke(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:T.cursor(o.head-a.length)}}return{range:s=o}});return s||e(i.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},QE=[{key:"Backspace",run:XE}];function JE(i,e){let t=wg(i,i.selection.main.head),n=t.brackets||ns.brackets;for(let s of n){let r=Cg(Ke(s,0));if(e==s)return r==s?iR(i,s,n.indexOf(s+s+s)>-1,t):eR(i,s,r,t.before||ns.before);if(e==r&&Eg(i,i.selection.main.from))return tR(i,s,r)}return null}function Eg(i,e){let t=!1;return i.field(Sg).between(0,i.doc.length,n=>{n==e&&(t=!0)}),t}function so(i,e){let t=i.sliceString(e,e+2);return t.slice(0,Pt(Ke(t,0)))}function ZE(i,e){let t=i.sliceString(e-2,e);return Pt(Ke(t,0))==t.length?t:t.slice(1)}function eR(i,e,t,n){let s=null,r=i.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:ji.of(o.to+e.length),range:T.range(o.anchor+e.length,o.head+e.length)};let l=so(i.doc,o.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:ji.of(o.head+e.length),range:T.cursor(o.head+e.length)}:{range:s=o}});return s?null:i.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function tR(i,e,t){let n=null,s=i.changeByRange(r=>r.empty&&so(i.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:T.cursor(r.head+t.length)}:n={range:r});return n?null:i.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function iR(i,e,t,n){let s=n.stringPrefixes||ns.stringPrefixes,r=null,o=i.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:ji.of(l.to+e.length),range:T.range(l.anchor+e.length,l.head+e.length)};let a=l.head,u=so(i.doc,a),c;if(u==e){if(rh(i,a))return{changes:{insert:e+e,from:a},effects:ji.of(a+e.length),range:T.cursor(a+e.length)};if(Eg(i,a)){let f=t&&i.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+f.length,insert:f},range:T.cursor(a+f.length)}}}else{if(t&&i.sliceDoc(a-2*e.length,a)==e+e&&(c=oh(i,a-2*e.length,s))>-1&&rh(i,c))return{changes:{insert:e+e+e+e,from:a},effects:ji.of(a+e.length),range:T.cursor(a+e.length)};if(i.charCategorizer(a)(u)!=ye.Word&&oh(i,a,s)>-1&&!nR(i,a,e,s))return{changes:{insert:e+e,from:a},effects:ji.of(a+e.length),range:T.cursor(a+e.length)}}return{range:r=l}});return r?null:i.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function rh(i,e){let t=_e(i).resolveInner(e+1);return t.parent&&t.from==e}function nR(i,e,t,n){let s=_e(i).resolveInner(e,-1),r=n.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=i.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&n.indexOf(l.slice(0,a))>-1){let c=s.firstChild;for(;c&&c.from==s.from&&c.to-c.from>t.length+a;){if(i.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let u=s.to==e&&s.parent;if(!u)break;s=u}return!1}function oh(i,e,t){let n=i.charCategorizer(e);if(n(i.sliceDoc(e-1,e))!=ye.Word)return e;for(let s of t){let r=e-s.length;if(i.sliceDoc(r,e)==s&&n(i.sliceDoc(r-1,r))!=ye.Word)return r}return-1}function sR(i={}){return[WE,Ye,Pe.of(i),HE,rR,UE]}const Rg=[{key:"Ctrl-Space",run:qo},{mac:"Alt-`",run:qo},{mac:"Alt-i",run:qo},{key:"Escape",run:VE},{key:"ArrowDown",run:Hs(!0)},{key:"ArrowUp",run:Hs(!1)},{key:"PageDown",run:Hs(!0,"page")},{key:"PageUp",run:Hs(!1,"page")},{key:"Enter",run:BE}],rR=Vi.highest(Yr.computeN([Pe],i=>i.facet(Pe).defaultKeymap?[Rg]:[]));class lh{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class Ai{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let s=n.facet(ss).markerFilter;s&&(e=s(e,n));let r=e.slice().sort((p,g)=>p.from-g.from||p.to-g.to),o=new Xt,l=[],a=0,u=n.doc.iter(),c=0,h=n.doc.length;for(let p=0;;){let g=p==r.length?null:r[p];if(!g&&!l.length)break;let m,x;if(l.length)m=a,x=l.reduce((v,w)=>Math.min(v,w.to),g&&g.from>m?g.from:1e8);else{if(m=g.from,m>h)break;x=g.to,l.push(g),p++}for(;p<r.length;){let v=r[p];if(v.from==m&&(v.to>v.from||v.to==m))l.push(v),p++,x=Math.min(v.to,x);else{x=Math.min(v.from,x);break}}x=Math.min(x,h);let y=!1;if(l.some(v=>v.from==m&&(v.to==x||x==h))&&(y=m==x,!y&&x-m<10)){let v=m-(c+u.value.length);v>0&&(u.next(v),c=m);for(let w=m;;){if(w>=x){y=!0;break}if(!u.lineBreak&&c+u.value.length>w)break;w=c+u.value.length,c+=u.value.length,u.next()}}let b=yR(l);if(y)o.add(m,m,q.widget({widget:new pR(b),diagnostics:l.slice()}));else{let v=l.reduce((w,S)=>S.markClass?w+" "+S.markClass:w,"");o.add(m,x,q.mark({class:"cm-lintRange cm-lintRange-"+b+v,diagnostics:l.slice(),inclusiveEnd:l.some(w=>w.to>x)}))}if(a=x,a==h)break;for(let v=0;v<l.length;v++)l[v].to<=a&&l.splice(v--,1)}let f=o.finish();return new Ai(f,t,xn(f))}}function xn(i,e=null,t=0){let n=null;return i.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!n)n=new lh(s,r,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new lh(n.from,r,n.diagnostic)}}),n}function oR(i,e){let t=e.pos,n=e.end||t,s=i.state.facet(ss).hideOn(i,t,n);if(s!=null)return s;let r=i.startState.doc.lineAt(e.pos);return!!(i.effects.some(o=>o.is(kg))||i.changes.touchesRange(r.from,Math.max(r.to,n)))}function lR(i,e){return i.field(st,!1)?e:e.concat(J.appendConfig.of(bR))}const kg=J.define(),Qa=J.define(),Ag=J.define(),st=Ne.define({create(){return new Ai(q.none,null,null)},update(i,e){if(e.docChanged&&i.diagnostics.size){let t=i.diagnostics.map(e.changes),n=null,s=i.panel;if(i.selected){let r=e.changes.mapPos(i.selected.from,1);n=xn(t,i.selected.diagnostic,r)||xn(t,null,r)}!t.size&&s&&e.state.facet(ss).autoPanel&&(s=null),i=new Ai(t,s,n)}for(let t of e.effects)if(t.is(kg)){let n=e.state.facet(ss).autoPanel?t.value.length?rs.open:null:i.panel;i=Ai.init(t.value,n,e.state)}else t.is(Qa)?i=new Ai(i.diagnostics,t.value?rs.open:null,i.selected):t.is(Ag)&&(i=new Ai(i.diagnostics,i.panel,t.value));return i},provide:i=>[Zn.from(i,e=>e.panel),V.decorations.from(i,e=>e.diagnostics)]}),aR=q.mark({class:"cm-lintRange cm-lintRange-active"});function uR(i,e,t){let{diagnostics:n}=i.state.field(st),s,r=-1,o=-1;n.between(e-(t<0?1:0),e+(t>0?1:0),(a,u,{spec:c})=>{if(e>=a&&e<=u&&(a==u||(e>a||t>0)&&(e<u||t<0)))return s=c.diagnostics,r=a,o=u,!1});let l=i.state.facet(ss).tooltipFilter;return s&&l&&(s=l(s,i.state)),s?{pos:r,end:o,above:i.state.doc.lineAt(r).to<o,create(){return{dom:cR(i,s)}}}:null}function cR(i,e){return fe("ul",{class:"cm-tooltip-lint"},e.map(t=>Mg(i,t,!1)))}const hR=i=>{let e=i.state.field(st,!1);(!e||!e.panel)&&i.dispatch({effects:lR(i.state,[Qa.of(!0)])});let t=Jn(i,rs.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},ah=i=>{let e=i.state.field(st,!1);return!e||!e.panel?!1:(i.dispatch({effects:Qa.of(!1)}),!0)},fR=i=>{let e=i.state.field(st,!1);if(!e)return!1;let t=i.state.selection.main,n=e.diagnostics.iter(t.to+1);return!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==t.from&&n.to==t.to)?!1:(i.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)},dR=[{key:"Mod-Shift-m",run:hR,preventDefault:!0},{key:"F8",run:fR}],ss=$.define({combine(i){return{sources:i.map(e=>e.source).filter(e=>e!=null),..._t(i.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:uh,tooltipFilter:uh,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,s,r)=>e(n,s,r)||t(n,s,r):e:t,autoPanel:(e,t)=>e||t})}}});function uh(i,e){return i?e?(t,n)=>e(i(t,n),n):i:e}function Tg(i){let e=[];if(i)e:for(let{name:t}of i){for(let n=0;n<t.length;n++){let s=t[n];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function Mg(i,e,t){var n;let s=t?Tg(e.actions):[];return fe("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},fe("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(i):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((r,o)=>{let l=!1,a=p=>{if(p.preventDefault(),l)return;l=!0;let g=xn(i.state.field(st).diagnostics,e);g&&r.apply(i,g.from,g.to)},{name:u}=r,c=s[o]?u.indexOf(s[o]):-1,h=c<0?u:[u.slice(0,c),fe("u",u.slice(c,c+1)),u.slice(c+1)],f=r.markClass?" "+r.markClass:"";return fe("button",{type:"button",class:"cm-diagnosticAction"+f,onclick:a,onmousedown:a,"aria-label":` Action: ${u}${c<0?"":` (access key "${s[o]})"`}.`},h)}),e.source&&fe("div",{class:"cm-diagnosticSource"},e.source))}class pR extends Zt{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return fe("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class ch{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Mg(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class rs{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)ah(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=Tg(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=xn(this.view.state.field(st).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()},n=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=fe("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:n}),this.dom=fe("div",{class:"cm-panel-lint"},this.list,fe("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>ah(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(st).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(st),n=0,s=!1,r=null,o=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:u})=>{for(let c of u.diagnostics){if(o.has(c))continue;o.add(c);let h=-1,f;for(let p=n;p<this.items.length;p++)if(this.items[p].diagnostic==c){h=p;break}h<0?(f=new ch(this.view,c),this.items.splice(n,0,f),s=!0):(f=this.items[h],h>n&&(this.items.splice(n,h-n),s=!0)),t&&f.diagnostic==t.diagnostic?f.dom.hasAttribute("aria-selected")||(f.dom.setAttribute("aria-selected","true"),r=f):f.dom.hasAttribute("aria-selected")&&f.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new ch(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let u=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/u:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(st),n=xn(t.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:Ag.of(n)})}static open(e){return new rs(e)}}function gR(i,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(i)}</svg>')`}function Gs(i){return gR(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${i}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const mR=V.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Gs("#d11")},".cm-lintRange-warning":{backgroundImage:Gs("orange")},".cm-lintRange-info":{backgroundImage:Gs("#999")},".cm-lintRange-hint":{backgroundImage:Gs("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function xR(i){return i=="error"?4:i=="warning"?3:i=="info"?2:1}function yR(i){let e="hint",t=1;for(let n of i){let s=xR(n.severity);s>t&&(t=s,e=n.severity)}return e}const bR=[st,V.decorations.compute([st],i=>{let{selected:e,panel:t}=i.field(st);return!e||!t||e.from==e.to?q.none:q.set([aR.range(e.from,e.to)])}),E1(uR,{hideOn:oR}),mR];var hh=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(QE)),e.defaultKeymap!==!1&&(n=n.concat(Gw)),e.searchKeymap!==!1&&(n=n.concat(mE)),e.historyKeymap!==!1&&(n=n.concat(QC)),e.foldKeymap!==!1&&(n=n.concat(uC)),e.completionKeymap!==!1&&(n=n.concat(Rg)),e.lintKeymap!==!1&&(n=n.concat(dR));var s=[];return e.lineNumbers!==!1&&s.push(L1()),e.highlightActiveLineGutter!==!1&&s.push(B1()),e.highlightSpecialChars!==!1&&s.push(ZS()),e.history!==!1&&s.push(_C()),e.foldGutter!==!1&&s.push(dC()),e.drawSelection!==!1&&s.push(_S()),e.dropCursor!==!1&&s.push(qS()),e.allowMultipleSelections!==!1&&s.push(ne.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&s.push(Z1()),e.syntaxHighlighting!==!1&&s.push(Ep(xC,{fallback:!0})),e.bracketMatching!==!1&&s.push(EC()),e.closeBrackets!==!1&&s.push(qE()),e.autocompletion!==!1&&s.push(sR()),e.rectangularSelection!==!1&&s.push(d1()),t!==!1&&s.push(m1()),e.highlightActiveLine!==!1&&s.push(r1()),e.highlightSelectionMatches!==!1&&s.push(Qw()),e.tabSize&&typeof e.tabSize=="number"&&s.push(Qr.of(" ".repeat(e.tabSize))),s.concat([Yr.of(n.flat())]).filter(Boolean)};const vR="#e5c07b",fh="#e06c75",SR="#56b6c2",CR="#ffffff",nr="#abb2bf",ia="#7d8799",wR="#61afef",ER="#98c379",dh="#d19a66",RR="#c678dd",kR="#21252b",ph="#2c313a",gh="#282c34",Yo="#353a42",AR="#3E4451",mh="#528bff",TR=V.theme({"&":{color:nr,backgroundColor:gh},".cm-content":{caretColor:mh},".cm-cursor, .cm-dropCursor":{borderLeftColor:mh},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:AR},".cm-panels":{backgroundColor:kR,color:nr},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:gh,color:ia,border:"none"},".cm-activeLineGutter":{backgroundColor:ph},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Yo},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Yo,borderBottomColor:Yo},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:ph,color:nr}}},{dark:!0}),MR=fs.define([{tag:k.keyword,color:RR},{tag:[k.name,k.deleted,k.character,k.propertyName,k.macroName],color:fh},{tag:[k.function(k.variableName),k.labelName],color:wR},{tag:[k.color,k.constant(k.name),k.standard(k.name)],color:dh},{tag:[k.definition(k.name),k.separator],color:nr},{tag:[k.typeName,k.className,k.number,k.changed,k.annotation,k.modifier,k.self,k.namespace],color:vR},{tag:[k.operator,k.operatorKeyword,k.url,k.escape,k.regexp,k.link,k.special(k.string)],color:SR},{tag:[k.meta,k.comment],color:ia},{tag:k.strong,fontWeight:"bold"},{tag:k.emphasis,fontStyle:"italic"},{tag:k.strikethrough,textDecoration:"line-through"},{tag:k.link,color:ia,textDecoration:"underline"},{tag:k.heading,fontWeight:"bold",color:fh},{tag:[k.atom,k.bool,k.special(k.variableName)],color:dh},{tag:[k.processingInstruction,k.string,k.inserted],color:ER},{tag:k.invalid,color:CR}]),jR=[TR,Ep(MR)];var OR=V.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),IR=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:s=!1,theme:r="light",placeholder:o="",basicSetup:l=!0}=e,a=[];switch(t&&a.unshift(Yr.of([Ww])),l&&(typeof l=="boolean"?a.unshift(hh()):a.unshift(hh(l))),o&&a.unshift(u1(o)),r){case"light":a.push(OR);break;case"dark":a.push(jR);break;case"none":break;default:a.push(r);break}return n===!1&&a.push(V.editable.of(!1)),s&&a.push(ne.readOnly.of(!0)),[...a]},PR=i=>({line:i.state.doc.lineAt(i.state.selection.main.from),lineCount:i.state.doc.lines,lineBreak:i.state.lineBreak,length:i.state.doc.length,readOnly:i.state.readOnly,tabSize:i.state.tabSize,selection:i.state.selection,selectionAsSingle:i.state.selection.asSingle().main,ranges:i.state.selection.ranges,selectionCode:i.state.sliceDoc(i.state.selection.main.from,i.state.selection.main.to),selections:i.state.selection.ranges.map(e=>i.state.sliceDoc(e.from,e.to)),selectedText:i.state.selection.ranges.some(e=>!e.empty)});class DR{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(t=>{try{t()}catch(n){console.error("TimeoutLatch callback error:",n)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class xh{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var Xo=null,LR=()=>typeof window>"u"?new xh:(Xo||(Xo=new xh),Xo),yh=$t.define(),FR=200,NR=[];function BR(i){var{value:e,selection:t,onChange:n,onStatistics:s,onCreateEditor:r,onUpdate:o,extensions:l=NR,autoFocus:a,theme:u="light",height:c=null,minHeight:h=null,maxHeight:f=null,width:p=null,minWidth:g=null,maxWidth:m=null,placeholder:x="",editable:y=!0,readOnly:b=!1,indentWithTab:v=!0,basicSetup:w=!0,root:S,initialState:E}=i,[A,O]=j.useState(),[R,H]=j.useState(),[N,I]=j.useState(),W=j.useState(()=>({current:null}))[0],P=j.useState(()=>({current:null}))[0],U=V.theme({"&":{height:c,minHeight:h,maxHeight:f,width:p,minWidth:g,maxWidth:m},"& .cm-scroller":{height:"100% !important"}}),Q=V.updateListener.of(ie=>{if(ie.docChanged&&typeof n=="function"&&!ie.transactions.some(C=>C.annotation(yh))){W.current?W.current.reset():(W.current=new DR(()=>{if(P.current){var C=P.current;P.current=null,C()}W.current=null},FR),LR().add(W.current));var ee=ie.state.doc,G=ee.toString();n(G,ie)}s&&s(PR(ie))}),he=IR({theme:u,editable:y,readOnly:b,placeholder:x,indentWithTab:v,basicSetup:w}),pe=[Q,U,...he];return o&&typeof o=="function"&&pe.push(V.updateListener.of(o)),pe=pe.concat(l),j.useLayoutEffect(()=>{if(A&&!N){var ie={doc:e,selection:t,extensions:pe},ee=E?ne.fromJSON(E.json,ie,E.fields):ne.create(ie);if(I(ee),!R){var G=new V({state:ee,parent:A,root:S});H(G),r&&r(G,ee)}}return()=>{R&&(I(void 0),H(void 0))}},[A,N]),j.useEffect(()=>{i.container&&O(i.container)},[i.container]),j.useEffect(()=>()=>{R&&(R.destroy(),H(void 0)),W.current&&(W.current.cancel(),W.current=null)},[R]),j.useEffect(()=>{a&&R&&R.focus()},[a,R]),j.useEffect(()=>{R&&R.dispatch({effects:J.reconfigure.of(pe)})},[u,l,c,h,f,p,g,m,x,y,b,v,w,n,o]),j.useEffect(()=>{if(e!==void 0){var ie=R?R.state.doc.toString():"";if(R&&e!==ie){var ee=W.current&&!W.current.isDone,G=()=>{R&&e!==R.state.doc.toString()&&R.dispatch({changes:{from:0,to:R.state.doc.toString().length,insert:e||""},annotations:[yh.of(!0)]})};ee?P.current=G:G()}}},[e,R]),{state:N,setState:I,view:R,setView:H,container:A,setContainer:O}}var VR=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],jg=j.forwardRef((i,e)=>{var{className:t,value:n="",selection:s,extensions:r=[],onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:u,autoFocus:c,theme:h="light",height:f,minHeight:p,maxHeight:g,width:m,minWidth:x,maxWidth:y,basicSetup:b,placeholder:v,indentWithTab:w,editable:S,readOnly:E,root:A,initialState:O}=i,R=Hr(i,VR),H=j.useRef(null),{state:N,view:I,container:W,setContainer:P}=BR({root:A,value:n,autoFocus:c,theme:h,height:f,minHeight:p,maxHeight:g,width:m,minWidth:x,maxWidth:y,basicSetup:b,placeholder:v,indentWithTab:w,editable:S,readOnly:E,selection:s,onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:u,extensions:r,initialState:O});j.useImperativeHandle(e,()=>({editor:H.current,state:N,view:I}),[H,W,N,I]);var U=j.useCallback(he=>{H.current=he,P(he)},[P]);if(typeof n!="string")throw new Error("value must be typeof string but got "+typeof n);var Q=typeof h=="string"?"cm-theme-"+h:"cm-theme";return d.jsxRuntimeExports.jsx("div",be({ref:U,className:""+Q+(t?" "+t:"")},R))});jg.displayName="CodeMirror";function zR({value:i,language:e,readOnly:t=!1,height:n="300px",onChange:s}){const[r]=D.useStyletron(),o=e==="json"?[IC()]:[],l=V.theme({"&":{fontSize:"14px",fontFamily:"monospace"},".cm-content":{padding:"12px"},".cm-editor":{backgroundColor:t?"#F8F8F8":"#FFFFFF"},".cm-editor.cm-focused":{outline:"none"}});return d.jsxRuntimeExports.jsx("div",{className:r({border:"1px solid #E0E0E0",borderRadius:"4px",overflow:"hidden",height:n}),children:d.jsxRuntimeExports.jsx(jg,{value:i,height:n,extensions:[...o,l],onChange:s,editable:!t,basicSetup:{lineNumbers:!0,foldGutter:!1,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!1,bracketMatching:!0,closeBrackets:!1,autocompletion:!1,highlightSelectionMatches:!1,searchKeymap:!1}})})}const $i={boolValue:"boolValue",listValue:"listValue",nullValue:"nullValue",numberValue:"numberValue",stringValue:"stringValue",structValue:"structValue"};function Og(i){return!!i&&typeof i=="object"&&"fields"in i&&typeof i.fields=="object"&&!Array.isArray(i.fields)}function $R(i){const e=Object.entries(i),[t,n]=e[0]||[];return{kind:t,kindValue:n}}function _R(i){const e={};for(const[t,n]of Object.entries(i))e[t]=Nr(n);return e}function Nr(i){if(i==null)return i;if(Og(i))return _R(i.fields);if(typeof i=="object"&&i!==null){const e=i,{kind:t,kindValue:n}=$R(e);switch(t){case $i.listValue:return n&&typeof n=="object"&&"values"in n?n.values.map(r=>Nr(r)):[];case $i.nullValue:return null;case $i.structValue:return n?Nr(n):{};case $i.boolValue:case $i.numberValue:case $i.stringValue:return n;default:return i}}return i}function HR(i){const{label:e,value:t}=i,n=Og(t)?Nr(t):t,s=JSON.stringify(n,null,2);return d.jsxRuntimeExports.jsx(xa,{title:d.jsxRuntimeExports.jsx(bt.LabelSmall,{children:e}),children:d.jsxRuntimeExports.jsx(zR,{readOnly:!0,language:"json",value:s,onChange:()=>null})})}function GR(i){const[e,t]=D.useStyletron(),{label:n,value:s,markdown:r=!0,error:o=!1}=i;if(!s)return null;const l=s.substring(0,1e4);return d.jsxRuntimeExports.jsxs("div",{className:e({backgroundColor:o?t.colors.backgroundNegativeLight:t.colors.backgroundSecondary,borderRadius:t.borders.radius300,minHeight:t.sizing.scale1600,overflow:"auto",padding:t.sizing.scale600,resize:"vertical"}),children:[d.jsxRuntimeExports.jsx(bt.LabelSmall,{id:"textarea-title",children:n}),d.jsxRuntimeExports.jsx(bt.ParagraphSmall,{"aria-labelledby":"textarea-title",className:e({marginBottom:0,marginTop:t.sizing.scale100}),children:r?d.jsxRuntimeExports.jsx(d.Markdown,{children:l}):l})]})}function WR(i){const[e,t]=D.useStyletron(),{task:n,bodySchema:s,overrides:r,metadata:o}=i,{subTasks:l}=n,a=d.useInterpolationResolver();if(l!=null&&l.length){const u=ya(l,n);return d.jsxRuntimeExports.jsxs(Dn,{children:[d.jsxRuntimeExports.jsx(d.Box,{children:d.jsxRuntimeExports.jsx(jf,{matrix:u,onTaskClick:kf,overrides:{TaskListRenderer:r==null?void 0:r.TaskListRenderer,SubTaskListRenderer:r==null?void 0:r.SubTaskListRenderer}})}),l.map((c,h)=>d.jsxRuntimeExports.jsx(Ig,{task:c,bodySchema:s,overrides:r,metadata:o},h))]})}if(s!=null&&s.length){const u=a(s,{row:n});return d.jsxRuntimeExports.jsx("div",{className:e({display:"flex",flexDirection:"column",gap:t.sizing.scale600}),children:u.map((c,h)=>{const{label:f}=c;if(c.type==="struct"){const p=d.getObjectValue(n.record,c.accessor);return d.jsxRuntimeExports.jsx(HR,{label:f,value:p},h)}if(c.type==="textarea"){const p=d.getObjectValue(n.record,c.accessor),{error:g,markdown:m}=c;return d.jsxRuntimeExports.jsx(GR,{label:f,value:p,error:g,markdown:m},h)}if(c.type==="metadata"){const{cells:p}=c;return d.jsxRuntimeExports.jsx(hb,{label:f,value:n.record,cells:p},h)}return null})})}return d.jsxRuntimeExports.jsxs("div",{children:["No subtasks, no body schema for ",n.name]})}function bh(i){const[e,t]=D.useStyletron(),{task:n,id:s,metadata:r}=i,{name:o,state:l}=n;return d.jsxRuntimeExports.jsxs(Dn,{id:s,children:[d.jsxRuntimeExports.jsxs("div",{className:e({display:"flex",gap:t.sizing.scale500}),children:[d.jsxRuntimeExports.jsx("div",{className:e({marginTop:"2px"}),children:d.jsxRuntimeExports.jsx(ba,{state:l})}),d.jsxRuntimeExports.jsx("div",{className:e({...t.typography.LabelLarge,marginBottom:t.sizing.scale100}),children:o})]}),r&&d.jsxRuntimeExports.jsx(d.Row,{items:r,record:n.record})]})}function Ig(i){var o;const{task:e,metadata:t,bodySchema:n,overrides:s}=i,r=Rf(e);return(o=e.subTasks)!=null&&o.length||n!=null&&n.length?d.jsxRuntimeExports.jsx(Ef,{id:r,title:d.jsxRuntimeExports.jsx(bh,{task:e,metadata:t}),defaultExpanded:e.focused,state:e.state,children:d.jsxRuntimeExports.jsx(WR,{task:e,bodySchema:n,metadata:t,overrides:s})}):d.jsxRuntimeExports.jsx(bh,{id:r,task:e,metadata:t})}function UR(i,e){const{tasks:t}=i,{accessor:n,subTasksAccessor:s}=t;function r(l,a,u){const c=u.findIndex((p,g)=>{const m=i.tasks.stateBuilder(p,g,u,e);return m!==oe.SUCCESS&&m!==oe.SKIPPED}),h=d.getObjectValue(l,t.header.heading),f=d.getObjectValue(l,"name");return{name:h!=null&&h.trim()?h:f,state:i.tasks.stateBuilder(l,a,u,e),subTasks:s?d.getObjectValue(l,s,[]).map(r):[],record:l,focused:c===a||c===-1&&a===u.length-1}}return d.getObjectValue(e,n,[]).map(r)}function qR(i){var e;return i.length?i.some(({state:t})=>t===oe.RUNNING)?oe.RUNNING:i.some(({state:t})=>t===oe.ERROR)?oe.ERROR:((e=i.at(-1))==null?void 0:e.state)??oe.PENDING:oe.PENDING}function Pg(i){const{schema:e,data:t,overrides:n}=i,[s,r]=D.useStyletron(),o=(n==null?void 0:n.taskList)??UR(e,t);if(!o.length)return d.jsxRuntimeExports.jsx(Yt,{illustration:d.jsxRuntimeExports.jsx(pi,{height:"64px",width:"64px",kind:vt.PRIMARY}),title:e.emptyState.title,description:e.emptyState.description});const l=ya(o);return d.jsxRuntimeExports.jsxs(Dn,{children:[d.jsxRuntimeExports.jsx(d.Box,{title:d.jsxRuntimeExports.jsxs("div",{className:s({display:"flex",alignItems:"center",gap:r.sizing.scale500}),children:[d.jsxRuntimeExports.jsx(ba,{state:qR(o)}),"Overview"]}),children:d.jsxRuntimeExports.jsx(Dn,{children:d.jsxRuntimeExports.jsx(jf,{matrix:l,onTaskClick:a=>{kf(a)},overrides:{TaskListRenderer:n==null?void 0:n.TaskListRenderer,SubTaskListRenderer:n==null?void 0:n.SubTaskListRenderer}})})}),d.jsxRuntimeExports.jsx(Dn,{children:o.map((a,u)=>d.jsxRuntimeExports.jsx(Ig,{task:a,metadata:e.tasks.header.metadata,bodySchema:e.tasks.body,overrides:n},u))})]})}function KR(i,e){try{localStorage.setItem(i,JSON.stringify(e))}catch{}}function YR(i,e){try{const t=localStorage.getItem(i);return t===null?e:JSON.parse(t)??e}catch{return e}}const XR={};function Dg(){return YR(Lh,XR)}function QR(i,e){const t=Dg();return d.lodashExports.isEqual(d.lodashExports.get(t,i),e)?!1:(KR(Lh,d.lodashExports.set(d.lodashExports.cloneDeep(t),i,e)),!0)}function _i(i,e){const t=Dg(),[n,s]=j.useState(d.getObjectValue(t,i,e)??e);return[n,o=>{const l=o instanceof Function?o(n):o;QR(i,l),s(l)}]}function Ja({tableSettingsId:i,filterSettingsId:e,initialState:t}){var O;const n=e??i,[s,r]=_i(`${n}.globalFilter`,(t==null?void 0:t.globalFilter)??ni.globalFilter),[o,l]=_i(`${n}.columnFilters`,(t==null?void 0:t.columnFilters)??ni.columnFilters),[a,u]=_i(`${i}.pageSize`,((O=t==null?void 0:t.pagination)==null?void 0:O.pageSize)??ni.pagination.pageSize),[c,h]=_i(`${i}.sorting`,(t==null?void 0:t.sorting)??ni.sorting),[f,p]=_i(`${i}.columnOrder`,(t==null?void 0:t.columnOrder)??ni.columnOrder),[g,m]=_i(`${i}.columnVisibility`,(t==null?void 0:t.columnVisibility)??ni.columnVisibility),[x,y]=j.useState(0),[b,v]=j.useState({}),[w,S]=j.useState((t==null?void 0:t.rowSelectionEnabled)??ni.rowSelectionEnabled),[E,A]=j.useState((t==null?void 0:t.grouping)??ni.grouping);return{globalFilter:s,setGlobalFilter:r,columnFilters:o,setColumnFilters:l,pagination:{pageIndex:x,pageSize:a},setPagination:R=>{const N=typeof R=="function"?R({pageIndex:x,pageSize:a}):R;y(N.pageIndex),u(N.pageSize)},sorting:c,setSorting:h,columnOrder:f,setColumnOrder:p,columnVisibility:g,setColumnVisibility:m,rowSelection:b,setRowSelection:v,rowSelectionEnabled:w,setRowSelectionEnabled:S,grouping:E,setGrouping:A}}const JR=({isOpen:i,onDismiss:e,heading:t,onConfirm:n,confirmLabel:s="Confirm",destructive:r=!1,children:o,size:l=rr.SIZE.small})=>{const[a,u]=j.useState(!1),[c,h]=j.useState(null);j.useEffect(()=>{i||(u(!1),h(null))},[i]);const f=async()=>{u(!0);try{await n(),e()}catch(p){h(p instanceof Error?p.message:"An unexpected error occurred."),u(!1)}};return d.jsxRuntimeExports.jsxs(d.Dialog,{isOpen:i,onDismiss:e,heading:t,size:l,placement:rr.PLACEMENT.topCenter,buttonDock:{primaryAction:d.jsxRuntimeExports.jsx(_.Button,{isLoading:a,onClick:f,overrides:r?{BaseButton:{style:({$theme:p})=>({backgroundColor:p.colors.backgroundNegative})}}:void 0,children:s}),dismissiveAction:d.jsxRuntimeExports.jsx(_.Button,{kind:_.KIND.tertiary,onClick:e,disabled:a,children:"Cancel"})},children:[o,c&&d.jsxRuntimeExports.jsx(or.Banner,{kind:or.KIND.negative,children:c})]})};function ZR({action:i,record:e,onClose:t}){const n=Ae.useNavigate(),s=d.useStudioMutation(i.operation.type==="mutation"?i.operation.mutation:null),r=async()=>{i.operation.type==="mutation"?await s.mutateAsync(e):n(i.operation.route)},{modal:o}=i;return d.jsxRuntimeExports.jsxs(JR,{isOpen:!0,onDismiss:t,onConfirm:r,heading:o.header.title,confirmLabel:o.button.label,destructive:o.destructive,size:o.size,children:[o.banner&&d.jsxRuntimeExports.jsx(d.Banner,{kind:o.banner.kind,artwork:o.banner.icon?{type:or.ARTWORK_TYPE.icon,icon:()=>d.jsxRuntimeExports.jsx(d.Icon,{name:o.banner.icon})}:void 0,children:o.banner.content}),o.body&&d.jsxRuntimeExports.jsx(d.Markdown,{children:o.body})]})}function Lg({action:i,record:e,onClose:t}){var n;if(((n=i.modal)==null?void 0:n.type)==="custom"){const s=i.modal.component;return d.jsxRuntimeExports.jsx(s,{record:e,onClose:t})}return ek(i)?d.jsxRuntimeExports.jsx(ZR,{action:i,record:e,onClose:t}):null}function ek(i){var e;return((e=i.modal)==null?void 0:e.type)==="confirm"}const Fg=j.forwardRef((i,e)=>{const{item:t,onSelectAction:n,onClose:s,hoveredItem:r,setHoveredItem:o,keyboardActive:l,setKeyboardActive:a,...u}=i,c=r===t,h=t.disabled?void 0:()=>n(t),f=d.jsxRuntimeExports.jsx(ro.MenuAdapter,{...u,ref:e,role:"option",artwork:t.display.icon?({size:p})=>d.jsxRuntimeExports.jsx(d.Icon,{name:t.display.icon,size:`${p}px`}):void 0,artworkSize:ro.ARTWORK_SIZES.MEDIUM,overrides:{Root:{style:{height:"44px",opacity:t.disabled?.4:1}}},$disabled:t.disabled,onClick:h,children:d.jsxRuntimeExports.jsx(ro.ListItemLabel,{children:t.display.label})});return!t.disabled||!t.disabledMessage?f:d.jsxRuntimeExports.jsx(Oi.Tooltip,{content:t.disabledMessage,autoFocus:!1,accessibilityType:Oi.ACCESSIBILITY_TYPE.tooltip,showArrow:!0,placement:Oi.PLACEMENT.left,isOpen:!!u.$isHighlighted&&l||c,popperOptions:{modifiers:{flip:{enabled:!1},preventOverflow:{enabled:!0,boundariesElement:"window",padding:8}}},onEsc:s,onMouseEnterDelay:0,onMouseLeaveDelay:0,onMouseEnter:()=>{o(t),a(!1)},onMouseLeave:()=>o(null),children:f})});Fg.displayName="ActionMenuItem";function tk({actions:i,onSelectAction:e,onClose:t}){const[n,s]=j.useState(null),[r,o]=j.useState(!1);return d.jsxRuntimeExports.jsx("div",{onKeyDown:()=>{s(null),o(!0)},children:d.jsxRuntimeExports.jsx(rm.StatefulMenu,{items:i,onItemSelect:({item:l})=>{l.disabled||e(l)},overrides:{Option:{component:Fg,props:{onSelectAction:e,onClose:t,hoveredItem:n,setHoveredItem:s,keyboardActive:r,setKeyboardActive:o}},List:{style:({$theme:l})=>({padding:l.sizing.scale600})}}})})}function ik(i,e){return j.useMemo(()=>i.map(t=>{var s;const n=(s=t.disabled)==null?void 0:s.find(r=>r.condition);return{display:t.display,hierarchy:t.hierarchy,disabled:!!n,disabledMessage:n==null?void 0:n.message,onClick:()=>e(t)}}),[i,e])}function Ng({actions:i,buttonProps:e,record:t,popoverProps:n}){const s=j.useRef(!1),[r,o]=j.useState(null),l=Ae.useNavigate(),[,a]=D.useStyletron(),u=ik(i,f=>{var p;f.modal?o(f):((p=f.operation)==null?void 0:p.type)==="route"&&l(f.operation.route)}),c=()=>{document.body.style.overflow="hidden",s.current=!0},h=()=>{document.body.style.overflow="",s.current=!1};return j.useEffect(()=>()=>{s.current&&(document.body.style.overflow="")},[]),d.jsxRuntimeExports.jsxs(d.jsxRuntimeExports.Fragment,{children:[d.jsxRuntimeExports.jsx(Nt.StatefulPopover,{focusLock:!0,placement:Nt.PLACEMENT.bottomLeft,popperOptions:{modifiers:{preventOverflow:{enabled:!0,boundariesElement:"window",padding:8}}},...n,content:({close:f})=>d.jsxRuntimeExports.jsx(tk,{actions:u,onSelectAction:p=>{p.onClick(),f()},onClose:f}),onClose:h,onOpen:c,children:d.jsxRuntimeExports.jsx(_.Button,{kind:_.KIND.tertiary,shape:_.SHAPE.pill,overrides:{BaseButton:{style:{paddingLeft:a.sizing.scale100,paddingRight:a.sizing.scale100}}},...e,size:_.SIZE.compact,title:"Actions","data-tracking-name":"actions-popover-button",children:d.jsxRuntimeExports.jsx(d.Icon,{name:"overflowMenu"})})}),r&&d.jsxRuntimeExports.jsx(Lg,{action:r,record:t,onClose:()=>o(null)})]})}function nk({actions:i,record:e,...t}){const n=d.useInterpolationResolver(),s=j.useMemo(()=>n(i,{row:e}),[n,i,e]);return d.jsxRuntimeExports.jsx(Ng,{actions:s,record:e,...t})}function Bg(i,e){const t={enableSearch:!i.disableSearch,enableFilters:!i.disableFilters};return{data:e.data,loading:e.loading,error:e.error,columns:i.columns,emptyState:i.emptyState,actions:"actions"in i&&i.actions?({row:n})=>d.jsxRuntimeExports.jsx(nk,{actions:i.actions,record:n.record}):void 0,actionBarConfig:t,disablePagination:i.disablePagination,disableSorting:i.disableSorting,pageSizes:i.pageSizes,enableStickySides:i.enableStickySides}}function sk({isDetailViewLoading:i=!1,queryConfig:e,tableConfig:t,pageId:n}){var f,p;const{projectId:s,phase:r,entity:o}=d.useStudioParams("detail"),{data:l,isLoading:a,error:u}=d.useStudioQuery({queryName:`List${d.capitalizeFirstLetter(e.service)}`,serviceOptions:{namespace:s,...e.serviceOptions},clientOptions:{...e.clientOptions,enabled:!i&&((f=e.clientOptions)==null?void 0:f.enabled)}}),c=Ja({tableSettingsId:`${r}/${o}/${n}`,filterSettingsId:`${s}/${r}/${o}/${n}`}),h=Bg(t,{data:((p=l==null?void 0:l[`${e.service}List`])==null?void 0:p.items)??[],loading:a||i,error:u??void 0});return d.jsxRuntimeExports.jsx(_r,{...h,state:c})}function rk({page:i,data:e,isLoading:t}){switch(i.type){case"custom":return j.createElement(i.component,{data:e,isLoading:t});case"execution":return d.jsxRuntimeExports.jsx(Pg,{schema:i,data:e??{}});case"table":{const n=i;return d.jsxRuntimeExports.jsx(sk,{isDetailViewLoading:t,queryConfig:n.queryConfig,tableConfig:n.tableConfig,pageId:n.id})}default:return d.jsxRuntimeExports.jsxs("div",{children:["Page type '",i.type,"' not yet supported"]})}}function ok(i){const e=D.mergeOverrides(i.overrides,{Root:{style:{transform:"unset"}},TabBorder:{style:{zIndex:-1}},TabHighlight:{style:{zIndex:0}}});return d.jsxRuntimeExports.jsx(lr.Tabs,{...i,overrides:e})}function lk(i){const e=D.mergeOverrides(i.overrides,{TabPanel:{style:({$theme:t})=>({paddingTop:t.sizing.scale950,paddingLeft:0,paddingRight:0})}});return d.jsxRuntimeExports.jsx(lr.Tab,{...i,overrides:e})}function Vg({tabs:i,activeTabId:e,onTabSelect:t}){var s;const n=e??((s=i[0])==null?void 0:s.id);return!i||i.length===0?d.jsxRuntimeExports.jsx("div",{children:"No tabs available"}):d.jsxRuntimeExports.jsx(ok,{activeKey:n,onChange:({activeKey:r})=>t==null?void 0:t(r),children:i.map(r=>d.jsxRuntimeExports.jsx(lk,{title:r.label,children:r.content},r.id))})}function vh({action:i,onClick:e,loading:t,kind:n,shape:s,overrides:r}){var c;const[o,l]=D.useStyletron(),a=(c=i.disabled)==null?void 0:c.find(h=>h.condition),u=d.jsxRuntimeExports.jsx(_.Button,{kind:n,shape:s,size:_.SIZE.compact,isLoading:t,disabled:!!a,overrides:r,startEnhancer:i.display.icon?()=>d.jsxRuntimeExports.jsx(d.Icon,{name:i.display.icon,size:l.sizing.scale550,color:"inherit"}):void 0,onClick:e,children:i.display.label});return a!=null&&a.message?d.jsxRuntimeExports.jsx(Oi.StatefulTooltip,{content:a.message,accessibilityType:Oi.ACCESSIBILITY_TYPE.tooltip,placement:Oi.PLACEMENT.bottom,showArrow:!0,children:d.jsxRuntimeExports.jsx("span",{className:o({display:"inline-flex"}),children:u})}):u}function ak(i){return{primary:i.find(e=>e.hierarchy===hi.PRIMARY),secondary:i.filter(e=>e.hierarchy===hi.SECONDARY),tertiary:i.filter(e=>!e.hierarchy||e.hierarchy===hi.TERTIARY)}}function uk({actions:i,record:e,loading:t}){const[n,s]=D.useStyletron(),[r,o]=j.useState(null),l=Ae.useNavigate();if(i.length===0)return null;const{primary:a,secondary:u,tertiary:c}=ak(i),h=f=>{var p;f.modal?o(f):((p=f.operation)==null?void 0:p.type)==="route"&&l(f.operation.route)};return d.jsxRuntimeExports.jsxs(d.jsxRuntimeExports.Fragment,{children:[d.jsxRuntimeExports.jsxs("div",{className:n({display:"flex",gap:s.sizing.scale300}),children:[a&&d.jsxRuntimeExports.jsx(vh,{action:a,onClick:()=>h(a),loading:t,kind:_.KIND.primary,overrides:{Root:{style:{width:"200px"}}}}),u.map(f=>d.jsxRuntimeExports.jsx(vh,{action:f,onClick:()=>h(f),loading:t,kind:_.KIND.secondary,shape:_.SHAPE.pill},f.display.label)),c.length>0&&d.jsxRuntimeExports.jsx(Ng,{actions:c,record:e,popoverProps:{placement:Nt.PLACEMENT.bottomRight}})]}),r&&d.jsxRuntimeExports.jsx(Lg,{action:r,record:e,onClose:()=>o(null)})]})}const ck=D.styled("div",({$theme:i})=>({...i.borders.border200,backgroundColor:i.colors.backgroundSecondary,borderRadius:i.borders.radius400,display:"flex",flexDirection:"column",gap:i.sizing.scale600,padding:i.sizing.scale800}));function hk({subtitle:i,title:e,titleEnhancer:t,onGoBack:n,children:s,actions:r,record:o,loading:l}){const[a,u]=D.useStyletron(),c=d.useInterpolationResolver(),h=j.useMemo(()=>r?c(r,{page:o}):void 0,[c,r,o]);return d.jsxRuntimeExports.jsxs(ck,{children:[d.jsxRuntimeExports.jsxs("div",{className:a({display:"flex",gap:u.sizing.scale800,justifyContent:"flex-start",alignItems:"flex-end"}),children:[d.jsxRuntimeExports.jsxs("h5",{className:a({margin:0,maxWidth:"50%"}),children:[i&&d.jsxRuntimeExports.jsx("div",{className:a({...u.typography.LabelSmall,color:u.colors.contentTertiary,marginBottom:u.sizing.scale300}),children:i}),d.jsxRuntimeExports.jsxs("div",{className:a({display:"flex",alignItems:"center",gap:u.sizing.scale300}),children:[n&&d.jsxRuntimeExports.jsx(_.Button,{"aria-label":"Go back",onClick:n,kind:_.KIND.tertiary,shape:_.SHAPE.circle,size:_.SIZE.compact,overrides:{BaseButton:{style:({$theme:f})=>({flexShrink:0,":hover":{backgroundColor:f.colors.contentInverseSecondary}})}},children:d.jsxRuntimeExports.jsx(d.Icon,{name:"arrowLeft",size:u.sizing.scale700})}),d.jsxRuntimeExports.jsx("div",{className:a({...u.typography.HeadingSmall,...Tf}),children:e})]})]}),t,h&&d.jsxRuntimeExports.jsx("div",{className:a({marginLeft:"auto",flexShrink:0}),children:d.jsxRuntimeExports.jsx(uk,{actions:h,record:o??{},loading:l})})]}),s]})}function zg({title:i,subtitle:e,onGoBack:t,headerContent:n,children:s,actions:r,record:o,loading:l,titleEnhancer:a}){const[u,c]=D.useStyletron();return d.jsxRuntimeExports.jsxs("div",{className:u({display:"flex",flexDirection:"column",gap:c.sizing.scale800}),children:[d.jsxRuntimeExports.jsx(hk,{title:i,subtitle:e,titleEnhancer:a,onGoBack:t,actions:r,record:o,loading:l,children:n}),s]})}function fk({phases:i=ma}){const[,e]=D.useStyletron(),{phase:t,entity:n,entityId:s,projectId:r,entityTab:o}=d.useStudioParams("detail"),l=Ae.useNavigate(),a=i[t].entities.find(b=>b.id===n),u=d.useInterpolationResolver(),{data:c,isLoading:h,error:f}=d.useStudioQuery({queryName:`Get${d.capitalizeFirstLetter((a==null?void 0:a.service)??"")}`,serviceOptions:{namespace:r,name:s},clientOptions:{enabled:!!(a!=null&&a.service)&&!!s}}),p=j.useCallback((b,v)=>{l(`/${r}/${t}/${n}/${s}/${b}`,v)},[l,r,t,n,s]),g=()=>{l(`/${r}/${t}/${n}`)},m=((a==null?void 0:a.views)??[]).find(b=>b.type==="detail")??void 0;if(j.useEffect(()=>{var w;if(f||h||!s||!((w=m==null?void 0:m.pages)!=null&&w.length))return;const b=m.pages.map(S=>S.id),v=b[0];o?b.includes(o)||p(v,{replace:!0}):p(v,{replace:!0})},[o,m,h,f,p]),f)return d.jsxRuntimeExports.jsx(Yt,{title:"Entity not found",description:`Could not load ${n} "${s}". ${f.message}`,illustration:d.jsxRuntimeExports.jsx(pi,{kind:vt.ERROR,width:e.sizing.scale1600,height:e.sizing.scale1600}),buttonConfig:{onClick:()=>l(`/${r}/${t}/${n}`),content:"Back to list"}});const x=c==null?void 0:c[a.service],y=u(m,{page:x});return d.jsxRuntimeExports.jsx(zg,{subtitle:a.name,title:s,onGoBack:g,actions:a.actions,record:x,loading:h,headerContent:d.jsxRuntimeExports.jsx(d.Row,{items:y.metadata,record:x,loading:h}),children:d.jsxRuntimeExports.jsx(Vg,{tabs:y.pages.map(b=>({id:b.id,label:b.label,content:d.jsxRuntimeExports.jsx(rk,{page:b,data:x,isLoading:h})})),activeTabId:o,onTabSelect:p})})}function dk({icon:i,docUrl:e,label:t,description:n}){const[s,r]=D.useStyletron();return d.jsxRuntimeExports.jsx("div",{className:s({display:"flex",justifyContent:"space-between",alignItems:"center"}),children:d.jsxRuntimeExports.jsxs("div",{className:s({display:"grid",gridTemplateColumns:i?"auto 1fr":"1fr",gridTemplateRows:"auto auto",columnGap:r.sizing.scale500,rowGap:r.sizing.scale100,alignItems:"center"}),children:[i&&d.jsxRuntimeExports.jsx(d.Icon,{name:i,size:r.sizing.scale600}),d.jsxRuntimeExports.jsx(bt.HeadingSmall,{as:"h2",className:s({margin:0}),children:t}),n&&i&&d.jsxRuntimeExports.jsx("div",{}),n&&d.jsxRuntimeExports.jsxs(d.DescriptionText,{children:[n,e&&d.jsxRuntimeExports.jsx(_.Button,{"aria-label":"Learn more",kind:_.KIND.tertiary,onClick:()=>window.open(e,"_blank"),shape:_.SHAPE.circle,size:_.SIZE.mini,overrides:{BaseButton:{style:{height:r.typography.ParagraphSmall.lineHeight,width:r.typography.ParagraphSmall.lineHeight}}},children:d.jsxRuntimeExports.jsx(d.Icon,{name:"arrowLaunch",size:r.sizing.scale500})})]})]})})}function pk({service:i,tableConfig:e,tableSettingsId:t}){var u;const{projectId:n}=d.useStudioParams("base"),{data:s,isLoading:r,error:o}=d.useStudioQuery({queryName:`List${d.capitalizeFirstLetter(i)}`,serviceOptions:{namespace:n}}),l=Ja({filterSettingsId:`${n}/${t}`,tableSettingsId:t}),a=Bg(e,{data:((u=s==null?void 0:s[`${i}List`])==null?void 0:u.items)??[],loading:r,error:o??void 0});return d.jsxRuntimeExports.jsx(_r,{...a,state:l})}function gk({phaseConfig:i,entities:e}){const[t,n]=D.useStyletron(),s=Ae.useNavigate(),{projectId:r,entity:o}=d.useStudioParams("list");j.useEffect(()=>{o||s(`/${r}/${i.id}/${e[0].id}`)},[o,s,r,i.id,e]);const l=e.findIndex(h=>h.id===o),a=l>=0?l.toString():"0",u=({activeKey:h})=>{const f=e[Number(h)];f&&s(`/${r}/${i.id}/${f.id}`)},c=e.find(h=>h.id===o);return c?d.jsxRuntimeExports.jsxs("div",{className:t({marginTop:n.sizing.scale800}),children:[d.jsxRuntimeExports.jsx(dk,{icon:i.icon,label:i.name,description:i.description,docUrl:i.docUrl}),d.jsxRuntimeExports.jsx(lr.Tabs,{activeKey:a,onChange:u,overrides:{Root:{style:({$theme:h})=>({marginTop:h.sizing.scale600})}},children:e.map((h,f)=>d.jsxRuntimeExports.jsx(lr.Tab,{title:h.name,children:String(f)===a&&d.jsxRuntimeExports.jsx(pk,{service:h.service,tableConfig:{...c.views[0].tableConfig,actions:h.actions},tableSettingsId:`${i.id}/${h.id}`})},String(f)))})]}):o?d.jsxRuntimeExports.jsx(Yt,{buttonConfig:{onClick:()=>s(`/${r}`),content:"Go home"},description:`Entity "${o}" not found`,illustration:d.jsxRuntimeExports.jsx(pi,{kind:vt.ERROR,width:n.sizing.scale1600,height:n.sizing.scale1600}),title:"Entity not found"}):null}function mk(i){return i.state==="active"&&i.views.some(e=>e.type==="list")}function xk({phases:i=ma}={}){const[,e]=D.useStyletron(),{phase:t,projectId:n}=d.useStudioParams("list"),s=Ae.useNavigate();if(!(t in i))return d.jsxRuntimeExports.jsx(Yt,{title:"Phase not found",description:`Phase "${t}" configuration not found. Available phases: ${Object.keys(i).join(", ")}`,illustration:d.jsxRuntimeExports.jsx(pi,{kind:vt.ERROR,width:e.sizing.scale1600,height:e.sizing.scale1600}),buttonConfig:{onClick:()=>s(`/${n}`),content:"Go home"}});const r=i[t].entities.filter(mk);return r.length===0?d.jsxRuntimeExports.jsx(Yt,{title:"Phase has no active entities",description:`Phase "${t}" has no active entities with list views configured.`,illustration:d.jsxRuntimeExports.jsx(pi,{kind:vt.ERROR,width:e.sizing.scale1600,height:e.sizing.scale1600}),buttonConfig:{onClick:()=>s(`/${n}`),content:"Go home"}}):d.jsxRuntimeExports.jsx(gk,{phaseConfig:i[t],entities:r})}const gs=D.styled(Ae.Link,({$theme:i})=>({textDecoration:"none",color:i.colors.contentTertiary,":visited":{color:i.colors.contentTertiary},":hover":{textDecoration:"underline"}})),yk=D.styled(Ae.Link,({$theme:i})=>({...i.typography.LabelMedium,display:"flex",alignItems:"center",justifyContent:"space-between",height:i.sizing.scale1200,paddingLeft:i.sizing.scale600,paddingRight:i.sizing.scale700,textDecoration:"none",":visited":{color:i.colors.contentPrimary},":hover":{backgroundColor:i.colors.menuFillHover}})),bk=D.styled("div",({$theme:i,$scrolled:e})=>({position:"sticky",top:"0",zIndex:1,backgroundColor:i.colors.backgroundPrimary,boxShadow:e?i.lighting.shadow400:`inset 0px -1px 0px ${i.colors.borderOpaque}`,transitionProperty:"box-shadow",transitionDuration:i.animation.timing100,transitionTimingFunction:i.animation.easeOutCurve,paddingTop:i.sizing.scale650,paddingBottom:i.sizing.scale650})),vk=D.styled("li",i=>({...i.$theme.typography.LabelMedium,color:i.$disabled?i.$theme.colors.contentTertiary:i.$theme.colors.contentPrimary,paddingTop:i.$theme.sizing.scale500,paddingBottom:i.$theme.sizing.scale300,paddingLeft:i.$theme.sizing.scale800,paddingRight:i.$theme.sizing.scale800,display:"flex",alignItems:"center",whiteSpace:"nowrap",gap:i.$theme.sizing.scale600})),Sk=D.styled("li",({$theme:i,$disabled:e})=>({cursor:e?"not-allowed":"pointer",paddingTop:i.sizing.scale200,paddingBottom:i.sizing.scale200,paddingLeft:i.sizing.scale1600,paddingRight:i.sizing.scale800,":hover":{backgroundColor:e?void 0:i.colors.menuFillHover},transitionProperty:"background-color",transitionDuration:i.animation.timing200,transitionTimingFunction:i.animation.easeOutCurve}));function Ck({phase:i,projectId:e,onSelect:t}){const[n,s]=D.useStyletron(),r=Ae.useNavigate(),{pathname:o}=Ae.useLocation(),l=o.split("/").filter(Boolean),a=l[1],u=l[2];return d.jsxRuntimeExports.jsx("ul",{className:n({listStyleType:"none",padding:0,margin:0}),children:i.entities.map(c=>{const h=c.state!=="active",f=!h&&a===i.id&&u===c.id;return d.jsxRuntimeExports.jsx(Sk,{$disabled:h,onClick:()=>{h||(t(),r(`/${e}/${i.id}/${c.id}`))},children:d.jsxRuntimeExports.jsx("span",{className:n({...s.typography.ParagraphSmall,fontWeight:f?"bold":void 0,color:h?s.colors.contentTertiary:void 0}),children:d.capitalizeFirstLetter(c.name)})},c.id)})})}function wk({phases:i,projectId:e,topLevelLinks:t}){const[n,s]=D.useStyletron(),[r,o]=j.useState(!1);return d.jsxRuntimeExports.jsxs(d.jsxRuntimeExports.Fragment,{children:[d.jsxRuntimeExports.jsx(_.Button,{onClick:()=>o(!0),kind:_.KIND.secondary,size:_.SIZE.mini,shape:_.SHAPE.pill,startEnhancer:()=>d.jsxRuntimeExports.jsx(d.Icon,{name:"menu",title:""}),overrides:{BaseButton:{style:{paddingLeft:s.sizing.scale500,paddingRight:s.sizing.scale500}}},children:"Menu"}),d.jsxRuntimeExports.jsx(ou.Drawer,{isOpen:r,autoFocus:!0,onClose:()=>o(!1),anchor:ou.ANCHOR.left,overrides:{DrawerContainer:{style:{width:"375px"}},DrawerBody:{style:{display:"flex",flexDirection:"column",justifyContent:"flex-start",marginLeft:0,marginRight:0,marginBottom:0,marginTop:"44px"}}},children:d.jsxRuntimeExports.jsxs("nav",{className:n({display:"flex",flexDirection:"column",gap:s.sizing.scale400}),children:[t&&t.length>0&&d.jsxRuntimeExports.jsxs("div",{children:[d.jsxRuntimeExports.jsx("ul",{className:n({listStyle:"none",margin:0,padding:0}),children:t.map(l=>d.jsxRuntimeExports.jsx("li",{children:d.jsxRuntimeExports.jsxs(yk,{to:l.path,onClick:()=>o(!1),children:[l.label,d.jsxRuntimeExports.jsx(d.Icon,{name:"chevronRight",title:""})]})},l.path))}),d.jsxRuntimeExports.jsx("hr",{className:n({borderTop:`1px solid ${s.colors.borderOpaque}`,borderBottom:0,margin:0})})]}),d.jsxRuntimeExports.jsx("span",{className:n({...s.typography.HeadingXSmall,paddingLeft:s.sizing.scale800,paddingRight:s.sizing.scale800}),children:e}),i.map(l=>d.jsxRuntimeExports.jsxs("div",{children:[d.jsxRuntimeExports.jsxs(vk,{$disabled:l.state==="disabled",children:[l.icon&&d.jsxRuntimeExports.jsx(d.Icon,{name:l.icon,size:"16px",title:""}),l.name,l.state==="comingSoon"&&d.jsxRuntimeExports.jsx(d.Tag,{size:"xSmall",closeable:!1,children:"Coming soon"})]}),d.jsxRuntimeExports.jsx(Ck,{phase:l,projectId:e,onSelect:()=>o(!1)})]},l.id))]})})]})}function Ek(){const[i,e]=j.useState(!1),t=j.useCallback(()=>{const n=window.scrollY>0;n!==i&&e(n)},[i]);return j.useEffect(()=>(window.addEventListener("scroll",t),()=>window.removeEventListener("scroll",t)),[t]),{isScrolled:i}}function Rk({categories:i,topLevelLinks:e}){const[t,n]=D.useStyletron(),{projectId:s,phase:r,entityId:o}=d.useStudioParams("base"),l=r===d.Phase.Project,a=i.flatMap(c=>c.phases),{isScrolled:u}=Ek();return d.jsxRuntimeExports.jsx(bk,{$scrolled:u,children:d.jsxRuntimeExports.jsx(an.Grid,{gridColumns:1,gridGutters:0,gridGaps:0,children:d.jsxRuntimeExports.jsx(an.Cell,{children:d.jsxRuntimeExports.jsxs("div",{className:t({display:"flex",alignItems:"center",gap:n.sizing.scale600}),children:[d.jsxRuntimeExports.jsx(wk,{phases:a,projectId:s,topLevelLinks:e}),d.jsxRuntimeExports.jsxs(om.Breadcrumbs,{overrides:{Root:{style:{color:n.colors.contentPrimary},props:{"data-tracking-name":"breadcrumb-bar"}}},children:[d.jsxRuntimeExports.jsx(gs,{to:"/","data-tracking-name":"home",children:"Home"}),d.jsxRuntimeExports.jsx(kk,{}),!l&&d.jsxRuntimeExports.jsx(Ak,{categories:i}),!l&&d.jsxRuntimeExports.jsx(Tk,{categories:i}),!l&&d.jsxRuntimeExports.jsx(Mk,{categories:i}),!l&&o&&d.jsxRuntimeExports.jsx(jk,{})]})]})})})})}function kk(){const{projectId:i,phase:e}=d.useStudioParams("base");return e===d.Phase.Project?d.jsxRuntimeExports.jsx("span",{children:i}):d.jsxRuntimeExports.jsx(gs,{to:`/${i}`,"data-tracking-name":"project",children:i})}function Ak({categories:i}){const{projectId:e,phase:t}=d.useStudioParams("base"),n=i.find(s=>s.phases.some(r=>r.id===t));return n?d.jsxRuntimeExports.jsx(gs,{to:`/${e}`,"data-tracking-name":"category",children:n.name}):null}function Tk({categories:i}){const{projectId:e,phase:t}=d.useStudioParams("base"),n=i.flatMap(r=>r.phases).find(r=>r.id===t),s=(n==null?void 0:n.name)??t;return d.jsxRuntimeExports.jsx(gs,{to:`/${e}/${t}`,"data-tracking-name":"phase",children:s})}function Mk({categories:i}){var l;const{projectId:e,phase:t,entity:n,entityId:s}=d.useStudioParams("base"),r=i.flatMap(a=>a.phases).find(a=>a.id===t),o=((l=r==null?void 0:r.entities.find(a=>a.id===n))==null?void 0:l.name)??n;return s?d.jsxRuntimeExports.jsx(gs,{to:`/${e}/${t}/${n}`,"data-tracking-name":"entity",children:o}):d.jsxRuntimeExports.jsx("span",{children:o})}function jk(){const{entityId:i}=d.useStudioParams("form-detail");return d.jsxRuntimeExports.jsx("span",{children:i})}function Ok({categories:i,topLevelLinks:e}){return d.jsxRuntimeExports.jsxs(d.jsxRuntimeExports.Fragment,{children:[d.jsxRuntimeExports.jsx(Rk,{categories:i,topLevelLinks:e}),d.jsxRuntimeExports.jsx(Ae.Outlet,{})]})}const Ik=[pf,wf,yf];function Pk(){return d.jsxRuntimeExports.jsxs(Ae.Routes,{children:[d.jsxRuntimeExports.jsx(Ae.Route,{index:!0,element:d.jsxRuntimeExports.jsx(Hi,{children:d.jsxRuntimeExports.jsx(Rx,{})})}),d.jsxRuntimeExports.jsx(Ae.Route,{path:"sandbox",element:d.jsxRuntimeExports.jsx(Hi,{children:d.jsxRuntimeExports.jsx(Dy,{})})}),d.jsxRuntimeExports.jsxs(Ae.Route,{element:d.jsxRuntimeExports.jsx(Ok,{categories:ob}),children:[d.jsxRuntimeExports.jsx(Ae.Route,{path:":projectId",element:d.jsxRuntimeExports.jsx(Hi,{children:d.jsxRuntimeExports.jsx(dm,{phases:Ik})})}),d.jsxRuntimeExports.jsx(Ae.Route,{path:":projectId/:phase/:entity/:entityId/:entityTab?",element:d.jsxRuntimeExports.jsx(Hi,{children:d.jsxRuntimeExports.jsx(fk,{})})}),d.jsxRuntimeExports.jsx(Ae.Route,{path:":projectId/:phase/:entity?",element:d.jsxRuntimeExports.jsx(Hi,{children:d.jsxRuntimeExports.jsx(xk,{})})})]})]})}function Za(i){return i instanceof d.Interpolation||d.StringInterpolation.isInterpolation(i)}function na(i){return Za(i)?!0:d.lodashExports.isArray(i)?i.some(na):d.isRecord(i)?d.lodashExports.values(i).some(na):!1}function $g(i){return d.lodashExports.mapValues(i,e=>{if(d.lodashExports.isNil(e)||Array.isArray(e))return e;if(!Za(e))return d.isRecord(e)?$g(e):e})}function Dk({children:i,value:e}){return d.jsxRuntimeExports.jsx(d.InterpolationContext.Provider,{value:e,children:i})}function eu({children:i,...e}){return d.jsxRuntimeExports.jsx(d.RepeatedLayoutContext.Provider,{value:e,children:i})}function Lk(){const{fieldRegistry:i}=fa(),e=Gr();return{fieldRegistry:i,change:e.change,submit:e.submit}}function tu({label:i="Add more",shape:e,onClick:t}){const[,n]=D.useStyletron();return d.jsxRuntimeExports.jsx(_.Button,{type:"button",kind:_.KIND.secondary,size:_.SIZE.compact,shape:e,startEnhancer:d.jsxRuntimeExports.jsx(d.Icon,{name:"plus",color:n.colors.contentPrimary,size:n.sizing.scale600}),overrides:{BaseButton:{style:{marginBottom:n.sizing.scale600,width:"260px"}}},onClick:t,children:i})}function Fk(i,e,t){const n={Popover:{props:{ignoreBoundary:!0}},Input:{props:{name:i}}};return e?D.mergeOverrides(n,{Tag:{props:{closeable:!1,disabled:!1}}}):t?D.mergeOverrides(n,{Input:{props:{readOnly:!0}},ControlContainer:{props:{onClick:()=>null},style:({$theme:s})=>({backgroundColor:s.colors.backgroundPrimary})},SelectArrow:{props:{size:0}},Tag:{props:{closeable:!1}}}):n}function Nk(i){return i?Array.isArray(i)?i:[i]:[]}function Qo(i){return JSON.stringify(i,(e,t)=>d.isRecord(t)?Object.fromEntries(Object.entries(t).sort(([n],[s])=>n.localeCompare(s))):t)}function Bk({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:u,labelEndEnhancer:c,placeholder:h,format:f,parse:p,options:g,visibleOptionLimit:m,isLoading:x=!1,clearable:y=!0,searchable:b=!0,multi:v=!1,creatable:w=!1}){const{input:S,meta:E}=ot(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p}),{baseUiOptions:A,findByValue:O,findByKey:R}=j.useMemo(()=>{const I=new Map;return{baseUiOptions:g.map(P=>{const U=Qo(P.id);return I.set(U,P),{id:U,label:P.label,disabled:P.disabled}}),findByValue:P=>I.get(Qo(P)),findByKey:P=>I.get(P)}},[g]);j.useEffect(()=>{if(x||w)return;const I=S.value;if(!(!I||Array.isArray(I)&&I.length===0))if(v){const W=I,P=W.filter(U=>O(U));P.length!==W.length&&S.onChange(P)}else O(I)||S.onChange("")},[O,x]);const H=I=>{var P;const W=I.value;v?S.onChange(W.map(U=>{var Q;return((Q=R(U.id))==null?void 0:Q.id)??U.id})):W.length>0?S.onChange(((P=R(W[0].id))==null?void 0:P.id)??W[0].id):S.onChange("")},N=j.useMemo(()=>{const I=[];for(const W of Nk(S.value)){const P=Qo(W),U=R(P);U?I.push({id:P,label:U.label,disabled:U.disabled}):w&&I.push({id:P,label:String(W)})}return I},[S.value,R,w]);return d.jsxRuntimeExports.jsx(Je,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:E.touched&&E.error?E.error:void 0,children:d.jsxRuntimeExports.jsx(Ji.Select,{id:i,value:N,options:A,onChange:H,onBlur:S.onBlur,onFocus:S.onFocus,placeholder:!l&&!o?h:"",disabled:l,clearable:!l&&!o&&y,searchable:b,multi:v,overrides:Fk(i,l,o),creatable:w,filterOptions:(I,W,P,U)=>Ji.filterOptions(I,W,P,U).slice(0,m),isLoading:x,getOptionLabel:({option:I})=>I.label})})}const Vk=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:u,labelEndEnhancer:c,format:h,parse:f,checkboxLabel:p,toggle:g=!1})=>{const{input:m,meta:x}=ot(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:h,parse:f}),y=v=>{m.onChange(v.currentTarget.checked)},b=p??(m.value?"Enabled":"Disabled");return d.jsxRuntimeExports.jsx(Je,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:x.touched&&x.error?x.error:void 0,children:d.jsxRuntimeExports.jsx(Ti.Checkbox,{checked:m.value??!1,onChange:o?void 0:y,onBlur:m.onBlur,onFocus:m.onFocus,disabled:l,checkmarkType:g?Ti.STYLE_TYPE.toggle_round:Ti.STYLE_TYPE.default,labelPlacement:Ti.LABEL_PLACEMENT.right,overrides:{Label:{style:({$theme:v})=>({fontSize:v.sizing.scale550})},Root:{style:o?{cursor:"default"}:{}}},children:b})})},zk={RadioMarkOuter:{style:({$disabled:i,$theme:e})=>i?{backgroundColor:e.colors.tickFillSelected}:{}}},$k={Root:{style:({$selected:i,$theme:e})=>({display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"flex-start",flex:"1 1 0%",":disabled":{opacity:.5,...i?{boxShadow:`inset 0px 0px 0px 3px ${e.colors.borderSelected}`}:{}}})},HeaderContainer:{style:{width:"100%",marginBottom:0}}},_k=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:u,labelEndEnhancer:c,format:h,parse:f,options:p})=>{const[,g]=D.useStyletron(),{input:m,meta:x}=ot(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:h,parse:f}),y=j.useMemo(()=>p.findIndex(v=>v.value===m.value),[p,m]),b=j.useCallback((v,w)=>{v.preventDefault(),v.stopPropagation(),m.onChange(p[w].value)},[m,p]);return d.jsxRuntimeExports.jsx(Je,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:x.touched&&x.error?x.error:void 0,children:d.jsxRuntimeExports.jsx(wi.TileGroup,{kind:wi.TILE_GROUP_KIND.singleSelect,onClick:b,selected:y,disabled:l||o,overrides:zk,children:p.map(v=>d.jsxRuntimeExports.jsx(wi.Tile,{tileKind:wi.TILE_KIND.selection,leadingContent:()=>d.jsxRuntimeExports.jsx(bt.LabelMedium,{$style:{textAlign:"left"},children:v.label}),headerAlignment:wi.ALIGNMENT.left,bodyAlignment:wi.ALIGNMENT.left,overrides:$k,children:d.jsxRuntimeExports.jsx(wi.StyledParagraph,{$style:{textAlign:"left",marginBottom:g.sizing.scale600},children:v.description})},String(v.value)))})})},Hk=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:u,labelEndEnhancer:c,format:h,parse:f,options:p,align:g=oo.ALIGN.horizontal})=>{var v;const{input:m,meta:x}=ot(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:h,parse:f}),y=p.every(({value:w})=>typeof w=="boolean"),b=j.useCallback(w=>{const S=w.currentTarget.value;m.onChange(y?S==="true":S)},[m,y]);return o?d.jsxRuntimeExports.jsx(Je,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:x.touched&&x.error?x.error:void 0,children:d.jsxRuntimeExports.jsx(ht.Input,{id:m.name,readOnly:!0,value:((v=p.find(w=>w.value===m.value))==null?void 0:v.label)??"",overrides:{InputContainer:{style:({$theme:w})=>({backgroundColor:w.colors.backgroundPrimary})}}})}):d.jsxRuntimeExports.jsx(Je,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:x.touched&&x.error?x.error:void 0,children:d.jsxRuntimeExports.jsx(oo.RadioGroup,{name:m.name,value:typeof m.value=="boolean"?String(m.value):m.value,align:g,disabled:l,onChange:b,onBlur:m.onBlur,onFocus:m.onFocus,overrides:{RadioGroupRoot:{style:({$theme:w})=>({gap:w.sizing.scale600})}},children:p.map(w=>d.jsxRuntimeExports.jsx(oo.Radio,{value:typeof w.value=="boolean"?String(w.value):w.value,disabled:w.disabled,overrides:{RadioMarkOuter:{style:({$theme:S})=>({height:S.sizing.scale600,width:S.sizing.scale600})},RadioMarkInner:{style:({$checked:S,$theme:E})=>({height:S?E.sizing.scale100:E.sizing.scale400,width:S?E.sizing.scale100:E.sizing.scale400,transform:"none"})}},children:w.label},String(w.value)))})})},Gk=i=>i.options.some(t=>!!t.description)?d.jsxRuntimeExports.jsx(_k,{...i}):d.jsxRuntimeExports.jsx(Hk,{...i}),Wk=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,description:o,caption:l,labelEndEnhancer:a,format:u,parse:c,placeholder:h,urlName:f})=>{const{input:p,meta:g}=ot(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:u,parse:c}),m=p.value;return d.jsxRuntimeExports.jsx(Je,{label:e,required:s,description:o,labelEndEnhancer:a,caption:l,error:g.touched&&g.error?g.error:void 0,children:d.isNavigableUrl(m)?d.jsxRuntimeExports.jsx(d.Link,{href:m,children:d.jsxRuntimeExports.jsx(d.TruncatedText,{children:f??e??m})}):d.jsxRuntimeExports.jsx("span",{children:h})})},Uk=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:u,caption:c,labelEndEnhancer:h,format:f,parse:p})=>{const{input:g,meta:m}=ot(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p});return d.jsxRuntimeExports.jsx(Je,{label:e,required:s,description:u,labelEndEnhancer:h,caption:c,error:m.touched&&m.error?m.error:void 0,children:d.jsxRuntimeExports.jsx(ht.Input,{id:g.name,type:"number",value:g.value==null?"":String(g.value),name:g.name,onChange:x=>g.onChange(qk(x.currentTarget.value)),onBlur:g.onBlur,onFocus:g.onFocus,placeholder:a,readOnly:o,disabled:l})})};function qk(i){if(i==="")return;const e=Number(i);return isNaN(e)?void 0:e}const Kk=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,disabled:o,description:l,caption:a,labelEndEnhancer:u,format:c,parse:h,options:f})=>{const[p,g]=D.useStyletron(),{input:m,meta:x}=ot(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:c,parse:h}),{value:y=[],onChange:b}=m,v=j.useCallback(S=>{const E=y.includes(S)?y.filter(A=>A!==S):[...y,S];b(E)},[y,b]),w=f.some(S=>S.description);return d.jsxRuntimeExports.jsx(Je,{label:e,required:s,description:l,labelEndEnhancer:u,caption:a,error:x.touched&&x.error?x.error:void 0,children:f.length===0?d.jsxRuntimeExports.jsx("span",{children:"No options available"}):d.jsxRuntimeExports.jsx("div",{className:p({display:"flex",flexDirection:w?"column":"row",flexWrap:w?void 0:"wrap",gap:g.sizing.scale600}),children:f.map(S=>d.jsxRuntimeExports.jsxs(Ti.Checkbox,{checked:y.includes(S.id),onChange:()=>v(S.id),disabled:o,overrides:{Label:{style:({$theme:E})=>({fontSize:E.sizing.scale550})}},children:[S.label,S.description&&d.jsxRuntimeExports.jsx(d.DescriptionText,{children:S.description})]},S.id))})})};var ln=(i=>(i.EPOCH_SECONDS="epoch",i.ISO_DATE_STRING="iso",i))(ln||{});function Yk(i=ln.ISO_DATE_STRING){const e=i===ln.EPOCH_SECONDS?n=>n?d.getDateFromEpochSeconds(parseInt(n)):null:n=>n?new Date(n):null,t=i===ln.EPOCH_SECONDS?n=>n?String(d.getEpochSecondsFromDate(n)):"":n=>n?n.toISOString():"";return{format:n=>Xk(e(n)),parse:n=>t(Qk(n))}}function Xk(i){if(!i)return null;const e=i.getTimezoneOffset();return new Date(i.getTime()+e*60*1e3)}function Qk(i){if(!i)return i;const e=i.getTimezoneOffset();return new Date(i.getTime()-e*60*1e3)}const Jk=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,placeholder:l,disabled:a,description:u,caption:c,labelEndEnhancer:h,noFutureDate:f,dateFormat:p=ln.ISO_DATE_STRING})=>{const{format:g,parse:m}=Yk(p),{input:x,meta:y}=ot(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:g,parse:m});return d.jsxRuntimeExports.jsx(Je,{label:e,required:s,description:u,labelEndEnhancer:h,caption:c,error:y.touched&&y.error?y.error:void 0,children:d.jsxRuntimeExports.jsx(lm.DatePicker,{id:x.name,value:x.value,onChange:({date:b})=>{d.lodashExports.isNil(b)&&Zk(x.value)||x.onChange(b)},placeholder:!a&&!o?l??"MM/dd/yyyy":"",formatString:"MM/dd/yyyy",mask:"99/99/9999",onOpen:x.onFocus,onRangeChange:x.onBlur,onClose:x.onBlur,maxDate:f?new Date:void 0,disabled:a,overrides:o?{Input:{props:{readOnly:!0,onFocus:()=>{},overrides:{InputContainer:{style:({$theme:b})=>({backgroundColor:b.colors.backgroundPrimary})}}}}}:void 0})})};function Zk(i){return d.lodashExports.isNil(i)||i===""||d.lodashExports.isArray(i)&&!i.length}const eA=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:u,caption:c,labelEndEnhancer:h,format:f,parse:p,rows:g,maxLength:m})=>{var S;const{input:x,meta:y}=ot(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p}),[b,v]=D.useStyletron(),w=((S=x.value)==null?void 0:S.length)??0;return d.jsxRuntimeExports.jsx(Je,{label:e,required:s,description:u,labelEndEnhancer:h,caption:c,error:y.touched&&y.error?y.error:void 0,counter:m?{length:w,maxLength:m}:void 0,children:o?d.jsxRuntimeExports.jsx("div",{className:b({...v.typography.font300,minHeight:String(v.typography.font300.lineHeight),border:`${v.sizing.scale0} solid ${v.colors.borderOpaque}`,borderRadius:v.borders.radius300,paddingTop:v.sizing.scale400,paddingBottom:v.sizing.scale400,paddingLeft:v.sizing.scale550,paddingRight:v.sizing.scale550}),children:d.jsxRuntimeExports.jsx(d.Markdown,{children:x.value})}):d.jsxRuntimeExports.jsx(Ch.Textarea,{id:x.name,name:x.name,value:x.value,onChange:E=>x.onChange(E.currentTarget.value),onBlur:x.onBlur,onFocus:x.onFocus,placeholder:a,disabled:l,rows:g,maxLength:m,overrides:{Input:{style:{resize:"vertical"}}}})})},_g=({title:i,description:e,tooltip:t,collapsible:n=!1,expanded:s,onToggle:r,endEnhancer:o,overrides:l={},children:a})=>{const[u,c]=D.useStyletron(),h=i&&t?d.jsxRuntimeExports.jsxs("div",{className:u({display:"flex",alignItems:"center",gap:c.sizing.scale100}),children:[i,d.jsxRuntimeExports.jsx(d.HelpTooltip,{text:t})]}):i,f=h&&o?d.jsxRuntimeExports.jsxs("div",{className:u({display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"}),children:[h,o]}):h,p=e?d.jsxRuntimeExports.jsx(d.Markdown,{children:e}):void 0;return n?d.jsxRuntimeExports.jsx(xa,{title:f,description:p,expanded:s,defaultExpanded:!1,onToggle:r,overrides:{Content:{style:{paddingTop:0}}},children:a}):d.jsxRuntimeExports.jsx(d.Box,{title:f,description:p,overrides:D.mergeOverrides({BoxContainer:{style:{marginBottom:c.sizing.scale600}}},l),children:a})},Hg=({name:i,span:e,children:t})=>{const[n,s]=D.useStyletron(),r=j.Children.toArray(t),o=(e==null?void 0:e.reduce((l,a)=>l+a,0))??r.length;return d.jsxRuntimeExports.jsxs("div",{className:n({flexGrow:1,boxSizing:"border-box"}),children:[i&&d.jsxRuntimeExports.jsx("div",{className:n(s.typography.LabelMedium),children:i}),d.jsxRuntimeExports.jsx(an.Grid,{gridColumns:o,gridMargins:[0],gridMaxWidth:0,children:r.map((l,a)=>d.jsxRuntimeExports.jsx(an.Cell,{span:e==null?void 0:e[a],children:l},a))})]})},tA=({children:i})=>{const[e]=D.useStyletron();return d.jsxRuntimeExports.jsx("div",{className:e({boxSizing:"border-box"}),children:i})},iA=({title:i,kind:e="info",dismissible:t=!1,content:n})=>{const[s,r]=j.useState(!1),[o,l]=D.useStyletron();return s?null:d.jsxRuntimeExports.jsx(d.Banner,{title:i,artwork:{type:or.ARTWORK_TYPE.icon,icon:()=>d.jsxRuntimeExports.jsx(d.Icon,{name:e==="info"?"circleI":"circleExclamation",size:l.sizing.scale800})},kind:e,action:t?{label:"Dismiss",icon:()=>d.jsxRuntimeExports.jsx(d.Icon,{name:"x-filled"}),onClick:()=>r(!0)}:void 0,children:typeof n=="string"?d.jsxRuntimeExports.jsx(d.Markdown,{children:n}):n})},nA=({name:i,description:e,children:t})=>{const[n,s]=D.useStyletron();return d.jsxRuntimeExports.jsxs("section",{children:[d.jsxRuntimeExports.jsxs("div",{className:n({display:"flex",alignItems:"flex-start",flexDirection:"column",gap:s.sizing.scale300,marginBottom:s.sizing.scale600}),children:[d.jsxRuntimeExports.jsx(bt.HeadingSmall,{margin:0,children:i}),e&&d.jsxRuntimeExports.jsx(bt.ParagraphSmall,{margin:0,children:d.jsxRuntimeExports.jsx(d.Markdown,{children:e})})]}),t]})};function Br(){return Br=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},Br.apply(null,arguments)}function Sh(i,e){if(i==null)return{};var t={};for(var n in i)if({}.hasOwnProperty.call(i,n)){if(e.indexOf(n)!==-1)continue;t[n]=i[n]}return t}var sA=function(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&!e.some(function(n,s){return n!==t[s]})};function rA(i){var e=j.useRef();return e.current||(e.current=i()),e.current}var oA=["length"],lA=["meta","input"],aA=ha.reduce(function(i,e){return i[e]=!0,i},{}),uA=function(e,t){var n={},s=n.subscription,r=s===void 0?aA:s,o=n.defaultValue,l=n.initialValue,a=n.isEqual,u=a===void 0?sA:a,c=n.validate,h=Gr("useFieldArray"),f=h.mutators,p=!!(f&&f.push&&f.pop);if(!p)throw new Error("Array mutators not found. You need to provide the mutators from final-form-arrays to your form");var g=j.useMemo(function(){return Object.keys(f).reduce(function(O,R){return O[R]=function(){for(var H=arguments.length,N=new Array(H),I=0;I<H;I++)N[I]=arguments[I];return f[R].apply(f,[e].concat(N))},O},{})},[e,f]),m=rA(function(){return function(O,R,H){if(c){var N=c(O,R,H);if(!N||Array.isArray(N))return N;var I=[];return I[Zi]=N,I}}}),x=ef(e,{subscription:Br({},r,{length:!0}),defaultValue:o,initialValue:l,isEqual:u,validate:m,format:function(R){return R}}),y=x.meta,b=y.length,v=Sh(y,oA),w=x.input,S=Sh(x,lA),E=function(R){for(var H=b||0,N=0;N<H;N++)R(e+"["+N+"]",N)},A=function(R){for(var H=b||0,N=[],I=0;I<H;I++)N.push(R(e+"["+I+"]",I));return N};return{fields:Br({name:e,forEach:E,length:b||0,map:A},g,S,{value:w.value}),meta:v}};function Gg(i,{minItems:e=0,readOnly:t=!1}={}){const{fields:n}=uA(i),s=j.useRef(Array.from({length:n.length??0},()=>crypto.randomUUID()));j.useEffect(()=>{const a=n.length??0;if(a<e)for(let u=a;u<e;u++)s.current.push(crypto.randomUUID()),n.push({})},[n,e]);const r=(n.length??0)>e&&!t,o=()=>{s.current.push(crypto.randomUUID()),n.push({})},l=a=>{r&&(s.current.splice(a,1),n.remove(a))};return{entries:n.map((a,u)=>({id:s.current[u],indexedFieldPath:a})),handleItemAdd:o,remove:l,isRemovable:r}}function cA({rootFieldPath:i,minItems:e=0,readOnly:t=!1,children:n,name:s,span:r,addLabel:o="Add more"}){const[l,a]=D.useStyletron(),{entries:u,handleItemAdd:c,remove:h,isRemovable:f}=Gg(i,{minItems:e,readOnly:t});return d.jsxRuntimeExports.jsxs(d.jsxRuntimeExports.Fragment,{children:[u.map(({id:p,indexedFieldPath:g},m)=>{const x=n(g,m),y=j.isValidElement(x)&&x.type===j.Fragment?x.props.children:x;return d.jsxRuntimeExports.jsx(eu,{index:m,rootFieldPath:i,children:d.jsxRuntimeExports.jsxs("div",{className:l({display:"flex",alignItems:"end",gap:a.sizing.scale300}),children:[d.jsxRuntimeExports.jsx(Hg,{name:s,span:r,children:y}),f&&d.jsxRuntimeExports.jsx(_.Button,{type:"button",kind:_.KIND.tertiary,shape:_.SHAPE.circle,size:_.SIZE.default,"aria-label":"Remove",onClick:()=>h(m),children:d.jsxRuntimeExports.jsx(d.Icon,{name:"deleteAlt",kind:d.IconKind.SECONDARY})})]})},p)}),!t&&d.jsxRuntimeExports.jsx(tu,{label:o,onClick:c})]})}function hA({rootFieldPath:i,groupLabel:e,addLabel:t,minItems:n=0,readOnly:s=!1,children:r,description:o,tooltip:l,collapsible:a}){const{entries:u,handleItemAdd:c,remove:h,isRemovable:f}=Gg(i,{minItems:n,readOnly:s}),p=t??(e?`Add ${e.toLowerCase()}`:"Add more"),[g,m]=D.useStyletron();return d.jsxRuntimeExports.jsxs("div",{className:g({display:"flex",flexDirection:"column",gap:m.sizing.scale800}),children:[u.map(({id:x,indexedFieldPath:y},b)=>d.jsxRuntimeExports.jsx(eu,{index:b,rootFieldPath:i,children:d.jsxRuntimeExports.jsx(_g,{title:e?`${e} ${b+1}`:void 0,description:o,tooltip:l,collapsible:a,endEnhancer:f&&d.jsxRuntimeExports.jsx(_.Button,{type:"button",kind:_.KIND.secondary,shape:_.SHAPE.pill,size:_.SIZE.compact,startEnhancer:d.jsxRuntimeExports.jsx(d.Icon,{name:"trashCan",kind:d.IconKind.PRIMARY}),"aria-label":"Remove",onClick:()=>h(b),children:"Remove"}),overrides:{BoxContainer:{style:{marginBottom:0}}},children:r(y,b)})},x)),!s&&d.jsxRuntimeExports.jsx(tu,{label:p,shape:_.SHAPE.pill,onClick:c})]})}var Wg=(i=>(i.Admin="admin",i.Viewer="viewer",i))(Wg||{});function fA({dependencies:i}){var e;return d.jsxRuntimeExports.jsx(d.ThemeProvider,{icons:i.theme.icons,children:d.jsxRuntimeExports.jsx(Yg.LayersManager,{zIndex:200,children:d.jsxRuntimeExports.jsx(Xg.SnackbarProvider,{children:d.jsxRuntimeExports.jsx(d.ServiceProvider,{...i.service,children:d.jsxRuntimeExports.jsx(d.ErrorProvider,{...i.error,children:d.jsxRuntimeExports.jsx(d.IconProvider,{icons:i.theme.icons,children:d.jsxRuntimeExports.jsxs(d.UserProvider,{...i.user??{timeZone:d.TimeZone.Local},children:[d.jsxRuntimeExports.jsx(hm,{links:(e=i.navigationBar)==null?void 0:e.links}),d.jsxRuntimeExports.jsx(Pk,{})]})})})})})})})}exports.ApplicationError=d.ApplicationError;exports.BooleanCell=d.BooleanCell;exports.CellType=d.CellType;exports.DateCell=d.DateCell;exports.DefaultCellRenderer=d.DefaultCellRenderer;exports.DescriptionCell=d.DescriptionCell;exports.DescriptionHierarchy=d.DescriptionHierarchy;exports.GrpcStatusCode=d.GrpcStatusCode;exports.Interpolation=d.Interpolation;exports.LinkCell=d.LinkCell;exports.MultiCell=d.MultiCell;exports.Phase=d.Phase;exports.StateCell=d.StateCell;exports.StringInterpolation=d.StringInterpolation;exports.TagCell=d.TagCell;exports.TextCell=d.TextCell;exports.TimeZone=d.TimeZone;exports.TypeCell=d.TypeCell;exports.capitalizeFirstLetter=d.capitalizeFirstLetter;exports.cellTooltipHoc=d.cellTooltipHoc;exports.getDateFromEpochSeconds=d.getDateFromEpochSeconds;exports.getEpochSecondsFromDate=d.getEpochSecondsFromDate;exports.getObjectSymbols=d.getObjectSymbols;exports.getObjectValue=d.getObjectValue;exports.isAbsoluteUrl=d.isAbsoluteUrl;exports.isNavigableUrl=d.isNavigableUrl;exports.isRecord=d.isRecord;exports.parseIsoString=d.parseIsoString;exports.safeStringify=d.safeStringify;exports.sentenceCaseEnumValue=d.sentenceCaseEnumValue;exports.timestampToString=d.timestampToString;exports.toFlatDotPathMap=d.toFlatDotPathMap;exports.useCellStyles=d.useCellStyles;exports.useCellToString=d.useCellToString;exports.useErrorNormalizer=d.useErrorNormalizer;exports.useGetCellRenderer=d.useGetCellRenderer;exports.useInterpolationResolver=d.useInterpolationResolver;exports.useRepeatedLayoutContext=d.useRepeatedLayoutContext;exports.useStudioMutation=d.useStudioMutation;exports.useStudioParams=d.useStudioParams;exports.useStudioQuery=d.useStudioQuery;exports.useUrlQueryString=d.useUrlQueryString;exports.ActionHierarchy=hi;exports.AddButton=tu;exports.ArrayFormGroup=hA;exports.ArrayFormRow=cA;exports.BooleanField=Vk;exports.CheckboxField=Kk;exports.CoreApp=fA;exports.DateField=Jk;exports.DateFormat=ln;exports.DetailView=zg;exports.DetailViewPages=Vg;exports.Execution=Pg;exports.FilterMode=$r;exports.Form=pa;exports.FormBanner=iA;exports.FormColumn=tA;exports.FormControl=Je;exports.FormDialog=lf;exports.FormErrorBanner=rf;exports.FormGroup=_g;exports.FormRow=Hg;exports.FormStep=nA;exports.FunctionInterpolation=bf;exports.InterpolationProvider=Dk;exports.MarkdownField=eA;exports.NumberField=Uk;exports.RadioField=Gk;exports.RepeatedLayoutProvider=eu;exports.SelectField=Bk;exports.StringField=da;exports.SubmitButton=of;exports.TASK_STATE=oe;exports.Table=_r;exports.TaskListRenderer=ll;exports.TaskStepCard=Mf;exports.TextareaField=af;exports.UrlField=Wk;exports.UserRole=Wg;exports.clearUnresolvedInterpolations=$g;exports.hasInterpolationProperty=na;exports.interpolate=Us;exports.isInterpolation=Za;exports.useField=ot;exports.useForm=Lk;exports.useFormState=ga;exports.useLocalStorageTableState=Ja;exports.useTableSelectionContext=J0;
22
+ */function Co(i,e){return i?O0(i)?Se.createElement(i,e):i:null}function O0(i){return I0(i)||typeof i=="function"||j0(i)}function I0(i){return typeof i=="function"&&(()=>{const e=Object.getPrototypeOf(i);return e.prototype&&e.prototype.isReactComponent})()}function j0(i){return typeof i=="object"&&typeof i.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(i.$$typeof.description)}function P0(i){const e={state:{},onStateChange:()=>{},renderFallbackValue:null,...i},[t]=Se.useState(()=>({current:v0(e)})),[n,s]=Se.useState(()=>t.current.initialState);return t.current.setOptions(r=>({...r,...i,state:{...n,...i.state},onStateChange:o=>{s(o),i.onStateChange==null||i.onStateChange(o)}})),t.current}function D0(i){const[e,t]=M.useState(-1),n=M.useRef(null),s=()=>{const r=n.current;if(!r)return;const{scrollWidth:o,clientWidth:l,scrollLeft:a}=r,u=o-l;t(u===0?-1:Math.round(a)/u)};return M.useEffect(()=>{const r=n.current;if(!r)return;s();const o=new ResizeObserver(s);return o.observe(r),()=>o.disconnect()},[i]),{scrollRatio:e,tableRef:n,handleScrollRatioUpdate:s}}var Wr=(i=>(i.NONE="none",i.CLIENT="client",i.SERVER="server",i))(Wr||{});const L0=15,Eu=15,F0=[{id:Eu,label:String(Eu)},{id:25,label:String(25)},{id:50,label:String(50)}],gl="__JOIN__",oi={globalFilter:"",columnFilters:[],pagination:{pageSize:L0},sorting:[],grouping:[],columnOrder:[],columnVisibility:{},rowSelectionEnabled:!1},Xh="ma-studio-table-settings";function va(i,e){var n;const t=((n=e==null?void 0:e.typeMeta)==null?void 0:n.kind)??"";return t in i?{...f.lodashExports.omit(i,t),...i[t]}:i}function Sa(i,e,t){const n="original"in e?e.original:e.record,s=va(i,n),r=s.id||t,o=e.getValue(r)??"";return"items"in s?typeof o!="string"?(console.warn(`Expected string from normalizeColumnAccessor for multi-cell column ${r}, got:`,typeof o,o),f.safeStringify(o).split(gl).at(0)??""):o.split(gl).at(0)??"":o}function N0({preFilteredRows:i,column:e}){const t=f.useCellToString();return M.useMemo(()=>{const n={},s={};return i.forEach(r=>{const o=Sa(e,r,e.id);if(o==null)return;const l=t({value:o,record:r.record,column:e}),a=l==null&&o===""?"":l;if(a==null||a in n)return;const u=f.safeStringify(o);n[a]=o,s[u]=a}),[s,n]},[i,t,e])}function B0({column:i,close:e,getFilterValue:t,setFilterValue:n,preFilteredRows:s}){const r=ma.CategoricalColumn({title:"",mapDataToValue:()=>""}).renderFilter,[o,l]=N0({preFilteredRows:s,column:i}),a=Object.keys(l),u=(t()??[]).map(d=>o[f.safeStringify(d)]).filter(Boolean),c=a.sort((d,p)=>{const g=u.includes(d),m=u.includes(p);return g===m?d.localeCompare(p):g?-1:1}),h=({selection:d,exclude:p})=>{const m=(p?a.filter(x=>!d.has(x)):Array.from(d)).map(x=>l[x]);n(m.length>0?m:void 0),e()};return f.jsxRuntimeExports.jsx(r,{data:c,setFilter:h,close:e,filterParams:{description:"",selection:new Set(u),exclude:!1}})}const V0=new Date("2022-01-01T00:00:00"),_0=i=>{var e;return i?{...i,range:((e=i==null?void 0:i.range)==null?void 0:e.map(t=>new Date(t)))??[]}:{operation:"",range:[],selection:[],description:"",exclude:!1}};function z0({close:i,getFilterValue:e,setFilterValue:t}){const n=ma.DatetimeColumn({title:"",mapDataToValue:()=>new Date}).renderFilter,s=[V0,new Date],r=_0(e());return f.jsxRuntimeExports.jsx(n,{data:s,setFilter:t,close:i,filterParams:r})}function Qh(i){switch(i){case f.CellType.DATE:return z0;default:return B0}}function $0(){const i=f.useCellToString();return e=>{const t=o=>!(o!=null&&o.length);return{isFilterInactive:t,getActiveFilter:o=>!Array.isArray(o)||!(o!=null&&o.length)?"":o.map(l=>i({record:{},value:l,column:e})).join(", "),getFilterSummary:o=>!Array.isArray(o)||!(o!=null&&o.length)?"":`(${o.length}) ${e.label?`${e.label}: `:""}${o.map(l=>i({record:{},value:l,column:e})).join(", ")}`,buildTableFilterFn:()=>{const o=(l,a,u)=>t(u)?!0:u.includes(Sa(e,l,a));return o.autoRemove=t,o}}}}function H0(){return i=>{const e=o=>{var l;return{...o,range:((l=o==null?void 0:o.range)==null?void 0:l.map(a=>new Date(a)))||[]}},t=o=>{var l,a;return!((l=o==null?void 0:o.range)!=null&&l.length)&&!((a=o==null?void 0:o.selection)!=null&&a.length)},n=o=>t(o)?"":(o==null?void 0:o.description)??"";return{isFilterInactive:t,getActiveFilter:n,getFilterSummary:o=>t(o)?"":`${i.label?`${i.label}: `:""}${n(o)}`,buildTableFilterFn:()=>{const o=(l,a,u)=>{if(t(u)||u.range.length===1)return!0;const c=u.range.some(p=>typeof p=="string")?e(u):u,h=Sa(i,l,a),d=f.getDateFromEpochSeconds(typeof h=="number"?h:parseFloat(String(h)));return ma.DatetimeColumn({title:"",mapDataToValue:()=>new Date}).buildFilter(c)(d)};return o.autoRemove=t,o}}}}function Jh(){const i=$0(),e=H0();return t=>t.type===f.CellType.DATE?e(t):i(t)}function G0(i){const{column:e,preFilteredRows:t}=i,[n,s]=D.useStyletron(),[r,o]=M.useState(!1),[l,a]=M.useState(!1),[u,c]=M.useState(null),d=Jh()({id:e.id,type:e.type,label:e.label}),p=()=>{c(setTimeout(()=>a(!0),1e3))},g=()=>{u&&clearTimeout(u),a(!1)},m=Qh(e.type);return f.jsxRuntimeExports.jsx(Nt.StatefulPopover,{placement:Nt.PLACEMENT.bottomLeft,content:({close:x})=>f.jsxRuntimeExports.jsx(m,{column:e,close:x,getFilterValue:e.getFilterValue,setFilterValue:e.setFilterValue,preFilteredRows:t}),onOpen:()=>o(!0),onClose:()=>o(!1),children:f.jsxRuntimeExports.jsx(ur.Tag,{kind:ur.KIND.blue,overrides:r?{Root:{style:({$theme:x})=>({borderColor:x.colors.accent,borderWidth:"2px"})}}:{},onActionClick:()=>e.setFilterValue(void 0),children:f.jsxRuntimeExports.jsx(Pi.Tooltip,{content:()=>f.jsxRuntimeExports.jsx("div",{className:n({maxWidth:s.sizing.scale4800,overflowWrap:"break-word"}),children:d.getActiveFilter(e.getFilterValue())}),placement:Nt.PLACEMENT.top,isOpen:l,onMouseEnter:p,onMouseLeave:g,showArrow:!0,children:f.jsxRuntimeExports.jsx(f.TruncatedText,{children:d.getFilterSummary(e.getFilterValue())})})})})}function W0(i){const{filterableColumns:e,preFilteredRows:t}=i,[n,s]=D.useStyletron(),r=e.filter(o=>{const l=o.getFilterValue();return l!=null});return r.length===0?null:f.jsxRuntimeExports.jsx("div",{className:n({display:"flex",flexWrap:"wrap",gap:s.sizing.scale300}),children:r.map(o=>f.jsxRuntimeExports.jsx(G0,{column:o,preFilteredRows:t},o.id))})}const U0=D.styled("li",({$theme:i})=>({...i.typography.ParagraphSmall,display:"flex",justifyContent:"space-between",alignItems:"center",paddingTop:i.sizing.scale500,paddingBottom:i.sizing.scale500,paddingLeft:i.sizing.scale600,paddingRight:i.sizing.scale800,cursor:"pointer",position:"relative",":hover":{backgroundColor:i.colors.menuFillHover},":before":q0(i.colors.borderOpaque)}));function q0(i){return{position:"absolute",width:"85%",content:'""',borderTop:"1px solid",borderColor:i,top:0,left:"7.5%"}}function K0({label:i,onClick:e}){return f.jsxRuntimeExports.jsxs(U0,{onClick:e,role:"option","aria-label":i,"data-testid":`filter-option-${i}`,children:[i,f.jsxRuntimeExports.jsx(f.Icon,{name:"chevronRight"})]})}const Y0=D.styled("ul",{margin:0,padding:0,listStyle:"none",maxHeight:"340px",overflowY:"auto"});function X0({filterableColumns:i,setSelectedColumn:e}){const[t,n]=D.useStyletron();return f.jsxRuntimeExports.jsxs("div",{className:t({backgroundColor:n.colors.backgroundPrimary,borderRadius:n.borders.radius300,width:"214px",display:"flex",flexDirection:"column"}),children:[f.jsxRuntimeExports.jsx("div",{className:t({...n.typography.LabelSmall,paddingBottom:n.sizing.scale300,paddingTop:n.sizing.scale500,paddingLeft:n.sizing.scale500,paddingRight:n.sizing.scale500}),children:"Select column to filter"}),f.jsxRuntimeExports.jsx(Y0,{role:"listbox",children:i.map(s=>f.jsxRuntimeExports.jsx(K0,{label:s.label,onClick:()=>e(s)},s.id))})]})}function Q0(i){const{columnFilters:e,filterableColumns:t,onClose:n,preFilteredRows:s,selectedColumn:r,setColumnFilters:o,setSelectedColumn:l}=i,[a,u]=D.useStyletron();if(r){const c=Qh(r.type);return f.jsxRuntimeExports.jsxs("div",{className:a({backgroundColor:u.colors.backgroundPrimary}),children:[f.jsxRuntimeExports.jsx(G.Button,{onClick:()=>l(void 0),kind:G.KIND.tertiary,size:G.SIZE.compact,children:f.jsxRuntimeExports.jsx(f.Icon,{name:"arrowLeft",size:u.sizing.scale650})}),f.jsxRuntimeExports.jsx(c,{column:r,close:n,getFilterValue:()=>{const h=e.find(d=>d.id===r.id);return h==null?void 0:h.value},setFilterValue:h=>{const d=e.filter(p=>p.id!==r.id);h!==void 0&&d.push({id:r.id,value:h}),o(d)},preFilteredRows:s})]})}return f.jsxRuntimeExports.jsx(X0,{filterableColumns:t,setSelectedColumn:l})}function J0(i){const{filterableColumns:e,columnFilters:t,setColumnFilters:n,preFilteredRows:s}=i,[r,o]=M.useState(),[l,a]=M.useState(!1),u=M.useCallback(()=>{o(void 0),a(!1)},[]);return f.jsxRuntimeExports.jsx(Nt.StatefulPopover,{placement:Nt.PLACEMENT.rightTop,onClose:u,onOpen:()=>a(!0),overrides:{Body:{style:{overflow:"hidden"}}},content:({close:c})=>f.jsxRuntimeExports.jsx(Q0,{columnFilters:t,filterableColumns:e,onClose:()=>{u(),c()},preFilteredRows:s,selectedColumn:r,setColumnFilters:n,setSelectedColumn:o}),children:f.jsxRuntimeExports.jsx(G.Button,{shape:G.SHAPE.pill,size:G.SIZE.compact,kind:l||t.length>0?G.KIND.primary:G.KIND.secondary,startEnhancer:f.jsxRuntimeExports.jsx(f.Icon,{name:"plus"}),overrides:{BaseButton:{style:{textWrap:"nowrap"}}},children:"Add filter"})})}function Z0({value:i,onChange:e}){const[t,n]=M.useState(i);M.useEffect(()=>{n(o=>o===i?o:i)},[i]);const s=M.useMemo(()=>{let o;return l=>{clearTimeout(o),o=setTimeout(()=>e(l),500)}},[e]),r=o=>{const l=o.target.value;n(l),s(l)};return f.jsxRuntimeExports.jsx(et.Input,{clearable:!0,type:"search",value:t,onChange:r,size:et.SIZE.compact,overrides:{Root:{style:{width:"250px"}}},placeholder:"Search...",startEnhancer:f.jsxRuntimeExports.jsx(f.Icon,{name:"search"})})}const ex=D.styled("div",({$theme:i})=>({display:"flex",flexDirection:"column",gap:i.sizing.scale300})),tx=D.styled("div",({$theme:i})=>({alignItems:"center",display:"flex",gap:i.sizing.scale300})),ix=D.styled("div",({$theme:i})=>({display:"flex",alignItems:"center",gap:i.sizing.scale300,marginLeft:"auto"}));function nx({globalFilter:i,setGlobalFilter:e,columnFilters:t,setColumnFilters:n,preFilteredRows:s,configuration:r,filterableColumns:o=[]}){return f.jsxRuntimeExports.jsxs(ex,{children:[f.jsxRuntimeExports.jsxs(tx,{children:[r.enableSearch&&f.jsxRuntimeExports.jsx(Z0,{value:i,onChange:e}),r.enableFilters&&o.length>0&&f.jsxRuntimeExports.jsx(J0,{filterableColumns:o,columnFilters:t,setColumnFilters:n,preFilteredRows:s}),r.middle,r.trailing&&f.jsxRuntimeExports.jsx(ix,{children:r.trailing})]}),r.enableFilters&&o.length>0&&f.jsxRuntimeExports.jsx(W0,{filterableColumns:o,preFilteredRows:s})]})}function sx({expanded:i}){const[,e]=D.useStyletron(),t=i?"chevronDown":"chevronRight",n=i?"Collapse":"Expand";return f.jsxRuntimeExports.jsx(f.Icon,{name:t,title:n,size:e.sizing.scale600})}function rx({cell:i,row:e,columnIndex:t}){const[n,s]=D.useStyletron();return i.getIsGrouped()||e.getCanExpand()&&t===0?f.jsxRuntimeExports.jsxs("div",{className:n({display:"flex",alignItems:"center",cursor:"pointer",gap:s.sizing.scale600}),onClick:e.getToggleExpandedHandler(),children:[f.jsxRuntimeExports.jsx(sx,{expanded:e.getIsExpanded()}),Co(i.column.columnDef.cell,i.getContext())]}):i.getIsAggregated()?Co(i.column.columnDef.aggregatedCell??i.column.columnDef.cell,i.getContext()):i.getIsPlaceholder()?null:Co(i.column.columnDef.cell,i.getContext())}function dr(i){return i.map(e=>({id:e.id,cells:e.getAllCells().map((t,n)=>({id:t.id,content:M.createElement(rx,{cell:t,row:e,columnIndex:n}),column:t.column.columnDef.meta,value:t.getValue(),isVisible:t.column.getIsVisible()})),record:e.original,canSelect:e.getCanSelect(),isSelected:e.getIsSelected(),onToggleSelection:t=>e.toggleSelected(t),canExpand:e.getCanExpand(),isExpanded:e.getIsExpanded(),onToggleExpanded:()=>e.toggleExpanded()}))}const ox=D.styled("div",({$theme:i})=>({textAlign:"center",margin:"90px auto",maxWidth:"450px",display:"flex",flexDirection:"column",alignItems:"center",gap:i.sizing.scale600}));function Jt(i){const[e]=D.useStyletron(),{illustration:t,title:n,description:s,buttonConfig:r}=i;return f.jsxRuntimeExports.jsxs(ox,{children:[t,f.jsxRuntimeExports.jsx(ze.HeadingXSmall,{className:e({margin:0}),children:n}),s&&f.jsxRuntimeExports.jsx(ze.ParagraphMedium,{className:e({margin:0}),children:s}),r&&f.jsxRuntimeExports.jsx(G.Button,{...f.lodashExports.omit(r,"content"),kind:G.KIND.secondary,shape:G.SHAPE.pill,children:r.content})]})}const lx=_t.StyledTable,Ca=D.withStyle(_t.StyledTableBody,({$theme:i})=>({backgroundColor:i.colors.tableHeadBackgroundColor})),Zh=_t.StyledTableBodyRow,Yi=D.withStyle(_t.StyledTableBodyCell,({$columnNumber:i,$enableRowSelection:e})=>({fontWeight:i===(e?1:0)?500:"normal",verticalAlign:"middle"})),ed=D.styled("div",{display:"flex",justifyContent:"center"});function fr({children:i}){const[e,t]=D.useStyletron();return f.jsxRuntimeExports.jsx(Ca,{children:f.jsxRuntimeExports.jsx(Zh,{children:f.jsxRuntimeExports.jsx(Yi,{colSpan:100,children:f.jsxRuntimeExports.jsx("div",{className:e({padding:t.sizing.scale600}),children:i})})})})}function ax({emptyState:i}){return f.jsxRuntimeExports.jsx(fr,{children:f.jsxRuntimeExports.jsx(Jt,{illustration:i.icon,title:i.title,description:i.content})})}var vt=(i=>(i[i.ERROR=0]="ERROR",i[i.PRIMARY=1]="PRIMARY",i))(vt||{});function mi({width:i="64",height:e="64",kind:t=vt.ERROR}){const[,n]=D.useStyletron(),s=t===vt.ERROR?n.colors.contentNegative:n.colors.contentStateDisabled;return f.jsxRuntimeExports.jsxs("svg",{role:"img","aria-label":"Circle Exclamation Mark icon",viewBox:"0 0 38 38",width:i,height:e,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f.jsxRuntimeExports.jsx("path",{d:"M19 37.8891C29.4321 37.8891 37.8889 29.4323 37.8889 19.0002C37.8889 8.56817 29.4321 0.111328 19 0.111328C8.56796 0.111328 0.111115 8.56817 0.111115 19.0002C0.111115 29.4323 8.56796 37.8891 19 37.8891Z",fill:s}),f.jsxRuntimeExports.jsx("path",{d:"M18.9999 35.3133C28.0094 35.3133 35.3131 28.0096 35.3131 19.0001C35.3131 9.99065 28.0094 2.68701 18.9999 2.68701C9.99044 2.68701 2.6868 9.99065 2.6868 19.0001C2.6868 28.0096 9.99044 35.3133 18.9999 35.3133Z",fill:"black"}),f.jsxRuntimeExports.jsx("path",{d:"M20.3652 24.5036C20.3652 25.2677 19.7728 25.8601 19.0087 25.8601C18.2446 25.8601 17.635 25.2677 17.635 24.5036C17.635 23.7394 18.2531 23.147 19.0087 23.147C19.7643 23.147 20.3652 23.7394 20.3652 24.5036ZM17.9441 21.9536L17.7552 12.1313H20.2536L20.0647 21.9536H17.9441Z",fill:"white"})]})}function ux({error:i}){switch(i.code){case f.GrpcStatusCode.DEADLINE_EXCEEDED:return f.jsxRuntimeExports.jsx(fr,{children:f.jsxRuntimeExports.jsx(Jt,{illustration:f.jsxRuntimeExports.jsx(mi,{kind:vt.ERROR,height:"64px",width:"64px"}),title:"It took too long to fulfill the request",description:"Try modifying the table filters to reduce the request size."})});case f.GrpcStatusCode.INVALID_ARGUMENT:default:return f.jsxRuntimeExports.jsx(fr,{children:f.jsxRuntimeExports.jsx(Jt,{illustration:f.jsxRuntimeExports.jsx(mi,{kind:vt.ERROR,height:"64px",width:"64px"}),title:"Unable to fetch data for the table",description:"Try reloading the table and retrying the request."})})}}var pr=(i=>(i[i.DEFAULT=0]="DEFAULT",i[i.GREY=1]="GREY",i))(pr||{});const cx={[pr.DEFAULT]:{outlineColor:"safety",questionMarkColor:"white",backgroundColor:"black"},[pr.GREY]:{outlineColor:"tableFilter",questionMarkColor:"white",backgroundColor:"black"}};function hx(i){const[,e]=D.useStyletron(),{kind:t=pr.DEFAULT,height:n="64",width:s="64"}=i,{outlineColor:r,questionMarkColor:o,backgroundColor:l}=cx[t];return f.jsxRuntimeExports.jsxs("svg",{width:s,height:n,viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f.jsxRuntimeExports.jsx("path",{d:"M9.22954 32.5703L1.11591 18.3516C0.961364 18.1172 0.961364 17.8047 1.11591 17.5703L9.22954 3.39062C9.38409 3.15625 9.61591 3 9.88636 3H26.1136C26.3841 3 26.6545 3.15625 26.7705 3.39062L34.8841 17.6094C35.0386 17.8437 35.0386 18.1562 34.8841 18.3906L26.7705 32.6094C26.6159 32.8437 26.3841 33 26.1136 33H9.88636C9.61591 32.9609 9.34545 32.8437 9.22954 32.5703Z",fill:e.colors[r]}),f.jsxRuntimeExports.jsx("path",{d:"M11.2 29.875L4.43863 18L11.2 6.125H24.8L31.5614 18L24.8 29.875H11.2Z",fill:e.colors[l]}),f.jsxRuntimeExports.jsx("path",{d:"M21.7864 15.3828C21.7864 15.8516 21.7091 16.2813 21.5545 16.6719C21.4 17.0625 21.1682 17.4531 20.8977 17.7656C20.6273 18.0781 20.2795 18.3516 19.8932 18.5469C19.5068 18.7422 19.0818 18.8984 18.6568 18.9375L18.5795 20.5781H16.8023L16.725 17.1797H17.6909C17.9227 17.1797 18.1932 17.1406 18.3864 17.0625C18.6182 16.9844 18.8114 16.8672 18.9659 16.7109C19.1205 16.5547 19.2364 16.3984 19.3523 16.1641C19.4682 15.9688 19.5068 15.7344 19.5068 15.5C19.5068 14.9922 19.3136 14.5625 18.9659 14.2109C18.6182 13.8984 18.1932 13.7031 17.6523 13.7031C17.1886 13.7031 16.7636 13.8203 16.4159 14.0156C16.0682 14.2109 15.7205 14.4844 15.4886 14.8359L13.8273 13.625C14.2909 13.0391 14.8318 12.5703 15.45 12.1797C16.0682 11.8281 16.8409 11.6328 17.7295 11.6328C18.3091 11.6328 18.85 11.7109 19.3136 11.9062C19.8159 12.1016 20.2409 12.375 20.5886 12.6875C20.9364 13 21.2455 13.3906 21.4386 13.8594C21.6705 14.3672 21.7864 14.875 21.7864 15.3828ZM17.6909 21.6719C18.0386 21.6719 18.3477 21.7891 18.5795 22.0234C18.8114 22.2578 18.9273 22.5703 18.9273 22.9219C18.9273 23.2734 18.8114 23.5859 18.5795 23.8203C18.3477 24.0547 18.0386 24.1719 17.6909 24.1719C17.3432 24.1719 17.0341 24.0547 16.8023 23.8203C16.5705 23.5859 16.4159 23.2734 16.4159 22.9219C16.4159 22.5703 16.5318 22.2578 16.8023 22.0234C17.0341 21.7891 17.3432 21.6719 17.6909 21.6719Z",fill:e.colors[o]})]})}function dx({clearFilters:i}){return f.jsxRuntimeExports.jsx(fr,{children:f.jsxRuntimeExports.jsx(Jt,{illustration:f.jsxRuntimeExports.jsx(hx,{}),title:"There is no information available for selected filters",description:"Please change or remove filters to see the information.",buttonConfig:{content:"Clear all filters",onClick:i}})})}function fx(i){if(typeof i.column.tooltip.content=="function"){const e=i.column.tooltip.content;return f.jsxRuntimeExports.jsx(e,{...i})}return f.jsxRuntimeExports.jsx(f.Markdown,{children:i.column.tooltip.content})}function px(i,e){return i?Array.isArray(i)?i.length===1&&i[0]===e:i===e:!1}function gx(i,e,t,n){return function(r){const{column:o,value:l}=r,{action:a}=o.tooltip;if(a==="filter"&&px(t,l))return f.jsxRuntimeExports.jsx(i,{...r});const u=()=>{a==="filter"&&n&&n([l])};return f.jsxRuntimeExports.jsx(f.CellTooltipWrapper,{actionHandler:u,content:f.jsxRuntimeExports.jsx(fx,{...r,row:e}),children:f.jsxRuntimeExports.jsx(i,{...r})})}}const mx=150;function xx(i){const e={},t=Object.entries(i.breakpoints);for(const[n,[,s]]of t.entries()){const r=`@media screen and (min-width: ${s}px)`;e[r]={maxWidth:`${mx*(n+1)}px`}}return e}const ml=i=>{const[e,t]=D.useStyletron(),{row:n,record:s,value:r,columnFilterValue:o,setColumnFilterValue:l}=i,u=f.useInterpolationResolver()(va(i.column,s),{row:s}),c=f.useCellStyles({record:s,style:u.style}),d=f.useGetCellRenderer()({column:u,record:s,value:r}),p=u.tooltip?gx(d,n,o,l):d;return f.jsxRuntimeExports.jsxs(f.CellContainer,{children:[f.jsxRuntimeExports.jsx("div",{className:e({...xx(t),...c}),children:f.jsxRuntimeExports.jsx(p,{column:u,record:s,value:r,CellComponent:ml})}),f.jsxRuntimeExports.jsx(f.CellEnhancer,{endEnhancer:u.endEnhancer})]})};function yx(i){return e=>{const t=va(i,e);return"items"in t?t.items.map(n=>f.getObjectValue(e,n.accessor??n.id)).join(gl):f.getObjectValue(e,t.accessor??t.id)}}function bx(i){const e=Jh();return M.useMemo(()=>i.map(t=>{const n=e(t);return{id:t.id,meta:t,accessorFn:yx(t),header:t.label,cell:s=>f.jsxRuntimeExports.jsx(ml,{column:s.column.columnDef.meta,row:dr([s.row])[0],record:s.row.original,value:s.getValue(),columnFilterValue:s.column.getFilterValue(),setColumnFilterValue:s.column.setFilterValue}),aggregatedCell:s=>t.aggregatedCell?f.jsxRuntimeExports.jsx(t.aggregatedCell,{column:s.column.columnDef.meta,record:s.row.original,value:s.getValue()}):f.jsxRuntimeExports.jsx(ml,{column:s.column.columnDef.meta,row:dr([s.row])[0],record:s.row.original,value:s.getValue(),columnFilterValue:s.column.getFilterValue(),setColumnFilterValue:s.column.setFilterValue}),filterFn:n.buildTableFilterFn(),enableColumnFilters:t.filterMode!==Wr.NONE,enableSorting:t.enableSorting??!0,enableGrouping:t.enableGrouping??!1,aggregationFn:t.aggregationFn,sortingFn:t.sortingFn??"auto",sortUndefined:"last"}}),[i,e])}function vx(i){const{paginationState:e,pageCount:t,gotoPage:n}=i,{pageIndex:s}=e,[r,o]=M.useState(!1);M.useEffect(()=>{const a=s+1>t;s!==0&&a&&(o(!0),n(0))},[s,t,n]),M.useEffect(()=>{r&&s===0&&o(!1)},[r,s]);const l=s+1>t&&s!==0;return{isResetting:r||l}}const td=Se.createContext({selectedRows:[],selectionEnabled:!1,setSelectionEnabled:()=>null,toggleAllRowsSelected:()=>null,getIsAllRowsSelected:()=>!1,getIsSomeRowsSelected:()=>!1}),Sx=()=>Se.useContext(td);function Cx({children:i,value:e}){return f.jsxRuntimeExports.jsx(td.Provider,{value:e,children:i})}function wx({state:i,initialState:e}){const[t,n]=M.useState(e.rowSelectionEnabled);return{enableRowSelection:(i.setRowSelectionEnabled?i.rowSelectionEnabled:t)??!1,setRowSelectionEnabled:i.setRowSelectionEnabled??n}}const id=i=>({width:i.sizing.scale900,minWidth:i.sizing.scale900,maxWidth:i.sizing.scale900});function nd({canSelect:i,isSelected:e,onToggleSelection:t}){if(!i)return null;const n=s=>{s.stopPropagation(),t(s.target.checked)};return f.jsxRuntimeExports.jsx(Oi.Checkbox,{checked:e,onChange:n,overrides:{Root:{style:{alignItems:"center"}}}})}function Ex(i){const[e,t]=M.useState(!1);return M.useEffect(()=>{const n=i.current;if(!n)return;const s=()=>t(!0),r=()=>t(!1);return n.addEventListener("mouseenter",s),n.addEventListener("mouseleave",r),()=>{n.removeEventListener("mouseenter",s),n.removeEventListener("mouseleave",r)}},[i]),e}const Rx={left:{right:"auto",left:"-7px",getOpacity:i=>i===-1?0:1-i},right:{right:"-7px",left:"auto",getOpacity:i=>i===-1?0:i}};function kx(i,e){if(i==="none")return{};const{getOpacity:t,...n}=Rx[i];return{"::before":{...n,content:'" "',position:"absolute",top:0,bottom:0,width:"7px",opacity:Math.ceil(t(e)),transition:"opacity 0.2s ease",background:`linear-gradient(to ${i}, rgba(0,0,0, 0.15), rgba(0, 0, 0, 0) 4px)`}}}const Ax=56;function Tx(i,e){const t={};return i?(t[0]={stickySide:"left",position:0,shadowSide:"none"},t[1]={stickySide:"left",position:Ax,shadowSide:"right"}):t[1]={stickySide:"left",position:0,shadowSide:"right"},t[e]={stickySide:"right",position:0,shadowSide:"left"},t}function sd(i){return function(t){const{enableStickySides:n,enableRowSelection:s,lastColumnIndex:r,scrollRatio:o=-1,role:l,children:a,...u}=t,[c,h]=D.useStyletron(),d=M.useRef(null),p=Ex(d);if(!n)return f.jsxRuntimeExports.jsx(i,{...u,children:a});const m={position:"sticky !important",backgroundColor:`${p&&l==="row"?h.colors.tableStripedBackground:h.colors.tableHeadBackgroundColor} !important`},x=Tx(s,r);return f.jsxRuntimeExports.jsx(i,{...u,ref:d,children:M.Children.map(a,(y,b)=>{const v=x[b];if(!v||!M.isValidElement(y))return y;const C={...m,[v.stickySide]:`${v.position}px !important`};return M.cloneElement(y,{className:`${c(C)} ${c(kx(v.shadowSide,o))}`,"data-testid":`sticky-cell-${v.stickySide}-sticky`})})})}}const Mx=sd(_t.StyledTableBodyRow),Ox=({rows:i,enableRowSelection:e,enableStickySides:t,scrollRatio:n,subRow:s,actions:r})=>{const[o,l]=D.useStyletron(),a=i[0].cells.filter(u=>u.isVisible).length+1;return f.jsxRuntimeExports.jsx(Ca,{children:i.map(u=>f.jsxRuntimeExports.jsxs(M.Fragment,{children:[f.jsxRuntimeExports.jsxs(Mx,{enableStickySides:t,enableRowSelection:e,lastColumnIndex:a,scrollRatio:n,role:"row",children:[e&&f.jsxRuntimeExports.jsx(Yi,{className:o(id(l)),children:f.jsxRuntimeExports.jsx(nd,{canSelect:u.canSelect??!1,isSelected:u.isSelected??!1,onToggleSelection:u.onToggleSelection??(()=>{})})}),u.cells.filter(c=>c.isVisible).map((c,h)=>f.jsxRuntimeExports.jsx(Yi,{$columnNumber:h,$enableRowSelection:e,children:c.content},c.id)),f.jsxRuntimeExports.jsx(Yi,{children:f.jsxRuntimeExports.jsx(ed,{children:r&&M.createElement(r,{row:u})})})]}),s&&u.isExpanded&&f.jsxRuntimeExports.jsx(_t.StyledTableBodyRow,{children:f.jsxRuntimeExports.jsx(Yi,{colSpan:u.cells.filter(c=>c.isVisible).length+(e?2:1),children:M.createElement(s,{row:u})})})]},u.id))})};function Ix(i,e,t){return n=>{const s=n.newIndex===-1,r=n.oldIndex+1,o=n.newIndex+1;if(s){const l=i[r];t(a=>({...a,[l.id]:!l.isVisible}))}else e(Xs.arrayMove(i.map(l=>l.id),r,o))}}function jx({columns:i,setColumnOrder:e,setColumnVisibility:t}){const[n,s]=D.useStyletron(),r=Ix(i,e,t);return f.jsxRuntimeExports.jsx(Nt.StatefulPopover,{placement:Nt.PLACEMENT.bottomRight,content:()=>f.jsxRuntimeExports.jsx("div",{className:n({backgroundColor:s.colors.backgroundPrimary,borderRadius:s.borders.radius300,width:"214px",display:"flex",flexDirection:"column"}),children:f.jsxRuntimeExports.jsx(Xs.List,{removable:!0,overrides:{Item:{style:{height:s.sizing.scale800}},Label:{component:o=>f.jsxRuntimeExports.jsx(Xs.StyledLabel,{...o,children:o.$value.label})},CloseHandle:{component:o=>f.jsxRuntimeExports.jsx(Xs.StyledCloseHandle,{...o,children:f.jsxRuntimeExports.jsx(Oi.Checkbox,{checked:o.$value.isVisible,disabled:!o.$value.canHide,title:`Toggle ${o.$value.label}`})})}},onChange:r,items:i.slice(1)})}),children:f.jsxRuntimeExports.jsx(G.Button,{title:"Configure columns",size:G.SIZE.mini,kind:G.KIND.tertiary,children:f.jsxRuntimeExports.jsx(f.Icon,{name:"settings"})})})}function Px(i){const{column:e}=i,t=e.getIsSorted(),n=t==="desc"?"sortDescending":"sortAscending",s=t?f.IconKind.ACCENT:f.IconKind.TERTIARY;return f.jsxRuntimeExports.jsx(f.Icon,{name:n,kind:s,title:"Toggle Sort"})}const xl=D.withStyle(_t.StyledTableHeadCell,({$theme:i})=>({zIndex:"unset",position:"inherit",...i.typography.LabelSmall})),Dx=D.withStyle(_t.StyledTableHeadCellSortable,({$theme:i})=>({zIndex:"unset",position:"inherit",...i.typography.LabelSmall})),Lx=D.withStyle(xl,{padding:0}),Fx=sd(_t.StyledTableHeadRow),Nx=({columns:i,setColumnOrder:e,setColumnVisibility:t,enableRowSelection:n,isSelected:s,onToggleSelection:r,enableStickySides:o,scrollRatio:l})=>{const[a,u]=D.useStyletron();return f.jsxRuntimeExports.jsx(_t.StyledTableHead,{children:f.jsxRuntimeExports.jsxs(Fx,{enableStickySides:o,enableRowSelection:n,lastColumnIndex:i.filter(c=>c.isVisible).length+1,scrollRatio:l,role:"header",children:[n&&f.jsxRuntimeExports.jsx(xl,{role:"columnheader",className:a(id(u)),children:f.jsxRuntimeExports.jsx(nd,{canSelect:n,isSelected:s,onToggleSelection:r})}),i.filter(c=>c.isVisible).map(c=>c.canSort?f.jsxRuntimeExports.jsx(Dx,{$isFocusVisible:!1,onClick:c.onToggleSort,role:"columnheader",children:f.jsxRuntimeExports.jsxs("div",{className:a({display:"flex",alignItems:"center",gap:u.sizing.scale300}),children:[f.jsxRuntimeExports.jsx("div",{children:c.label}),f.jsxRuntimeExports.jsx(Px,{column:{getIsSorted:()=>c.sortDirection??!1}})]})},c.id):f.jsxRuntimeExports.jsx(xl,{role:"columnheader",children:c.label},c.id)),e&&t&&f.jsxRuntimeExports.jsx(Lx,{role:"columnheader",children:f.jsxRuntimeExports.jsx(ed,{children:f.jsxRuntimeExports.jsx(jx,{columns:i,setColumnOrder:e,setColumnVisibility:t})})})]})})};function Bx(){return f.jsxRuntimeExports.jsx(Ca,{"aria-label":"Loading",children:[1,2,3].map(i=>f.jsxRuntimeExports.jsx(Zh,{children:f.jsxRuntimeExports.jsx(Yi,{colSpan:100,children:f.jsxRuntimeExports.jsx(Nh.Skeleton,{animation:!0,width:"100%",height:"22px"})})},i))})}function Vx(i){const{pageSizes:e,state:t,setPageSize:n}=i,{pageSize:s}=t,[r,o]=D.useStyletron(),l=e.find(a=>a.id===s);return f.jsxRuntimeExports.jsxs("div",{className:r({...o.typography.LabelMedium,display:"flex",gap:o.sizing.scale600,alignItems:"center"}),children:[f.jsxRuntimeExports.jsx("div",{className:r({minWidth:"fit-content",paddingLeft:o.sizing.scale600}),children:"Rows per page"}),f.jsxRuntimeExports.jsx(tn.Select,{placeholder:"","aria-label":"Select rows per page",clearable:!1,searchable:!1,options:e,value:l?[l]:[],onChange:({option:a})=>n(Number((a==null?void 0:a.id)??s)),overrides:{Root:{props:{"aria-label":"Select rows per page"}},ControlContainer:{style:({$theme:a})=>({borderColor:"transparent",backgroundColor:a.colors.buttonTertiaryFill,":hover":{backgroundColor:a.colors.buttonTertiaryHover}})},SingleValue:{style:({$theme:a})=>({color:a.colors.buttonTertiaryText,paddingLeft:a.sizing.scale200,paddingRight:a.sizing.scale500})}}})]})}function _x(i){const{state:e,pageCount:t,gotoPage:n,fetchPlugin:s}=i,{pageIndex:r}=e,[o]=D.useStyletron(),l=Math.min(r+1,t);return f.jsxRuntimeExports.jsxs("div",{className:o({display:"flex",justifyContent:"space-between",width:"100%",alignItems:"center"}),children:[f.jsxRuntimeExports.jsx(Vx,{pageSizes:i.pageSizes,state:i.state,setPageSize:i.setPageSize}),f.jsxRuntimeExports.jsx(Cm.Pagination,{numPages:t,currentPage:l,onPageChange:({nextPage:a})=>{s&&a===t&&s.fetchNextPage(),n(Math.max(0,a-1))},overrides:{Root:{style:{display:"flex",justifyContent:"flex-end"}},MaxLabel:s?{component:()=>null}:{},NextButton:s!=null&&s.isFetchNextPageInProgress?{component:zx}:{}}})]})}function zx(){return f.jsxRuntimeExports.jsx(G.Button,{isLoading:!0,kind:G.KIND.tertiary,children:"Next"})}function $x(i,e){const t=e[0].id;return i==null||i<=t?t:(e.find(r=>i<=r.id)??e[e.length-1]).id}function Hx(i){const e=i.disablePagination??!1,t=i.disableSorting??!1,n=i.pageSizes??F0;return{...i,emptyState:i.emptyState??{icon:f.jsxRuntimeExports.jsx(mi,{kind:vt.PRIMARY,height:"64px",width:"64px"}),title:"No data",content:"No data is present."},loading:i.loading??!1,loadingView:i.loadingView??Bx,error:i.error??void 0,actionBarConfig:{enableSearch:!0,enableFilters:!0,...i.actionBarConfig},disablePagination:e,disableSorting:t,pageSizes:n,state:Gx(i.state,e,n),pagination:i.pagination??_x,enableStickySides:i.enableStickySides??!0,body:i.body??Ox,header:i.header??Nx,unFilteredData:i.unFilteredData??i.data}}function Gx(i,e,t){var o;const n={...i,rowSelectionEnabled:(i==null?void 0:i.rowSelectionEnabled)??!1};if(e){const{pagination:l,setPagination:a,...u}=n;return u}const s=(o=n==null?void 0:n.pagination)==null?void 0:o.pageSize,r=$x(s,t);return{...n,pagination:{pageIndex:0,...n==null?void 0:n.pagination,pageSize:r}}}const Ru={globalFilter:"setGlobalFilter",columnFilters:"setColumnFilters",pagination:"setPagination",sorting:"setSorting",columnOrder:"setColumnOrder",columnVisibility:"setColumnVisibility",rowSelection:"setRowSelection",rowSelectionEnabled:"setRowSelectionEnabled",grouping:"setGrouping"};function Wx(i){const e={},t={},n=Object.keys(Ru);for(const s of n){const r=Ru[s];r in i?(s in i||console.warn(`Controlled state setter ${r} must be accompanied by property ${s}`),e[s]=i[s],e[r]=i[r]):s in i&&(t[s]=i[s])}return{initialState:t,state:e}}function Ux(i){const{loading:e,dataLength:t,error:n,hasFiltersApplied:s,filteredLength:r,columnsLength:o}=i;return e?"loading":n?"error":o===0?"no-columns":t===0?"empty":s&&r===0?"filtered-empty":"ready"}function rd(i,e,t){return i.getValue(e)?f.safeStringify(i.getValue(e)).toLowerCase().includes(t.toLowerCase()):!1}rd.autoRemove=i=>i==null;function qx(i){return i.map(e=>{const t=e.columnDef.meta,n=t.label??e.id;return{...t,label:n,type:t.type??f.CellType.TEXT,canFilter:e.getCanFilter(),getFilterValue:e.getFilterValue,setFilterValue:e.setFilterValue,canSort:e.getCanSort(),onToggleSort:e.getToggleSortingHandler()??(()=>{}),sortDirection:e.getIsSorted(),canHide:e.getCanHide(),isVisible:e.getIsVisible()}})}function Ur(i){var y,b,v,C;const e=Hx(i),t=bx(e.columns),[n,s]=D.useStyletron(),{state:r,initialState:o}=Wx(e.state??{}),{enableRowSelection:l,setRowSelectionEnabled:a}=wx({state:r,initialState:o}),{scrollRatio:u,tableRef:c,handleScrollRatioUpdate:h}=D0(t),d=P0({data:e.data,columns:t,initialState:o,...Object.keys(r).length>0&&{state:r},...r.setGlobalFilter?{onGlobalFilterChange:r.setGlobalFilter}:{},...r.setColumnFilters?{onColumnFiltersChange:r.setColumnFilters}:{},...r.setPagination?{onPaginationChange:r.setPagination}:{},...r.setSorting?{onSortingChange:r.setSorting}:{},...r.setColumnOrder?{onColumnOrderChange:r.setColumnOrder}:{},...r.setColumnVisibility?{onColumnVisibilityChange:r.setColumnVisibility}:{},...r.setRowSelection?{onRowSelectionChange:r.setRowSelection}:{},getCoreRowModel:S0(),getFilteredRowModel:R0(),...e.disableSorting?{enableSorting:!1}:{getSortedRowModel:M0()},...e.disablePagination?{}:{getPaginationRowModel:T0()},...(y=o.grouping)!=null&&y.length||(b=r.grouping)!=null&&b.length?{getGroupedRowModel:k0(),getExpandedRowModel:wu()}:{},...e.subRow?{getExpandedRowModel:wu(),getRowCanExpand:()=>!0}:{},enableRowSelection:l,getColumnCanGlobalFilter:()=>!0,globalFilterFn:rd,autoResetPageIndex:!1}),p=qx(d.getAllLeafColumns()),{isResetting:g}=vx({gotoPage:d.setPageIndex,pageCount:d.getPageCount(),paginationState:d.getState().pagination}),m=Ux({dataLength:e.data.length,error:e.error,loading:e.loading||g,hasFiltersApplied:((v=d.getState().globalFilter)==null?void 0:v.length)>0||(((C=d.getState().columnFilters)==null?void 0:C.length)??0)>0,filteredLength:d.getRowModel().rows.length,columnsLength:t.length}),x=e.unFilteredData.map(S=>({getValue:E=>{const A=t.find(I=>I.id===E);if(A)return A.accessorFn(S)},record:S}));return f.jsxRuntimeExports.jsx("div",{className:n({display:"flex",flexDirection:"column",gap:s.sizing.scale400}),children:f.jsxRuntimeExports.jsxs(Cx,{value:{selectedRows:dr(d.getSelectedRowModel().flatRows),selectionEnabled:l,setSelectionEnabled:a,toggleAllRowsSelected:S=>d.toggleAllRowsSelected(S),getIsAllRowsSelected:()=>d.getIsAllRowsSelected(),getIsSomeRowsSelected:()=>d.getIsSomeRowsSelected()},children:[f.jsxRuntimeExports.jsx(nx,{globalFilter:d.getState().globalFilter,setGlobalFilter:d.setGlobalFilter,columnFilters:d.getState().columnFilters,setColumnFilters:d.setColumnFilters,preFilteredRows:x,configuration:e.actionBarConfig,filterableColumns:p.filter(S=>S.canFilter&&S.filterMode!==Wr.NONE)}),f.jsxRuntimeExports.jsx("div",{className:n({overflow:"auto",position:"relative"}),ref:c,onScroll:h,children:f.jsxRuntimeExports.jsxs(lx,{children:[m==="loading"&&f.jsxRuntimeExports.jsx(e.loadingView,{}),m==="error"&&f.jsxRuntimeExports.jsx(ux,{error:e.error}),(m==="empty"||m==="no-columns")&&f.jsxRuntimeExports.jsx(ax,{emptyState:e.emptyState}),m==="filtered-empty"&&f.jsxRuntimeExports.jsx(dx,{clearFilters:()=>{d.setGlobalFilter(""),d.setColumnFilters([])}}),m!=="error"&&m!=="no-columns"&&f.jsxRuntimeExports.jsx(e.header,{columns:p,setColumnOrder:d.setColumnOrder,setColumnVisibility:d.setColumnVisibility,enableRowSelection:l,isSelected:d.getIsAllRowsSelected(),onToggleSelection:S=>d.toggleAllRowsSelected(S),enableStickySides:e.enableStickySides,scrollRatio:u}),m==="ready"&&f.jsxRuntimeExports.jsx(e.body,{rows:dr(d.getRowModel().rows),enableRowSelection:l,enableStickySides:e.enableStickySides,scrollRatio:u,subRow:e.subRow,actions:e.actions})]})}),!e.disablePagination&&m==="ready"&&d.getPreFilteredRowModel().rows.length>Math.min(...e.pageSizes.map(S=>S.id))&&f.jsxRuntimeExports.jsx(e.pagination,{gotoPage:d.setPageIndex,pageCount:d.getPageCount(),setPageSize:d.setPageSize,state:d.getState().pagination,pageSizes:e.pageSizes,fetchPlugin:e.fetchPlugin})]})})}function Kx(){const[i,e]=D.useStyletron(),{data:t,isLoading:n}=f.useStudioQuery({queryName:"ListProject",serviceOptions:{namespace:""}});return f.jsxRuntimeExports.jsx("div",{className:i({marginTop:e.sizing.scale400}),children:f.jsxRuntimeExports.jsx(Ur,{data:(t==null?void 0:t.projectList.items)??[],columns:ul,loading:n})})}function be(){return be=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},be.apply(null,arguments)}function qr(i,e){if(i==null)return{};var t={};for(var n in i)if({}.hasOwnProperty.call(i,n)){if(e.indexOf(n)!==-1)continue;t[n]=i[n]}return t}var Yx=46,Xx=/\\(\\)?/g,Qx=RegExp(`[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,"g"),Jx=function(e){var t=[];return e.charCodeAt(0)===Yx&&t.push(""),e.replace(Qx,function(n,s,r,o){var l=n;r?l=o.replace(Xx,"$1"):s&&(l=s.trim()),t.push(l)}),t},ws={},Zx=/[.[\]]+/,od=function(e){if(e==null||!e.length)return[];if(typeof e!="string")throw new Error("toPath() expects a string");return ws[e]==null&&(e.endsWith("[]")?ws[e]=e.split(Zx).filter(Boolean):ws[e]=Jx(e)),ws[e]},ge=function(e,t){for(var n=od(t),s=e,r=0;r<n.length;r++){var o=n[r];if(s==null||typeof s!="object"||Array.isArray(s)&&isNaN(o))return;s=s[o]}return s};function ey(i){var e=ty(i,"string");return typeof e=="symbol"?e:String(e)}function ty(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(i)}var iy=function i(e,t,n,s,r){if(t>=n.length)return s;var o=n[t];if(isNaN(o)){var l;if(e==null){var a,u=i(void 0,t+1,n,s,r);return u===void 0?void 0:(a={},a[o]=u,a)}if(Array.isArray(e))throw new Error("Cannot set a non-numeric property on an array");var c=i(e[o],t+1,n,s,r);if(c===void 0){var h=Object.keys(e).length;if(e[o]===void 0&&h===0)return;if(e[o]!==void 0&&h<=1)return!isNaN(n[t-1])&&!r?{}:void 0;e[o];var d=qr(e,[o].map(ey));return d}return be({},e,(l={},l[o]=c,l))}var p=Number(o);if(e==null){var g=i(void 0,t+1,n,s,r);if(g===void 0)return;var m=[];return m[p]=g,m}if(!Array.isArray(e))throw new Error("Cannot set a numeric property on an object");var x=e[p],y=i(x,t+1,n,s,r),b=[].concat(e);if(r&&y===void 0){if(b.splice(p,1),b.length===0)return}else b[p]=y;return b},ut=function(e,t,n,s){if(s===void 0&&(s=!1),e==null)throw new Error("Cannot call setIn() with "+String(e)+" state");if(t==null)throw new Error("Cannot call setIn() with "+String(t)+" key");return iy(e,0,od(t),n,s)},Un="FINAL_FORM/form-error",nn="FINAL_FORM/array-error";function ku(i,e){var t=i.errors,n=i.initialValues,s=i.lastSubmittedValues,r=i.submitErrors,o=i.submitFailed,l=i.submitSucceeded,a=i.submitting,u=i.values,c=e.active,h=e.blur,d=e.change,p=e.data,g=e.focus,m=e.modified,x=e.modifiedSinceLastSubmit,y=e.name,b=e.touched,v=e.validating,C=e.visited,S=ge(u,y),E=ge(t,y);E&&E[nn]&&(E=E[nn]);var A=r&&ge(r,y),I=n&&ge(n,y),R=e.isEqual(I,S),H=!!(s&&!e.isEqual(ge(s,y),S)),F=!E&&!A;return{active:c,blur:h,change:d,data:p,dirty:!R,dirtySinceLastSubmit:H,error:E,focus:g,initial:I,invalid:!F,length:Array.isArray(S)?S.length:void 0,modified:m,modifiedSinceLastSubmit:x,name:y,pristine:R,submitError:A,submitFailed:o,submitSucceeded:l,submitting:a,touched:b,valid:F,value:S,visited:C,validating:v}}var wa=["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","modified","modifiedSinceLastSubmit","pristine","submitError","submitFailed","submitSucceeded","submitting","touched","valid","value","visited","validating"],It=function(e,t){if(e===t)return!0;if(typeof e!="object"||!e||typeof t!="object"||!t)return!1;var n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(var r=Object.prototype.hasOwnProperty.bind(t),o=0;o<n.length;o++){var l=n[o];if(!r(l)||e[l]!==t[l])return!1}return!0};function ld(i,e,t,n,s,r){var o=!1;return s.forEach(function(l){n[l]&&(i[l]=e[l],(!t||(~r.indexOf(l)?!It(e[l],t[l]):e[l]!==t[l]))&&(o=!0))}),o}var ny=["data"],sy=function(e,t,n,s){var r={blur:e.blur,change:e.change,focus:e.focus,name:e.name},o=ld(r,e,t,n,wa,ny)||!t;return o||s?r:void 0},ad=["active","dirty","dirtyFields","dirtyFieldsSinceLastSubmit","dirtySinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","modified","modifiedSinceLastSubmit","pristine","submitting","submitError","submitErrors","submitFailed","submitSucceeded","touched","valid","validating","values","visited"],ry=["touched","visited"];function Au(i,e,t,n){var s={},r=ld(s,i,e,t,ad,ry)||!e;return r||n?s:void 0}var Tu=function(e){var t,n;return function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return(!t||r.length!==t.length||r.some(function(l,a){return!It(t[a],l)}))&&(t=r,n=e.apply(void 0,r)),n}},wo=(function(i){return!!i&&(typeof i=="object"||typeof i=="function")&&typeof i.then=="function"}),oy="4.20.10",ly=function(e,t){return e===t},Xi=function i(e){return Object.keys(e).some(function(t){var n=e[t];return n&&typeof n=="object"&&!(n instanceof Error)?i(n):typeof n<"u"})};function ay(i){var e=i.active,t=i.dirtySinceLastSubmit,n=i.modifiedSinceLastSubmit,s=i.error,r=i.errors,o=i.initialValues,l=i.pristine,a=i.submitting,u=i.submitFailed,c=i.submitSucceeded,h=i.submitError,d=i.submitErrors,p=i.valid,g=i.validating,m=i.values;return{active:e,dirty:!l,dirtySinceLastSubmit:t,modifiedSinceLastSubmit:n,error:s,errors:r,hasSubmitErrors:!!(h||d&&Xi(d)),hasValidationErrors:!!(s||Xi(r)),invalid:!p,initialValues:o,pristine:l,submitting:a,submitFailed:u,submitSucceeded:c,submitError:h,submitErrors:d,valid:p,validating:g>0,values:m}}function ud(i,e,t,n,s,r){var o=s(t,n,e,r);return o?(i(o),!0):!1}function Mu(i,e,t,n,s){var r=i.entries;Object.keys(r).forEach(function(o){var l=r[Number(o)];if(l){var a=l.subscription,u=l.subscriber,c=l.notified;ud(u,a,e,t,n,s||!c)&&(l.notified=!0)}})}function uy(i){if(!i)throw new Error("No config specified");var e=i.debug,t=i.destroyOnUnregister,n=i.keepDirtyOnReinitialize,s=i.initialValues,r=i.mutators,o=i.onSubmit,l=i.validate,a=i.validateOnBlur;if(!o)throw new Error("No onSubmit function specified");var u={subscribers:{index:0,entries:{}},fieldSubscribers:{},fields:{},formState:{asyncErrors:{},dirtySinceLastSubmit:!1,modifiedSinceLastSubmit:!1,errors:{},initialValues:s&&be({},s),invalid:!1,pristine:!0,submitting:!1,submitFailed:!1,submitSucceeded:!1,resetWhileSubmitting:!1,valid:!0,validating:0,values:s?be({},s):{}},lastFormState:void 0},c=0,h=!1,d=!1,p=!1,g=0,m={},x=function(w){return function(O){return delete m[w],O}},y=function(w,O,L){var N=ge(w.formState.values,O),Q=L(N);w.formState.values=ut(w.formState.values,O,Q)||{}},b=function(w,O,L){if(w.fields[O]){var N,Q;w.fields=be({},w.fields,(N={},N[L]=be({},w.fields[O],{name:L,blur:function(){return ee.blur(L)},change:function(he){return ee.change(L,he)},focus:function(){return ee.focus(L)},lastFieldState:void 0}),N)),delete w.fields[O],w.fieldSubscribers=be({},w.fieldSubscribers,(Q={},Q[L]=w.fieldSubscribers[O],Q)),delete w.fieldSubscribers[O];var Z=ge(w.formState.values,O);w.formState.values=ut(w.formState.values,O,void 0)||{},w.formState.values=ut(w.formState.values,L,Z),delete w.lastFormState}},v=function(w){return function(){if(r){for(var O={formState:u.formState,fields:u.fields,fieldSubscribers:u.fieldSubscribers,lastFormState:u.lastFormState},L=arguments.length,N=new Array(L),Q=0;Q<L;Q++)N[Q]=arguments[Q];var Z=r[w](N,O,{changeValue:y,getIn:ge,renameField:b,resetFieldState:ee.resetFieldState,setIn:ut,shallowEqual:It});return u.formState=O.formState,u.fields=O.fields,u.fieldSubscribers=O.fieldSubscribers,u.lastFormState=O.lastFormState,I(void 0,function(){R(),q()}),Z}}},C=r?Object.keys(r).reduce(function(U,w){return U[w]=v(w),U},{}):{},S=function(w){var O=[];if(l){var L=l(be({},u.formState.values));wo(L)?O.push(L.then(function(N){return w(N,!0)})):w(L,!1)}return O},E=function(w){return Object.keys(w.validators).reduce(function(O,L){var N=w.validators[Number(L)]();return N&&O.push(N),O},[])},A=function(w,O){var L=[],N=E(w);if(N.length){var Q;N.forEach(function(Z){var ce=Z(ge(u.formState.values,w.name),u.formState.values,Z.length===0||Z.length===3?ku(u.formState,u.fields[w.name]):void 0);if(ce&&wo(ce)){w.validating=!0;var he=ce.then(function(ue){u.fields[w.name]&&(u.fields[w.name].validating=!1,O(ue))});L.push(he)}else Q||(Q=ce)}),O(Q)}return L},I=function(w,O){if(h){d=!0,O();return}var L=u.fields,N=u.formState,Q=be({},L),Z=Object.keys(Q);if(!l&&!Z.some(function(si){return E(Q[si]).length})){O();return}var ce=!1;if(w){var he=Q[w];if(he){var ue=he.validateFields;ue&&(ce=!0,Z=ue.length?ue.concat(w):[w])}}var ke={},Ne={},xt={},ni=[].concat(S(function(si,wi){wi?Ne=si||{}:ke=si||{}}),Z.reduce(function(si,wi){return si.concat(A(L[wi],function(Rt){xt[wi]=Rt}))},[])),Me=ni.length>0,we=++g,Hi=Promise.all(ni).then(x(we));Me&&(m[we]=Hi);var yu=function(wi){var Rt=be({},ce?N.errors:{},ke,wi?Ne:N.asyncErrors),vu=function(Ei){Z.forEach(function(ri){if(L[ri]){var En=ge(ke,ri),mm=ge(Rt,ri),xm=E(Q[ri]).length,ym=xt[ri];Ei(ri,xm&&ym||l&&En||(!En&&!ce?mm:void 0))}})};vu(function(wn,Ei){Rt=ut(Rt,wn,Ei)||{}}),vu(function(wn,Ei){if(Ei&&Ei[nn]){var ri=ge(Rt,wn),En=[].concat(ri);En[nn]=Ei[nn],Rt=ut(Rt,wn,En)}}),It(N.errors,Rt)||(N.errors=Rt),wi&&(N.asyncErrors=Ne),N.error=ke[Un]};if(Me&&(u.formState.validating++,O()),yu(!1),O(),Me){var bu=function(){u.formState.validating--,O(),u.formState.validating===0&&u.lastFormState.validating&&q()};Hi.then(function(){g>we||yu(!0)}).then(bu,bu)}},R=function(w){if(!c){var O=u.fields,L=u.fieldSubscribers,N=u.formState,Q=be({},O),Z=function(he){var ue=Q[he],ke=ku(N,ue),Ne=ue.lastFieldState;ue.lastFieldState=ke;var xt=L[he];xt&&Mu(xt,ke,Ne,sy,Ne===void 0)};w?Z(w):Object.keys(Q).forEach(Z)}},H=function(){Object.keys(u.fields).forEach(function(w){u.fields[w].touched=!0})},F=function(){return!!(u.formState.error||Xi(u.formState.errors))},j=function(){var w=u.fields,O=u.formState,L=u.lastFormState,N=be({},w),Q=Object.keys(N),Z=!1,ce=Q.reduce(function(Me,we){var Hi=!N[we].isEqual(ge(O.values,we),ge(O.initialValues||{},we));return Hi&&(Z=!0,Me[we]=!0),Me},{}),he=Q.reduce(function(Me,we){var Hi=O.lastSubmittedValues||{};return N[we].isEqual(ge(O.values,we),ge(Hi,we))||(Me[we]=!0),Me},{});O.pristine=!Z,O.dirtySinceLastSubmit=!!(O.lastSubmittedValues&&Object.values(he).some(function(Me){return Me})),O.modifiedSinceLastSubmit=!!(O.lastSubmittedValues&&Object.keys(N).some(function(Me){return N[Me].modifiedSinceLastSubmit})),O.valid=!O.error&&!O.submitError&&!Xi(O.errors)&&!(O.submitErrors&&Xi(O.submitErrors));var ue=ay(O),ke=Q.reduce(function(Me,we){return Me.modified[we]=N[we].modified,Me.touched[we]=N[we].touched,Me.visited[we]=N[we].visited,Me},{modified:{},touched:{},visited:{}}),Ne=ke.modified,xt=ke.touched,ni=ke.visited;return ue.dirtyFields=L&&It(L.dirtyFields,ce)?L.dirtyFields:ce,ue.dirtyFieldsSinceLastSubmit=L&&It(L.dirtyFieldsSinceLastSubmit,he)?L.dirtyFieldsSinceLastSubmit:he,ue.modified=L&&It(L.modified,Ne)?L.modified:Ne,ue.touched=L&&It(L.touched,xt)?L.touched:xt,ue.visited=L&&It(L.visited,ni)?L.visited:ni,L&&It(L,ue)?L:ue},W=function(){return e&&!0&&e(j(),Object.keys(u.fields).reduce(function(w,O){return w[O]=u.fields[O],w},{}))},P=!1,B=!1,q=function U(){if(P)B=!0;else{if(P=!0,W(),!c&&!(h&&p)){var w=u.lastFormState,O=j();O!==w&&(u.lastFormState=O,Mu(u.subscribers,O,w,Au))}P=!1,B&&(B=!1,U())}},ne=function(){return Object.keys(u.fields).some(function(w){return u.fields[w].beforeSubmit&&u.fields[w].beforeSubmit()===!1})},ae=function(){return Object.keys(u.fields).forEach(function(w){return u.fields[w].afterSubmit&&u.fields[w].afterSubmit()})},ie=function(){return Object.keys(u.fields).forEach(function(w){return u.fields[w].modifiedSinceLastSubmit=!1})};I(void 0,function(){q()});var ee={batch:function(w){c++,w(),c--,R(),q()},blur:function(w){var O=u.fields,L=u.formState,N=O[w];N&&(delete L.active,O[w]=be({},N,{active:!1,touched:!0}),a?I(w,function(){R(),q()}):(R(),q()))},change:function(w,O){var L=u.fields,N=u.formState;if(ge(N.values,w)!==O){y(u,w,function(){return O});var Q=L[w];Q&&(L[w]=be({},Q,{modified:!0,modifiedSinceLastSubmit:!!N.lastSubmittedValues})),a?(R(),q()):I(w,function(){R(),q()})}},get destroyOnUnregister(){return!!t},set destroyOnUnregister(U){t=U},focus:function(w){var O=u.fields[w];O&&!O.active&&(u.formState.active=w,O.active=!0,O.visited=!0,R(),q())},mutators:C,getFieldState:function(w){var O=u.fields[w];return O&&O.lastFieldState},getRegisteredFields:function(){return Object.keys(u.fields)},getState:function(){return j()},initialize:function(w){var O=u.fields,L=u.formState,N=be({},O),Q=typeof w=="function"?w(L.values):w;n||(L.values=Q);var Z=n?Object.keys(N).reduce(function(ce,he){var ue=N[he],ke=ue.isEqual(ge(L.values,he),ge(L.initialValues||{},he));return ke||(ce[he]=ge(L.values,he)),ce},{}):{};L.initialValues=Q,L.values=Q,Object.keys(Z).forEach(function(ce){L.values=ut(L.values,ce,Z[ce])||{}}),I(void 0,function(){R(),q()})},isValidationPaused:function(){return h},pauseValidation:function(w){w===void 0&&(w=!0),h=!0,p=w},registerField:function(w,O,L,N){L===void 0&&(L={}),u.fieldSubscribers[w]||(u.fieldSubscribers[w]={index:0,entries:{}});var Q=u.fieldSubscribers[w].index++;u.fieldSubscribers[w].entries[Q]={subscriber:Tu(O),subscription:L,notified:!1};var Z=u.fields[w]||{active:!1,afterSubmit:N&&N.afterSubmit,beforeSubmit:N&&N.beforeSubmit,data:N&&N.data||{},isEqual:N&&N.isEqual||ly,lastFieldState:void 0,modified:!1,modifiedSinceLastSubmit:!1,name:w,touched:!1,valid:!0,validateFields:N&&N.validateFields,validators:{},validating:!1,visited:!1};Z.blur=Z.blur||function(){return ee.blur(w)},Z.change=Z.change||function(Ne){return ee.change(w,Ne)},Z.focus=Z.focus||function(){return ee.focus(w)},u.fields[w]=Z;var ce=!1,he=N&&N.silent,ue=function(){he&&u.fields[w]?R(w):(q(),R())};if(N){ce=!!(N.getValidator&&N.getValidator()),N.getValidator&&(u.fields[w].validators[Q]=N.getValidator);var ke=ge(u.formState.values,w)===void 0;N.initialValue!==void 0&&(ke||ge(u.formState.values,w)===ge(u.formState.initialValues,w))&&(u.formState.initialValues=ut(u.formState.initialValues||{},w,N.initialValue),u.formState.values=ut(u.formState.values,w,N.initialValue),I(void 0,ue)),N.defaultValue!==void 0&&N.initialValue===void 0&&ge(u.formState.initialValues,w)===void 0&&ke&&(u.formState.values=ut(u.formState.values,w,N.defaultValue))}return ce?I(void 0,ue):ue(),function(){var Ne=!1;u.fields[w]&&(Ne=!!(u.fields[w].validators[Q]&&u.fields[w].validators[Q]()),delete u.fields[w].validators[Q]);var xt=!!u.fieldSubscribers[w];xt&&delete u.fieldSubscribers[w].entries[Q];var ni=xt&&!Object.keys(u.fieldSubscribers[w].entries).length;ni&&(delete u.fieldSubscribers[w],delete u.fields[w],Ne&&(u.formState.errors=ut(u.formState.errors,w,void 0)||{}),t&&(u.formState.values=ut(u.formState.values,w,void 0,!0)||{})),he||(Ne?I(void 0,function(){q(),R()}):ni&&q())}},reset:function(w){w===void 0&&(w=u.formState.initialValues),u.formState.submitting&&(u.formState.resetWhileSubmitting=!0),u.formState.submitFailed=!1,u.formState.submitSucceeded=!1,delete u.formState.submitError,delete u.formState.submitErrors,delete u.formState.lastSubmittedValues,ee.initialize(w||{})},resetFieldState:function(w){u.fields[w]=be({},u.fields[w],{active:!1,lastFieldState:void 0,modified:!1,touched:!1,valid:!0,validating:!1,visited:!1}),I(void 0,function(){R(),q()})},restart:function(w){w===void 0&&(w=u.formState.initialValues),ee.batch(function(){for(var O in u.fields)ee.resetFieldState(O),u.fields[O]=be({},u.fields[O],{active:!1,lastFieldState:void 0,modified:!1,modifiedSinceLastSubmit:!1,touched:!1,valid:!0,validating:!1,visited:!1});ee.reset(w)})},resumeValidation:function(){h=!1,p=!1,d&&I(void 0,function(){R(),q()}),d=!1},setConfig:function(w,O){switch(w){case"debug":e=O;break;case"destroyOnUnregister":t=O;break;case"initialValues":ee.initialize(O);break;case"keepDirtyOnReinitialize":n=O;break;case"mutators":r=O,O?(Object.keys(C).forEach(function(L){L in O||delete C[L]}),Object.keys(O).forEach(function(L){C[L]=v(L)})):Object.keys(C).forEach(function(L){delete C[L]});break;case"onSubmit":o=O;break;case"validate":l=O,I(void 0,function(){R(),q()});break;case"validateOnBlur":a=O;break;default:throw new Error("Unrecognised option "+w)}},submit:function(){var w=u.formState;if(!w.submitting){if(delete w.submitErrors,delete w.submitError,w.lastSubmittedValues=be({},w.values),F()){H(),ie(),u.formState.submitFailed=!0,q(),R();return}var O=Object.keys(m);if(O.length){Promise.all(O.map(function(he){return m[Number(he)]})).then(ee.submit,console.error);return}var L=ne();if(!L){var N,Q=!1,Z=function(ue){w.submitting=!1;var ke=w.resetWhileSubmitting;return ke&&(w.resetWhileSubmitting=!1),ue&&Xi(ue)?(w.submitFailed=!0,w.submitSucceeded=!1,w.submitErrors=ue,w.submitError=ue[Un],H()):(ke||(w.submitFailed=!1,w.submitSucceeded=!0),ae()),q(),R(),Q=!0,N&&N(ue),ue};w.submitting=!0,w.submitFailed=!1,w.submitSucceeded=!1,w.lastSubmittedValues=be({},w.values),ie();var ce=o(w.values,ee,Z);if(!Q){if(ce&&wo(ce))return q(),R(),ce.then(Z,function(he){throw Z(),he});if(o.length>=3)return q(),R(),new Promise(function(he){N=he});Z(ce)}}}},subscribe:function(w,O){if(!w)throw new Error("No callback given.");if(!O)throw new Error("No subscription provided. What values do you want to listen to?");var L=Tu(w),N=u.subscribers,Q=N.index++;N.entries[Q]={subscriber:L,subscription:O,notified:!1};var Z=j();return ud(L,O,Z,Z,Au,!0),function(){delete N.entries[Q]}}};return ee}var cy=["render","children","component"];function hy(i,e,t){var n=i.render,s=i.children,r=i.component,o=qr(i,cy);if(r)return Se.createElement(r,Object.assign(e,o,{children:s,render:n}));if(n)return n(s===void 0?Object.assign(e,o):Object.assign(e,o,{children:s}));if(typeof s!="function")throw new Error("Must specify either a render prop, a render function as children, or a component prop to "+t);return s(Object.assign(e,o))}function Gt(i,e,t){t===void 0&&(t=function(r,o){return r===o});var n=M.useRef(i);M.useEffect(function(){t(i,n.current)||(e(),n.current=i)})}function dy(i){var e=M.useRef();return e.current||(e.current=i()),e.current}var Eo=function(e,t){if(e===t)return!0;if(typeof e!="object"||!e||typeof t!="object"||!t)return!1;var n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(var r=Object.prototype.hasOwnProperty.bind(t),o=0;o<n.length;o++){var l=n[o];if(!r(l)||e[l]!==t[l])return!1}return!0},fy=function(e){return!!(e&&typeof e.stopPropagation=="function")},cd=Se.createContext();function hd(i){var e=M.useRef(i);return M.useEffect(function(){e.current=i}),e}var py="6.5.8",dd=function(e,t,n){n.forEach(function(s){Object.defineProperty(e,s,{get:function(){return t[s]},enumerable:!0})})},fd=function(e,t){return dd(e,t,["active","dirty","dirtyFields","dirtySinceLastSubmit","dirtyFieldsSinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","modified","modifiedSinceLastSubmit","pristine","submitError","submitErrors","submitFailed","submitSucceeded","submitting","touched","valid","validating","values","visited"])},gy=function(e,t){return dd(e,t,["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","modified","modifiedSinceLastSubmit","pristine","submitError","submitFailed","submitSucceeded","submitting","touched","valid","validating","visited"])},my=["debug","decorators","destroyOnUnregister","form","initialValues","initialValuesEqual","keepDirtyOnReinitialize","mutators","onSubmit","subscription","validate","validateOnBlur"],xy={"final-form":oy,"react-final-form":py},pd=ad.reduce(function(i,e){return i[e]=!0,i},{});function yy(i){var e=i.debug,t=i.decorators,n=t===void 0?[]:t,s=i.destroyOnUnregister,r=i.form,o=i.initialValues,l=i.initialValuesEqual,a=i.keepDirtyOnReinitialize,u=i.mutators,c=i.onSubmit,h=i.subscription,d=h===void 0?pd:h,p=i.validate,g=i.validateOnBlur,m=qr(i,my),x={debug:e,destroyOnUnregister:s,initialValues:o,keepDirtyOnReinitialize:a,mutators:u,onSubmit:c,validate:p,validateOnBlur:g},y=dy(function(){var I=r||uy(x);return I.pauseValidation(),I}),b=Se.useState(function(){var I={};return y.subscribe(function(R){I=R},d)(),I}),v=b[0],C=b[1],S=hd(v);Se.useEffect(function(){y.isValidationPaused()&&y.resumeValidation();var I=[y.subscribe(function(R){Eo(R,S.current)||C(R)},d)].concat(n?n.map(function(R){return R(y)}):[]);return function(){y.pauseValidation(),I.reverse().forEach(function(R){return R()})}},n),process.env.NODE_ENV!=="production"&&Gt(n,function(){console.error("Form decorators should not change from one render to the next as new values will be ignored")},Eo),Gt(e,function(){y.setConfig("debug",e)}),Gt(s,function(){y.destroyOnUnregister=!!s}),Gt(a,function(){y.setConfig("keepDirtyOnReinitialize",a)}),Gt(o,function(){y.setConfig("initialValues",o)},l||Eo),Gt(u,function(){y.setConfig("mutators",u)}),Gt(c,function(){y.setConfig("onSubmit",c)}),Gt(p,function(){y.setConfig("validate",p)}),Gt(g,function(){y.setConfig("validateOnBlur",g)});var E=function(R){return R&&(typeof R.preventDefault=="function"&&R.preventDefault(),typeof R.stopPropagation=="function"&&R.stopPropagation()),y.submit()},A={form:be({},y,{reset:function(R){fy(R)?y.reset():y.reset(R)}}),handleSubmit:E};return fd(A,v),Se.createElement(cd.Provider,{value:y},hy(be({},m,{__versions:xy}),A,"ReactFinalForm"))}function Kr(i){var e=Se.useContext(cd);if(!e)throw new Error((i||"useForm")+" must be used inside of a <Form> component");return e}function by(i){var e=i===void 0?{}:i,t=e.onChange,n=e.subscription,s=n===void 0?pd:n,r=Kr("useFormState"),o=Se.useRef(!0),l=Se.useRef(t);l.current=t;var a=Se.useState(function(){var d={};return r.subscribe(function(p){d=p},s)(),t&&t(d),d}),u=a[0],c=a[1];Se.useEffect(function(){return r.subscribe(function(d){o.current?o.current=!1:(c(d),l.current&&l.current(d))},s)},[]);var h={};return fd(h,u),h}var vy=typeof window<"u"&&window.navigator&&window.navigator.product&&window.navigator.product==="ReactNative",Sy=function(e){var t=[];if(e)for(var n=0;n<e.length;n++){var s=e[n];s.selected&&t.push(s.value)}return t},Cy=function(e,t,n,s){if(!s&&e.nativeEvent&&e.nativeEvent.text!==void 0||s&&e.nativeEvent)return e.nativeEvent.text;var r=e,o=r.target,l=o.type,a=o.value,u=o.checked;switch(l){case"checkbox":if(n!==void 0){if(u)return Array.isArray(t)?t.concat(n):[n];if(!Array.isArray(t))return t;var c=t.indexOf(n);return c<0?t:t.slice(0,c).concat(t.slice(c+1))}else return!!u;case"select-multiple":return Sy(e.target.options);default:return a}};function Ro(i){var e=Se.useRef(i);return Se.useEffect(function(){e.current=i}),Se.useCallback(function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return e.current.apply(null,n)},[])}var wy=wa.reduce(function(i,e){return i[e]=!0,i},{}),ko=function(e,t){return e===void 0?"":e},Ey=function(e,t){return e===""?void 0:e},Ry=function(e,t){return e===t};function Ea(i,e){e===void 0&&(e={});var t=e,n=t.afterSubmit,s=t.allowNull,r=t.component,o=t.data,l=t.defaultValue,a=t.format,u=a===void 0?ko:a,c=t.formatOnBlur,h=t.initialValue,d=t.multiple,p=t.parse,g=p===void 0?Ey:p,m=t.subscription,x=m===void 0?wy:m,y=t.type,b=t.validateFields,v=t.value,C=Kr("useField"),S=hd(e),E=function(B,q){return C.registerField(i,B,x,{afterSubmit:n,beforeSubmit:function(){var ae=S.current,ie=ae.beforeSubmit,ee=ae.formatOnBlur,U=ae.format,w=U===void 0?ko:U;if(ee){var O=C.getFieldState(i),L=O.value,N=w(L,i);N!==L&&C.change(i,N)}return ie&&ie()},data:o,defaultValue:l,getValidator:function(){return S.current.validate},initialValue:h,isEqual:function(ae,ie){return(S.current.isEqual||Ry)(ae,ie)},silent:q,validateFields:b})},A=Se.useRef(!0),I=Se.useState(function(){var P={},B=C.destroyOnUnregister;return C.destroyOnUnregister=!1,E(function(q){P=q},!0)(),C.destroyOnUnregister=B,P}),R=I[0],H=I[1];Se.useEffect(function(){return E(function(P){A.current?A.current=!1:H(P)},!1)},[i,o,l,h]);var F={};gy(F,R);var j={name:i,get value(){var P=R.value;return c?r==="input"&&(P=ko(P)):P=u(P,i),P===null&&!s&&(P=""),y==="checkbox"||y==="radio"?v:r==="select"&&d?P||[]:P},get checked(){var P=R.value;if(y==="checkbox")return P=u(P,i),v===void 0?!!P:!!(Array.isArray(P)&&~P.indexOf(v));if(y==="radio")return u(P,i)===v},onBlur:Ro(function(P){if(R.blur(),c){var B=C.getFieldState(R.name);R.change(u(B.value,R.name))}}),onChange:Ro(function(P){if(process.env.NODE_ENV!=="production"&&P&&P.target){var B=P.target.type,q=~["checkbox","radio","select-multiple"].indexOf(B)&&!y&&r!=="select",ne=B==="select-multiple"?R.value:v;q&&console.error('You must pass `type="'+(B==="select-multiple"?"select":B)+'"` prop to your Field('+i+`) component.
23
+ `+("Without it we don't know how to unpack your `value` prop - "+(Array.isArray(ne)?"["+ne+"]":'"'+ne+'"')+"."))}var ae=P&&P.target?Cy(P,R.value,v,vy):P;R.change(g(ae,i))}),onFocus:Ro(function(P){return R.focus()})};d&&(j.multiple=d),y!==void 0&&(j.type=y);var W={input:j,meta:F};return W}function Ra(i){const e=i?{submitting:i.submitting,submitError:i.submitError,values:i.values,submitFailed:i.submitFailed,hasValidationErrors:i.hasValidationErrors,errors:i.errors,submitErrors:i.submitErrors,touched:i.touched,modifiedSinceLastSubmit:i.modifiedSinceLastSubmit}:void 0,t=by({subscription:e});return{submitting:t.submitting,submitError:t.submitError,values:t.values,submitFailed:t.submitFailed,hasValidationErrors:t.hasValidationErrors,errors:t.errors,submitErrors:t.submitErrors,touched:t.touched,modifiedSinceLastSubmit:t.modifiedSinceLastSubmit}}const ka=({children:i,formId:e,kind:t=G.KIND.primary,disabled:n,overrides:s,...r})=>{const{submitting:o}=Ra({submitting:!0});return f.jsxRuntimeExports.jsx(G.Button,{type:"submit",kind:t,form:e,disabled:n,isLoading:o,overrides:wm.mergeOverrides({BaseButton:{style:{minWidth:"200px"}}},s),...r,children:i})};function hn(){return hn=Object.assign||function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},hn.apply(this,arguments)}var gd=function(e,t,n){var s=e[0],r=e[1],o=e[2],l=n.changeValue;l(t,s,function(c){var h=[].concat(c||[]);return h.splice(r,0,o),h});var a=new RegExp("^"+s+"\\[(\\d+)\\](.*)"),u={};Object.keys(t.fields).forEach(function(c){var h=a.exec(c);if(h){var d=Number(h[1]);if(d>=r){var p=s+"["+(d+1)+"]"+h[2];u[p]=t.fields[c],u[p].name=p}d===r&&delete t.fields[c]}}),t.fields=hn({},t.fields,u)},ky=function(e,t,n){var s=e[0],r=e[1],o=n.changeValue;o(t,s,function(l){return l?[].concat(l,r):r})},Ay=function(e,t,n){var s=e[0],r=e[1],o=e[2],l=n.changeValue;if(r===o)return;l(t,s,function(c){var h=[].concat(c||[]),d=h[r];return h.splice(r,1),h.splice(o,0,d),h});var a=s+"["+r+"]";Object.keys(t.fields).forEach(function(c){if(c.substring(0,a.length)===a){var h=c.substring(a.length),d=a+h,p=t.fields[d];if(r<o)for(var g=r;g<o;g++){var m=s+"["+g+"]"+h;u({destKey:m,source:t.fields[s+"["+(g+1)+"]"+h]})}else for(var x=r;x>o;x--){var y=s+"["+x+"]"+h;u({destKey:y,source:t.fields[s+"["+(x-1)+"]"+h]})}var b=s+"["+o+"]"+h;u({destKey:b,source:p})}});function u(c){var h=c.destKey,d=c.source;t.fields[h]=hn({},d,{name:h,change:t.fields[h]&&t.fields[h].change,blur:t.fields[h]&&t.fields[h].blur,focus:t.fields[h]&&t.fields[h].focus,lastFieldState:void 0})}},Ty=function(e,t,n){var s=e[0],r=n.changeValue,o;return r(t,s,function(l){if(l)return l.length?(o=l[l.length-1],l.slice(0,l.length-1)):[]}),o},My=function(e,t,n){var s=e[0],r=e[1],o=n.changeValue;o(t,s,function(l){return l?[].concat(l,[r]):[r]})},md=function(e,t,n){var s=e[0],r=e[1],o=n.changeValue,l;o(t,s,function(c){var h=[].concat(c||[]);return l=h[r],h.splice(r,1),h});var a=new RegExp("^"+s+"\\[(\\d+)\\](.*)"),u=hn({},t.fields);return Object.keys(t.fields).forEach(function(c){var h=a.exec(c);if(h){var d=Number(h[1]);if(d===r)delete t.fields[c];else if(d>r){delete t.fields[c];var p=s+"["+(d-1)+"]"+h[2];t.fields[p]=u[c],t.fields[p].name=p}}}),l},Oy=function(e,t){return e.reduce(function(n,s){return s<t?n+1:n},0)},Iy=function(e,t,n){var s=e[0],r=e[1],o=n.changeValue,l=[].concat(r);l.sort();for(var a=0;a<l.length;a++)a>0&&l[a]===l[a-1]&&l.splice(a--,1);var u=[];o(t,s,function(d){if(u=r.map(function(m){return d&&d[m]}),!d||!l.length)return d;var p=[].concat(d),g=[];return l.forEach(function(m){p.splice(m-g.length,1),g.push(d&&d[m])}),p});var c=new RegExp("^"+s+"\\[(\\d+)\\](.*)"),h={};return Object.keys(t.fields).forEach(function(d){var p=c.exec(d);if(p){var g=Number(p[1]);if(!~l.indexOf(g)){var m=s+"["+(g-Oy(l,g))+"]"+p[2];h[m]=t.fields[d],h[m].name=m}}else h[d]=t.fields[d]}),t.fields=h,u},jy=function(e,t,n){var s=e[0];return md([s,0],t,n)},Py=function(e,t,n){var s=e[0],r=e[1],o=e[2],l=n.changeValue;if(r===o)return;l(t,s,function(h){var d=[].concat(h||[]),p=d[r];return d[r]=d[o],d[o]=p,d});var a=s+"["+r+"]",u=s+"["+o+"]";Object.keys(t.fields).forEach(function(h){if(h.substring(0,a.length)===a){var d=h.substring(a.length),p=a+d,g=u+d,m=t.fields[p];c({destKey:p,source:t.fields[g]}),c({destKey:g,source:m})}});function c(h){var d=h.destKey,p=h.source;t.fields[d]=hn({},p,{name:d,change:t.fields[d].change,blur:t.fields[d].blur,focus:t.fields[d].focus,lastFieldState:void 0})}},Dy=function(e,t,n){var s=e[0],r=e[1];return gd([s,0,r],t,n)},Ly=function(e,t,n){var s=e[0],r=e[1],o=e[2],l=n.changeValue;l(t,s,function(a){var u=[].concat(a||[]);return u.splice(r,1,o),u})},Fy={insert:gd,concat:ky,move:Ay,pop:Ty,push:My,remove:md,removeBatch:Iy,shift:jy,swap:Py,unshift:Dy,update:Ly},Ny=function(e){return!!(e&&typeof e.focus=="function")},By=function(){return typeof document>"u"?[]:Array.prototype.slice.call(document.forms).reduce(function(e,t){return e.concat(Array.prototype.slice.call(t).filter(Ny))},[])},Vy=function(e,t){return e.find(function(n){return n.name&&ge(t,n.name)})},_y=function(){},zy=function(e,t){return function(n){var s=function(c){e||(e=By),t||(t=Vy);var h=t(e(),c);h&&h.focus()},r=n.submit,o={},l=n.subscribe(function(u){o=u},{errors:!0,submitErrors:!0}),a=function(){var c=o,h=c.errors,d=c.submitErrors;h&&Object.keys(h).length?s(h):d&&Object.keys(d).length&&s(d)};return n.submit=function(){var u=r.call(n);return u&&typeof u.then=="function"?u.then(a,_y):a(),u},function(){l(),n.submit=r}}};const $y=D.styled("div",({$height:i})=>({height:`${i}px`,flexShrink:0})),Hy=D.styled("footer",({$theme:i})=>({display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",position:"fixed",boxSizing:"border-box",left:0,bottom:0,boxShadow:i.lighting.shallowAbove,backgroundColor:i.colors.backgroundPrimary,paddingTop:i.sizing.scale600,paddingBottom:i.sizing.scale600,paddingLeft:i.sizing.scale900,paddingRight:i.sizing.scale900,gap:i.sizing.scale400})),Ou=D.styled("div",({$theme:i})=>({display:"flex",alignItems:"center",gap:i.sizing.scale200}));function Gy({leftContent:i,rightContent:e}){const t=M.useRef(null),[n,s]=M.useState(0);return M.useEffect(()=>{const r=t.current;if(!r)return;const o=new ResizeObserver(()=>{s(r.offsetHeight)});return o.observe(r),()=>o.disconnect()},[]),f.jsxRuntimeExports.jsxs(f.jsxRuntimeExports.Fragment,{children:[f.jsxRuntimeExports.jsx($y,{$height:n}),f.jsxRuntimeExports.jsxs(Hy,{ref:t,children:[f.jsxRuntimeExports.jsx(Ou,{children:i}),f.jsxRuntimeExports.jsx(Ou,{children:e})]})]})}const xd=M.createContext(null);function Aa(){const i=M.useContext(xd);if(!i)throw new Error("useFormContext must be used within a <Form>");return i}const Wy=zy(),Yr=({onSubmit:i,initialValues:e,id:t,children:n,render:s,footer:r,focusOnError:o=!0})=>{const[l,a]=D.useStyletron(),u=M.useRef(new Map),c=M.useMemo(()=>({fieldRegistry:u.current}),[]);return f.jsxRuntimeExports.jsx(xd.Provider,{value:c,children:f.jsxRuntimeExports.jsx(yy,{onSubmit:i,initialValues:e,mutators:{...Fy},decorators:o?[Wy]:void 0,render:({handleSubmit:h})=>{const d=f.jsxRuntimeExports.jsxs("form",{className:l({display:"flex",flexDirection:"column",gap:a.sizing.scale600}),id:t,onSubmit:h,children:[n,Uy(r)]});return s?s(d):d}})})};function Uy(i){if(!i)return null;if(typeof i=="object"&&("left"in i||"right"in i)){const{left:e,right:t}=i;return f.jsxRuntimeExports.jsx(Gy,{leftContent:e,rightContent:t})}return i}const yd=(...i)=>e=>{for(const t of i){const n=t(e);if(n!==void 0)return n}},zi=i=>i==null?!0:typeof i=="string"?i.trim()==="":Array.isArray(i)?i.length===0:f.isRecord(i)?Object.keys(i).length===0:!1,qy=(i="This field is required.")=>e=>{if(!(typeof e=="boolean"||typeof e=="number"))return zi(e)?i:void 0},Ky=(i,e=`Must be at least ${i}.`)=>t=>{if(zi(t))return;const n=Number(t);return isNaN(n)||n<i?e:void 0},Yy=(i,e=`Must be at most ${i}.`)=>t=>{if(zi(t))return;const n=Number(t);return isNaN(n)||n>i?e:void 0},Xy=(i,e=`Must be at least ${i} characters.`)=>t=>zi(t)?void 0:String(t).length<i?e:void 0,Qy=(i,e=`Must be at most ${i} characters.`)=>t=>zi(t)?void 0:String(t).length>i?e:void 0,Jy=(i,e="Invalid format.")=>t=>zi(t)||(typeof i=="string"?new RegExp(i):i).test(String(t))?void 0:e,Zy=(i="Must be a valid URL.")=>e=>{if(!zi(e))return f.isAbsoluteUrl(String(e))?void 0:i};function zt(i){if(!i)return;const e=[];if(i.min!==void 0&&e.push(Ky(i.min)),i.max!==void 0&&e.push(Yy(i.max)),i.minLength!==void 0&&e.push(Xy(i.minLength)),i.maxLength!==void 0&&e.push(Qy(i.maxLength)),i.regex&&e.push(Jy(i.regex.pattern,i.regex.errorMessage)),i.url){const t=typeof i.url=="object"?i.url.errorMessage:void 0;e.push(Zy(t))}if(i.validate&&e.push(i.validate),e.length!==0)return e.length===1?e[0]:yd(...e)}const eb=({label:i,required:e,description:t})=>{const[n,s]=D.useStyletron();return f.jsxRuntimeExports.jsxs("span",{className:n({display:"flex",gap:s.sizing.scale200,minHeight:s.sizing.scale600,alignItems:"center"}),children:[i,e?f.jsxRuntimeExports.jsx("span",{className:n({color:s.colors.negative}),children:"*"}):null,t?f.jsxRuntimeExports.jsx(f.HelpTooltip,{text:t}):null]})},tb=({counter:i,labelEndEnhancer:e})=>{const[t,n]=D.useStyletron();return f.jsxRuntimeExports.jsxs(f.jsxRuntimeExports.Fragment,{children:[i&&f.jsxRuntimeExports.jsxs("span",{className:t({...n.typography.font100,color:n.colors.contentPrimary}),children:[i.length,"/",i.maxLength]}),e]})},Ye=({label:i,required:e,description:t,labelEndEnhancer:n,caption:s,error:r,counter:o,children:l})=>{const[a,u]=D.useStyletron(),c=o||n?f.jsxRuntimeExports.jsx(tb,{counter:o,labelEndEnhancer:n}):void 0;return f.jsxRuntimeExports.jsx("div",{className:a({width:"100%"}),children:f.jsxRuntimeExports.jsx(Em.FormControl,{label:i&&f.jsxRuntimeExports.jsx(eb,{label:i,required:e,description:t}),labelEndEnhancer:c,caption:s&&f.jsxRuntimeExports.jsx(f.TruncatedText,{children:f.jsxRuntimeExports.jsx(f.Markdown,{children:s})}),error:r,overrides:{ControlContainer:{style:{marginBottom:0}},LabelEndEnhancer:{style:{display:"flex",alignItems:"center",gap:u.sizing.scale300}},Caption:{style:({$error:h,$positive:d})=>({display:h||d?"flex":"block"})}},children:l})})};function ib(i,e){const{fieldRegistry:t}=Aa();M.useEffect(()=>(e&&t.set(i,{label:e}),()=>{t.delete(i)}),[i,e,t])}function it(i,e){ib(i,e==null?void 0:e.label);const t=e!=null&&e.required?yd(qy(),...e.validate?[e.validate]:[]):e==null?void 0:e.validate,s=Ea(i,{validate:t?l=>t(l):void 0,defaultValue:e==null?void 0:e.defaultValue,initialValue:e==null?void 0:e.initialValue,parse:e==null?void 0:e.parse,format:e==null?void 0:e.format}),r={value:s.input.value,name:s.input.name,onChange:s.input.onChange,onBlur:s.input.onBlur,onFocus:s.input.onFocus},o={error:typeof s.meta.error=="string"?s.meta.error:void 0,touched:!!s.meta.touched};return{input:r,meta:o}}const bd=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:u,labelEndEnhancer:c,format:h,parse:d,checkboxLabel:p,toggle:g=!1})=>{const{input:m,meta:x}=it(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:h,parse:d}),y=v=>{m.onChange(v.currentTarget.checked)},b=p??(m.value?"Enabled":"Disabled");return f.jsxRuntimeExports.jsx(Ye,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:x.touched&&x.error?x.error:void 0,children:f.jsxRuntimeExports.jsx(Oi.Checkbox,{checked:m.value??!1,onChange:o?void 0:y,onBlur:m.onBlur,onFocus:m.onFocus,disabled:l,checkmarkType:g?Oi.STYLE_TYPE.toggle_round:Oi.STYLE_TYPE.default,labelPlacement:Oi.LABEL_PLACEMENT.right,overrides:{Label:{style:({$theme:v})=>({fontSize:v.sizing.scale550})},Root:{style:o?{cursor:"default"}:{}}},children:b})})};function nb({name:i,config:e}){const t=e,n=zt(t.validation);return f.jsxRuntimeExports.jsx(bd,{name:i,label:t.label,required:t.required,disabled:t.disabled,readOnly:t.readOnly,description:t.description,caption:t.caption,checkboxLabel:t.checkboxLabel,toggle:t.toggle,validate:n})}const vd=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,disabled:o,description:l,caption:a,labelEndEnhancer:u,format:c,parse:h,options:d})=>{const[p,g]=D.useStyletron(),{input:m,meta:x}=it(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:c,parse:h}),{value:y=[],onChange:b}=m,v=M.useCallback(S=>{const E=y.includes(S)?y.filter(A=>A!==S):[...y,S];b(E)},[y,b]),C=d.some(S=>S.description);return f.jsxRuntimeExports.jsx(Ye,{label:e,required:s,description:l,labelEndEnhancer:u,caption:a,error:x.touched&&x.error?x.error:void 0,children:d.length===0?f.jsxRuntimeExports.jsx("span",{children:"No options available"}):f.jsxRuntimeExports.jsx("div",{className:p({display:"flex",flexDirection:C?"column":"row",flexWrap:C?void 0:"wrap",gap:g.sizing.scale600}),children:d.map(S=>f.jsxRuntimeExports.jsxs(Oi.Checkbox,{checked:y.includes(S.id),onChange:()=>v(S.id),disabled:o,overrides:{Label:{style:({$theme:E})=>({fontSize:E.sizing.scale550})}},children:[S.label,S.description&&f.jsxRuntimeExports.jsx(f.DescriptionText,{children:S.description})]},S.id))})})};function sb({name:i,config:e}){const t=e,n=zt(t.validation);return f.jsxRuntimeExports.jsx(vd,{name:i,label:t.label,required:t.required,disabled:t.disabled,readOnly:t.readOnly,description:t.description,caption:t.caption,options:t.options??[],validate:n})}var sn=(i=>(i.EPOCH_SECONDS="epoch",i.ISO_DATE_STRING="iso",i))(sn||{});function rb(i=sn.ISO_DATE_STRING){const e=i===sn.EPOCH_SECONDS?n=>n?f.getDateFromEpochSeconds(parseInt(n)):null:n=>n?new Date(n):null,t=i===sn.EPOCH_SECONDS?n=>n?String(f.getEpochSecondsFromDate(n)):"":n=>n?n.toISOString():"";return{format:n=>ob(e(n)),parse:n=>t(lb(n))}}function ob(i){if(!i)return null;const e=i.getTimezoneOffset();return new Date(i.getTime()+e*60*1e3)}function lb(i){if(!i)return i;const e=i.getTimezoneOffset();return new Date(i.getTime()-e*60*1e3)}const Sd=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,placeholder:l,disabled:a,description:u,caption:c,labelEndEnhancer:h,noFutureDate:d,dateFormat:p=sn.ISO_DATE_STRING})=>{const{format:g,parse:m}=rb(p),{input:x,meta:y}=it(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:g,parse:m});return f.jsxRuntimeExports.jsx(Ye,{label:e,required:s,description:u,labelEndEnhancer:h,caption:c,error:y.touched&&y.error?y.error:void 0,children:f.jsxRuntimeExports.jsx(Rm.DatePicker,{id:x.name,value:x.value,onChange:({date:b})=>{f.lodashExports.isNil(b)&&ab(x.value)||x.onChange(b)},placeholder:!a&&!o?l??"MM/dd/yyyy":"",formatString:"MM/dd/yyyy",mask:"99/99/9999",onOpen:x.onFocus,onRangeChange:x.onBlur,onClose:x.onBlur,maxDate:d?new Date:void 0,disabled:a,overrides:o?{Input:{props:{readOnly:!0,onFocus:()=>{},overrides:{InputContainer:{style:({$theme:b})=>({backgroundColor:b.colors.backgroundPrimary})}}}}}:void 0})})};function ab(i){return f.lodashExports.isNil(i)||i===""||f.lodashExports.isArray(i)&&!i.length}function ub({name:i,config:e}){const t=e,n=zt(t.validation);return f.jsxRuntimeExports.jsx(Sd,{name:i,label:t.label,required:t.required,disabled:t.disabled,readOnly:t.readOnly,placeholder:t.placeholder,description:t.description,caption:t.caption,dateFormat:t.dateFormat,noFutureDate:t.noFutureDate,validate:n})}function Xr({label:i="Add more",shape:e,onClick:t}){const[,n]=D.useStyletron();return f.jsxRuntimeExports.jsx(G.Button,{type:"button",kind:G.KIND.secondary,size:G.SIZE.compact,shape:e,startEnhancer:f.jsxRuntimeExports.jsx(f.Icon,{name:"plus",color:n.colors.contentPrimary,size:n.sizing.scale600}),overrides:{BaseButton:{style:{marginBottom:n.sizing.scale600,width:"260px"}}},onClick:t,children:i})}function cb({row:i,keyConfig:e,valueConfig:t,readOnly:n,disabled:s,deletable:r=!0,size:o,keyError:l,onChange:a,onDelete:u,onFocus:c,onBlur:h}){const[d,p]=D.useStyletron(),g=i.key&&i.value?h:void 0;return f.jsxRuntimeExports.jsxs("div",{className:d({display:"flex",alignItems:"flex-start",gap:p.sizing.scale300,width:"100%"}),children:[f.jsxRuntimeExports.jsx(et.Input,{value:i.key,onChange:m=>a({...i,key:m.currentTarget.value}),onFocus:c,onBlur:g,placeholder:(e==null?void 0:e.placeholder)??"Key",readOnly:n||(e==null?void 0:e.readOnly),disabled:s,size:o,error:!!l,overrides:{Root:{style:{flex:1},props:l?{title:l}:void 0}}}),f.jsxRuntimeExports.jsx(et.Input,{value:i.value,onChange:m=>a({...i,value:m.currentTarget.value}),onFocus:c,onBlur:g,placeholder:(t==null?void 0:t.placeholder)??"Value",readOnly:n,disabled:s,size:o,overrides:{Root:{style:{flex:3}}}}),!n&&r&&f.jsxRuntimeExports.jsx(G.Button,{type:"button","aria-label":"Delete",kind:G.KIND.tertiary,shape:G.SHAPE.circle,onClick:()=>u(i),overrides:{BaseButton:{style:{marginBottom:p.sizing.scale600}}},children:f.jsxRuntimeExports.jsx(f.Icon,{name:"trashCan",kind:f.IconKind.TERTIARY})})]})}const hb={},db="cannot have duplicated values";function fb({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:u,labelEndEnhancer:c,format:h,parse:d,keyConfig:p,valueConfig:g,singleValue:m,creatable:x=!0,deletable:y=!0,emptyMessage:b,size:v}){const[C,S]=D.useStyletron(),{input:E,meta:A}=it(i,{required:s,validate:r,defaultValue:t??hb,initialValue:n,label:e,format:h,parse:d}),I=M.useRef(0),[R,H]=M.useState(()=>{const B=pb(E.value);return I.current=B.length,m&&B.length===0?(I.current=1,[{id:0,key:"",value:""}]):B}),F=M.useCallback(B=>{H(q=>{const ne=q.map(ae=>ae.id===B.id?B:ae);return E.onChange(Iu(ne)),ne})},[E]),j=()=>{H(B=>[...B,{id:I.current++,key:"",value:""}])},W=M.useCallback(B=>{H(q=>{const ne=q.filter(ae=>ae.id!==B.id);return E.onChange(Iu(ne)),ne})},[E]),P=new Set(R.map(B=>B.key).filter((B,q,ne)=>B&&ne.indexOf(B)!==q));return f.jsxRuntimeExports.jsx(Ye,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:A.touched&&A.error?A.error:void 0,children:f.jsxRuntimeExports.jsxs("div",{className:C({display:"flex",flexDirection:"column",gap:S.sizing.scale300}),children:[R.length===0&&b&&f.jsxRuntimeExports.jsx("div",{className:C({...S.typography.ParagraphSmall,marginBottom:S.sizing.scale200}),children:b}),R.map(B=>f.jsxRuntimeExports.jsx(cb,{row:B,keyConfig:p,valueConfig:g,readOnly:o,disabled:l,deletable:y&&!m,size:v,keyError:P.has(B.key)?`${(p==null?void 0:p.placeholder)??"Keys"} ${db}`:void 0,onChange:F,onDelete:W,onFocus:E.onFocus,onBlur:E.onBlur},B.id)),!m&&!o&&x&&f.jsxRuntimeExports.jsx(Xr,{onClick:j,label:"Add more"})]})})}function pb(i){return Object.entries(i??{}).map(([e,t],n)=>({id:n,key:e,value:t}))}function Iu(i){return Object.fromEntries(i.map(e=>[e.key,e.value]))}function gb({name:i,config:e}){const t=e,n=zt(t.validation);return f.jsxRuntimeExports.jsx(fb,{name:i,label:t.label,required:t.required,disabled:t.disabled,readOnly:t.readOnly,description:t.description,caption:t.caption,singleValue:t.singleValue,creatable:t.creatable,deletable:t.deletable,emptyMessage:t.emptyMessage,keyConfig:t.keyConfig,valueConfig:t.valueConfig,size:t.size,validate:n})}const Cd=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:u,caption:c,labelEndEnhancer:h,format:d,parse:p,rows:g,maxLength:m})=>{var S;const{input:x,meta:y}=it(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:d,parse:p}),[b,v]=D.useStyletron(),C=((S=x.value)==null?void 0:S.length)??0;return f.jsxRuntimeExports.jsx(Ye,{label:e,required:s,description:u,labelEndEnhancer:h,caption:c,error:y.touched&&y.error?y.error:void 0,counter:m?{length:C,maxLength:m}:void 0,children:o?f.jsxRuntimeExports.jsx("div",{className:b({...v.typography.font300,minHeight:String(v.typography.font300.lineHeight),border:`${v.sizing.scale0} solid ${v.colors.borderOpaque}`,borderRadius:v.borders.radius300,paddingTop:v.sizing.scale400,paddingBottom:v.sizing.scale400,paddingLeft:v.sizing.scale550,paddingRight:v.sizing.scale550}),children:f.jsxRuntimeExports.jsx(f.Markdown,{children:x.value})}):f.jsxRuntimeExports.jsx(Bh.Textarea,{id:x.name,name:x.name,value:x.value,onChange:E=>x.onChange(E.currentTarget.value),onBlur:x.onBlur,onFocus:x.onFocus,placeholder:a,disabled:l,rows:g,maxLength:m,overrides:{Input:{style:{resize:"vertical"}}}})})};function mb({name:i,config:e}){const t=e,n=zt(t.validation);return f.jsxRuntimeExports.jsx(Cd,{name:i,label:t.label,required:t.required,disabled:t.disabled,readOnly:t.readOnly,placeholder:t.placeholder,description:t.description,caption:t.caption,rows:t.rows,maxLength:t.maxLength,validate:n})}const wd=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:u,caption:c,labelEndEnhancer:h,format:d,parse:p})=>{const{input:g,meta:m}=it(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:d,parse:p});return f.jsxRuntimeExports.jsx(Ye,{label:e,required:s,description:u,labelEndEnhancer:h,caption:c,error:m.touched&&m.error?m.error:void 0,children:f.jsxRuntimeExports.jsx(et.Input,{id:g.name,type:"number",value:g.value==null?"":String(g.value),name:g.name,onChange:x=>g.onChange(xb(x.currentTarget.value)),onBlur:g.onBlur,onFocus:g.onFocus,placeholder:a,readOnly:o,disabled:l})})};function xb(i){if(i==="")return;const e=Number(i);return isNaN(e)?void 0:e}function yb({name:i,config:e}){const t=e,n=zt(t.validation);return f.jsxRuntimeExports.jsx(wd,{name:i,label:t.label,required:t.required,disabled:t.disabled,readOnly:t.readOnly,placeholder:t.placeholder,description:t.description,caption:t.caption,validate:n})}const bb={RadioMarkOuter:{style:({$disabled:i,$theme:e})=>i?{backgroundColor:e.colors.tickFillSelected}:{}}},vb={Root:{style:({$selected:i,$theme:e})=>({display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"flex-start",flex:"1 1 0%",":disabled":{opacity:.5,...i?{boxShadow:`inset 0px 0px 0px 3px ${e.colors.borderSelected}`}:{}}})},HeaderContainer:{style:{width:"100%",marginBottom:0}}},Sb=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:u,labelEndEnhancer:c,format:h,parse:d,options:p})=>{const[,g]=D.useStyletron(),{input:m,meta:x}=it(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:h,parse:d}),y=M.useMemo(()=>p.findIndex(v=>v.value===m.value),[p,m]),b=M.useCallback((v,C)=>{v.preventDefault(),v.stopPropagation(),m.onChange(p[C].value)},[m,p]);return f.jsxRuntimeExports.jsx(Ye,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:x.touched&&x.error?x.error:void 0,children:f.jsxRuntimeExports.jsx(Ri.TileGroup,{kind:Ri.TILE_GROUP_KIND.singleSelect,onClick:b,selected:y,disabled:l||o,overrides:bb,children:p.map(v=>f.jsxRuntimeExports.jsx(Ri.Tile,{tileKind:Ri.TILE_KIND.selection,leadingContent:()=>f.jsxRuntimeExports.jsx(ze.LabelMedium,{$style:{textAlign:"left"},children:v.label}),headerAlignment:Ri.ALIGNMENT.left,bodyAlignment:Ri.ALIGNMENT.left,overrides:vb,children:f.jsxRuntimeExports.jsx(Ri.StyledParagraph,{$style:{textAlign:"left",marginBottom:g.sizing.scale600},children:v.description})},String(v.value)))})})},Cb=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:u,labelEndEnhancer:c,format:h,parse:d,options:p,align:g=fo.ALIGN.horizontal})=>{var v;const{input:m,meta:x}=it(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:h,parse:d}),y=p.every(({value:C})=>typeof C=="boolean"),b=M.useCallback(C=>{const S=C.currentTarget.value;m.onChange(y?S==="true":S)},[m,y]);return o?f.jsxRuntimeExports.jsx(Ye,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:x.touched&&x.error?x.error:void 0,children:f.jsxRuntimeExports.jsx(et.Input,{id:m.name,readOnly:!0,value:((v=p.find(C=>C.value===m.value))==null?void 0:v.label)??"",overrides:{InputContainer:{style:({$theme:C})=>({backgroundColor:C.colors.backgroundPrimary})}}})}):f.jsxRuntimeExports.jsx(Ye,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:x.touched&&x.error?x.error:void 0,children:f.jsxRuntimeExports.jsx(fo.RadioGroup,{name:m.name,value:typeof m.value=="boolean"?String(m.value):m.value,align:g,disabled:l,onChange:b,onBlur:m.onBlur,onFocus:m.onFocus,overrides:{RadioGroupRoot:{style:({$theme:C})=>({gap:C.sizing.scale600})}},children:p.map(C=>f.jsxRuntimeExports.jsx(fo.Radio,{value:typeof C.value=="boolean"?String(C.value):C.value,disabled:C.disabled,overrides:{RadioMarkOuter:{style:({$theme:S})=>({height:S.sizing.scale600,width:S.sizing.scale600})},RadioMarkInner:{style:({$checked:S,$theme:E})=>({height:S?E.sizing.scale100:E.sizing.scale400,width:S?E.sizing.scale100:E.sizing.scale400,transform:"none"})}},children:C.label},String(C.value)))})})},Ed=i=>i.options.some(t=>!!t.description)?f.jsxRuntimeExports.jsx(Sb,{...i}):f.jsxRuntimeExports.jsx(Cb,{...i});function wb({name:i,config:e}){const t=e,n=zt(t.validation);return f.jsxRuntimeExports.jsx(Ed,{name:i,label:t.label,required:t.required,disabled:t.disabled,readOnly:t.readOnly,description:t.description,caption:t.caption,options:t.options??[],align:t.align,validate:n})}function Eb(i,e,t){const n={Popover:{props:{ignoreBoundary:!0}},Input:{props:{name:i}}};return e?D.mergeOverrides(n,{Tag:{props:{closeable:!1,disabled:!1}}}):t?D.mergeOverrides(n,{Input:{props:{readOnly:!0}},ControlContainer:{props:{onClick:()=>null},style:({$theme:s})=>({backgroundColor:s.colors.backgroundPrimary})},SelectArrow:{props:{size:0}},Tag:{props:{closeable:!1}}}):n}function Rb(i){return i?Array.isArray(i)?i:[i]:[]}function Ao(i){return JSON.stringify(i,(e,t)=>f.isRecord(t)?Object.fromEntries(Object.entries(t).sort(([n],[s])=>n.localeCompare(s))):t)}function Rd({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:u,labelEndEnhancer:c,placeholder:h,format:d,parse:p,options:g,visibleOptionLimit:m,isLoading:x=!1,clearable:y=!0,searchable:b=!0,multi:v=!1,creatable:C=!1}){const{input:S,meta:E}=it(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:d,parse:p}),{baseUiOptions:A,findByValue:I,findByKey:R}=M.useMemo(()=>{const j=new Map;return{baseUiOptions:g.map(P=>{const B=Ao(P.id);return j.set(B,P),{id:B,label:P.label,disabled:P.disabled}}),findByValue:P=>j.get(Ao(P)),findByKey:P=>j.get(P)}},[g]);M.useEffect(()=>{if(x||C)return;const j=S.value;if(!(!j||Array.isArray(j)&&j.length===0))if(v){const W=j,P=W.filter(B=>I(B));P.length!==W.length&&S.onChange(P)}else I(j)||S.onChange("")},[I,x]);const H=j=>{var P;const W=j.value;v?S.onChange(W.map(B=>{var q;return((q=R(B.id))==null?void 0:q.id)??B.id})):W.length>0?S.onChange(((P=R(W[0].id))==null?void 0:P.id)??W[0].id):S.onChange("")},F=M.useMemo(()=>{const j=[];for(const W of Rb(S.value)){const P=Ao(W),B=R(P);B?j.push({id:P,label:B.label,disabled:B.disabled}):C&&j.push({id:P,label:String(W)})}return j},[S.value,R,C]);return f.jsxRuntimeExports.jsx(Ye,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:E.touched&&E.error?E.error:void 0,children:f.jsxRuntimeExports.jsx(tn.Select,{id:i,value:F,options:A,onChange:H,onBlur:S.onBlur,onFocus:S.onFocus,placeholder:!l&&!o?h:"",disabled:l,clearable:!l&&!o&&y,searchable:b,multi:v,overrides:Eb(i,l,o),creatable:C,filterOptions:(j,W,P,B)=>tn.filterOptions(j,W,P,B).slice(0,m),isLoading:x,getOptionLabel:({option:j})=>j.label})})}function kb({name:i,config:e}){const t=e,n=zt(t.validation);return f.jsxRuntimeExports.jsx(Rd,{name:i,label:t.label,required:t.required,disabled:t.disabled,readOnly:t.readOnly,placeholder:t.placeholder,description:t.description,caption:t.caption,options:t.options??[],multi:t.multi,clearable:t.clearable,searchable:t.searchable,creatable:t.creatable,isLoading:t.isLoading,visibleOptionLimit:t.visibleOptionLimit,validate:n})}function Ab(i){const{closeable:e,index:t,onRemove:n,readOnly:s,updateValue:r,value:o}=i,[,l]=D.useStyletron(),[a,u]=M.useState(!1),[c,h]=M.useState(o),d={paddingTop:l.sizing.scale100,paddingRight:l.sizing.scale100,paddingBottom:l.sizing.scale100,paddingLeft:l.sizing.scale100},p=()=>{h(o),u(!1)},g=()=>{r(c,t),u(!1)},m=x=>{x.key==="Enter"&&g()};return a&&!s?f.jsxRuntimeExports.jsx(f.Tag,{contentMaxWidth:"100%",overrides:{ActionIcon:{component:f.Icon,props:{name:"check",onMouseDown:g,size:l.sizing.scale500}},Root:{style:d}},behavior:f.TAG_BEHAVIOR.selection,hierarchy:ur.HIERARCHY.secondary,children:f.jsxRuntimeExports.jsx(et.StyledInput,{$adjoined:et.ADJOINED.none,autoFocus:!0,onBlur:p,onChange:x=>h(x.target.value),onKeyDown:m,size:c.length+1,$size:et.SIZE.compact,style:{padding:0},value:c})}):f.jsxRuntimeExports.jsx(f.Tag,{closeable:e,onActionClick:n,onClick:()=>u(!0),overrides:{Root:{style:d}},hierarchy:ur.HIERARCHY.primary,children:o})}const Tb=M.forwardRef(function(e,t){const{clear:n,readOnly:s,removeValue:r,updateValue:o,value:l,valueList:a,...u}=e,[,c]=D.useStyletron(),h=()=>{var p;n(),t&&typeof t!="function"&&((p=t.current)==null||p.focus())},d=p=>{var g;p.target===p.currentTarget&&t&&typeof t!="function"&&((g=t.current)==null||g.focus())};return f.jsxRuntimeExports.jsxs(f.jsxRuntimeExports.Fragment,{children:[f.jsxRuntimeExports.jsxs(tn.StyledValueContainer,{$multi:!0,$style:{gap:c.sizing.scale100},onClick:d,children:[a.map((p,g)=>f.jsxRuntimeExports.jsx(Ab,{value:p,index:g,closeable:!s,onRemove:()=>r(g),readOnly:s,updateValue:o},g)),f.jsxRuntimeExports.jsx(et.StyledInput,{...u,$adjoined:et.ADJOINED.none,readOnly:s,ref:t,size:String(l??"").length+1,$size:et.SIZE.compact,value:l})]}),a.length>0&&!s&&f.jsxRuntimeExports.jsx(tn.StyledIconsContainer,{children:f.jsxRuntimeExports.jsx(tn.StyledClearIcon,{onClick:h,children:f.jsxRuntimeExports.jsx(km.DeleteAlt,{})})})]})});function Mb({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:u,caption:c,labelEndEnhancer:h,format:d,parse:p}){const{input:g,meta:m}=it(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:d,parse:p}),[x,y]=M.useState(""),b=Array.isArray(g.value)?g.value:[],v=R=>{g.onChange([...b,R]),y("")},C=R=>g.onChange(b.filter((H,F)=>F!==R)),S=(R,H)=>{const F=[...b];F[H]=R,g.onChange(F)},E=()=>{g.onChange([]),y("")},A=R=>{if(o)return;const H=R.key==="Enter"&&x,F=R.key==="Backspace"&&b.length>0&&!x;H?(R.preventDefault(),v(x)):F&&C(b.length-1)},I=()=>{g.onBlur(),x&&v(x)};return f.jsxRuntimeExports.jsx(Ye,{label:e,required:s,description:u,labelEndEnhancer:h,caption:c,error:m.touched&&m.error?m.error:void 0,children:f.jsxRuntimeExports.jsx(et.Input,{...g,id:i,value:x,onChange:R=>y(R.currentTarget.value),onBlur:I,placeholder:!l&&!o&&b.length===0?a:"",readOnly:o,disabled:l,overrides:{InputContainer:{style:({$theme:R})=>o&&!l?{backgroundColor:R.colors.backgroundPrimary}:{}},Input:{component:Tb,props:{clear:E,onKeyDown:A,readOnly:o,removeValue:C,updateValue:S,valueList:b},style:{width:"auto",flexGrow:1,padding:0}}}})})}function Ob({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:u,caption:c,labelEndEnhancer:h,format:d,parse:p}){const{input:g,meta:m}=it(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:d,parse:p});return f.jsxRuntimeExports.jsx(Ye,{label:e,required:s,description:u,labelEndEnhancer:h,caption:c,error:m.touched&&m.error?m.error:void 0,children:f.jsxRuntimeExports.jsx(et.Input,{id:g.name,value:g.value??"",name:g.name,onChange:x=>g.onChange(x.currentTarget.value),onBlur:g.onBlur,onFocus:g.onFocus,placeholder:a,readOnly:o,disabled:l})})}function Qr(i){return i.multi?f.jsxRuntimeExports.jsx(Mb,{...i}):f.jsxRuntimeExports.jsx(Ob,{...i})}function Ib({name:i,config:e}){const t=e,n=zt(t.validation);return f.jsxRuntimeExports.jsx(Qr,{name:i,label:t.label,required:t.required,disabled:t.disabled,readOnly:t.readOnly,placeholder:t.placeholder,description:t.description,caption:t.caption,multi:t.multi,validate:n})}const Ta=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:u,caption:c,labelEndEnhancer:h,format:d,parse:p,rows:g,maxLength:m})=>{var v;const{input:x,meta:y}=it(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:d,parse:p}),b=((v=x.value)==null?void 0:v.length)??0;return f.jsxRuntimeExports.jsx(Ye,{label:e,required:s,description:u,labelEndEnhancer:h,caption:c,error:y.touched&&y.error?y.error:void 0,counter:m?{length:b,maxLength:m}:void 0,children:f.jsxRuntimeExports.jsx(Bh.Textarea,{id:x.name,name:x.name,value:x.value??"",onChange:C=>x.onChange(C.currentTarget.value),onBlur:x.onBlur,onFocus:x.onFocus,placeholder:a,readOnly:o,disabled:l,rows:g,maxLength:m,overrides:{Input:{style:{resize:"vertical"}}}})})};function jb({name:i,config:e}){const t=e;return f.jsxRuntimeExports.jsx(Ta,{name:i,label:t.label,required:t.required,disabled:t.disabled,readOnly:t.readOnly,placeholder:t.placeholder,description:t.description,caption:t.caption,rows:t.rows,maxLength:t.maxLength})}const kd=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,description:o,caption:l,labelEndEnhancer:a,format:u,parse:c,placeholder:h,urlName:d})=>{const{input:p,meta:g}=it(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:u,parse:c}),m=p.value;return f.jsxRuntimeExports.jsx(Ye,{label:e,required:s,description:o,labelEndEnhancer:a,caption:l,error:g.touched&&g.error?g.error:void 0,children:f.isNavigableUrl(m)?f.jsxRuntimeExports.jsx(f.Link,{href:m,children:f.jsxRuntimeExports.jsx(f.TruncatedText,{children:d??e??m})}):f.jsxRuntimeExports.jsx("span",{children:h})})};function Pb({name:i,config:e}){const t=e,n=zt(t.validation);return f.jsxRuntimeExports.jsx(kd,{name:i,label:t.label,required:t.required,disabled:t.disabled,readOnly:t.readOnly,placeholder:t.placeholder,description:t.description,caption:t.caption,urlName:t.urlName,validate:n})}const Db={string:Ib,number:yb,boolean:nb,select:kb,checkbox:sb,radio:wb,date:ub,textarea:jb,url:Pb,map:gb,markdown:mb},Lb=M.createContext(null),Fb=()=>M.useContext(Lb);function Nb(i){const e=Fb();return(e==null?void 0:e.renderers[i])??Db[i]}function Bb({fieldPath:i,config:e}){const t=Nb((e==null?void 0:e.type)??"");return!t||!e?null:f.jsxRuntimeExports.jsx(t,{name:i,config:e})}function To(i){return i==null||i===""||Array.isArray(i)&&!i.length}function Ad(i,e){return"is"in i?e===i.is:"isNot"in i?!To(e)&&e!==i.isNot:"isEmpty"in i?i.isEmpty?To(e):!To(e):"containsAny"in i?Array.isArray(e)?i.containsAny.some(t=>e.includes(t)):i.containsAny.some(t=>e===t):!0}function Vb({layout:i,children:e}){const{input:t}=Ea(i.when,{subscription:{value:!0}});return Ad(i,t.value)?f.jsxRuntimeExports.jsx(f.jsxRuntimeExports.Fragment,{children:e}):null}const _b=({children:i})=>{const[e,t]=D.useStyletron();return f.jsxRuntimeExports.jsx("div",{className:e({display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gridColumnGap:t.sizing.scale800}),children:i})},Ma=({children:i,title:e,description:t,expanded:n,defaultExpanded:s=!1,onToggle:r,disabled:o=!1,overrides:l={}})=>{const[a,u]=M.useState(s),c=n!==void 0,h=c?n:a;M.useEffect(()=>{c&&!r&&console.warn("CollapsibleBox: `expanded` prop provided without `onToggle`. This will make the component unresponsive to user interaction. Either provide `onToggle` or use `defaultExpanded` instead.")},[c,r]);const d=()=>{if(o)return;const x=!h;c||u(x),r==null||r(x)},[p,g]=D.getOverrides(l.HeaderTitle,f.StyledBoxTitle),m=e?f.jsxRuntimeExports.jsxs("div",{children:[f.jsxRuntimeExports.jsx(p,{...g,children:e}),t&&f.jsxRuntimeExports.jsx(f.DescriptionText,{children:t})]}):void 0;return f.jsxRuntimeExports.jsx(Am.Panel,{expanded:h,onChange:d,title:m,overrides:D.mergeOverrides({PanelContainer:{component:f.StyledBoxContainer,style:({$expanded:x,$theme:y})=>({...!x&&{gap:0},transitionProperty:"gap",transitionDuration:y.animation.timing500})},Header:{style:{padding:0}},Content:{style:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0}},ToggleIcon:{style:{alignSelf:"flex-start"}}},{...l.Container&&{PanelContainer:l.Container},...l.Header&&{Header:l.Header},...l.Content&&{Content:l.Content},...l.ToggleIcon&&{ToggleIcon:l.ToggleIcon}}),children:i})},Oa=({title:i,description:e,tooltip:t,collapsible:n=!1,expanded:s,onToggle:r,endEnhancer:o,overrides:l={},children:a})=>{const[u,c]=D.useStyletron(),h=i&&t?f.jsxRuntimeExports.jsxs("div",{className:u({display:"flex",alignItems:"center",gap:c.sizing.scale100}),children:[i,f.jsxRuntimeExports.jsx(f.HelpTooltip,{text:t})]}):i,d=h&&o?f.jsxRuntimeExports.jsxs("div",{className:u({display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"}),children:[h,o]}):h,p=e?f.jsxRuntimeExports.jsx(f.Markdown,{children:e}):void 0;return n?f.jsxRuntimeExports.jsx(Ma,{title:d,description:p,expanded:s,defaultExpanded:!1,onToggle:r,overrides:{Content:{style:{paddingTop:0}}},children:a}):f.jsxRuntimeExports.jsx(f.Box,{title:d,description:p,overrides:D.mergeOverrides({BoxContainer:{style:{marginBottom:c.sizing.scale600}}},l),children:a})},Ia=({name:i,span:e,children:t})=>{const[n,s]=D.useStyletron(),r=M.Children.toArray(t),o=(e==null?void 0:e.reduce((l,a)=>l+a,0))??r.length;return f.jsxRuntimeExports.jsxs("div",{className:n({flexGrow:1,boxSizing:"border-box"}),children:[i&&f.jsxRuntimeExports.jsx("div",{className:n(s.typography.LabelMedium),children:i}),f.jsxRuntimeExports.jsx(ar.Grid,{gridColumns:o,gridMargins:[0],gridMaxWidth:0,children:r.map((l,a)=>f.jsxRuntimeExports.jsx(ar.Cell,{span:e==null?void 0:e[a],children:l},a))})]})};function zb({config:i,fields:e}){const t=f.jsxRuntimeExports.jsx(Td,{items:i.items,fields:e});switch(i.type){case"group":return f.jsxRuntimeExports.jsx(Oa,{title:i.title,description:i.description,tooltip:i.tooltip,collapsible:i.collapsible,children:t});case"row":return f.jsxRuntimeExports.jsx(Ia,{name:i.name,span:i.span,children:t});case"grid":return f.jsxRuntimeExports.jsx(_b,{children:t});case"condition":return f.jsxRuntimeExports.jsx(Vb,{layout:i,children:t})}}function Td({items:i,fields:e}){return f.jsxRuntimeExports.jsx(f.jsxRuntimeExports.Fragment,{children:i.map((t,n)=>typeof t=="string"?f.jsxRuntimeExports.jsx(Bb,{fieldPath:t,config:e[t]},t):f.jsxRuntimeExports.jsx(zb,{config:t,fields:e},n))})}function $b(i,e){const t=f.lodashExports.cloneDeep(i);return Hb(t,e),t}function Hb(i,e){const t=f.lodashExports.toPath(e);if(t.length===0)return;do f.lodashExports.unset(i,t),t.pop();while(t.length>0&&f.lodashExports.isEmpty(f.lodashExports.get(i,t)));const n=f.lodashExports.get(i,t);Array.isArray(n)&&f.lodashExports.set(i,t,n.filter(s=>s!==void 0))}function Gb(i,e){return Md(e.layout,i)}function Md(i,e){return i.reduce((t,n)=>typeof n=="string"?t:n.type==="condition"&&!Ad(n,f.lodashExports.get(t,n.when))?Od(n.items,t):Md(n.items,t),e)}function Od(i,e){return i.reduce((t,n)=>typeof n=="string"?$b(t,n):Od(n.items,t),e)}const Mo={fields:{mode:{type:"select",label:"Mode",options:[{id:"basic",label:"Basic"},{id:"advanced",label:"Advanced"}],clearable:!1},advancedSetting:{type:"string",label:"Advanced Setting"}},layout:["mode",{type:"condition",when:"mode",is:"advanced",items:["advancedSetting"]}]};function Wb(){const[i,e]=M.useState();return f.jsxRuntimeExports.jsxs(Ui,{children:[f.jsxRuntimeExports.jsx(ze.HeadingXXLarge,{children:"Component Sandbox"}),f.jsxRuntimeExports.jsx(bs.Block,{marginBottom:"24px",children:"This is a sandbox for testing WIP components and features."}),f.jsxRuntimeExports.jsx(bs.Block,{width:"400px",children:f.jsxRuntimeExports.jsxs(Yr,{initialValues:{mode:"basic"},onSubmit:t=>{const n=Gb(t,Mo);e(n)},children:[f.jsxRuntimeExports.jsx(Td,{items:Mo.layout,fields:Mo.fields}),f.jsxRuntimeExports.jsx(ka,{children:"Submit"})]})}),i?f.jsxRuntimeExports.jsxs(bs.Block,{marginTop:"24px",children:[f.jsxRuntimeExports.jsx(ze.LabelMedium,{marginBottom:"scale300",children:"Last submitted values"}),f.jsxRuntimeExports.jsx(bs.Block,{as:"pre",backgroundColor:"backgroundSecondary",padding:"12px",children:JSON.stringify(i,null,2)})]}):null]})}var Xt=(i=>(i.PRIMARY="primary",i.SECONDARY="secondary",i.TERTIARY="tertiary",i))(Xt||{});class Id extends f.Interpolation{execute(e){return this.interpolator(e)}}function Fn(i){return typeof i=="function"?new Id(i):new f.StringInterpolation(i)}function Ub(){var a;const{fieldRegistry:i}=Aa(),{submitErrors:e,errors:t,touched:n}=Ra({submitErrors:!0,errors:!0,touched:!0}),s=e==null?void 0:e[Un],r=s instanceof Error?s.message:s,o=r?[{fieldPath:Un,errorMessage:r}]:[];if(!t)return o;const l=[];for(const[u,c]of Object.entries(n??{})){if(!c)continue;const h=f.lodashExports.get(t,u);typeof h=="string"&&l.push({fieldPath:u,fieldLabel:(a=i.get(u))==null?void 0:a.label,errorMessage:h,focus:()=>{var d;(d=document.querySelector(`[name="${u}"]`))==null||d.focus()}})}return[...o,...l]}function jd(){const[i,e]=D.useStyletron(),t=Ub();return t.length===0?null:f.jsxRuntimeExports.jsx(f.Banner,{kind:"negative",children:t.map(n=>f.jsxRuntimeExports.jsxs("div",{className:i({...e.typography.ParagraphSmall,textAlign:"left"}),children:[n.fieldLabel&&f.jsxRuntimeExports.jsx(Tm.StyledLink,{$as:"button",type:"button",onClick:n.focus,className:i({background:"none",border:"none",cursor:"pointer",padding:"0"}),children:n.fieldLabel}),n.fieldLabel&&n.errorMessage&&f.jsxRuntimeExports.jsx(f.jsxRuntimeExports.Fragment,{children:" "}),f.jsxRuntimeExports.jsx(f.Markdown,{children:n.errorMessage})]},n.fieldPath))})}const Pd=({isOpen:i,onDismiss:e,heading:t,size:n=cr.SIZE.large,onSubmit:s,initialValues:r,submitLabel:o="Submit",children:l})=>{const a=M.useId(),u=async c=>{try{await s(c),e()}catch(h){return{[Un]:h instanceof Error?h:new Error(String(h))}}};return f.jsxRuntimeExports.jsxs(Yr,{id:a,initialValues:r,onSubmit:u,render:c=>f.jsxRuntimeExports.jsx(f.Dialog,{isOpen:i,onDismiss:e,heading:t,size:n,placement:cr.PLACEMENT.topCenter,buttonDock:{primaryAction:f.jsxRuntimeExports.jsx(ka,{formId:a,children:o}),dismissiveAction:f.jsxRuntimeExports.jsx(G.Button,{kind:G.KIND.tertiary,onClick:e,overrides:{BaseButton:{style:{minWidth:"150px"}}},children:"Cancel"})},children:c}),children:[l,f.jsxRuntimeExports.jsx(jd,{})]})},ju="-",qb=8,Kb=(i={withDate:!1})=>{const e=`${ju}${crypto.randomUUID().substring(0,qb)}`;if(i.withDate){const t=new Date().toISOString(),n=f.parseIsoString(t);if(!n)return console.warn("Date.toISOString() returned an invalid ISO string",t),e;const{date:s,time:r}=n,o=s.replace(/-/g,""),l=r.replace(/\..*$/,"").replace(/:/g,"");return`${ju}${o}-${l}${e}`}return e},Yb=({record:i,onClose:e})=>{var o;const{projectId:t}=f.useStudioParams("base"),n=f.useStudioMutation({mutationName:"CreatePipelineRun"}),s=async l=>{n.isPending||await n.mutateAsync(l)},r={metadata:{name:`run${Kb({withDate:!0})}`,namespace:t},spec:{pipeline:{name:((o=i==null?void 0:i.metadata)==null?void 0:o.name)??"",namespace:t}}};return f.jsxRuntimeExports.jsxs(Pd,{isOpen:!0,onDismiss:e,heading:"Start new pipeline run",onSubmit:s,submitLabel:"Run",initialValues:r,children:[f.jsxRuntimeExports.jsx(Qr,{name:"spec.pipeline.name",label:"Pipeline to run",readOnly:!0}),f.jsxRuntimeExports.jsx(Ta,{name:"spec.description",label:"Description",placeholder:"Enter a description for this run…",description:"Optional. Helps identify this run in the pipeline run list."})]})},Jr=[{id:"metadata.creationTimestamp.seconds",label:"Created",type:f.CellType.DATE},{id:"spec.pipeline.name",label:"Pipeline",items:[{id:"spec.pipeline.name",type:f.CellType.TEXT},{id:"spec.revision.name",type:f.CellType.DESCRIPTION}]},{id:"spec.actor.name",label:"Started by",type:f.CellType.TEXT},{id:"status.state",label:"State",type:f.CellType.STATE,stateTextMap:{0:"Queued",1:"Pending",2:"Running",3:"Succeeded",4:"Killed",5:"Failed",6:"Skipped"},stateColorMap:{0:"gray",1:"blue",2:"blue",3:"green",4:"red",5:"red",6:"gray"}}],Dd={id:"status.state",label:"State",type:f.CellType.STATE,stateTextMap:{0:"Invalid",1:"Created",2:"Building",3:"Ready",4:"Error"},stateColorMap:{0:"red",1:"green",2:"yellow",3:"green",4:"red"}},Ld={id:"spec.type",label:"Type",type:f.CellType.TYPE,typeTextMap:{0:"Invalid",1:"Train",2:"Evaluation",3:"Performance Evaluation",4:"Experiment",5:"Retrain",6:"Prediction",7:"Performance Monitoring",8:"Basis Feature",9:"Data Prep",10:"Online Offline Feature Consistency",11:"Feature Group Compute",12:"Online Offline Feature Consistency Orchestration",13:"Post Processing",14:"Optimization",15:"Scorer"}},Xb={type:"detail",metadata:[{id:"metadata.creationTimestamp.seconds",label:"Created",type:f.CellType.DATE},{id:"spec.owner.name",label:"Owner",type:f.CellType.TEXT},Ld,{id:"spec.commit.branch",label:"Branch",type:f.CellType.TEXT},Dd],pages:[{id:"runs",label:"Pipeline Runs",type:"table",queryConfig:{endpoint:"list",service:"pipelineRun",serviceOptions:{listOptions:{labelSelector:"pipeline.michelangelo/name=${page.metadata.name}"}}},tableConfig:{columns:[{id:"metadata.name",label:"Name",url:"/${studio.projectId}/${studio.phase}/runs/${row.metadata.name}"},...Jr]}}]},Qb=[{id:"metadata.name",label:"Name",url:"/${studio.projectId}/${studio.phase}/pipelines/${data.metadata.name}",tooltip:{content:"Click to filter by this pipeline name",action:"filter"}},{id:"metadata.creationTimestamp.seconds",label:"Created",type:f.CellType.DATE},Ld,{id:"spec.commit.branch",label:"Branch",type:f.CellType.TEXT},Dd],Jb={type:"list",tableConfig:{columns:Qb}},ja={id:"pipelines",name:"Pipelines",service:"pipeline",state:"active",views:[Jb,Xb],actions:[{display:{label:"Run",icon:"playerPlay"},hierarchy:Xt.PRIMARY,modal:{type:"custom",component:Yb}},{display:{label:"Delete",icon:"trashCan"},hierarchy:Xt.TERTIARY,operation:{type:"mutation",mutation:{mutationName:"DeletePipeline",successOperations:[{type:"invalidate",targets:["ListPipeline"]},{type:"route",route:"/${studio.projectId}/${studio.phase}/pipelines"}]}},modal:{type:"confirm",header:{title:"Delete Pipeline"},body:Fn(({data:i})=>`Delete pipeline **${i.metadata.name}**? This action cannot be undone.`),button:{label:"Delete"},destructive:!0}}]},le={ERROR:"ERROR",PENDING:"PENDING",RUNNING:"RUNNING",SUCCESS:"SUCCESS",SKIPPED:"SKIPPED"},Fd={[le.ERROR]:{borderColorName:"borderNegativeLight",backgroundColorName:"backgroundNegativeLight"},[le.PENDING]:{borderColorName:"contentInverseTertiary",colorName:"contentInverseTertiary"},[le.SKIPPED]:{borderColorName:"contentInverseTertiary",colorName:"contentInverseTertiary"},[le.RUNNING]:{borderColorName:"borderAccent",backgroundColorName:"backgroundAccentLight"},[le.SUCCESS]:{borderColorName:"borderPositive"}},Zb={[le.SUCCESS]:{name:"circleCheck",colorName:"eatsGreen400"},[le.ERROR]:{name:"circleX",colorName:"contentNegative"},[le.PENDING]:{name:"diamondEmpty",colorName:"contentInverseTertiary"},[le.RUNNING]:{name:"arrowCircular",colorName:"contentAccent"},[le.SKIPPED]:{name:"playerNext",colorName:"contentNegative"}},ev={type:"detail",metadata:Jr,pages:[{id:"steps",label:"Steps",type:"execution",emptyState:{title:"No execution data",description:"No steps available for this pipeline run"},tasks:{accessor:"status.steps",subTasksAccessor:"subSteps",header:{heading:"displayName",metadata:[{id:"startTime.seconds",label:"Start time",type:f.CellType.DATE},{id:"endTime.seconds",label:"End time",type:f.CellType.DATE},{id:"duration",label:"Duration",type:f.CellType.TEXT,accessor:i=>{var e,t;if((e=i.startTime)!=null&&e.seconds&&((t=i.endTime)!=null&&t.seconds)){const n=parseInt(i.startTime.seconds)*1e3,r=parseInt(i.endTime.seconds)*1e3-n;return`${Math.round(r/1e3)}s`}return null}},{id:"logUrl",label:"Logs"},{id:"state",label:"Status",type:f.CellType.STATE,stateTextMap:{0:"Pending",1:"Pending",2:"Running",3:"Success",4:"Killed",5:"Failed",6:"Skipped"},stateColorMap:{0:"gray",1:"blue",2:"blue",3:"green",4:"red",5:"red",6:"gray"}},{id:"retry",label:"Actions",type:f.CellType.RETRY,accessor:"activityId",hideEmpty:!0}]},body:[{type:"struct",label:"Input Parameters",accessor:"input"},{type:"struct",label:"Output Results",accessor:"output"},{type:"textarea",label:"Task Message",accessor:"message",markdown:!1}],stateBuilder:i=>{switch(i.state){case 1:return le.PENDING;case 2:return le.RUNNING;case 3:return le.SUCCESS;case 4:return le.ERROR;case 5:return le.ERROR;case 6:return le.SKIPPED;default:return le.PENDING}}}}]},tv=[{id:"metadata.name",label:"Name",items:[{id:"metadata.name",url:"/${studio.projectId}/${studio.phase}/runs/${data.metadata.name}"},{id:"spec.description",type:f.CellType.DESCRIPTION}]},...Jr],iv={type:"list",tableConfig:{columns:tv}},Pa={id:"runs",name:"Pipeline Runs",service:"pipelineRun",state:"active",views:[iv,ev]},Nd={id:"data",icon:"database",name:"Prepare & Analyze Data",description:"Create data pipelines and analyze your datasets",docUrl:"https://michelangelo-ai.org/docs/user-guides/getting-started/prepare-your-data",state:"disabled",pipelineTypes:["PIPELINE_TYPE_DATA_PREP","PIPELINE_TYPE_BASIS_FEATURE"],entities:[{...ja,state:"disabled"},{...Pa,state:"disabled"},{id:"datasources",name:"Data Sources",state:"disabled",service:"datasource",views:[]}]};function nv(i){return i.filter(e=>!!e.name&&!!e.url).map(e=>({id:e.name,accessor:()=>e.name,url:e.url,tooltip:e.tooltip}))}function sv(i){const{links:e,title:t,isLoading:n=!1}=i;return f.jsxRuntimeExports.jsx(f.Box,{title:t,children:f.jsxRuntimeExports.jsx(f.Row,{items:nv(e),loading:n})})}const Oo={BoxContainer:{style:{flexBasis:"320px",flexGrow:1}}};function Io({title:i,revision:e,emptyText:t,isLoading:n}){const[s,r]=D.useStyletron();return n?f.jsxRuntimeExports.jsx(f.Box,{title:i,overrides:Oo,children:f.jsxRuntimeExports.jsx("div",{className:s({display:"flex",justifyContent:"center"}),children:f.jsxRuntimeExports.jsx(Mm.Spinner,{})})}):e!=null&&e.name?f.jsxRuntimeExports.jsxs(f.Box,{title:i,overrides:Oo,children:[f.jsxRuntimeExports.jsx(ze.LabelSmall,{color:r.colors.contentSecondary,marginBottom:r.sizing.scale200,children:"Revision"}),f.jsxRuntimeExports.jsx(ze.ParagraphMedium,{marginTop:"0",marginBottom:"0",children:e.name})]}):f.jsxRuntimeExports.jsx(f.Box,{title:i,overrides:Oo,children:f.jsxRuntimeExports.jsx(f.Banner,{kind:"info",artwork:{type:Wn.ARTWORK_TYPE.icon,icon:()=>f.jsxRuntimeExports.jsx(f.Icon,{name:"circleI",size:r.sizing.scale800})},children:t})})}const jo={UNKNOWN:0,TRUE:1,FALSE:2},rt={INVALID:0,VALIDATION:1,PLACEMENT:2,RESOURCE_ACQUISITION:3,ROLLOUT_COMPLETE:4,ROLLOUT_FAILED:5,ROLLBACK_IN_PROGRESS:6,ROLLBACK_COMPLETE:7,ROLLBACK_FAILED:8,CLEAN_UP_IN_PROGRESS:9,CLEAN_UP_COMPLETE:10,CLEAN_UP_FAILED:11},kt={INVALID:0,INITIALIZING:1,HEALTHY:2,UNHEALTHY:3,EMPTY:4},Es={INFERENCE_SERVER:1,OFFLINE:2,MOBILE:3,SELF_HOSTED:4},rv={[Es.INFERENCE_SERVER]:"Online",[Es.OFFLINE]:"Offline",[Es.MOBILE]:"Mobile",[Es.SELF_HOSTED]:"Self-hosted"},Bd={id:"status.stage",label:"Stage",type:f.CellType.TYPE,typeTextMap:{[rt.INVALID]:"Invalid",[rt.VALIDATION]:"Validation",[rt.PLACEMENT]:"Placement",[rt.RESOURCE_ACQUISITION]:"Resource acquisition",[rt.ROLLOUT_COMPLETE]:"Rollout complete",[rt.ROLLOUT_FAILED]:"Rollout failed",[rt.ROLLBACK_IN_PROGRESS]:"Rollback in progress",[rt.ROLLBACK_COMPLETE]:"Rollback complete",[rt.ROLLBACK_FAILED]:"Rollback failed",[rt.CLEAN_UP_IN_PROGRESS]:"Clean up in progress",[rt.CLEAN_UP_COMPLETE]:"Clean up complete",[rt.CLEAN_UP_FAILED]:"Clean up failed"}},Vd={id:"status.state",label:"State",type:f.CellType.STATE,stateTextMap:{[kt.INVALID]:"Invalid",[kt.INITIALIZING]:"Initializing",[kt.HEALTHY]:"Healthy",[kt.UNHEALTHY]:"Unhealthy",[kt.EMPTY]:"Empty"},stateColorMap:{[kt.INVALID]:"gray",[kt.INITIALIZING]:"blue",[kt.HEALTHY]:"green",[kt.UNHEALTHY]:"red",[kt.EMPTY]:"gray"}};function ov({data:i,isLoading:e}){var p,g,m,x,y,b,v;const[t,n]=D.useStyletron(),{projectId:s,phase:r}=f.useStudioParams("detail"),o=i,l=(p=o==null?void 0:o.spec)==null?void 0:p.target,a=(l==null?void 0:l.case)==="inferenceServer"?(g=l.value)==null?void 0:g.name:void 0,u=[{name:a,url:`/${s}/${r}/targets/${a}`}],c=(x=(m=o==null?void 0:o.spec)==null?void 0:m.definition)==null?void 0:x.type,h=[{id:"type-of-deployment",label:"Type of deployment",value:c!=null?rv[c]??"":""}],d=Object.fromEntries(h.map(C=>[C.id,C.value]));return f.jsxRuntimeExports.jsxs("div",{className:t({display:"flex",flexDirection:"column",gap:n.sizing.scale600}),children:[f.jsxRuntimeExports.jsx(sv,{title:"Useful links",links:u,isLoading:e}),f.jsxRuntimeExports.jsxs("section",{children:[f.jsxRuntimeExports.jsx(ze.HeadingSmall,{marginTop:"0",marginBottom:n.sizing.scale600,children:"Key status indicators"}),f.jsxRuntimeExports.jsxs("div",{className:t({display:"flex",gap:n.sizing.scale600,flexWrap:"wrap"}),children:[f.jsxRuntimeExports.jsx(Io,{title:"Current model in production",revision:(y=o==null?void 0:o.status)==null?void 0:y.currentRevision,emptyText:"No currently deployed model",isLoading:e}),f.jsxRuntimeExports.jsx(Io,{title:"Candidate model",revision:(b=o==null?void 0:o.status)==null?void 0:b.candidateRevision,emptyText:"No model currently being deployed",isLoading:e}),f.jsxRuntimeExports.jsx(Io,{title:"Desired model to be deployed",revision:(v=o==null?void 0:o.spec)==null?void 0:v.desiredRevision,emptyText:"No model configured to be deployed",isLoading:e})]})]}),f.jsxRuntimeExports.jsxs("section",{children:[f.jsxRuntimeExports.jsx(ze.HeadingSmall,{marginTop:"0",marginBottom:n.sizing.scale600,children:"Configuration"}),f.jsxRuntimeExports.jsx(f.Box,{children:f.jsxRuntimeExports.jsx(Yr,{onSubmit:()=>{},initialValues:d,children:f.jsxRuntimeExports.jsx("div",{className:t({display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:n.sizing.scale1200,rowGap:n.sizing.scale600}),children:h.map(C=>e?f.jsxRuntimeExports.jsx(Nh.Skeleton,{animation:!0,height:"48px",width:"100%"},C.id):f.jsxRuntimeExports.jsx(Qr,{name:C.id,label:C.label,readOnly:!0},C.id))})})})]})]})}const lv={type:"detail",metadata:[{id:"metadata.creationTimestamp.seconds",label:"Created",type:f.CellType.DATE},{id:'metadata.labels["michelangelo/owner"]',label:"Owner",type:f.CellType.TEXT},Bd,Vd],pages:[{id:"info",label:"Information",type:"custom",component:ov},{id:"ongoing-operations",label:"Ongoing operations",type:"execution",emptyState:{title:"No deployment rollout in progress",description:"Ongoing operations will appear here when a deployment rollout is in progress"},tasks:{accessor:i=>{var t,n,s;return(((t=i==null?void 0:i.status)==null?void 0:t.stage)===rt.ROLLOUT_FAILED?(n=i==null?void 0:i.status)==null?void 0:n.conditionsSnapshot:(s=i==null?void 0:i.status)==null?void 0:s.conditions)??[]},header:{heading:"type",metadata:[{id:"lastUpdatedTimestamp",label:"Last updated",type:f.CellType.DATE,accessor:i=>{const e=i.lastUpdatedTimestamp;return e?Math.floor(Number(e)/1e3):void 0}}]},body:[{type:"textarea",label:"Information",accessor:"message",markdown:!1},{type:"textarea",label:"Details",accessor:"reason",markdown:!1}],stateBuilder:i=>{switch(i.status){case jo.TRUE:return le.SUCCESS;case jo.FALSE:return le.ERROR;case jo.UNKNOWN:default:return le.RUNNING}}}}]},av=[{id:"metadata.name",label:"Name",type:f.CellType.TEXT,url:"/${studio.projectId}/${studio.phase}/deployments/${row.metadata.name}"},{id:"status.currentRevision.name",label:"Model",type:f.CellType.TEXT},{id:"spec.definition.type",label:"Type",type:f.CellType.TAG,accessor:i=>{var t,n;const e=(n=(t=i==null?void 0:i.spec)==null?void 0:t.definition)==null?void 0:n.type;return e?e==="TARGET_TYPE_OFFLINE"?"Offline":e==="TARGET_TYPE_MOBILE"?"Mobile":"Online":null}},Bd,{id:"spec.inferenceServer.name",label:"Target",type:f.CellType.TEXT,accessor:i=>{var t,n;const e=(t=i==null?void 0:i.spec)==null?void 0:t.target;return(e==null?void 0:e.case)==="inferenceServer"?((n=e.value)==null?void 0:n.name)??null:null}},{id:"spec.owner.name",label:"Owner",type:f.CellType.TEXT},Vd],uv={type:"list",tableConfig:{columns:av}},cv={id:"deployments",name:"Deployments",service:"deployment",state:"active",views:[uv,lv]},Oe={INVALID:0,INITIALIZED:1,CREATE_PENDING:2,SERVING:3,FAILED:4,DELETE_PENDING:5,CREATING:6,DELETING:7,DELETED:8},Po={UNKNOWN:0,TRUE:1,FALSE:2},_d={id:"status.state",label:"State",type:f.CellType.STATE,stateTextMap:{[Oe.INVALID]:"Invalid",[Oe.INITIALIZED]:"Initialized",[Oe.CREATE_PENDING]:"Create pending",[Oe.SERVING]:"Serving",[Oe.FAILED]:"Failed",[Oe.DELETE_PENDING]:"Delete pending",[Oe.CREATING]:"Initializing",[Oe.DELETING]:"Deleting",[Oe.DELETED]:"Deleted"},stateColorMap:{[Oe.INVALID]:"gray",[Oe.INITIALIZED]:"blue",[Oe.CREATE_PENDING]:"blue",[Oe.SERVING]:"green",[Oe.FAILED]:"red",[Oe.DELETE_PENDING]:"blue",[Oe.CREATING]:"blue",[Oe.DELETING]:"blue",[Oe.DELETED]:"gray"}},hv={type:"detail",metadata:[{id:"status.createTime",label:"Created",type:f.CellType.DATE,accessor:i=>{var t;const e=(t=i==null?void 0:i.status)==null?void 0:t.createTime;return e?Math.floor(new Date(e).getTime()/1e3):void 0}},{id:"spec.owner.name",label:"Owner",type:f.CellType.TEXT},_d],pages:[{id:"stages",label:"Stages",type:"execution",emptyState:{title:"No stages reported",description:"Stages will appear here once the inference server is initialized"},tasks:{accessor:"status.conditions",header:{heading:"type",metadata:[{id:"lastUpdatedTimestamp",label:"Last updated",type:f.CellType.DATE,accessor:i=>{const e=i.lastUpdatedTimestamp;return e?Math.floor(Number(e)/1e3):void 0}}]},body:[{type:"textarea",label:"Information",accessor:"message",markdown:!1},{type:"textarea",label:"Details",accessor:"reason",markdown:!1}],stateBuilder:i=>{switch(i.status){case Po.TRUE:return le.SUCCESS;case Po.FALSE:return le.ERROR;case Po.UNKNOWN:default:return le.RUNNING}}}}]},dv=[{id:"metadata.name",label:"Target name",type:f.CellType.TEXT,url:"/${studio.projectId}/${studio.phase}/targets/${row.metadata.name}"},{id:"status.updateTime",label:"Last updated",type:f.CellType.DATE,accessor:i=>{var t;const e=(t=i==null?void 0:i.status)==null?void 0:t.updateTime;return e?Math.floor(new Date(e).getTime()/1e3):void 0}},{id:"type",label:"Type",type:f.CellType.TAG,accessor:()=>"Inference Server"},_d],fv={type:"list",tableConfig:{columns:dv}},pv={id:"targets",name:"Targets",service:"inferenceServer",state:"active",views:[fv,hv]},zd={id:"deploy",icon:"deploy",name:"Deploy & Predict",description:"Deploy your models and predict new data",state:"comingSoon",pipelineTypes:["PIPELINE_TYPE_PREDICTION","PIPELINE_TYPE_SCORER"],entities:[pv,cv]},$d={id:"monitor",icon:"monitor",name:"Monitor & Debug",description:"Monitor model performance and debug issues in production",state:"comingSoon",pipelineTypes:["PIPELINE_TYPE_PERF_EVAL","PIPELINE_TYPE_PERFORMANCE_MONITORING","PIPELINE_TYPE_ONLINE_OFFLINE_FEATURE_CONSISTENCY","PIPELINE_TYPE_ONLINE_OFFLINE_FEATURE_CONSISTENCY_ORCHESTRATION"],entities:[]},Hd={id:"status.state",label:"State",type:f.CellType.STATE,stateTextMap:{0:"Queued",1:"Running",2:"Killed",3:"Failed",4:"Succeeded",5:"Pending Kill"},stateColorMap:{0:"gray",1:"blue",2:"gray",3:"red",4:"green",6:"yellow"}},Gd={id:"spec.pipeline.name",label:"Pipeline",items:[{id:"spec.pipeline.name",type:f.CellType.TEXT},{id:"spec.revision.name",type:f.CellType.DESCRIPTION}]},gv={type:"detail",metadata:[{id:"metadata.creationTimestamp.seconds",label:"Created",type:f.CellType.DATE},{id:"spec.actor.name",label:"Started by",type:f.CellType.TEXT},Gd,Hd],pages:[{id:"runs",label:"Recent Runs",type:"table",queryConfig:{endpoint:"list",service:"pipelineRun",serviceOptions:{listOptions:{labelSelector:"pipelinerun.michelangelo/triggered-by=${page.metadata.name}"}}},tableConfig:{columns:[{id:"metadata.name",label:"Name",url:"/${studio.projectId}/${studio.phase}/runs/${row.metadata.name}"},...Jr]}}]},mv={type:"list",tableConfig:{columns:[{id:"metadata.name",label:"Name",url:"/${studio.projectId}/${studio.phase}/triggers/${data.metadata.name}"},{id:"metadata.creationTimestamp.seconds",label:"Created",type:f.CellType.DATE},{id:"spec.actor.name",label:"Started by",type:f.CellType.TEXT},Gd,Hd]}};var Wd=(i=>(i[i.NO_ACTION=0]="NO_ACTION",i[i.KILL=1]="KILL",i[i.PAUSE=2]="PAUSE",i[i.RESUME=3]="RESUME",i))(Wd||{}),yl=(i=>(i[i.INVALID=0]="INVALID",i[i.RUNNING=1]="RUNNING",i[i.KILLED=2]="KILLED",i[i.FAILED=3]="FAILED",i[i.SUCCEEDED=4]="SUCCEEDED",i[i.PENDING_KILL=5]="PENDING_KILL",i[i.PAUSED=6]="PAUSED",i))(yl||{});const Pu=i=>{var t;const e=(t=i.status)==null?void 0:t.state;return e===yl.RUNNING||e===yl.PAUSED},Ud={id:"triggers",name:"Triggers",service:"triggerRun",state:"active",views:[mv,gv],actions:[{display:{label:"Kill",icon:"stopCircle"},hierarchy:Fn(({data:i})=>Pu(i)?Xt.SECONDARY:Xt.TERTIARY),disabled:[{condition:Fn(({data:i})=>!Pu(i)),message:"Only running or paused trigger runs can be killed"}],operation:{type:"mutation",mutation:{mutationName:"UpdateTriggerRun",successOperations:[{type:"invalidate",targets:["GetTriggerRun","ListTriggerRun"],delayMs:2e3}],middleware:{operations:[{destination:"spec.action",default:Wd.KILL}]}}},modal:{type:"confirm",header:{title:"Kill Trigger Run"},body:Fn(({data:i})=>`Kill run **${i.metadata.name}** in pipeline **${i.spec.pipeline.name}**? This action cannot be undone.`),button:{label:"Kill"}}}]},qd={id:"retrain",icon:"lightbulb",name:"Experiment & Productionize",description:"Experiment with pipelines and productionize your machine learning workflows",state:"active",pipelineTypes:["PIPELINE_TYPE_RETRAIN","PIPELINE_TYPE_EXPERIMENT","PIPELINE_TYPE_POST_PROCESSING","PIPELINE_TYPE_OPTIMIZATION"],entities:[ja,Pa,Ud]},xv="michelangelo/SpecUpdateTimestamp",yv=1e6;function bv(i){var t,n,s,r;const e=(n=(t=i.metadata)==null?void 0:t.labels)==null?void 0:n[xv];return e?Number(e)/yv:(r=(s=i.metadata)==null?void 0:s.creationTimestamp)==null?void 0:r.seconds}const vv="michelangelo/environment",Sv={development:"Development",production:"Production",testing:"Testing"};function Cv(i){const e=i==null?void 0:i[vv];return e?Sv[e.toLowerCase()]??"":""}const Wt={INVALID:0,CUSTOM:1,REGRESSION:2,BINARY_CLASSIFICATION:3,MULTICLASS_CLASSIFICATION:4,CLUSTERING:5,LLM_COMPLETION:6,LLM_CHAT_COMPLETION:7,LLM_EMBEDDING:8},wv={[Wt.INVALID]:"Unknown",[Wt.CUSTOM]:"Custom",[Wt.REGRESSION]:"Regression",[Wt.BINARY_CLASSIFICATION]:"Binary Classification",[Wt.MULTICLASS_CLASSIFICATION]:"Multi-class Classification",[Wt.CLUSTERING]:"Clustering",[Wt.LLM_COMPLETION]:"LLM Completion",[Wt.LLM_CHAT_COMPLETION]:"LLM Chat",[Wt.LLM_EMBEDDING]:"LLM Embedding"},Ev=[{id:"metadata.name",label:"Model",items:[{id:"metadata.name",url:"/${studio.projectId}/${studio.phase}/models/${data.metadata.name}"},{id:"spec.description",type:f.CellType.DESCRIPTION}]},{id:"metadata.labels",label:"Environment",type:f.CellType.TEXT,accessor:i=>{var t;const e=(t=i==null?void 0:i.metadata)==null?void 0:t.labels;return Cv(e)||null}},{id:"spec.modelFamily.name",label:"Model Family",type:f.CellType.TEXT},{id:"spec.kind",label:"Type",type:f.CellType.TYPE,typeTextMap:wv},{id:"metadata",label:"Last Updated",type:f.CellType.DATE,accessor:i=>bv(i)}],Rv={type:"list",tableConfig:{columns:Ev}},kv={id:"models",name:"Trained Models",service:"model",state:"active",views:[Rv]},Kd={id:"train",icon:"chartLine",name:"Train & Evaluate",description:"Train machine learning models and evaluate their performance",docUrl:"https://michelangelo-ai.org/docs/user-guides/train-and-deploy-models/train-and-register-a-model",state:"active",pipelineTypes:["PIPELINE_TYPE_TRAIN","PIPELINE_TYPE_EVAL"],entities:[ja,Pa,Ud,kv,{id:"evaluations",name:"Evaluations",state:"disabled",service:"evaluationReport",views:[]},{id:"notebooks",name:"Notebooks",state:"disabled",service:"notebook",views:[]}]},Da={data:Nd,train:Kd,deploy:zd,retrain:qd,monitor:$d},Av=[{id:"core-ml",name:"Core ML",phases:Object.values(Da)}],Tv=D.styled("hr",({$theme:i})=>({border:"none",borderBottom:`2px dashed ${i.colors.contentInverseTertiary}`,margin:`${i.sizing.scale200} 0`})),Nn=D.styled("div",({$theme:i})=>({display:"flex",flexDirection:"column",gap:i.sizing.scale800}));function Yd(i){const{id:e,defaultExpanded:t,state:n,overrides:s,...r}=i,o={Container:{props:{id:e,onClick:l=>l.stopPropagation()},...n&&{style:({$theme:l})=>({borderColor:l.colors[Fd[n].borderColorName]})}},Content:{style:({$theme:l})=>({paddingTop:l.sizing.scale300})},...s};return f.jsxRuntimeExports.jsx(Ma,{...r,defaultExpanded:t??!1,overrides:o})}function Xd(i){return`task-${i.name}`}function Qd(i){const e=document.getElementById(Xd(i));if(!e)return;const t=e.getBoundingClientRect();window.scrollTo({top:window.scrollY+t.top-16,behavior:"smooth"})}function La(i,e){if(!i.length)return[];const t=i.find(n=>n.focused)??i[i.length-1];return t.subTasks.length===0?[{parent:e,taskList:i}]:[{parent:e,taskList:i},...La(t.subTasks,t)]}const Mv=D.styled("div",({$theme:i})=>({display:"flex",flex:"auto",gap:i.sizing.scale300,flexWrap:"wrap",alignItems:"center"})),Jd=D.styled("div",({$theme:i,$color:e,$direction:t})=>{const n=t==="up";return{width:0,height:0,borderLeft:n?"10px solid transparent":`8px solid ${i.colors[e]}`,borderRight:n?"10px solid transparent":"0px solid transparent",borderTop:n?"8px solid transparent":"10px solid transparent",borderBottom:n?`8px solid ${i.colors[e]}`:"10px solid transparent"}});function Fa(i){const{state:e}=i,[,{colors:t,sizing:n}]=D.useStyletron(),s=Zb[e];return f.jsxRuntimeExports.jsx(f.Icon,{name:s.name,color:t[s.colorName],size:n.scale700})}const Zd={overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Ov=D.styled("div",({$theme:{colors:i,sizing:e},$state:t,role:n})=>{const{colorName:s="contentPrimary",backgroundColorName:r="backgroundPrimary",borderColorName:o}=Fd[t];return{flex:"1 1 0",position:"relative",display:"flex",alignItems:"center",gap:e.scale300,height:"44px",padding:"0 16px",boxSizing:"border-box",border:`2px solid ${i[o]}`,borderRadius:"12px",backgroundColor:i[r],color:i[s],cursor:n==="button"?"pointer":"default"}}),Iv=D.styled("div",({$theme:{typography:i}})=>({...i.LabelSmall,...Zd}));function ef(i){const{task:e,onClick:t}=i,{focused:n,name:s,state:r,subTasks:o}=e,l=!!(o!=null&&o.length),[a]=D.useStyletron();return f.jsxRuntimeExports.jsxs(Ov,{$state:r,tabIndex:0,...t?{role:"button",onClick:t}:{},children:[f.jsxRuntimeExports.jsx(Fa,{state:r}),f.jsxRuntimeExports.jsx(Iv,{children:s}),l&&n?f.jsxRuntimeExports.jsx("div",{className:a({position:"absolute",bottom:"-25px",left:"50%",transform:"translate(-50%, 0)"}),children:f.jsxRuntimeExports.jsx(Jd,{$color:"contentInverseTertiary",$direction:"up"})}):null]})}function bl({taskList:i,onTaskClick:e}){return f.jsxRuntimeExports.jsx(f.jsxRuntimeExports.Fragment,{children:i.map((t,n)=>f.jsxRuntimeExports.jsxs(M.Fragment,{children:[n>0&&f.jsxRuntimeExports.jsx(Jd,{$color:"contentInverseSecondary",$direction:"right"}),f.jsxRuntimeExports.jsx(ef,{task:t,...e?{onClick:()=>e(t)}:{}})]},n))})}function tf({matrix:i,onTaskClick:e,overrides:t}){const[n,s]=D.getOverrides(t==null?void 0:t.TaskListRenderer,bl),[r,o]=D.getOverrides((t==null?void 0:t.SubTaskListRenderer)??(t==null?void 0:t.TaskListRenderer),bl);return f.jsxRuntimeExports.jsx(f.jsxRuntimeExports.Fragment,{children:i.map((l,a)=>{const u=l.parent?r:n,c=l.parent?o:s;return f.jsxRuntimeExports.jsxs(M.Fragment,{children:[a>0&&f.jsxRuntimeExports.jsx(Tv,{}),f.jsxRuntimeExports.jsx(Mv,{children:f.jsxRuntimeExports.jsx(u,{taskList:l.taskList,onTaskClick:e,parent:l.parent,...c})})]},a)})})}function jv(i){const{label:e,cells:t,value:n}=i;return f.jsxRuntimeExports.jsx(Yd,{title:f.jsxRuntimeExports.jsx(ze.LabelSmall,{children:e}),children:f.jsxRuntimeExports.jsx(f.Row,{items:t,record:n??void 0})})}const nf=1024;let Pv=0,Do=class{constructor(e,t){this.from=e,this.to=t}};class te{constructor(e={}){this.id=Pv++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=tt.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}}te.closedBy=new te({deserialize:i=>i.split(" ")});te.openedBy=new te({deserialize:i=>i.split(" ")});te.group=new te({deserialize:i=>i.split(" ")});te.isolate=new te({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});te.contextHash=new te({perNode:!0});te.lookAhead=new te({perNode:!0});te.mounted=new te({perNode:!0});class gr{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[te.mounted.id]}}const Dv=Object.create(null);class tt{constructor(e,t,n,s=0){this.name=e,this.props=t,this.id=n,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):Dv,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new tt(e.name||"",t,e.id,n);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(te.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let s of n.split(" "))t[s]=e[n];return n=>{for(let s=n.prop(te.group),r=-1;r<(s?s.length:0);r++){let o=t[r<0?n.name:s[r]];if(o)return o}}}}tt.none=new tt("",Object.create(null),0,8);class Na{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let s=null;for(let r of e){let o=r(n);if(o){s||(s=Object.assign({},n.props));let l=o[1],a=o[0];a.combine&&a.id in s&&(l=a.combine(s[a.id],l)),s[a.id]=l}}t.push(s?new tt(n.name,s,n.id,n.flags):n)}return new Na(t)}}const Rs=new WeakMap,Du=new WeakMap;var Ie;(function(i){i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays"})(Ie||(Ie={}));class Re{constructor(e,t,n,s,r){if(this.type=e,this.children=t,this.positions=n,this.length=s,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=gr.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let s=n.toString();s&&(t&&(t+=","),t+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Sl(this.topNode,e)}cursorAt(e,t=0,n=0){let s=Rs.get(this)||this.topNode,r=new Sl(s);return r.moveTo(e,t),Rs.set(this,r._tree),r}get topNode(){return new ft(this,0,0,null)}resolve(e,t=0){let n=qn(Rs.get(this)||this.topNode,e,t,!1);return Rs.set(this,n),n}resolveInner(e,t=0){let n=qn(Du.get(this)||this.topNode,e,t,!0);return Du.set(this,n),n}resolveStack(e,t=0){return Nv(this,e,t)}iterate(e){let{enter:t,leave:n,from:s=0,to:r=this.length}=e,o=e.mode||0,l=(o&Ie.IncludeAnonymous)>0;for(let a=this.cursor(o|Ie.IncludeAnonymous);;){let u=!1;if(a.from<=r&&a.to>=s&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;u=!0}for(;u&&n&&(l||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:_a(tt.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,s)=>new Re(this.type,t,n,s,this.propValues),e.makeTree||((t,n,s)=>new Re(tt.none,t,n,s)))}static build(e){return Bv(e)}}Re.empty=new Re(tt.none,[],[],0);class Ba{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Ba(this.buffer,this.index)}}class xi{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return tt.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],s=this.set.types[t],r=s.name;if(/\W/.test(r)&&!s.isError&&(r=JSON.stringify(r)),e+=4,n==e)return r;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,n,s,r){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(sf(r,s,o[a+1],o[a+2])&&(l=a,n>0));a=o[a+3]);return l}slice(e,t,n){let s=this.buffer,r=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){r[a++]=s[l++],r[a++]=s[l++]-n;let u=r[a++]=s[l++]-n;r[a++]=s[l++]-e,o=Math.max(o,u)}return new xi(r,o,this.set)}}function sf(i,e,t,n){switch(i){case-2:return t<e;case-1:return n>=e&&t<e;case 0:return t<e&&n>e;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function qn(i,e,t,n){for(var s;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to<e);){let o=!n&&i instanceof ft&&i.index<0?null:i.parent;if(!o)return i;i=o}let r=n?0:Ie.IgnoreOverlays;if(n)for(let o=i,l=o.parent;l;o=l,l=o.parent)o instanceof ft&&o.index<0&&((s=l.enter(e,t,r))===null||s===void 0?void 0:s.from)!=o.from&&(i=l);for(;;){let o=i.enter(e,t,r);if(!o)return i;i=o}}class rf{cursor(e=0){return new Sl(this,e)}getChild(e,t=null,n=null){let s=Lu(this,e,t,n);return s.length?s[0]:null}getChildren(e,t=null,n=null){return Lu(this,e,t,n)}resolve(e,t=0){return qn(this,e,t,!1)}resolveInner(e,t=0){return qn(this,e,t,!0)}matchContext(e){return vl(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let s=t.lastChild;if(!s||s.to!=t.to)break;s.type.isError&&s.from==s.to?(n=t,t=s.prevSibling):t=s}return n}get node(){return this}get next(){return this.parent}}class ft extends rf{constructor(e,t,n,s){super(),this._tree=e,this.from=t,this.index=n,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,s,r=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,u=t>0?l.length:-1;e!=u;e+=t){let c=l[e],h=a[e]+o.from;if(sf(s,n,h,h+c.length)){if(c instanceof xi){if(r&Ie.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,t,n-h,s);if(d>-1)return new hi(new Lv(o,c,e,h),null,d)}else if(r&Ie.IncludeAnonymous||!c.type.isAnonymous||Va(c)){let d;if(!(r&Ie.IgnoreMounts)&&(d=gr.get(c))&&!d.overlay)return new ft(d.tree,h,e,o);let p=new ft(c,h,e,o);return r&Ie.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,n,s)}}}if(r&Ie.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let s;if(!(n&Ie.IgnoreOverlays)&&(s=gr.get(this._tree))&&s.overlay){let r=e-this.from;for(let{from:o,to:l}of s.overlay)if((t>0?o<=r:o<r)&&(t<0?l>=r:l>r))return new ft(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Lu(i,e,t,n){let s=i.cursor(),r=[];if(!s.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=s.type.is(t),!s.nextSibling())return r}for(;;){if(n!=null&&s.type.is(n))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return n==null?r:[]}}function vl(i,e,t=e.length-1){for(let n=i;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}class Lv{constructor(e,t,n,s){this.parent=e,this.buffer=t,this.index=n,this.start=s}}class hi extends rf{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,n);return r<0?null:new hi(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&Ie.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new hi(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new hi(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new hi(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,s=this.index+4,r=n.buffer[this.index+3];if(r>s){let o=n.buffer[this.index+1];e.push(n.slice(s,r,o)),t.push(0)}return new Re(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function of(i){if(!i.length)return null;let e=0,t=i[0];for(let r=1;r<i.length;r++){let o=i[r];(o.from>t.from||o.to<t.to)&&(t=o,e=r)}let n=t instanceof ft&&t.index<0?null:t.parent,s=i.slice();return n?s[e]=n:s.splice(e,1),new Fv(s,t)}class Fv{constructor(e,t){this.heads=e,this.node=t}get next(){return of(this.heads)}}function Nv(i,e,t){let n=i.resolveInner(e,t),s=null;for(let r=n instanceof ft?n:n.context.parent;r;r=r.parent)if(r.index<0){let o=r.parent;(s||(s=[n])).push(o.resolve(e,t)),r=o}else{let o=gr.get(r.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new ft(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[n])).push(qn(l,e,t,!1))}}return s?of(s):n}class Sl{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof ft)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=n+s.buffer[e+1],this.to=n+s.buffer[e+2],!0}yield(e){return e?e instanceof ft?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,n);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&Ie.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Ie.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Ie.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let s=n<0?0:this.stack[n]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(s)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:s}=this;if(s){if(e>0){if(this.index<s.buffer.buffer.length)return!1}else for(let r=0;r<this.index;r++)if(s.buffer.buffer[r+3]<this.index)return!1;({index:t,parent:n}=s)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,o=e<0?-1:n._tree.children.length;r!=o;r+=e){let l=n._tree.children[r];if(this.mode&Ie.IncludeAnonymous||l instanceof xi||!l.type.isAnonymous||Va(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let s=this.index,r=this.stack.length;r>=0;){for(let o=e;o;o=o._parent)if(o.index==s){if(s==this.index)return o;t=o,n=r+1;break e}s=this.stack[--r]}for(let s=n;s<this.stack.length;s++)t=new hi(this.buffer,t,this.stack[s]);return this.bufferNode=new hi(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let s=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(s=!0)}for(;;){if(s&&t&&t(this),s=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,s=!0}}}matchContext(e){if(!this.buffer)return vl(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let s=e.length-1,r=this.stack.length-1;s>=0;r--){if(r<0)return vl(this._tree,e,s);let o=n[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[s]&&e[s]!=o.name)return!1;s--}}return!0}}function Va(i){return i.children.some(e=>e instanceof xi||!e.type.isAnonymous||Va(e))}function Bv(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:s=nf,reused:r=[],minRepeatType:o=n.types.length}=i,l=Array.isArray(t)?new Ba(t,t.length):t,a=n.types,u=0,c=0;function h(S,E,A,I,R,H){let{id:F,start:j,end:W,size:P}=l,B=c,q=u;if(P<0)if(l.next(),P==-1){let U=r[F];A.push(U),I.push(j-S);return}else if(P==-3){u=F;return}else if(P==-4){c=F;return}else throw new RangeError(`Unrecognized record size: ${P}`);let ne=a[F],ae,ie,ee=j-S;if(W-j<=s&&(ie=x(l.pos-E,R))){let U=new Uint16Array(ie.size-ie.skip),w=l.pos-ie.size,O=U.length;for(;l.pos>w;)O=y(ie.start,U,O);ae=new xi(U,W-ie.start,n),ee=ie.start-S}else{let U=l.pos-P;l.next();let w=[],O=[],L=F>=o?F:-1,N=0,Q=W;for(;l.pos>U;)L>=0&&l.id==L&&l.size>=0?(l.end<=Q-s&&(g(w,O,j,N,l.end,Q,L,B,q),N=w.length,Q=l.end),l.next()):H>2500?d(j,U,w,O):h(j,U,w,O,L,H+1);if(L>=0&&N>0&&N<w.length&&g(w,O,j,N,j,Q,L,B,q),w.reverse(),O.reverse(),L>-1&&N>0){let Z=p(ne,q);ae=_a(ne,w,O,0,w.length,0,W-j,Z,Z)}else ae=m(ne,w,O,W-j,B-W,q)}A.push(ae),I.push(ee)}function d(S,E,A,I){let R=[],H=0,F=-1;for(;l.pos>E;){let{id:j,start:W,end:P,size:B}=l;if(B>4)l.next();else{if(F>-1&&W<F)break;F<0&&(F=P-s),R.push(j,W,P),H++,l.next()}}if(H){let j=new Uint16Array(H*4),W=R[R.length-2];for(let P=R.length-3,B=0;P>=0;P-=3)j[B++]=R[P],j[B++]=R[P+1]-W,j[B++]=R[P+2]-W,j[B++]=B;A.push(new xi(j,R[2]-W,n)),I.push(W-S)}}function p(S,E){return(A,I,R)=>{let H=0,F=A.length-1,j,W;if(F>=0&&(j=A[F])instanceof Re){if(!F&&j.type==S&&j.length==R)return j;(W=j.prop(te.lookAhead))&&(H=I[F]+j.length+W)}return m(S,A,I,R,H,E)}}function g(S,E,A,I,R,H,F,j,W){let P=[],B=[];for(;S.length>I;)P.push(S.pop()),B.push(E.pop()+A-R);S.push(m(n.types[F],P,B,H-R,j-H,W)),E.push(R-A)}function m(S,E,A,I,R,H,F){if(H){let j=[te.contextHash,H];F=F?[j].concat(F):[j]}if(R>25){let j=[te.lookAhead,R];F=F?[j].concat(F):[j]}return new Re(S,E,A,I,F)}function x(S,E){let A=l.fork(),I=0,R=0,H=0,F=A.end-s,j={size:0,start:0,skip:0};e:for(let W=A.pos-S;A.pos>W;){let P=A.size;if(A.id==E&&P>=0){j.size=I,j.start=R,j.skip=H,H+=4,I+=4,A.next();continue}let B=A.pos-P;if(P<0||B<W||A.start<F)break;let q=A.id>=o?4:0,ne=A.start;for(A.next();A.pos>B;){if(A.size<0)if(A.size==-3)q+=4;else break e;else A.id>=o&&(q+=4);A.next()}R=ne,I+=P,H+=q}return(E<0||I==S)&&(j.size=I,j.start=R,j.skip=H),j.size>4?j:void 0}function y(S,E,A){let{id:I,start:R,end:H,size:F}=l;if(l.next(),F>=0&&I<o){let j=A;if(F>4){let W=l.pos-(F-4);for(;l.pos>W;)A=y(S,E,A)}E[--A]=j,E[--A]=H-S,E[--A]=R-S,E[--A]=I}else F==-3?u=I:F==-4&&(c=I);return A}let b=[],v=[];for(;l.pos>0;)h(i.start||0,i.bufferStart||0,b,v,-1,0);let C=(e=i.length)!==null&&e!==void 0?e:b.length?v[0]+b[0].length:0;return new Re(a[i.topID],b.reverse(),v.reverse(),C)}const Fu=new WeakMap;function Qs(i,e){if(!i.isAnonymous||e instanceof xi||e.type!=i)return 1;let t=Fu.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof Re)){t=1;break}t+=Qs(i,n)}Fu.set(e,t)}return t}function _a(i,e,t,n,s,r,o,l,a){let u=0;for(let g=n;g<s;g++)u+=Qs(i,e[g]);let c=Math.ceil(u*1.5/8),h=[],d=[];function p(g,m,x,y,b){for(let v=x;v<y;){let C=v,S=m[v],E=Qs(i,g[v]);for(v++;v<y;v++){let A=Qs(i,g[v]);if(E+A>=c)break;E+=A}if(v==C+1){if(E>c){let A=g[C];p(A.children,A.positions,0,A.children.length,m[C]+b);continue}h.push(g[C])}else{let A=m[v-1]+g[v-1].length-S;h.push(_a(i,g,m,C,v,S,A,null,a))}d.push(S+b-r)}}return p(e,t,n,s,0),(l||a)(h,d,o)}class Di{constructor(e,t,n,s,r=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=s,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let s=[new Di(0,e.length,e,0,!1,n)];for(let r of t)r.to>e.length&&s.push(r);return s}static applyChanges(e,t,n=128){if(!t.length)return e;let s=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,u=0;;l++){let c=l<t.length?t[l]:null,h=c?c.fromA:1e9;if(h-a>=n)for(;o&&o.from<h;){let d=o;if(a>=d.from||h<=d.to||u){let p=Math.max(d.from,a)-u,g=Math.min(d.to,h)-u;d=p>=g?null:new Di(p,g,d.tree,d.offset+u,l>0,!!c)}if(d&&s.push(d),o.to>h)break;o=r<e.length?e[r++]:null}if(!c)break;a=c.toA,u=c.toA-c.toB}return s}}class lf{startParse(e,t,n){return typeof e=="string"&&(e=new Vv(e)),n=n?n.length?n.map(s=>new Do(s.from,s.to)):[new Do(0,0)]:[new Do(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let s=this.startParse(e,t,n);for(;;){let r=s.advance();if(r)return r}}}class Vv{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new te({perNode:!0});class mr{constructor(e,t,n,s,r,o,l,a,u,c=0,h){this.p=e,this.stack=t,this.state=n,this.reducePos=s,this.pos=r,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=u,this.lookAhead=c,this.parent=h}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let s=e.parser.context;return new mr(e,[],t,n,n,0,[],0,s?new Nu(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,s=e&65535,{parser:r}=this.p,o=this.reducePos<this.pos-25;o&&this.setLookAhead(this.pos);let l=r.dynamicPrecedence(s);if(l&&(this.score+=l),n==0){this.pushState(r.getGoto(this.state,s,!0),this.reducePos),s<r.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(s,this.reducePos);return}let a=this.stack.length-(n-1)*3-(e&262144?6:0),u=a?this.stack[a-2]:this.p.ranges[0].from,c=this.reducePos-u;c>=2e3&&!(!((t=this.p.parser.nodeSet.types[s])===null||t===void 0)&&t.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=u,this.p.lastBigReductionSize=c));let h=a?this.stack[a-1]:0,d=this.bufferBase+this.buffer.length-h;if(s<r.minRepeatTerm||e&131072){let p=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,u,p,d+4,!0)}if(e&262144)this.state=this.stack[a];else{let p=this.stack[a-3];this.state=r.getGoto(p,s,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(s,u)}storeNode(e,t,n,s=4,r=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,l=this.buffer.length;if(l==0&&o.parent&&(l=o.bufferBase-o.parent.bufferBase,o=o.parent),l>0&&o.buffer[l-4]==0&&o.buffer[l-1]>-1){if(t==n)return;if(o.buffer[l-2]>=t){o.buffer[l-2]=n;return}}}if(!r||this.pos==n)this.buffer.push(e,t,n,s);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>n;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>n;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=n,this.buffer[o+3]=s}}shift(e,t,n,s){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let r=e,{parser:o}=this.p;(s>this.pos||t<=o.maxNode)&&(this.pos=s,o.stateFlag(r,1)||(this.reducePos=s)),this.pushState(r,n),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,s,4)}else this.pos=s,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,s,4)}apply(e,t,n,s){e&65536?this.reduce(e):this.shift(e,t,n,s)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(n,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new mr(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,s,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new _v(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if((n&65536)==0)return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let s=[];for(let r=0,o;r<t.length;r+=2)(o=t[r+1])!=this.state&&this.p.parser.hasAction(o,e)&&s.push(t[r],o);if(this.stack.length<120)for(let r=0;s.length<8&&r<t.length;r+=2){let o=t[r+1];s.some((l,a)=>a&1&&l==o)||s.push(t[r],o)}t=s}let n=[];for(let s=0;s<t.length&&n.length<4;s+=2){let r=t[s+1];if(r==this.state)continue;let o=this.split();o.pushState(r,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[s],this.pos),o.reducePos=this.pos,o.score-=200,n.push(o)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if((t&65536)==0)return!1;if(!e.validAction(this.state,t)){let n=t>>19,s=t&65535,r=this.stack.length-n*3;if(r<0||e.getGoto(this.stack[r],s,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(s,r)=>{if(!t.includes(s))return t.push(s),e.allActions(s,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-r;if(l>1){let a=o&65535,u=this.stack.length-l*3;if(u>=0&&e.getGoto(this.stack[u],a,!1)>=0)return l<<19|65536|a}}else{let l=n(o,r+1);if(l!=null)return l}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new Nu(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class Nu{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class _v{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=s}}class xr{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new xr(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new xr(this.stack,this.pos,this.index)}}function ks(i,e=Uint16Array){if(typeof i!="string")return i;let t=null;for(let n=0,s=0;n<i.length;){let r=0;for(;;){let o=i.charCodeAt(n++),l=!1;if(o==126){r=65535;break}o>=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),r+=a,l)break;r*=46}t?t[s++]=r:t=new e(r)}return t}class Js{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const Bu=new Js;class zv{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Bu,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,s=this.rangeIndex,r=this.pos+e;for(;r<n.from;){if(!s)return null;let o=this.ranges[--s];r-=n.from-o.to,n=o}for(;t<0?r>n.to:r>=n.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];r+=o.from-n.to,n=o}return r}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,s;if(t>=0&&t<this.chunk.length)n=this.pos+e,s=this.chunk.charCodeAt(t);else{let r=this.resolveOffset(e,1);if(r==null)return-1;if(n=r,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)s=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=n;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-n)),s=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),s}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=Bu,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let s of this.ranges){if(s.from>=t)break;s.to>e&&(n+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return n}}class rn{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;$v(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}rn.prototype.contextual=rn.prototype.fallback=rn.prototype.extend=!1;rn.prototype.fallback=rn.prototype.extend=!1;function $v(i,e,t,n,s,r){let o=0,l=1<<n,{dialect:a}=t.p.parser;e:for(;(l&i[o])!=0;){let u=i[o+1];for(let p=o+3;p<u;p+=2)if((i[p+1]&l)>0){let g=i[p];if(a.allows(g)&&(e.token.value==-1||e.token.value==g||Hv(g,e.token.value,s,r))){e.acceptToken(g);break}}let c=e.next,h=0,d=i[o+2];if(e.next<0&&d>h&&i[u+d*3-3]==65535){o=i[u+d*3-1];continue e}for(;h<d;){let p=h+d>>1,g=u+p+(p<<1),m=i[g],x=i[g+1]||65536;if(c<m)d=p;else if(c>=x)h=p+1;else{o=i[g+2],e.advance();continue e}}break}}function Vu(i,e,t){for(let n=e,s;(s=i[n])!=65535;n++)if(s==t)return n-e;return-1}function Hv(i,e,t,n){let s=Vu(t,n,e);return s<0||Vu(t,n,i)<s}const nt=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG);let Lo=null;function _u(i,e,t){let n=i.cursor(Ie.IncludeAnonymous);for(n.moveTo(e);;)if(!(t<0?n.childBefore(e):n.childAfter(e)))for(;;){if((t<0?n.to<e:n.from>e)&&!n.type.isError)return t<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(i.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:i.length}}class Gv{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?_u(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?_u(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],s=this.index[t];if(s==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=n.children[s],o=this.start[t]+n.positions[s];if(o>e)return this.nextStart=o,null;if(r instanceof Re){if(o==e){if(o<this.safeFrom)return null;let l=o+r.length;if(l<=this.safeTo){let a=r.prop(te.lookAhead);if(!a||l+a<this.fragment.to)return r}}this.index[t]++,o+r.length>=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class Wv{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new Js)}getActions(e){let t=0,n=null,{parser:s}=e.p,{tokenizers:r}=s,o=s.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let u=0;u<r.length;u++){if((1<<u&o)==0)continue;let c=r[u],h=this.tokens[u];if(!(n&&!c.fallback)&&((c.contextual||h.start!=e.pos||h.mask!=o||h.context!=l)&&(this.updateCachedToken(h,c,e),h.mask=o,h.context=l),h.lookAhead>h.end+25&&(a=Math.max(h.lookAhead,a)),h.value!=0)){let d=t;if(h.extended>-1&&(t=this.addActions(e,h.extended,h.end,t)),t=this.addActions(e,h.value,h.end,t),!c.extend&&(n=h,t>d))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!n&&e.pos==this.stream.end&&(n=new Js,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Js,{pos:n,p:s}=e;return t.start=n,t.end=Math.min(n+1,s.stream.end),t.value=n==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,n){let s=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(s,e),n),e.value>-1){let{parser:r}=n.p;for(let o=0;o<r.specialized.length;o++)if(r.specialized[o]==e.value){let l=r.specializers[o](this.stream.read(e.start,e.end),n);if(l>=0&&n.p.parser.dialect.allows(l>>1)){(l&1)==0?e.value=l>>1:e.extended=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(s+1)}putAction(e,t,n,s){for(let r=0;r<s;r+=3)if(this.actions[r]==e)return s;return this.actions[s++]=e,this.actions[s++]=t,this.actions[s++]=n,s}addActions(e,t,n,s){let{state:r}=e,{parser:o}=e.p,{data:l}=o;for(let a=0;a<2;a++)for(let u=o.stateSlot(r,a?2:1);;u+=3){if(l[u]==65535)if(l[u+1]==1)u=qt(l,u+2);else{s==0&&l[u+1]==2&&(s=this.putAction(qt(l,u+2),t,n,s));break}l[u]==t&&(s=this.putAction(qt(l,u+1),t,n,s))}return s}}class Uv{constructor(e,t,n,s){this.parser=e,this.input=t,this.ranges=s,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new zv(t,s),this.tokens=new Wv(e,this.stream),this.topTerm=e.top[1];let{from:r}=s[0];this.stacks=[mr.start(this,e.top[0],r)],this.fragments=n.length&&this.stream.end-r>e.bufferLength*4?new Gv(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],s,r;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let l=e[o];for(;;){if(this.tokens.mainToken=null,l.pos>t)n.push(l);else{if(this.advanceStack(l,n,e))continue;{s||(s=[],r=[]),s.push(l);let a=this.tokens.getMainToken(l);r.push(a.value,a.end)}}break}}if(!n.length){let o=s&&Kv(s);if(o)return nt&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw nt&&s&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,r,n);if(o)return nt&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(n.length>o)for(n.sort((l,a)=>a.score-l.score);n.length>o;)n.pop();n.some(l=>l.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let o=0;o<n.length-1;o++){let l=n[o];for(let a=o+1;a<n.length;a++){let u=n[a];if(l.sameState(u)||l.buffer.length>500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)n.splice(a--,1);else{n.splice(o--,1);continue e}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let o=1;o<n.length;o++)n[o].pos<this.minStackPos&&(this.minStackPos=n[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let s=e.pos,{parser:r}=this,o=nt?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let h=this.fragments.nodeAt(s);h;){let d=this.parser.nodeSet.types[h.type.id]==h.type?r.getGoto(e.state,h.type.id):-1;if(d>-1&&h.length&&(!u||(h.prop(te.contextHash)||0)==c))return e.useNode(h,d),nt&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(h.type.id)})`),!0;if(!(h instanceof Re)||h.children.length==0||h.positions[0]>0)break;let p=h.children[0];if(p instanceof Re&&h.positions[0]==0)h=p;else break}}let l=r.stateSlot(e.state,4);if(l>0)return e.reduce(l),nt&&console.log(o+this.stackID(e)+` (via always-reduce ${r.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let u=0;u<a.length;){let c=a[u++],h=a[u++],d=a[u++],p=u==a.length||!n,g=p?e:e.split(),m=this.tokens.mainToken;if(g.apply(c,h,m?m.start:g.pos,d),nt&&console.log(o+this.stackID(g)+` (via ${(c&65536)==0?"shift":`reduce of ${r.getName(c&65535)}`} for ${r.getName(h)} @ ${s}${g==e?"":", split"})`),p)return!0;g.pos>s?t.push(g):n.push(g)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return zu(e,t),!0}}runRecovery(e,t,n){let s=null,r=!1;for(let o=0;o<e.length;o++){let l=e[o],a=t[o<<1],u=t[(o<<1)+1],c=nt?this.stackID(l)+" -> ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),nt&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,n))))continue;let h=l.split(),d=c;for(let p=0;p<10&&h.forceReduce()&&(nt&&console.log(d+this.stackID(h)+" (via force-reduce)"),!this.advanceFully(h,n));p++)nt&&(d=this.stackID(h)+" -> ");for(let p of l.recoverByInsert(a))nt&&console.log(c+this.stackID(p)+" (via recover-insert)"),this.advanceFully(p,n);this.stream.end>l.pos?(u==l.pos&&(u++,a=0),l.recoverByDelete(a,u),nt&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),zu(l,n)):(!s||s.score<l.score)&&(s=l)}return s}stackToTree(e){return e.close(),Re.build({buffer:xr.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(Lo||(Lo=new WeakMap)).get(e);return t||Lo.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function zu(i,e){for(let t=0;t<e.length;t++){let n=e[t];if(n.pos==i.pos&&n.sameState(i)){e[t].score<i.score&&(e[t]=i);return}}e.push(i)}class qv{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}}class yr extends lf{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;l<e.repeatNodeCount;l++)t.push("");let n=Object.keys(e.topRules).map(l=>e.topRules[l][1]),s=[];for(let l=0;l<t.length;l++)s.push([]);function r(l,a,u){s[l].push([a,a.deserialize(String(u))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=te[a]);for(let u=1;u<l.length;){let c=l[u++];if(c>=0)r(c,a,l[u++]);else{let h=l[u+-c];for(let d=-c;d>0;d--)r(l[u++],a,h);u++}}}this.nodeSet=new Na(t.map((l,a)=>tt.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:s[a],top:n.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=nf;let o=ks(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map($u),this.states=ks(e.states,Uint32Array),this.data=ks(e.stateData),this.goto=ks(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new rn(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let s=new Uv(this,e,t,n);for(let r of this.wrappers)s=r(s,e,t,n);return s}getGoto(e,t,n=!1){let s=this.goto;if(t>=s[0])return-1;for(let r=s[t+1];;){let o=s[r++],l=o&1,a=s[r++];if(l&&n)return a;for(let u=r+(o>>1);r<u;r++)if(s[r]==e)return a;if(l)return-1}}hasAction(e,t){let n=this.data;for(let s=0;s<2;s++)for(let r=this.stateSlot(e,s?2:1),o;;r+=3){if((o=n[r])==65535)if(n[r+1]==1)o=n[r=qt(n,r+2)];else{if(n[r+1]==2)return qt(n,r+2);break}if(o==t||o==0)return qt(n,r+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,n=>n==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),s=n?t(n):void 0;for(let r=this.stateSlot(e,1);s==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=qt(this.data,r+2);else break;s=t(qt(this.data,r+1))}return s}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=qt(this.data,n+2);else break;if((this.data[n+2]&1)==0){let s=this.data[n+1];t.some((r,o)=>o&1&&r==s)||t.push(this.data[n],s)}}return t}configure(e){let t=Object.assign(Object.create(yr.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(n=>{let s=e.tokenizers.find(r=>r.from==n);return s?s.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,s)=>{let r=e.specializers.find(l=>l.from==n.external);if(!r)return n;let o=Object.assign(Object.assign({},n),{external:r.to});return t.specializers[s]=$u(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(" ")){let o=t.indexOf(r);o>=0&&(n[o]=!0)}let s=null;for(let r=0;r<t.length;r++)if(!n[r])for(let o=this.dialects[t[r]],l;(l=this.data[o++])!=65535;)(s||(s=new Uint8Array(this.maxTerm+1)))[l]=1;return new qv(e,n,s)}static deserialize(e){return new yr(e)}}function qt(i,e){return i[e]|i[e+1]<<16}function Kv(i){let e=null;for(let t of i){let n=t.p.stoppedAt;(t.pos==t.p.stream.end||n!=null&&t.pos>n)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function $u(i){if(i.external){let e=i.extend?1:0;return(t,n)=>i.external(t,n)<<1|e}return i.get}let Yv=0;class ct{constructor(e,t,n,s){this.name=e,this.set=t,this.base=n,this.modified=s,this.id=Yv++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e=="string"?e:"?";if(e instanceof ct&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let s=new ct(n,[],null,[]);if(s.set.push(s),t)for(let r of t.set)s.set.push(r);return s}static defineModifier(e){let t=new br(e);return n=>n.modified.indexOf(t)>-1?n:br.get(n.base||n,n.modified.concat(t).sort((s,r)=>s.id-r.id))}}let Xv=0;class br{constructor(e){this.name=e,this.instances=[],this.id=Xv++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(l=>l.base==e&&Qv(t,l.modified));if(n)return n;let s=[],r=new ct(e.name,s,e,t);for(let l of t)l.instances.push(r);let o=Jv(t);for(let l of e.set)if(!l.modified.length)for(let a of o)s.push(br.get(l,a));return r}}function Qv(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function Jv(i){let e=[[]];for(let t=0;t<i.length;t++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(i[t]));return e.sort((t,n)=>n.length-t.length)}function af(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let s of t.split(" "))if(s){let r=[],o=2,l=s;for(let h=0;;){if(l=="..."&&h>0&&h+3==s.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!d)throw new RangeError("Invalid path: "+s);if(r.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),h+=d[0].length,h==s.length)break;let p=s[h++];if(h==s.length&&p=="!"){o=0;break}if(p!="/")throw new RangeError("Invalid path: "+s);l=s.slice(h)}let a=r.length-1,u=r[a];if(!u)throw new RangeError("Invalid path: "+s);let c=new Kn(n,o,a>0?r.slice(0,a):null);e[u]=c.sort(e[u])}}return uf.add(e)}const uf=new te({combine(i,e){let t,n,s;for(;i||e;){if(!i||e&&i.depth>=e.depth?(s=e,e=e.next):(s=i,i=i.next),t&&t.mode==s.mode&&!s.context&&!t.context)continue;let r=new Kn(s.tags,s.mode,s.context);t?t.next=r:n=r,t=r}return n}});class Kn{constructor(e,t,n,s){this.tags=e,this.mode=t,this.context=n,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Kn.empty=new Kn([],2,null);function cf(i,e){let t=Object.create(null);for(let r of i)if(!Array.isArray(r.tag))t[r.tag.id]=r.class;else for(let o of r.tag)t[o.id]=r.class;let{scope:n,all:s=null}=e||{};return{style:r=>{let o=s;for(let l of r)for(let a of l.set){let u=t[a.id];if(u){o=o?o+" "+u:u;break}}return o},scope:n}}function Zv(i,e){let t=null;for(let n of i){let s=n.style(e);s&&(t=t?t+" "+s:s)}return t}function eS(i,e,t,n=0,s=i.length){let r=new tS(n,Array.isArray(e)?e:[e],t);r.highlightRange(i.cursor(),n,s,"",r.highlighters),r.flush(s)}class tS{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,s,r){let{type:o,from:l,to:a}=e;if(l>=n||a<=t)return;o.isTop&&(r=this.highlighters.filter(p=>!p.scope||p.scope(o)));let u=s,c=iS(e)||Kn.empty,h=Zv(r,c.tags);if(h&&(u&&(u+=" "),u+=h,c.mode==1&&(s+=(s?" ":"")+h)),this.startSpan(Math.max(t,l),u),c.opaque)return;let d=e.tree&&e.tree.prop(te.mounted);if(d&&d.overlay){let p=e.node.enter(d.overlay[0].from+l,1),g=this.highlighters.filter(x=>!x.scope||x.scope(d.tree.type)),m=e.firstChild();for(let x=0,y=l;;x++){let b=x<d.overlay.length?d.overlay[x]:null,v=b?b.from+l:a,C=Math.max(t,y),S=Math.min(n,v);if(C<S&&m)for(;e.from<S&&(this.highlightRange(e,C,S,s,r),this.startSpan(Math.min(S,e.to),u),!(e.to>=v||!e.nextSibling())););if(!b||v>n)break;y=b.to+l,y>t&&(this.highlightRange(p.cursor(),Math.max(t,b.from+l),Math.min(n,y),"",g),this.startSpan(Math.min(n,y),u))}m&&e.parent()}else if(e.firstChild()){d&&(s="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,s,r),this.startSpan(Math.min(n,e.to),u)}while(e.nextSibling());e.parent()}}}function iS(i){let e=i.type.prop(uf);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}const V=ct.define,As=V(),li=V(),Hu=V(li),Gu=V(li),ai=V(),Ts=V(ai),Fo=V(ai),Ot=V(),ki=V(Ot),At=V(),Tt=V(),Cl=V(),kn=V(Cl),Ms=V(),k={comment:As,lineComment:V(As),blockComment:V(As),docComment:V(As),name:li,variableName:V(li),typeName:Hu,tagName:V(Hu),propertyName:Gu,attributeName:V(Gu),className:V(li),labelName:V(li),namespace:V(li),macroName:V(li),literal:ai,string:Ts,docString:V(Ts),character:V(Ts),attributeValue:V(Ts),number:Fo,integer:V(Fo),float:V(Fo),bool:V(ai),regexp:V(ai),escape:V(ai),color:V(ai),url:V(ai),keyword:At,self:V(At),null:V(At),atom:V(At),unit:V(At),modifier:V(At),operatorKeyword:V(At),controlKeyword:V(At),definitionKeyword:V(At),moduleKeyword:V(At),operator:Tt,derefOperator:V(Tt),arithmeticOperator:V(Tt),logicOperator:V(Tt),bitwiseOperator:V(Tt),compareOperator:V(Tt),updateOperator:V(Tt),definitionOperator:V(Tt),typeOperator:V(Tt),controlOperator:V(Tt),punctuation:Cl,separator:V(Cl),bracket:kn,angleBracket:V(kn),squareBracket:V(kn),paren:V(kn),brace:V(kn),content:Ot,heading:ki,heading1:V(ki),heading2:V(ki),heading3:V(ki),heading4:V(ki),heading5:V(ki),heading6:V(ki),contentSeparator:V(Ot),list:V(Ot),quote:V(Ot),emphasis:V(Ot),strong:V(Ot),link:V(Ot),monospace:V(Ot),strikethrough:V(Ot),inserted:V(),deleted:V(),changed:V(),invalid:V(),meta:Ms,documentMeta:V(Ms),annotation:V(Ms),processingInstruction:V(Ms),definition:ct.defineModifier("definition"),constant:ct.defineModifier("constant"),function:ct.defineModifier("function"),standard:ct.defineModifier("standard"),local:ct.defineModifier("local"),special:ct.defineModifier("special")};for(let i in k){let e=k[i];e instanceof ct&&(e.name=i)}cf([{tag:k.link,class:"tok-link"},{tag:k.heading,class:"tok-heading"},{tag:k.emphasis,class:"tok-emphasis"},{tag:k.strong,class:"tok-strong"},{tag:k.keyword,class:"tok-keyword"},{tag:k.atom,class:"tok-atom"},{tag:k.bool,class:"tok-bool"},{tag:k.url,class:"tok-url"},{tag:k.labelName,class:"tok-labelName"},{tag:k.inserted,class:"tok-inserted"},{tag:k.deleted,class:"tok-deleted"},{tag:k.literal,class:"tok-literal"},{tag:k.string,class:"tok-string"},{tag:k.number,class:"tok-number"},{tag:[k.regexp,k.escape,k.special(k.string)],class:"tok-string2"},{tag:k.variableName,class:"tok-variableName"},{tag:k.local(k.variableName),class:"tok-variableName tok-local"},{tag:k.definition(k.variableName),class:"tok-variableName tok-definition"},{tag:k.special(k.variableName),class:"tok-variableName2"},{tag:k.definition(k.propertyName),class:"tok-propertyName tok-definition"},{tag:k.typeName,class:"tok-typeName"},{tag:k.namespace,class:"tok-namespace"},{tag:k.className,class:"tok-className"},{tag:k.macroName,class:"tok-macroName"},{tag:k.propertyName,class:"tok-propertyName"},{tag:k.operator,class:"tok-operator"},{tag:k.comment,class:"tok-comment"},{tag:k.meta,class:"tok-meta"},{tag:k.invalid,class:"tok-invalid"},{tag:k.punctuation,class:"tok-punctuation"}]);const nS=af({String:k.string,Number:k.number,"True False":k.bool,PropertyName:k.propertyName,Null:k.null,", :":k.separator,"[ ]":k.squareBracket,"{ }":k.brace}),sS=yr.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[nS],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});let wl=[],hf=[];(()=>{let i="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<i.length;e++)(e%2?hf:wl).push(t=t+i[e])})();function rS(i){if(i<768)return!1;for(let e=0,t=wl.length;;){let n=e+t>>1;if(i<wl[n])t=n;else if(i>=hf[n])e=n+1;else return!0;if(e==t)return!1}}function Wu(i){return i>=127462&&i<=127487}const Uu=8205;function oS(i,e,t=!0,n=!0){return(t?df:lS)(i,e,n)}function df(i,e,t){if(e==i.length)return e;e&&ff(i.charCodeAt(e))&&pf(i.charCodeAt(e-1))&&e--;let n=No(i,e);for(e+=qu(n);e<i.length;){let s=No(i,e);if(n==Uu||s==Uu||t&&rS(s))e+=qu(s),n=s;else if(Wu(s)){let r=0,o=e-2;for(;o>=0&&Wu(No(i,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function lS(i,e,t){for(;e>0;){let n=df(i,e-2,t);if(n<e)return n;e--}return 0}function No(i,e){let t=i.charCodeAt(e);if(!pf(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return ff(n)?(t-55296<<10)+(n-56320)+65536:t}function ff(i){return i>=56320&&i<57344}function pf(i){return i>=55296&&i<56320}function qu(i){return i<65536?1:2}class oe{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=dn(this,e,t);let s=[];return this.decompose(0,e,s,2),n.length&&n.decompose(0,n.length,s,3),this.decompose(t,this.length,s,1),jt.from(s,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=dn(this,e,t);let n=[];return this.decompose(e,t,n,0),jt.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),s=new Bn(this),r=new Bn(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=n)return!0}}iter(e=1){return new Bn(this,e)}iterRange(e,t=this.length){return new gf(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;n=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new mf(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?oe.empty:e.length<=32?new ve(e):jt.from(ve.split(e,[]))}}class ve extends oe{constructor(e,t=aS(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?n:l)>=e)return new uS(s,l,n,o);s=l+1,n++}}decompose(e,t,n,s){let r=e<=0&&t>=this.length?this:new ve(Ku(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=n.pop(),l=Zs(r.text,o.text.slice(),0,r.length);if(l.length<=32)n.push(new ve(l,o.length+r.length));else{let a=l.length>>1;n.push(new ve(l.slice(0,a)),new ve(l.slice(a)))}}else n.push(r)}replace(e,t,n){if(!(n instanceof ve))return super.replace(e,t,n);[e,t]=dn(this,e,t);let s=Zs(this.text,Zs(n.text,Ku(this.text,0,e)),t),r=this.length+n.length-(t-e);return s.length<=32?new ve(s,r):jt.from(ve.split(s,[]),r)}sliceString(e,t=this.length,n=`
24
+ `){[e,t]=dn(this,e,t);let s="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(s+=n),e<a&&t>r&&(s+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],s=-1;for(let r of e)n.push(r),s+=r.length+1,n.length==32&&(t.push(new ve(n,s)),n=[],s=-1);return s>-1&&t.push(new ve(n,s)),t}}class jt extends oe{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,s){for(let r=0;;r++){let o=this.children[r],l=s+o.length,a=n+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,n,s);s=l+1,n=a+1}}decompose(e,t,n,s){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=o){let u=s&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!u?n.push(l):l.decompose(e-o,t-o,n,u)}o=a+1}}replace(e,t,n){if([e,t]=dn(this,e,t),n.lines<this.lines)for(let s=0,r=0;s<this.children.length;s++){let o=this.children[s],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,n),u=this.lines-o.lines+a.lines;if(a.lines<u>>4&&a.lines>u>>6){let c=this.children.slice();return c[s]=a,new jt(c,this.length-(t-e)+n.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=`
25
+ `){[e,t]=dn(this,e,t);let s="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(s+=n),e<a&&t>o&&(s+=l.sliceString(e-o,t-o,n)),o=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof jt))return 0;let n=0,[s,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==l)return n;let a=this.children[s],u=e.children[r];if(a!=u)return n+a.scanIdentical(u,t);n+=a.length+1}}static from(e,t=e.reduce((n,s)=>n+s.length+1,-1)){let n=0;for(let p of e)n+=p.lines;if(n<32){let p=[];for(let g of e)g.flatten(p);return new ve(p,t)}let s=Math.max(32,n>>5),r=s<<1,o=s>>1,l=[],a=0,u=-1,c=[];function h(p){let g;if(p.lines>r&&p instanceof jt)for(let m of p.children)h(m);else p.lines>o&&(a>o||!a)?(d(),l.push(p)):p instanceof ve&&a&&(g=c[c.length-1])instanceof ve&&p.lines+g.lines<=32?(a+=p.lines,u+=p.length+1,c[c.length-1]=new ve(g.text.concat(p.text),g.length+1+p.length)):(a+p.lines>s&&d(),a+=p.lines,u+=p.length+1,c.push(p))}function d(){a!=0&&(l.push(c.length==1?c[0]:jt.from(c,u)),u=-1,a=c.length=0)}for(let p of e)h(p);return d(),l.length==1?l[0]:new jt(l,t)}}oe.empty=new ve([""],0);function aS(i){let e=-1;for(let t of i)e+=t.length+1;return e}function Zs(i,e,t=0,n=1e9){for(let s=0,r=0,o=!0;r<i.length&&s<=n;r++){let l=i[r],a=s+l.length;a>=t&&(a>n&&(l=l.slice(0,n-s)),s<t&&(l=l.slice(t-s)),o?(e[e.length-1]+=l,o=!1):e.push(l)),s=a+1}return e}function Ku(i,e,t){return Zs(i,[""],e,t)}class Bn{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof ve?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,s=this.nodes[n],r=this.offsets[n],o=r>>1,l=s instanceof ve?s.text.length:s.children.length;if(o==(t>0?l:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
26
+ `,this;e--}else if(s instanceof ve){let a=s.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof ve?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class gf{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Bn(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=n?s:t<0?s.slice(s.length-n):s.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class mf{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(oe.prototype[Symbol.iterator]=function(){return this.iter()},Bn.prototype[Symbol.iterator]=gf.prototype[Symbol.iterator]=mf.prototype[Symbol.iterator]=function(){return this});class uS{constructor(e,t,n,s){this.from=e,this.to=t,this.number=n,this.text=s}get length(){return this.to-this.from}}function dn(i,e,t){return e=Math.max(0,Math.min(i.length,e)),[e,Math.max(e,Math.min(i.length,t))]}function Le(i,e,t=!0,n=!0){return oS(i,e,t,n)}function cS(i){return i>=56320&&i<57344}function hS(i){return i>=55296&&i<56320}function Xe(i,e){let t=i.charCodeAt(e);if(!hS(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return cS(n)?(t-55296<<10)+(n-56320)+65536:t}function za(i){return i<=65535?String.fromCharCode(i):(i-=65536,String.fromCharCode((i>>10)+55296,(i&1023)+56320))}function Pt(i){return i<65536?1:2}const El=/\r\n?|\n/;var Ue=(function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i})(Ue||(Ue={}));class Bt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,s=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(n,s,r),s+=r):s+=o,n+=r}}iterChangedRanges(e,t=!1){Rl(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],s=this.sections[t++];s<0?e.push(n,s):e.push(s,n)}return new Bt(e)}composeDesc(e){return this.empty?e:e.empty?this:xf(this,e)}mapDesc(e,t=!1){return e.empty?this:kl(this,e,t)}mapPos(e,t=-1,n=Ue.Simple){let s=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],u=s+l;if(a<0){if(u>e)return r+(e-s);r+=l}else{if(n!=Ue.Simple&&u>=e&&(n==Ue.TrackDel&&s<e&&u>e||n==Ue.TrackBefore&&s<e||n==Ue.TrackAfter&&u>e))return null;if(u>e||u==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=u}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let n=0,s=0;n<this.sections.length&&s<=t;){let r=this.sections[n++],o=this.sections[n++],l=s+r;if(o>=0&&s<=t&&l>=e)return s<e&&l>t?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],s=this.sections[t++];e+=(e?" ":"")+n+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Bt(e)}static create(e){return new Bt(e)}}class Ae extends Bt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Rl(this,(t,n,s,r,o)=>e=e.replace(s,s+(n-t),o),!1),e}mapDesc(e,t=!1){return kl(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let s=0,r=0;s<t.length;s+=2){let o=t[s],l=t[s+1];if(l>=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;n.length<a;)n.push(oe.empty);n.push(o?e.slice(r,r+o):oe.empty)}r+=o}return new Ae(t,n)}compose(e){return this.empty?e:e.empty?this:xf(this,e,!0)}map(e,t=!1){return e.empty?this:kl(this,e,t,!0)}iterChanges(e,t=!1){Rl(this,e,t)}get desc(){return Bt.create(this.sections)}filter(e){let t=[],n=[],s=[],r=new Yn(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,a-l);Ve(s,c,-1);let h=r.ins==-1?-1:r.off==0?r.ins:0;Ve(t,c,h),h>0&&di(n,t,r.text),r.forward(c),l+=c}let u=e[o++];for(;l<u;){if(r.done)break e;let c=Math.min(r.len,u-l);Ve(t,c,-1),Ve(s,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),l+=c}}return{changes:new Ae(t,n),filtered:Bt.create(s)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],s=this.sections[t+1];s<0?e.push(n):s==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let s=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!s.length)return;o<t&&Ve(s,t-o,-1);let h=new Ae(s,r);l=l?l.compose(h.map(l)):h,s=[],r=[],o=0}function u(c){if(Array.isArray(c))for(let h of c)u(h);else if(c instanceof Ae){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:h,to:d=h,insert:p}=c;if(h>d||h<0||d>t)throw new RangeError(`Invalid change range ${h} to ${d} (in doc of length ${t})`);let g=p?typeof p=="string"?oe.of(p.split(n||El)):p:oe.empty,m=g.length;if(h==d&&m==0)return;h<o&&a(),h>o&&Ve(s,h-o,-1),Ve(s,d-h,m),di(r,s,g),o=d}}return u(e),a(!l),l}static empty(e){return new Ae(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let s=0;s<e.length;s++){let r=e[s];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;n.length<s;)n.push(oe.empty);n[s]=oe.of(r.slice(1)),t.push(r[0],n[s].length)}}}return new Ae(t,n)}static createSet(e,t){return new Ae(e,t)}}function Ve(i,e,t,n=!1){if(e==0&&t<=0)return;let s=i.length-2;s>=0&&t<=0&&t==i[s+1]?i[s]+=e:s>=0&&e==0&&i[s]==0?i[s+1]+=t:n?(i[s]+=e,i[s+1]+=t):i.push(e,t)}function di(i,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n<i.length)i[i.length-1]=i[i.length-1].append(t);else{for(;i.length<n;)i.push(oe.empty);i.push(t)}}function Rl(i,e,t){let n=i.inserted;for(let s=0,r=0,o=0;o<i.sections.length;){let l=i.sections[o++],a=i.sections[o++];if(a<0)s+=l,r+=l;else{let u=s,c=r,h=oe.empty;for(;u+=l,c+=a,a&&n&&(h=h.append(n[o-2>>1])),!(t||o==i.sections.length||i.sections[o+1]<0);)l=i.sections[o++],a=i.sections[o++];e(s,u,r,c,h),s=u,r=c}}}function kl(i,e,t,n=!1){let s=[],r=n?[]:null,o=new Yn(i),l=new Yn(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);Ve(s,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let u=l.len;for(Ve(s,l.ins,-1);u;){let c=Math.min(o.len,u);o.ins>=0&&a<o.i&&o.len<=c&&(Ve(s,0,o.ins),r&&di(r,s,o.text),a=o.i),o.forward(c),u-=c}l.next()}else if(o.ins>=0){let u=0,c=o.len;for(;c;)if(l.ins==-1){let h=Math.min(c,l.len);u+=h,c-=h,l.forward(h)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;Ve(s,u,a<o.i?o.ins:0),r&&a<o.i&&di(r,s,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?Ae.createSet(s,r):Bt.create(s);throw new Error("Mismatched change set lengths")}}}function xf(i,e,t=!1){let n=[],s=t?[]:null,r=new Yn(i),o=new Yn(e);for(let l=!1;;){if(r.done&&o.done)return s?Ae.createSet(n,s):Bt.create(n);if(r.ins==0)Ve(n,r.len,0,l),r.next();else if(o.len==0&&!o.done)Ve(n,0,o.ins,l),s&&di(s,n,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),u=n.length;if(r.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;Ve(n,a,c,l),s&&c&&di(s,n,o.text)}else o.ins==-1?(Ve(n,r.off?0:r.len,a,l),s&&di(s,n,r.textBit(a))):(Ve(n,r.off?0:r.len,o.off?0:o.ins,l),s&&!o.off&&di(s,n,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||n.length>u),r.forward2(a),o.forward(a)}}}}class Yn{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?oe.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?oe.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Ii{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let n,s;return this.empty?n=s=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),n==this.from&&s==this.to?this:new Ii(n,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return T.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return T.range(this.anchor,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return T.range(e.anchor,e.head)}static create(e,t,n){return new Ii(e,t,n)}}class T{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:T.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new T([this.main],0)}addRange(e,t=!0){return T.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,T.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new T(e.ranges.map(t=>Ii.fromJSON(t)),e.main)}static single(e,t=e){return new T([T.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,s=0;s<e.length;s++){let r=e[s];if(r.empty?r.from<=n:r.from<n)return T.normalized(e.slice(),t);n=r.to}return new T(e,t)}static cursor(e,t=0,n,s){return Ii.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(s??16777215)<<6)}static range(e,t,n,s){let r=(n??16777215)<<6|(s==null?7:Math.min(6,s));return t<e?Ii.create(t,e,48|r):Ii.create(e,t,(t>e?8:0)|r)}static normalized(e,t=0){let n=e[t];e.sort((s,r)=>s.from-r.from),t=e.indexOf(n);for(let s=1;s<e.length;s++){let r=e[s],o=e[s-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);s<=t&&t--,e.splice(--s,2,r.anchor>r.head?T.range(a,l):T.range(l,a))}}return new T(e,t)}}function yf(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let $a=0;class ${constructor(e,t,n,s,r){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=s,this.id=$a++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new $(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:Ha),!!e.static,e.enables)}of(e){return new er([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new er(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new er(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}}function Ha(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}class er{constructor(e,t,n,s){this.dependencies=e,this.facet=t,this.type=n,this.value=s,this.id=$a++}dynamicSlot(e){var t;let n=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,u=!1,c=[];for(let h of this.dependencies)h=="doc"?a=!0:h=="selection"?u=!0:(((t=e[h.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[h.id]);return{create(h){return h.values[o]=n(h),1},update(h,d){if(a&&d.docChanged||u&&(d.docChanged||d.selection)||Al(h,c)){let p=n(h);if(l?!Yu(p,h.values[o],s):!s(p,h.values[o]))return h.values[o]=p,1}return 0},reconfigure:(h,d)=>{let p,g=d.config.address[r];if(g!=null){let m=Sr(d,g);if(this.dependencies.every(x=>x instanceof $?d.facet(x)===h.facet(x):x instanceof Fe?d.field(x,!1)==h.field(x,!1):!0)||(l?Yu(p=n(h),m,s):s(p=n(h),m)))return h.values[o]=m,0}else p=n(h);return h.values[o]=p,1}}}}function Yu(i,e,t){if(i.length!=e.length)return!1;for(let n=0;n<i.length;n++)if(!t(i[n],e[n]))return!1;return!0}function Al(i,e){let t=!1;for(let n of e)Vn(i,n)&1&&(t=!0);return t}function dS(i,e,t){let n=t.map(a=>i[a.id]),s=t.map(a=>a.type),r=n.filter(a=>!(a&1)),o=i[e.id]>>1;function l(a){let u=[];for(let c=0;c<n.length;c++){let h=Sr(a,n[c]);if(s[c]==2)for(let d of h)u.push(d);else u.push(h)}return e.combine(u)}return{create(a){for(let u of n)Vn(a,u);return a.values[o]=l(a),1},update(a,u){if(!Al(a,r))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,u){let c=Al(a,n),h=u.config.facets[e.id],d=u.facet(e);if(h&&!c&&Ha(t,h))return a.values[o]=d,0;let p=l(a);return e.compare(p,d)?(a.values[o]=d,0):(a.values[o]=p,1)}}}const Os=$.define({static:!0});class Fe{constructor(e,t,n,s,r){this.id=e,this.createF=t,this.updateF=n,this.compareF=s,this.spec=r,this.provides=void 0}static define(e){let t=new Fe($a++,e.create,e.update,e.compare||((n,s)=>n===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Os).find(n=>n.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,s)=>{let r=n.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(n.values[t]=o,1)},reconfigure:(n,s)=>{let r=n.facet(Os),o=s.facet(Os),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(n.values[t]=l.create(n),1):s.config.address[this.id]!=null?(n.values[t]=s.field(this),0):(n.values[t]=this.create(n),1)}}}init(e){return[this,Os.of({field:this,create:e})]}get extension(){return this}}const Ti={lowest:4,low:3,default:2,high:1,highest:0};function An(i){return e=>new bf(e,i)}const $i={highest:An(Ti.highest),high:An(Ti.high),default:An(Ti.default),low:An(Ti.low),lowest:An(Ti.lowest)};class bf{constructor(e,t){this.inner=e,this.prec=t}}class Zr{of(e){return new Tl(this,e)}reconfigure(e){return Zr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tl{constructor(e,t){this.compartment=e,this.inner=t}}class vr{constructor(e,t,n,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let s=[],r=Object.create(null),o=new Map;for(let d of fS(e,t,o))d instanceof Fe?s.push(d):(r[d.facet.id]||(r[d.facet.id]=[])).push(d);let l=Object.create(null),a=[],u=[];for(let d of s)l[d.id]=u.length<<1,u.push(p=>d.slot(p));let c=n==null?void 0:n.config.facets;for(let d in r){let p=r[d],g=p[0].facet,m=c&&c[d]||[];if(p.every(x=>x.type==0))if(l[g.id]=a.length<<1|1,Ha(m,p))a.push(n.facet(g));else{let x=g.combine(p.map(y=>y.value));a.push(n&&g.compare(x,n.facet(g))?n.facet(g):x)}else{for(let x of p)x.type==0?(l[x.id]=a.length<<1|1,a.push(x.value)):(l[x.id]=u.length<<1,u.push(y=>x.dynamicSlot(y)));l[g.id]=u.length<<1,u.push(x=>dS(x,g,p))}}let h=u.map(d=>d(l));return new vr(e,o,h,l,a,r)}}function fS(i,e,t){let n=[[],[],[],[],[]],s=new Map;function r(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let u=n[a].indexOf(o);u>-1&&n[a].splice(u,1),o instanceof Tl&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let u of o)r(u,l);else if(o instanceof Tl){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;t.set(o.compartment,u),r(u,l)}else if(o instanceof bf)r(o.inner,o.prec);else if(o instanceof Fe)n[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof er)n[l].push(o),o.facet.extensions&&r(o.facet.extensions,Ti.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(u,l)}}return r(i,Ti.default),n.reduce((o,l)=>o.concat(l))}function Vn(i,e){if(e&1)return 2;let t=e>>1,n=i.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;i.status[t]=4;let s=i.computeSlot(i,i.config.dynamicSlots[t]);return i.status[t]=2|s}function Sr(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}const vf=$.define(),Ml=$.define({combine:i=>i.some(e=>e),static:!0}),Sf=$.define({combine:i=>i.length?i[0]:void 0,static:!0}),Cf=$.define(),wf=$.define(),Ef=$.define(),Rf=$.define({combine:i=>i.length?i[0]:!1});class $t{constructor(e,t){this.type=e,this.value=t}static define(){return new pS}}class pS{of(e){return new $t(this,e)}}class gS{constructor(e){this.map=e}of(e){return new J(this,e)}}class J{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new J(this.type,t)}is(e){return this.type==e}static define(e={}){return new gS(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let s of e){let r=s.map(t);r&&n.push(r)}return n}}J.reconfigure=J.define();J.appendConfig=J.define();class Te{constructor(e,t,n,s,r,o){this.startState=e,this.changes=t,this.selection=n,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,n&&yf(n,t.newLength),r.some(l=>l.type==Te.time)||(this.annotations=r.concat(Te.time.of(Date.now())))}static create(e,t,n,s,r,o){return new Te(e,t,n,s,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Te.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Te.time=$t.define();Te.userEvent=$t.define();Te.addToHistory=$t.define();Te.remote=$t.define();function mS(i,e){let t=[];for(let n=0,s=0;;){let r,o;if(n<i.length&&(s==e.length||e[s]>=i[n]))r=i[n++],o=i[n++];else if(s<e.length)r=e[s++],o=e[s++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function kf(i,e,t){var n;let s,r,o;return t?(s=e.changes,r=Ae.empty(e.changes.length),o=i.changes.compose(e.changes)):(s=e.changes.map(i.changes),r=i.changes.mapDesc(e.changes,!0),o=i.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):(n=i.selection)===null||n===void 0?void 0:n.map(s),effects:J.mapEffects(i.effects,s).concat(J.mapEffects(e.effects,r)),annotations:i.annotations.length?i.annotations.concat(e.annotations):e.annotations,scrollIntoView:i.scrollIntoView||e.scrollIntoView}}function Ol(i,e,t){let n=e.selection,s=on(e.annotations);return e.userEvent&&(s=s.concat(Te.userEvent.of(e.userEvent))),{changes:e.changes instanceof Ae?e.changes:Ae.of(e.changes||[],t,i.facet(Sf)),selection:n&&(n instanceof T?n:T.single(n.anchor,n.head)),effects:on(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function Af(i,e,t){let n=Ol(i,e.length?e[0]:{},i.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;n=kf(n,Ol(i,e[r],o?n.changes.newLength:i.doc.length),o)}let s=Te.create(i,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return yS(t?xS(s):s)}function xS(i){let e=i.startState,t=!0;for(let s of e.facet(Cf)){let r=s(i);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:mS(t,r))}if(t!==!0){let s,r;if(t===!1)r=i.changes.invertedDesc,s=Ae.empty(e.doc.length);else{let o=i.changes.filter(t);s=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}i=Te.create(e,s,i.selection&&i.selection.map(r),J.mapEffects(i.effects,r),i.annotations,i.scrollIntoView)}let n=e.facet(wf);for(let s=n.length-1;s>=0;s--){let r=n[s](i);r instanceof Te?i=r:Array.isArray(r)&&r.length==1&&r[0]instanceof Te?i=r[0]:i=Af(e,on(r),!1)}return i}function yS(i){let e=i.startState,t=e.facet(Ef),n=i;for(let s=t.length-1;s>=0;s--){let r=t[s](i);r&&Object.keys(r).length&&(n=kf(n,Ol(e,r,i.changes.newLength),!0))}return n==i?i:Te.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}const bS=[];function on(i){return i==null?bS:Array.isArray(i)?i:[i]}var ye=(function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i})(ye||(ye={}));const vS=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Il;try{Il=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function SS(i){if(Il)return Il.test(i);for(let e=0;e<i.length;e++){let t=i[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||vS.test(t)))return!0}return!1}function CS(i){return e=>{if(!/\S/.test(e))return ye.Space;if(SS(e))return ye.Word;for(let t=0;t<i.length;t++)if(e.indexOf(i[t])>-1)return ye.Word;return ye.Other}}class se{constructor(e,t,n,s,r,o){this.config=e,this.doc=t,this.selection=n,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Vn(this,l<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return Vn(this,n),Sr(this,n)}update(...e){return Af(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:s}=t;for(let l of e.effects)l.is(Zr.reconfigure)?(t&&(s=new Map,t.compartments.forEach((a,u)=>s.set(u,a)),t=null),s.set(l.value.compartment,l.value.extension)):l.is(J.reconfigure)?(t=null,n=l.value):l.is(J.appendConfig)&&(t=null,n=on(n).concat(l.value));let r;t?r=e.startState.values.slice():(t=vr.resolve(n,s,this),r=new se(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,u)=>u.reconfigure(a,this),null).values);let o=e.startState.facet(Ml)?e.newSelection:e.newSelection.asSingle();new se(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:T.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),s=this.changes(n.changes),r=[n.range],o=on(n.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),u=this.changes(a.changes),c=u.map(s);for(let d=0;d<l;d++)r[d]=r[d].map(c);let h=s.mapDesc(u,!0);r.push(a.range.map(h)),s=s.compose(c),o=J.mapEffects(o,c).concat(J.mapEffects(on(a.effects),h))}return{changes:s,selection:T.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Ae?e:Ae.of(e,this.doc.length,this.facet(se.lineSeparator))}toText(e){return oe.of(e.split(this.facet(se.lineSeparator)||El))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Vn(this,t),Sr(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let s=e[n];s instanceof Fe&&this.config.address[s.id]!=null&&(t[n]=s.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(n){for(let r in n)if(Object.prototype.hasOwnProperty.call(e,r)){let o=n[r],l=e[r];s.push(o.init(a=>o.spec.fromJSON(l,a)))}}return se.create({doc:e.doc,selection:T.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=vr.resolve(e.extensions||[],new Map),n=e.doc instanceof oe?e.doc:oe.of((e.doc||"").split(t.staticFacet(se.lineSeparator)||El)),s=e.selection?e.selection instanceof T?e.selection:T.single(e.selection.anchor,e.selection.head):T.single(0);return yf(s,n.length),t.staticFacet(Ml)||(s=s.asSingle()),new se(t,n,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(se.tabSize)}get lineBreak(){return this.facet(se.lineSeparator)||`
27
+ `}get readOnly(){return this.facet(Rf)}phrase(e,...t){for(let n of this.facet(se.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,s)=>{if(s=="$")return"$";let r=+(s||1);return!r||r>t.length?n:t[r-1]})),e}languageDataAt(e,t,n=-1){let s=[];for(let r of this.facet(vf))for(let o of r(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){return CS(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:s}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-n,l=e-n;for(;o>0;){let a=Le(t,o,!1);if(r(t.slice(a,o))!=ye.Word)break;o=a}for(;l<s;){let a=Le(t,l);if(r(t.slice(l,a))!=ye.Word)break;l=a}return o==l?null:T.range(o+n,l+n)}}se.allowMultipleSelections=Ml;se.tabSize=$.define({combine:i=>i.length?i[0]:4});se.lineSeparator=Sf;se.readOnly=Rf;se.phrases=$.define({compare(i,e){let t=Object.keys(i),n=Object.keys(e);return t.length==n.length&&t.every(s=>i[s]==e[s])}});se.languageData=vf;se.changeFilter=Cf;se.transactionFilter=wf;se.transactionExtender=Ef;Zr.reconfigure=J.define();function Ht(i,e,t={}){let n={};for(let s of i)for(let r of Object.keys(s)){let o=s[r],l=n[r];if(l===void 0)n[r]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,r))n[r]=t[r](l,o);else throw new Error("Config merge conflict for field "+r)}for(let s in e)n[s]===void 0&&(n[s]=e[s]);return n}class Fi{eq(e){return this==e}range(e,t=e){return Xn.create(e,t,this)}}Fi.prototype.startSide=Fi.prototype.endSide=0;Fi.prototype.point=!1;Fi.prototype.mapMode=Ue.TrackDel;class Xn{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new Xn(e,t,n)}}function jl(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}class Ga{constructor(e,t,n,s){this.from=e,this.to=t,this.value=n,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,s=0){let r=n?this.to:this.from;for(let o=s,l=r.length;;){if(o==l)return o;let a=o+l>>1,u=r[a]-e||(n?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return u>=0?o:l;u>=0?l=a:o=a+1}}between(e,t,n,s){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,r);r<o;r++)if(s(this.from[r]+e,this.to[r]+e,this.value[r])===!1)return!1}map(e,t){let n=[],s=[],r=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let u=this.value[a],c=this.from[a]+e,h=this.to[a]+e,d,p;if(c==h){let g=t.mapPos(c,u.startSide,u.mapMode);if(g==null||(d=p=g,u.startSide!=u.endSide&&(p=t.mapPos(c,u.endSide),p<d)))continue}else if(d=t.mapPos(c,u.startSide),p=t.mapPos(h,u.endSide),d>p||d==p&&u.startSide>0&&u.endSide<=0)continue;(p-d||u.endSide-u.startSide)<0||(o<0&&(o=d),u.point&&(l=Math.max(l,p-d)),n.push(u),s.push(d-o),r.push(p-o))}return{mapped:n.length?new Ga(s,r,n,l):null,pos:o}}}class re{constructor(e,t,n,s){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=s}static create(e,t,n,s){return new re(e,t,n,s)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:s=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(n&&(t=t.slice().sort(jl)),this.isEmpty)return t.length?re.of(t):this;let l=new Tf(this,null,-1).goto(0),a=0,u=[],c=new Zt;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let h=t[a++];c.addInner(h.from,h.to,h.value)||u.push(h)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||s>this.chunkEnd(l.chunkIndex)||r<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||s>l.to||r<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value)||u.push(Xn.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!u.length?re.empty:this.nextLayer.update({add:u,filter:o,filterFrom:s,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],s=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],u=e.touchesRange(l,l+a.length);if(u===!1)s=Math.max(s,a.maxPoint),t.push(a),n.push(e.mapPos(l));else if(u===!0){let{mapped:c,pos:h}=a.map(l,e);c&&(s=Math.max(s,c.maxPoint),t.push(c),n.push(h))}}let r=this.nextLayer.map(e);return t.length==0?r:new re(n,t,r||re.empty,s)}between(e,t,n){if(!this.isEmpty){for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s];if(t>=r&&e<=r+o.length&&o.between(r,e-r,t-r,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return Qn.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Qn.from(e).goto(t)}static compare(e,t,n,s,r=-1){let o=e.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=r),l=t.filter(h=>h.maxPoint>0||!h.isEmpty&&h.maxPoint>=r),a=Xu(o,l,n),u=new Tn(o,a,r),c=new Tn(l,a,r);n.iterGaps((h,d,p)=>Qu(u,h,c,d,p,s)),n.empty&&n.length==0&&Qu(u,0,c,0,0,s)}static eq(e,t,n=0,s){s==null&&(s=999999999);let r=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=Xu(r,o),a=new Tn(r,l,0).goto(n),u=new Tn(o,l,0).goto(n);for(;;){if(a.to!=u.to||!Pl(a.active,u.active)||a.point&&(!u.point||!a.point.eq(u.point)))return!1;if(a.to>s)return!0;a.next(),u.next()}}static spans(e,t,n,s,r=-1){let o=new Tn(e,null,r).goto(t),l=t,a=o.openStart;for(;;){let u=Math.min(o.to,n);if(o.point){let c=o.activeForPoint(o.to),h=o.pointFrom<t?c.length+1:o.point.startSide<0?c.length:Math.min(c.length,a);s.point(l,u,o.point,c,h,o.pointRank),a=Math.min(o.openEnd(u),c.length)}else u>l&&(s.span(l,u,o.active,a),a=o.openEnd(u));if(o.to>n)return a+(o.point&&o.to>n?1:0);l=o.to,o.next()}}static of(e,t=!1){let n=new Zt;for(let s of e instanceof Xn?[e]:t?wS(e):e)n.add(s.from,s.to,s.value);return n.finish()}static join(e){if(!e.length)return re.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let s=e[n];s!=re.empty;s=s.nextLayer)t=new re(s.chunkPos,s.chunk,t,Math.max(s.maxPoint,t.maxPoint));return t}}re.empty=new re([],[],null,-1);function wS(i){if(i.length>1)for(let e=i[0],t=1;t<i.length;t++){let n=i[t];if(jl(e,n)>0)return i.slice().sort(jl);e=n}return i}re.empty.nextLayer=re.empty;class Zt{finishChunk(e){this.chunks.push(new Ga(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new Zt)).add(e,t,n)}addInner(e,t,n){let s=e-this.lastTo||n.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(re.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=re.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Xu(i,e,t){let n=new Map;for(let r of i)for(let o=0;o<r.chunk.length;o++)r.chunk[o].maxPoint<=0&&n.set(r.chunk[o],r.chunkPos[o]);let s=new Set;for(let r of e)for(let o=0;o<r.chunk.length;o++){let l=n.get(r.chunk[o]);l!=null&&(t?t.mapPos(l):l)==r.chunkPos[o]&&!(t!=null&&t.touchesRange(l,l+r.chunk[o].length))&&s.add(r.chunk[o])}return s}class Tf{constructor(e,t,n,s=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=s}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let s=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(s)||this.layer.chunkEnd(this.chunkIndex)<e||s.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let s=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<s)&&this.setRangeIndex(s)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Qn{constructor(e){this.heap=e}static from(e,t=null,n=-1){let s=[];for(let r=0;r<e.length;r++)for(let o=e[r];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&s.push(new Tf(o,t,n,r));return s.length==1?s[0]:new Qn(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)Bo(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)Bo(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Bo(this.heap,0)}}}function Bo(i,e){for(let t=i[e];;){let n=(e<<1)+1;if(n>=i.length)break;let s=i[n];if(n+1<i.length&&s.compare(i[n+1])>=0&&(s=i[n+1],n++),t.compare(s)<0)break;i[n]=t,i[e]=s,e=n}}class Tn{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Qn.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Is(this.active,e),Is(this.activeTo,e),Is(this.activeRank,e),this.minActive=Ju(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:s,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||s-this.activeTo[t])>0;)t++;js(this.active,t,n),js(this.activeTo,t,s),js(this.activeRank,t,r),e&&js(e,t,this.cursor.from),this.minActive=Ju(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),n&&Is(n,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=r,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=r.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let s=n.length-1;s>=0&&n[s]<e;s--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function Qu(i,e,t,n,s,r){i.goto(e),t.goto(n);let o=n+s,l=n,a=n-e;for(;;){let u=i.to+a-t.to,c=u||i.endSide-t.endSide,h=c<0?i.to+a:t.to,d=Math.min(h,o);if(i.point||t.point?i.point&&t.point&&(i.point==t.point||i.point.eq(t.point))&&Pl(i.activeForPoint(i.to),t.activeForPoint(t.to))||r.comparePoint(l,d,i.point,t.point):d>l&&!Pl(i.active,t.active)&&r.compareRange(l,d,i.active,t.active),h>o)break;(u||i.openEnd!=t.openEnd)&&r.boundChange&&r.boundChange(h),l=h,c<=0&&i.next(),c>=0&&t.next()}}function Pl(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(i[t]!=e[t]&&!i[t].eq(e[t]))return!1;return!0}function Is(i,e){for(let t=e,n=i.length-1;t<n;t++)i[t]=i[t+1];i.pop()}function js(i,e,t){for(let n=i.length-1;n>=e;n--)i[n+1]=i[n];i[e]=t}function Ju(i,e){let t=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||i[s].endSide-i[t].endSide)<0&&(t=s,n=e[s]);return t}function vn(i,e,t=i.length){let n=0;for(let s=0;s<t&&s<i.length;)i.charCodeAt(s)==9?(n+=e-n%e,s++):(n++,s=Le(i,s));return n}function Dl(i,e,t,n){for(let s=0,r=0;;){if(r>=e)return s;if(s==i.length)break;r+=i.charCodeAt(s)==9?t-r%t:1,s=Le(i,s)}return n===!0?-1:i.length}const Ll="ͼ",Zu=typeof Symbol>"u"?"__"+Ll:Symbol.for(Ll),Fl=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),ec=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class yi{constructor(e,t){this.rules=[];let{finish:n}=t||{};function s(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,a,u){let c=[],h=/^@(\w+)\b/.exec(o[0]),d=h&&h[1]=="keyframes";if(h&&l==null)return a.push(o[0]+";");for(let p in l){let g=l[p];if(/&/.test(p))r(p.split(/,\s*/).map(m=>o.map(x=>m.replace(/&/,x))).reduce((m,x)=>m.concat(x)),g,a);else if(g&&typeof g=="object"){if(!h)throw new RangeError("The value of a property ("+p+") should be a primitive value.");r(s(p),g,c,d)}else g!=null&&c.push(p.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+g+";")}(c.length||d)&&a.push((n&&!h&&!u?o.map(n):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)r(s(o),e[o],this.rules)}getRules(){return this.rules.join(`
28
+ `)}static newName(){let e=ec[Zu]||1;return ec[Zu]=e+1,Ll+e.toString(36)}static mount(e,t,n){let s=e[Fl],r=n&&n.nonce;s?r&&s.setNonce(r):s=new ES(e,r),s.mount(Array.isArray(t)?t:[t],e)}}let tc=new Map;class ES{constructor(e,t){let n=e.ownerDocument||e,s=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let r=tc.get(n);if(r)return e[Fl]=r;this.sheet=new s.CSSStyleSheet,tc.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Fl]=this}mount(e,t){let n=this.sheet,s=0,r=0;for(let o=0;o<e.length;o++){let l=e[o],a=this.modules.indexOf(l);if(a<r&&a>-1&&(this.modules.splice(a,1),r--,a=-1),a==-1){if(this.modules.splice(r++,0,l),n)for(let u=0;u<l.rules.length;u++)n.insertRule(l.rules[u],s++)}else{for(;r<a;)s+=this.modules[r++].rules.length;s+=l.rules.length,r++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
29
+ `;this.styleTag.textContent=o;let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var bi={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Jn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},RS=typeof navigator<"u"&&/Mac/.test(navigator.platform),kS=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var De=0;De<10;De++)bi[48+De]=bi[96+De]=String(De);for(var De=1;De<=24;De++)bi[De+111]="F"+De;for(var De=65;De<=90;De++)bi[De]=String.fromCharCode(De+32),Jn[De]=String.fromCharCode(De);for(var Vo in bi)Jn.hasOwnProperty(Vo)||(Jn[Vo]=bi[Vo]);function AS(i){var e=RS&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||kS&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?Jn:bi)[i.keyCode]||i.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function fe(){var i=arguments[0];typeof i=="string"&&(i=document.createElement(i));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var s=t[n];typeof s=="string"?i.setAttribute(n,s):s!=null&&(i[n]=s)}e++}for(;e<arguments.length;e++)Mf(i,arguments[e]);return i}function Mf(i,e){if(typeof e=="string")i.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)i.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)Mf(i,e[t]);else throw new RangeError("Unsupported child node: "+e)}let We=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Nl=typeof document<"u"?document:{documentElement:{style:{}}};const Bl=/Edge\/(\d+)/.exec(We.userAgent),Of=/MSIE \d/.test(We.userAgent),Vl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(We.userAgent),eo=!!(Of||Vl||Bl),ic=!eo&&/gecko\/(\d+)/i.test(We.userAgent),_o=!eo&&/Chrome\/(\d+)/.exec(We.userAgent),TS="webkitFontSmoothing"in Nl.documentElement.style,_l=!eo&&/Apple Computer/.test(We.vendor),nc=_l&&(/Mobile\/\w+/.test(We.userAgent)||We.maxTouchPoints>2);var z={mac:nc||/Mac/.test(We.platform),windows:/Win/.test(We.platform),linux:/Linux|X11/.test(We.platform),ie:eo,ie_version:Of?Nl.documentMode||6:Vl?+Vl[1]:Bl?+Bl[1]:0,gecko:ic,gecko_version:ic?+(/Firefox\/(\d+)/.exec(We.userAgent)||[0,0])[1]:0,chrome:!!_o,chrome_version:_o?+_o[1]:0,ios:nc,android:/Android\b/.test(We.userAgent),webkit_version:TS?+(/\bAppleWebKit\/(\d+)/.exec(We.userAgent)||[0,0])[1]:0,safari:_l,safari_version:_l?+(/\bVersion\/(\d+(\.\d+)?)/.exec(We.userAgent)||[0,0])[1]:0,tabSize:Nl.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Zn(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function zl(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function tr(i,e){if(!e.anchorNode)return!1;try{return zl(i,e.anchorNode)}catch{return!1}}function fn(i){return i.nodeType==3?Bi(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function _n(i,e,t,n){return t?sc(i,e,t,n,-1)||sc(i,e,t,n,1):!1}function Ni(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function Cr(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function sc(i,e,t,n,s){for(;;){if(i==t&&e==n)return!0;if(e==(s<0?0:Vt(i))){if(i.nodeName=="DIV")return!1;let r=i.parentNode;if(!r||r.nodeType!=1)return!1;e=Ni(i)+(s<0?0:1),i=r}else if(i.nodeType==1){if(i=i.childNodes[e+(s<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;e=s<0?Vt(i):0}else return!1}}function Vt(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function cs(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function MS(i){let e=i.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function If(i,e){let t=e.width/i.offsetWidth,n=e.height/i.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-i.offsetWidth)<1)&&(t=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-i.offsetHeight)<1)&&(n=1),{scaleX:t,scaleY:n}}function OS(i,e,t,n,s,r,o,l){let a=i.ownerDocument,u=a.defaultView||window;for(let c=i,h=!1;c&&!h;)if(c.nodeType==1){let d,p=c==a.body,g=1,m=1;if(p)d=MS(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(h=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let b=c.getBoundingClientRect();({scaleX:g,scaleY:m}=If(c,b)),d={left:b.left,right:b.left+c.clientWidth*g,top:b.top,bottom:b.top+c.clientHeight*m}}let x=0,y=0;if(s=="nearest")e.top<d.top?(y=e.top-(d.top+o),t>0&&e.bottom>d.bottom+y&&(y=e.bottom-d.bottom+o)):e.bottom>d.bottom&&(y=e.bottom-d.bottom+o,t<0&&e.top-y<d.top&&(y=e.top-(d.top+o)));else{let b=e.bottom-e.top,v=d.bottom-d.top;y=(s=="center"&&b<=v?e.top+b/2-v/2:s=="start"||s=="center"&&t<0?e.top-o:e.bottom-v+o)-d.top}if(n=="nearest"?e.left<d.left?(x=e.left-(d.left+r),t>0&&e.right>d.right+x&&(x=e.right-d.right+r)):e.right>d.right&&(x=e.right-d.right+r,t<0&&e.left<d.left+x&&(x=e.left-(d.left+r))):x=(n=="center"?e.left+(e.right-e.left)/2-(d.right-d.left)/2:n=="start"==l?e.left-r:e.right-(d.right-d.left)+r)-d.left,x||y)if(p)u.scrollBy(x,y);else{let b=0,v=0;if(y){let C=c.scrollTop;c.scrollTop+=y/m,v=(c.scrollTop-C)*m}if(x){let C=c.scrollLeft;c.scrollLeft+=x/g,b=(c.scrollLeft-C)*g}e={left:e.left-b,top:e.top-v,right:e.right-b,bottom:e.bottom-v},b&&Math.abs(b-x)<1&&(n="nearest"),v&&Math.abs(v-y)<1&&(s="nearest")}if(p)break;(e.top<d.top||e.bottom>d.bottom||e.left<d.left||e.right>d.right)&&(e={left:Math.max(e.left,d.left),right:Math.min(e.right,d.right),top:Math.max(e.top,d.top),bottom:Math.min(e.bottom,d.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function IS(i){let e=i.ownerDocument,t,n;for(let s=i.parentNode;s&&!(s==e.body||t&&n);)if(s.nodeType==1)!n&&s.scrollHeight>s.clientHeight&&(n=s),!t&&s.scrollWidth>s.clientWidth&&(t=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:t,y:n}}class jS{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?Vt(t):0),n,Math.min(e.focusOffset,n?Vt(n):0))}set(e,t,n,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=s}}let Ai=null;z.safari&&z.safari_version>=26&&(Ai=!1);function jf(i){if(i.setActive)return i.setActive();if(Ai)return i.focus(Ai);let e=[];for(let t=i;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(i.focus(Ai==null?{get preventScroll(){return Ai={preventScroll:!0},!0}}:void 0),!Ai){Ai=!1;for(let t=0;t<e.length;){let n=e[t++],s=e[t++],r=e[t++];n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}}}let rc;function Bi(i,e,t=e){let n=rc||(rc=document.createRange());return n.setEnd(i,t),n.setStart(i,e),n}function ln(i,e,t,n){let s={key:e,code:e,keyCode:t,which:t,cancelable:!0};n&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=n);let r=new KeyboardEvent("keydown",s);r.synthetic=!0,i.dispatchEvent(r);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,i.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function PS(i){for(;i;){if(i&&(i.nodeType==9||i.nodeType==11&&i.host))return i;i=i.assignedSlot||i.parentNode}return null}function Pf(i){for(;i.attributes.length;)i.removeAttributeNode(i.attributes[0])}function DS(i,e){let t=e.focusNode,n=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=n)return!1;for(n=Math.min(n,Vt(t));;)if(n){if(t.nodeType!=1)return!1;let s=t.childNodes[n-1];s.contentEditable=="false"?n--:(t=s,n=Vt(t))}else{if(t==i)return!0;n=Ni(t),t=t.parentNode}}function Df(i){return i.scrollTop>Math.max(1,i.scrollHeight-i.clientHeight-4)}function Lf(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&n>0)return{node:t,offset:n};if(t.nodeType==1&&n>0){if(t.contentEditable=="false")return null;t=t.childNodes[n-1],n=Vt(t)}else if(t.parentNode&&!Cr(t))n=Ni(t),t=t.parentNode;else return null}}function Ff(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&n<t.nodeValue.length)return{node:t,offset:n};if(t.nodeType==1&&n<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[n],n=0}else if(t.parentNode&&!Cr(t))n=Ni(t)+1,t=t.parentNode;else return null}}class _e{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new _e(e.parentNode,Ni(e),t)}static after(e,t){return new _e(e.parentNode,Ni(e)+1,t)}}const Wa=[];class de{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let n=this.dom,s=null,r;for(let o of this.children){if(o.flags&7){if(!o.dom&&(r=s?s.nextSibling:n.firstChild)){let l=de.get(r);(!l||!l.parent&&l.canReuseDOM(o))&&o.reuseDOM(r)}o.sync(e,t),o.flags&=-8}if(r=s?s.nextSibling:n.firstChild,t&&!t.written&&t.node==n&&r!=o.dom&&(t.written=!0),o.dom.parentNode==n)for(;r&&r!=o.dom;)r=oc(r);else n.insertBefore(o.dom,r);s=o.dom}for(r=s?s.nextSibling:n.firstChild,r&&t&&t.node==n&&(t.written=!0);r;)r=oc(r)}else if(this.flags&1)for(let n of this.children)n.flags&7&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let s=Vt(e)==0?0:t==0?-1:1;for(;;){let r=e.parentNode;if(r==this.dom)break;s==0&&r.firstChild!=r.lastChild&&(e==r.firstChild?s=-1:s=1),e=r}s<0?n=e:n=e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!de.get(n);)n=n.nextSibling;if(!n)return this.length;for(let s=0,r=0;;s++){let o=this.children[s];if(o.dom==n)return r;r+=o.length+o.breakAfter}}domBoundsAround(e,t,n=0){let s=-1,r=-1,o=-1,l=-1;for(let a=0,u=n,c=n;a<this.children.length;a++){let h=this.children[a],d=u+h.length;if(u<e&&d>t)return h.domBoundsAround(e,t,u);if(d>=e&&s==-1&&(s=a,r=u),u>t&&h.dom.parentNode==this.dom){o=a,l=c;break}c=d,u=d+h.breakAfter}return{from:r,to:l<0?n+this.length:l,startDOM:(s?this.children[s-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=Wa){this.markDirty();for(let s=e;s<t;s++){let r=this.children[s];r.parent==this&&n.indexOf(r)<0&&r.destroy()}n.length<250?this.children.splice(e,t-e,...n):this.children=[].concat(this.children.slice(0,e),n,this.children.slice(t));for(let s=0;s<n.length;s++)n[s].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new Nf(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,n,s,r,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}}de.prototype.breakAfter=0;function oc(i){let e=i.nextSibling;return i.parentNode.removeChild(i),e}class Nf{constructor(e,t,n){this.children=e,this.pos=t,this.i=n,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}}function Bf(i,e,t,n,s,r,o,l,a){let{children:u}=i,c=u.length?u[e]:null,h=r.length?r[r.length-1]:null,d=h?h.breakAfter:o;if(!(e==n&&c&&!o&&!d&&r.length<2&&c.merge(t,s,r.length?h:null,t==0,l,a))){if(n<u.length){let p=u[n];p&&(s<p.length||p.breakAfter&&(h!=null&&h.breakAfter))?(e==n&&(p=p.split(s),s=0),!d&&h&&p.merge(0,s,h,!0,0,a)?r[r.length-1]=p:((s||p.children.length&&!p.children[0].length)&&p.merge(0,s,null,!1,0,a),r.push(p))):p!=null&&p.breakAfter&&(h?h.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,t>0&&(!o&&r.length&&c.merge(t,c.length,r[0],!1,l,0)?c.breakAfter=r.shift().breakAfter:(t<c.length||c.children.length&&c.children[c.children.length-1].length==0)&&c.merge(t,c.length,null,!1,l,0),e++));e<n&&r.length;)if(u[n-1].become(r[r.length-1]))n--,r.pop(),a=r.length?0:l;else if(u[e].become(r[0]))e++,r.shift(),l=r.length?0:a;else break;!r.length&&e&&n<u.length&&!u[e-1].breakAfter&&u[n].merge(0,0,u[e-1],!1,l,a)&&e--,(e<n||r.length)&&i.replaceChildren(e,n,r)}}function Vf(i,e,t,n,s,r){let o=i.childCursor(),{i:l,off:a}=o.findPos(t,1),{i:u,off:c}=o.findPos(e,-1),h=e-t;for(let d of n)h+=d.length;i.length+=h,Bf(i,u,c,l,a,n,0,s,r)}const LS=256;class St extends de{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,n){return this.flags&8||n&&(!(n instanceof St)||this.length-(t-e)+n.length>LS||n.flags&8)?!1:(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new St(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new _e(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return FS(this.dom,e,t)}}class ei extends de{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let s of t)s.setParent(this)}setAttrs(e){if(Pf(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,s,r,o){return n&&(!(n instanceof ei&&n.mark.eq(this.mark))||e&&r<=0||t<this.length&&o<=0)?!1:(Vf(this,e,t,n?n.children.slice():[],r-1,o-1),this.markDirty(),!0)}split(e){let t=[],n=0,s=-1,r=0;for(let l of this.children){let a=n+l.length;a>e&&t.push(n<e?l.split(e-n):l),s<0&&n>=e&&(s=r),n=a,r++}let o=this.length-e;return this.length=e,s>-1&&(this.children.length=s,this.markDirty()),new ei(this.mark,t,o)}domAtPos(e){return _f(this,e)}coordsAt(e,t){return $f(this,e,t)}}function FS(i,e,t){let n=i.nodeValue.length;e>n&&(e=n);let s=e,r=e,o=0;e==0&&t<0||e==n&&t>=0?z.chrome||z.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):t<0?s--:r<n&&r++;let l=Bi(i,s,r).getClientRects();if(!l.length)return null;let a=l[(o?o<0:t>=0)?0:l.length-1];return z.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,u=>u.width)||a),o?cs(a,o<0):a||null}class Yt extends de{static create(e,t,n){return new Yt(e,t,n)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}split(e){let t=Yt.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,n,s,r,o){return n&&(!(n instanceof Yt)||!this.widget.compare(n.widget)||e>0&&r<=0||t<this.length&&o<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}become(e){return e instanceof Yt&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return oe.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,n=t&&t.state.doc,s=this.posAtStart;return n?n.slice(s,s+this.length):oe.empty}domAtPos(e){return(this.length?e==0:this.side>0)?_e.before(this.dom):_e.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let s=this.dom.getClientRects(),r=null;if(!s.length)return null;let o=this.side?this.side<0:e>0;for(let l=o?s.length-1:0;r=s[l],!(e>0?l==0:l==s.length-1||r.top<r.bottom);l+=o?-1:1);return cs(r,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class pn extends de{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof pn&&e.side==this.side}split(){return new pn(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?_e.before(this.dom):_e.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return oe.empty}get isHidden(){return!0}}St.prototype.children=Yt.prototype.children=pn.prototype.children=Wa;function _f(i,e){let t=i.dom,{children:n}=i,s=0;for(let r=0;s<n.length;s++){let o=n[s],l=r+o.length;if(!(l==r&&o.getSide()<=0)){if(e>r&&e<l&&o.dom.parentNode==t)return o.domAtPos(e-r);if(e<=r)break;r=l}}for(let r=s;r>0;r--){let o=n[r-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let r=s;r<n.length;r++){let o=n[r];if(o.dom.parentNode==t)return o.domAtPos(0)}return new _e(t,0)}function zf(i,e,t){let n,{children:s}=i;t>0&&e instanceof ei&&s.length&&(n=s[s.length-1])instanceof ei&&n.mark.eq(e.mark)?zf(n,e.children[0],t-1):(s.push(e),e.setParent(i)),i.length+=e.length}function $f(i,e,t){let n=null,s=-1,r=null,o=-1;function l(u,c){for(let h=0,d=0;h<u.children.length&&d<=c;h++){let p=u.children[h],g=d+p.length;g>=c&&(p.children.length?l(p,c-d):(!r||r.isHidden&&(t>0||BS(r,p)))&&(g>c||d==g&&p.getSide()>0)?(r=p,o=c-d):(d<c||d==g&&p.getSide()<0&&!p.isHidden)&&(n=p,s=c-d)),d=g}}l(i,e);let a=(t<0?n:r)||n||r;return a?a.coordsAt(Math.max(0,a==n?s:o),t):NS(i)}function NS(i){let e=i.dom.lastChild;if(!e)return i.dom.getBoundingClientRect();let t=fn(e);return t[t.length-1]||null}function BS(i,e){let t=i.coordsAt(0,1),n=e.coordsAt(0,1);return t&&n&&n.top<t.bottom}function $l(i,e){for(let t in i)t=="class"&&e.class?e.class+=" "+i.class:t=="style"&&e.style?e.style+=";"+i.style:e[t]=i[t];return e}const lc=Object.create(null);function wr(i,e,t){if(i==e)return!0;i||(i=lc),e||(e=lc);let n=Object.keys(i),s=Object.keys(e);if(n.length-(t&&n.indexOf(t)>-1?1:0)!=s.length-(t&&s.indexOf(t)>-1?1:0))return!1;for(let r of n)if(r!=t&&(s.indexOf(r)==-1||i[r]!==e[r]))return!1;return!0}function Hl(i,e,t){let n=!1;if(e)for(let s in e)t&&s in t||(n=!0,s=="style"?i.style.cssText="":i.removeAttribute(s));if(t)for(let s in t)e&&e[s]==t[s]||(n=!0,s=="style"?i.style.cssText=t[s]:i.setAttribute(s,t[s]));return n}function VS(i){let e=Object.create(null);for(let t=0;t<i.attributes.length;t++){let n=i.attributes[t];e[n.name]=n.value}return e}class ii{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var qe=(function(i){return i[i.Text=0]="Text",i[i.WidgetBefore=1]="WidgetBefore",i[i.WidgetAfter=2]="WidgetAfter",i[i.WidgetRange=3]="WidgetRange",i})(qe||(qe={}));class K extends Fi{constructor(e,t,n,s){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=s}get heightRelevant(){return!1}static mark(e){return new hs(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new vi(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,s;if(e.isBlockGap)n=-5e8,s=4e8;else{let{start:r,end:o}=Hf(e,t);n=(r?t?-3e8:-1:5e8)-1,s=(o?t?2e8:1:-6e8)+1}return new vi(e,n,s,t,e.widget||null,!0)}static line(e){return new ds(e)}static set(e,t=!1){return re.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}K.none=re.empty;class hs extends K{constructor(e){let{start:t,end:n}=Hf(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof hs&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((n=e.attrs)===null||n===void 0?void 0:n.class))&&wr(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}hs.prototype.point=!1;class ds extends K{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ds&&this.spec.class==e.spec.class&&wr(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}ds.prototype.mapMode=Ue.TrackBefore;ds.prototype.point=!0;class vi extends K{constructor(e,t,n,s,r,o){super(t,n,r,e),this.block=s,this.isReplace=o,this.mapMode=s?t<=0?Ue.TrackBefore:Ue.TrackAfter:Ue.TrackDel}get type(){return this.startSide!=this.endSide?qe.WidgetRange:this.startSide<=0?qe.WidgetBefore:qe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof vi&&_S(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}vi.prototype.point=!0;function Hf(i,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=i;return t==null&&(t=i.inclusive),n==null&&(n=i.inclusive),{start:t??e,end:n??e}}function _S(i,e){return i==e||!!(i&&e&&i.compare(e))}function ir(i,e,t,n=0){let s=t.length-1;s>=0&&t[s]+n>=i?t[s]=Math.max(t[s],e):t.push(i,e)}class Ee extends de{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,s,r,o){if(n){if(!(n instanceof Ee))return!1;this.dom||n.transferDOM(this)}return s&&this.setDeco(n?n.attrs:null),Vf(this,e,t,n?n.children.slice():[],r,o),!0}split(e){let t=new Ee;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i:n,off:s}=this.childPos(e);s&&(t.append(this.children[n].split(s),0),this.children[n].merge(s,this.children[n].length,null,!1,0,0),n++);for(let r=n;r<this.children.length;r++)t.append(this.children[r],0);for(;n>0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){wr(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){zf(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=$l(t,this.attrs||{})),n&&(this.attrs=$l({class:n},this.attrs||{}))}domAtPos(e){return _f(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(Pf(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(Hl(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let s=this.dom.lastChild;for(;s&&de.get(s)instanceof ei;)s=s.lastChild;if(!s||!this.length||s.nodeName!="BR"&&((n=de.get(s))===null||n===void 0?void 0:n.isEditable)==!1&&(!z.ios||!this.children.some(r=>r instanceof St))){let r=document.createElement("BR");r.cmIgnore=!0,this.dom.appendChild(r)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let n of this.children){if(!(n instanceof St)||/[^ -~]/.test(n.text))return null;let s=fn(n.dom);if(s.length!=1)return null;e+=s[0].width,t=s[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=$f(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:s}=this.parent.view.viewState,r=n.bottom-n.top;if(Math.abs(r-s.lineHeight)<2&&s.textHeight<r){let o=(r-s.textHeight)/2;return{top:n.top+o,bottom:n.bottom-o,left:n.left,right:n.left}}}return n}become(e){return e instanceof Ee&&this.children.length==0&&e.children.length==0&&wr(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,t){for(let n=0,s=0;n<e.children.length;n++){let r=e.children[n],o=s+r.length;if(o>=t){if(r instanceof Ee)return r;if(o>t)break}s=o+r.breakAfter}return null}}class Qt extends de{constructor(e,t,n){super(),this.widget=e,this.length=t,this.deco=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,s,r,o){return n&&(!(n instanceof Qt)||!this.widget.compare(n.widget)||e>0&&r<=0||t<this.length&&o<=0)?!1:(this.length=e+(n?n.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?_e.before(this.dom):_e.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new Qt(this.widget,t,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return Wa}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):oe.empty}domBoundsAround(){return null}become(e){return e instanceof Qt&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);return n||(this.widget instanceof Gl?null:cs(this.dom.getBoundingClientRect(),this.length?e==0:t<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:n}=this.deco;return t==n?!1:e<0?t<0:n>0}}class Gl extends ii{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class zn{constructor(e,t,n,s){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=s,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof Qt&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ee),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Ps(new pn(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof Qt)&&this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:o,lineBreak:l,done:a}=this.cursor.next(this.skip);if(this.skip=0,a)throw new Error("Ran out of text content when drawing inline views");if(l){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=o,this.textOff=0}let s=Math.min(this.text.length-this.textOff,e),r=Math.min(s,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(Ps(new St(this.text.slice(this.textOff,this.textOff+r)),t),n),this.atCursorPos=!0,this.textOff+=r,e-=r,n=s<=r?0:t.length}}span(e,t,n,s){this.buildText(t-e,n,s),this.pos=t,this.openStart<0&&(this.openStart=s)}point(e,t,n,s,r,o){if(this.disallowBlockEffectsFor[o]&&n instanceof vi){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(n instanceof vi)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Qt(n.widget||gn.block,l,n));else{let a=Yt.create(n.widget||gn.inline,l,l?0:n.startSide),u=this.atCursorPos&&!a.isEditable&&r<=s.length&&(e<t||n.startSide>0),c=!a.isEditable&&(e<t||r>s.length||n.startSide<=0),h=this.getLine();this.pendingBuffer==2&&!u&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(s),u&&(h.append(Ps(new pn(1),s),r),r=s.length+Math.max(0,r-s.length)),h.append(Ps(a,s),r),this.atCursorPos=c,this.pendingBuffer=c?e<t||r>s.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=s.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=r)}static build(e,t,n,s,r){let o=new zn(e,t,n,r);return o.openEnd=re.spans(s,t,n,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function Ps(i,e){for(let t of e)i=new ei(t,[i],i.length);return i}class gn extends ii{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}gn.inline=new gn("span");gn.block=new gn("div");var xe=(function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i})(xe||(xe={}));const Vi=xe.LTR,Ua=xe.RTL;function Gf(i){let e=[];for(let t=0;t<i.length;t++)e.push(1<<+i[t]);return e}const zS=Gf("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),$S=Gf("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Wl=Object.create(null),Mt=[];for(let i of["()","[]","{}"]){let e=i.charCodeAt(0),t=i.charCodeAt(1);Wl[e]=t,Wl[t]=-e}function Wf(i){return i<=247?zS[i]:1424<=i&&i<=1524?2:1536<=i&&i<=1785?$S[i-1536]:1774<=i&&i<=2220?4:8192<=i&&i<=8204?256:64336<=i&&i<=65023?4:1}const HS=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class fi{get dir(){return this.level%2?Ua:Vi}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,s){let r=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==n)return o;(r<0||(s!=0?s<0?l.from<t:l.to>t:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function Uf(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++){let n=i[t],s=e[t];if(n.from!=s.from||n.to!=s.to||n.direction!=s.direction||!Uf(n.inner,s.inner))return!1}return!0}const pe=[];function GS(i,e,t,n,s){for(let r=0;r<=n.length;r++){let o=r?n[r-1].to:e,l=r<n.length?n[r].from:t,a=r?256:s;for(let u=o,c=a,h=a;u<l;u++){let d=Wf(i.charCodeAt(u));d==512?d=c:d==8&&h==4&&(d=16),pe[u]=d==4?2:d,d&7&&(h=d),c=d}for(let u=o,c=a,h=a;u<l;u++){let d=pe[u];if(d==128)u<l-1&&c==pe[u+1]&&c&24?d=pe[u]=c:pe[u]=256;else if(d==64){let p=u+1;for(;p<l&&pe[p]==64;)p++;let g=u&&c==8||p<t&&pe[p]==8?h==1?1:8:256;for(let m=u;m<p;m++)pe[m]=g;u=p-1}else d==8&&h==1&&(pe[u]=1);c=d,d&7&&(h=d)}}}function WS(i,e,t,n,s){let r=s==1?2:1;for(let o=0,l=0,a=0;o<=n.length;o++){let u=o?n[o-1].to:e,c=o<n.length?n[o].from:t;for(let h=u,d,p,g;h<c;h++)if(p=Wl[d=i.charCodeAt(h)])if(p<0){for(let m=l-3;m>=0;m-=3)if(Mt[m+1]==-p){let x=Mt[m+2],y=x&2?s:x&4?x&1?r:s:0;y&&(pe[h]=pe[Mt[m]]=y),l=m;break}}else{if(Mt.length==189)break;Mt[l++]=h,Mt[l++]=d,Mt[l++]=a}else if((g=pe[h])==2||g==1){let m=g==s;a=m?0:1;for(let x=l-3;x>=0;x-=3){let y=Mt[x+2];if(y&2)break;if(m)Mt[x+2]|=2;else{if(y&4)break;Mt[x+2]|=4}}}}}function US(i,e,t,n){for(let s=0,r=n;s<=t.length;s++){let o=s?t[s-1].to:i,l=s<t.length?t[s].from:e;for(let a=o;a<l;){let u=pe[a];if(u==256){let c=a+1;for(;;)if(c==l){if(s==t.length)break;c=t[s++].to,l=s<t.length?t[s].from:e}else if(pe[c]==256)c++;else break;let h=r==1,d=(c<e?pe[c]:n)==1,p=h==d?h?1:2:n;for(let g=c,m=s,x=m?t[m-1].to:i;g>a;)g==x&&(g=t[--m].from,x=m?t[m-1].to:i),pe[--g]=p;a=c}else r=u,a++}}}function Ul(i,e,t,n,s,r,o){let l=n%2?2:1;if(n%2==s%2)for(let a=e,u=0;a<t;){let c=!0,h=!1;if(u==r.length||a<r[u].from){let m=pe[a];m!=l&&(c=!1,h=m==16)}let d=!c&&l==1?[]:null,p=c?n:n+1,g=a;e:for(;;)if(u<r.length&&g==r[u].from){if(h)break e;let m=r[u];if(!c)for(let x=m.to,y=u+1;;){if(x==t)break e;if(y<r.length&&r[y].from==x)x=r[y++].to;else{if(pe[x]==l)break e;break}}if(u++,d)d.push(m);else{m.from>a&&o.push(new fi(a,m.from,p));let x=m.direction==Vi!=!(p%2);ql(i,x?n+1:n,s,m.inner,m.from,m.to,o),a=m.to}g=m.to}else{if(g==t||(c?pe[g]!=l:pe[g]==l))break;g++}d?Ul(i,a,g,n+1,s,d,o):a<g&&o.push(new fi(a,g,p)),a=g}else for(let a=t,u=r.length;a>e;){let c=!0,h=!1;if(!u||a>r[u-1].to){let m=pe[a-1];m!=l&&(c=!1,h=m==16)}let d=!c&&l==1?[]:null,p=c?n:n+1,g=a;e:for(;;)if(u&&g==r[u-1].to){if(h)break e;let m=r[--u];if(!c)for(let x=m.from,y=u;;){if(x==e)break e;if(y&&r[y-1].to==x)x=r[--y].from;else{if(pe[x-1]==l)break e;break}}if(d)d.push(m);else{m.to<a&&o.push(new fi(m.to,a,p));let x=m.direction==Vi!=!(p%2);ql(i,x?n+1:n,s,m.inner,m.from,m.to,o),a=m.from}g=m.from}else{if(g==e||(c?pe[g-1]!=l:pe[g-1]==l))break;g--}d?Ul(i,g,a,n+1,s,d,o):g<a&&o.push(new fi(g,a,p)),a=g}}function ql(i,e,t,n,s,r,o){let l=e%2?2:1;GS(i,s,r,n,l),WS(i,s,r,n,l),US(s,r,n,l),Ul(i,s,r,e,t,n,o)}function qS(i,e,t){if(!i)return[new fi(0,0,e==Ua?1:0)];if(e==Vi&&!t.length&&!HS.test(i))return qf(i.length);if(t.length)for(;i.length>pe.length;)pe[pe.length]=256;let n=[],s=e==Vi?0:1;return ql(i,s,s,t,0,i.length,n),n}function qf(i){return[new fi(0,i,0)]}let Kf="";function KS(i,e,t,n,s){var r;let o=n.head-i.from,l=fi.find(e,o,(r=n.bidiLevel)!==null&&r!==void 0?r:-1,n.assoc),a=e[l],u=a.side(s,t);if(o==u){let d=l+=s?1:-1;if(d<0||d>=e.length)return null;a=e[l=d],o=a.side(!s,t),u=a.side(s,t)}let c=Le(i.text,o,a.forward(s,t));(c<a.from||c>a.to)&&(c=u),Kf=i.text.slice(Math.min(o,c),Math.max(o,c));let h=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return h&&c==u&&h.level+(s?0:1)<a.level?T.cursor(h.side(!s,t)+i.from,h.forward(s,t)?1:-1,h.level):T.cursor(c+i.from,a.forward(s,t)?-1:1,a.level)}function YS(i,e,t){for(let n=e;n<t;n++){let s=Wf(i.charCodeAt(n));if(s==1)return Vi;if(s==2||s==4)return Ua}return Vi}const Yf=$.define(),Xf=$.define(),Qf=$.define(),Jf=$.define(),Kl=$.define(),Zf=$.define(),ep=$.define(),qa=$.define(),Ka=$.define(),tp=$.define({combine:i=>i.some(e=>e)}),ip=$.define({combine:i=>i.some(e=>e)}),np=$.define();class an{constructor(e,t="nearest",n="nearest",s=5,r=5,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=s,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new an(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new an(T.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Ds=J.define({map:(i,e)=>i.map(e)}),sp=J.define();function Je(i,e,t){let n=i.facet(Jf);n.length?n[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const Kt=$.define({combine:i=>i.length?i[0]:!0});let XS=0;const Qi=$.define({combine(i){return i.filter((e,t)=>{for(let n=0;n<t;n++)if(i[n].plugin==e.plugin)return!1;return!0})}});class Ce{constructor(e,t,n,s,r){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=s,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(Qi.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Qi.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:s,provide:r,decorations:o}=t||{};return new Ce(XS++,e,n,s,l=>{let a=[];return o&&a.push(es.of(u=>{let c=u.plugin(l);return c?o(c):K.none})),r&&a.push(r(l)),a})}static fromClass(e,t){return Ce.define((n,s)=>new e(n,s),t)}}class zo{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Je(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Je(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Je(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const rp=$.define(),Ya=$.define(),es=$.define(),op=$.define(),fs=$.define(),lp=$.define();function ac(i,e){let t=i.state.facet(lp);if(!t.length)return t;let n=t.map(r=>r instanceof Function?r(i):r),s=[];return re.spans(n,e.from,e.to,{point(){},span(r,o,l,a){let u=r-e.from,c=o-e.from,h=s;for(let d=l.length-1;d>=0;d--,a--){let p=l[d].spec.bidiIsolate,g;if(p==null&&(p=YS(e.text,u,c)),a>0&&h.length&&(g=h[h.length-1]).to==u&&g.direction==p)g.to=c,h=g.inner;else{let m={from:u,to:c,direction:p,inner:[]};h.push(m),h=m.inner}}}}),s}const ap=$.define();function Xa(i){let e=0,t=0,n=0,s=0;for(let r of i.state.facet(ap)){let o=r(i);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:e,right:t,top:n,bottom:s}}const In=$.define();class pt{constructor(e,t,n,s){this.fromA=e,this.toA=t,this.fromB=n,this.toB=s}join(e){return new pt(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let s=e[t-1];if(!(s.fromA>n.toA)){if(s.toA<n.fromA)break;n=n.join(s),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(t.length==0)return e;let n=[];for(let s=0,r=0,o=0,l=0;;s++){let a=s==e.length?null:e[s],u=o-l,c=a?a.fromB:1e9;for(;r<t.length&&t[r]<c;){let h=t[r],d=t[r+1],p=Math.max(l,h),g=Math.min(c,d);if(p<=g&&new pt(p+u,g+u,p,g).addToSet(n),d>c)break;r+=2}if(!a)return n;new pt(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),o=a.toA,l=a.toB}}}class Er{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=Ae.empty(this.startState.doc.length);for(let r of n)this.changes=this.changes.compose(r.changes);let s=[];this.changes.iterChangedRanges((r,o,l,a)=>s.push(new pt(r,o,l,a))),this.changedRanges=s}static create(e,t,n){return new Er(e,t,n)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}class uc extends de{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=K.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new Ee],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new pt(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:u,toA:c})=>c<this.minWidthFrom||u>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?s=this.domChanged.newSel.head:!nC(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let r=s>-1?JS(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:u,to:c}=this.hasComposition;n=new pt(u,c,e.changes.mapPos(u,-1),e.changes.mapPos(c,1)).addToSet(n.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(z.ie||z.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=tC(o,l,e.changes);return n=pt.extendWithRanges(n,a),!(this.flags&7)&&n.length==0?!1:(this.updateInner(n,e.startState.doc.length,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:s}=this.view;s.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=z.chrome||z.ios?{node:s.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||s.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let o of this.children)o instanceof Qt&&o.widget instanceof Gl&&r.push(o.dom);s.updateGaps(r)}updateChildren(e,t,n){let s=n?n.range.addToSet(e.slice()):e,r=this.childCursor(t);for(let o=s.length-1;;o--){let l=o>=0?s[o]:null;if(!l)break;let{fromA:a,toA:u,fromB:c,toB:h}=l,d,p,g,m;if(n&&n.range.fromB<h&&n.range.toB>c){let C=zn.build(this.view.state.doc,c,n.range.fromB,this.decorations,this.dynamicDecorationMap),S=zn.build(this.view.state.doc,n.range.toB,h,this.decorations,this.dynamicDecorationMap);p=C.breakAtStart,g=C.openStart,m=S.openEnd;let E=this.compositionView(n);S.breakAtStart?E.breakAfter=1:S.content.length&&E.merge(E.length,E.length,S.content[0],!1,S.openStart,0)&&(E.breakAfter=S.content[0].breakAfter,S.content.shift()),C.content.length&&E.merge(0,0,C.content[C.content.length-1],!0,0,C.openEnd)&&C.content.pop(),d=C.content.concat(E).concat(S.content)}else({content:d,breakAtStart:p,openStart:g,openEnd:m}=zn.build(this.view.state.doc,c,h,this.decorations,this.dynamicDecorationMap));let{i:x,off:y}=r.findPos(u,1),{i:b,off:v}=r.findPos(a,-1);Bf(this,b,v,x,y,d,p,g,m)}n&&this.fixCompositionDOM(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let n of t.effects)n.is(sp)&&(this.editContextFormatting=n.value)}compositionView(e){let t=new St(e.text.nodeValue);t.flags|=8;for(let{deco:s}of e.marks)t=new ei(s,[t],t.length);let n=new Ee;return n.append(t,0),n}fixCompositionDOM(e){let t=(r,o)=>{o.flags|=8|(o.children.some(a=>a.flags&7)?1:0),this.markedForComposition.add(o);let l=de.get(r);l&&l!=o&&(l.dom=null),o.setDOM(r)},n=this.childPos(e.range.fromB,1),s=this.children[n.i];t(e.line,s);for(let r=e.marks.length-1;r>=-1;r--)n=s.childPos(n.off,1),s=s.children[n.i],t(r>=0?e.marks[r].node:e.text,s)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let n=this.view.root.activeElement,s=n==this.dom,r=!s&&!(this.view.state.facet(Kt)||this.dom.tabIndex>-1)&&tr(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(s||t||r))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(l.anchor)),u=l.empty?a:this.moveToLine(this.domAtPos(l.head));if(z.gecko&&l.empty&&!this.hasComposition&&QS(a)){let h=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(h,a.node.childNodes[a.offset]||null)),a=u=new _e(h,0),o=!0}let c=this.view.observer.selectionRange;(o||!c.focusNode||(!_n(a.node,a.offset,c.anchorNode,c.anchorOffset)||!_n(u.node,u.offset,c.focusNode,c.focusOffset))&&!this.suppressWidgetCursorChange(c,l))&&(this.view.observer.ignore(()=>{z.android&&z.chrome&&this.dom.contains(c.focusNode)&&iC(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let h=Zn(this.view.root);if(h)if(l.empty){if(z.gecko){let d=ZS(a.node,a.offset);if(d&&d!=3){let p=(d==1?Lf:Ff)(a.node,a.offset);p&&(a=new _e(p.node,p.offset))}}h.collapse(a.node,a.offset),l.bidiLevel!=null&&h.caretBidiLevel!==void 0&&(h.caretBidiLevel=l.bidiLevel)}else if(h.extend){h.collapse(a.node,a.offset);try{h.extend(u.node,u.offset)}catch{}}else{let d=document.createRange();l.anchor>l.head&&([a,u]=[u,a]),d.setEnd(u.node,u.offset),d.setStart(a.node,a.offset),h.removeAllRanges(),h.addRange(d)}r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(a,u)),this.impreciseAnchor=a.precise?null:new _e(c.anchorNode,c.anchorOffset),this.impreciseHead=u.precise?null:new _e(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&_n(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Zn(e.root),{anchorNode:s,anchorOffset:r}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let o=Ee.find(this,t.head);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),u=this.coordsAt(t.head,1);if(!a||!u||a.bottom>u.top)return;let c=this.domAtPos(t.head+t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(s,r)}moveToLine(e){let t=this.dom,n;if(e.node!=t)return e;for(let s=e.offset;!n&&s<t.childNodes.length;s++){let r=de.get(t.childNodes[s]);r instanceof Ee&&(n=r.domAtPos(0))}for(let s=e.offset-1;!n&&s>=0;s--){let r=de.get(t.childNodes[s]);r instanceof Ee&&(n=r.domAtPos(r.length))}return n?new _e(n.node,n.offset,!0):e}nearest(e){for(let t=e;t;){let n=de.get(t);if(n&&n.rootView==this)return n;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let s=this.children[t];if(n<s.length||s instanceof Ee)break;t++,n=0}return this.children[t].domAtPos(n)}coordsAt(e,t){let n=null,s=0;for(let r=this.length,o=this.children.length-1;o>=0;o--){let l=this.children[o],a=r-l.breakAfter,u=a-l.length;if(a<e)break;if(u<=e&&(u<e||l.covers(-1))&&(a>e||l.covers(1))&&(!n||l instanceof Ee&&!(n instanceof Ee&&t>=0)))n=l,s=u;else if(n&&u==e&&a==e&&l instanceof Qt&&Math.abs(t)<2){if(l.deco.startSide<0)break;o&&(n=null)}r=u}return n?n.coordsAt(e-s,t):null}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),s=this.children[t];if(!(s instanceof Ee))return null;for(;s.children.length;){let{i:l,off:a}=s.childPos(n,1);for(;;l++){if(l==s.children.length)return null;if((s=s.children[l]).length)break}n=a}if(!(s instanceof St))return null;let r=Le(s.text,n);if(r==n)return null;let o=Bi(s.dom,n,r).getClientRects();for(let l=0;l<o.length;l++){let a=o[l];if(l==o.length-1||a.top<a.bottom&&a.left<a.right)return a}return null}measureVisibleLineHeights(e){let t=[],{from:n,to:s}=e,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==xe.LTR;for(let u=0,c=0;c<this.children.length;c++){let h=this.children[c],d=u+h.length;if(d>s)break;if(u>=n){let p=h.dom.getBoundingClientRect();if(t.push(p.height),o){let g=h.dom.lastChild,m=g?fn(g):[];if(m.length){let x=m[m.length-1],y=a?x.right-p.left:p.right-x.left;y>l&&(l=y,this.minWidth=r,this.minWidthFrom=u,this.minWidthTo=d)}}}u=d+h.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?xe.RTL:xe.LTR}measureTextSize(){for(let r of this.children)if(r instanceof Ee){let o=r.measureTextSize();if(o)return o}let e=document.createElement("div"),t,n,s;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let r=fn(e.firstChild)[0];t=e.getBoundingClientRect().height,n=r?r.width/27:7,s=r?r.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:s}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new Nf(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,s=0;;s++){let r=s==t.viewports.length?null:t.viewports[s],o=r?r.from-1:this.length;if(o>n){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(K.replace({widget:new Gl(l),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!r)break;n=r.to+1}return K.set(e)}updateDeco(){let e=1,t=this.view.state.facet(es).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),n=!1,s=this.view.state.facet(op).map((r,o)=>{let l=typeof r=="function";return l&&(n=!0),l?r(this.view):r});for(s.length&&(this.dynamicDecorationMap[e++]=n,t.push(re.join(s))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}scrollIntoView(e){if(e.isSnapshot){let u=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=u.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let u of this.view.state.facet(np))try{if(u(this.view,e.range,e))return!0}catch(c){Je(this.view.state,c,"scroll handler")}let{range:t}=e,n=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),s;if(!n)return;!t.empty&&(s=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,s.left),top:Math.min(n.top,s.top),right:Math.max(n.right,s.right),bottom:Math.max(n.bottom,s.bottom)});let r=Xa(this.view),o={left:n.left-r.left,top:n.top-r.top,right:n.right+r.right,bottom:n.bottom+r.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;OS(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==xe.LTR)}lineHasWidget(e){let{i:t}=this.childCursor().findPos(e);if(t==this.children.length)return!1;let n=s=>s instanceof Yt||s.children.some(n);return n(this.children[t])}}function QS(i){return i.node.nodeType==1&&i.node.firstChild&&(i.offset==0||i.node.childNodes[i.offset-1].contentEditable=="false")&&(i.offset==i.node.childNodes.length||i.node.childNodes[i.offset].contentEditable=="false")}function up(i,e){let t=i.observer.selectionRange;if(!t.focusNode)return null;let n=Lf(t.focusNode,t.focusOffset),s=Ff(t.focusNode,t.focusOffset),r=n||s;if(s&&n&&s.node!=n.node){let l=de.get(s.node);if(!l||l instanceof St&&l.text!=s.node.nodeValue)r=s;else if(i.docView.lastCompositionAfterCursor){let a=de.get(n.node);!a||a instanceof St&&a.text!=n.node.nodeValue||(r=s)}}if(i.docView.lastCompositionAfterCursor=r!=n,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function JS(i,e,t){let n=up(i,t);if(!n)return null;let{node:s,from:r,to:o}=n,l=s.nodeValue;if(/[\n\r]/.test(l)||i.state.doc.sliceString(n.from,n.to)!=l)return null;let a=e.invertedDesc,u=new pt(a.mapPos(r),a.mapPos(o),r,o),c=[];for(let h=s.parentNode;;h=h.parentNode){let d=de.get(h);if(d instanceof ei)c.push({node:h,deco:d.mark});else{if(d instanceof Ee||h.nodeName=="DIV"&&h.parentNode==i.contentDOM)return{range:u,text:s,marks:c,line:h};if(h!=i.contentDOM)c.push({node:h,deco:new hs({inclusive:!0,attributes:VS(h),tagName:h.tagName.toLowerCase()})});else return null}}}function ZS(i,e){return i.nodeType!=1?0:(e&&i.childNodes[e-1].contentEditable=="false"?1:0)|(e<i.childNodes.length&&i.childNodes[e].contentEditable=="false"?2:0)}let eC=class{constructor(){this.changes=[]}compareRange(e,t){ir(e,t,this.changes)}comparePoint(e,t){ir(e,t,this.changes)}boundChange(e){ir(e,e,this.changes)}};function tC(i,e,t){let n=new eC;return re.compare(i,e,t,n),n.changes}function iC(i,e){for(let t=i;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function nC(i,e){let t=!1;return e&&i.iterChangedRanges((n,s)=>{n<e.to&&s>e.from&&(t=!0)}),t}function sC(i,e,t=1){let n=i.charCategorizer(e),s=i.doc.lineAt(e),r=e-s.from;if(s.length==0)return T.cursor(e);r==0?t=1:r==s.length&&(t=-1);let o=r,l=r;t<0?o=Le(s.text,r,!1):l=Le(s.text,r);let a=n(s.text.slice(o,l));for(;o>0;){let u=Le(s.text,o,!1);if(n(s.text.slice(u,o))!=a)break;o=u}for(;l<s.length;){let u=Le(s.text,l);if(n(s.text.slice(l,u))!=a)break;l=u}return T.range(o+s.from,l+s.from)}function rC(i,e){return e.left>i?e.left-i:Math.max(0,i-e.right)}function oC(i,e){return e.top>i?e.top-i:Math.max(0,i-e.bottom)}function $o(i,e){return i.top<e.bottom-1&&i.bottom>e.top+1}function cc(i,e){return e<i.top?{top:e,left:i.left,right:i.right,bottom:i.bottom}:i}function hc(i,e){return e>i.bottom?{top:i.top,left:i.left,right:i.right,bottom:e}:i}function Yl(i,e,t){let n,s,r,o,l=!1,a,u,c,h;for(let g=i.firstChild;g;g=g.nextSibling){let m=fn(g);for(let x=0;x<m.length;x++){let y=m[x];s&&$o(s,y)&&(y=cc(hc(y,s.bottom),s.top));let b=rC(e,y),v=oC(t,y);if(b==0&&v==0)return g.nodeType==3?dc(g,e,t):Yl(g,e,t);(!n||o>v||o==v&&r>b)&&(n=g,s=y,r=b,o=v,l=b?e<y.left?x>0:x<m.length-1:!0),b==0?t>y.bottom&&(!c||c.bottom<y.bottom)?(a=g,c=y):t<y.top&&(!h||h.top>y.top)&&(u=g,h=y):c&&$o(c,y)?c=hc(c,y.bottom):h&&$o(h,y)&&(h=cc(h,y.top))}}if(c&&c.bottom>=t?(n=a,s=c):h&&h.top<=t&&(n=u,s=h),!n)return{node:i,offset:0};let d=Math.max(s.left,Math.min(s.right,e));if(n.nodeType==3)return dc(n,d,t);if(l&&n.contentEditable!="false")return Yl(n,d,t);let p=Array.prototype.indexOf.call(i.childNodes,n)+(e>=(s.left+s.right)/2?1:0);return{node:i,offset:p}}function dc(i,e,t){let n=i.nodeValue.length,s=-1,r=1e9,o=0;for(let l=0;l<n;l++){let a=Bi(i,l,l+1).getClientRects();for(let u=0;u<a.length;u++){let c=a[u];if(c.top==c.bottom)continue;o||(o=e-c.left);let h=(c.top>t?c.top-t:t-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&h<r){let d=e>=(c.left+c.right)/2,p=d;if((z.chrome||z.gecko)&&Bi(i,l).getBoundingClientRect().left==c.right&&(p=!d),h<=0)return{node:i,offset:l+(p?1:0)};s=l+(p?1:0),r=h}}}return{node:i,offset:s>-1?s:o>0?i.nodeValue.length:0}}function cp(i,e,t,n=-1){var s,r;let o=i.contentDOM.getBoundingClientRect(),l=o.top+i.viewState.paddingTop,a,{docHeight:u}=i.viewState,{x:c,y:h}=e,d=h-l;if(d<0)return 0;if(d>u)return i.state.doc.length;for(let C=i.viewState.heightOracle.textHeight/2,S=!1;a=i.elementAtHeight(d),a.type!=qe.Text;)for(;d=n>0?a.bottom+C:a.top-C,!(d>=0&&d<=u);){if(S)return t?null:0;S=!0,n=-n}h=l+d;let p=a.from;if(p<i.viewport.from)return i.viewport.from==0?0:t?null:fc(i,o,a,c,h);if(p>i.viewport.to)return i.viewport.to==i.state.doc.length?i.state.doc.length:t?null:fc(i,o,a,c,h);let g=i.dom.ownerDocument,m=i.root.elementFromPoint?i.root:g,x=m.elementFromPoint(c,h);x&&!i.contentDOM.contains(x)&&(x=null),x||(c=Math.max(o.left+1,Math.min(o.right-1,c)),x=m.elementFromPoint(c,h),x&&!i.contentDOM.contains(x)&&(x=null));let y,b=-1;if(x&&((s=i.docView.nearest(x))===null||s===void 0?void 0:s.isEditable)!=!1){if(g.caretPositionFromPoint){let C=g.caretPositionFromPoint(c,h);C&&({offsetNode:y,offset:b}=C)}else if(g.caretRangeFromPoint){let C=g.caretRangeFromPoint(c,h);C&&({startContainer:y,startOffset:b}=C)}y&&(!i.contentDOM.contains(y)||z.safari&&lC(y,b,c)||z.chrome&&aC(y,b,c))&&(y=void 0),y&&(b=Math.min(Vt(y),b))}if(!y||!i.docView.dom.contains(y)){let C=Ee.find(i.docView,p);if(!C)return d>a.top+a.height/2?a.to:a.from;({node:y,offset:b}=Yl(C.dom,c,h))}let v=i.docView.nearest(y);if(!v)return null;if(v.isWidget&&((r=v.dom)===null||r===void 0?void 0:r.nodeType)==1){let C=v.dom.getBoundingClientRect();return e.y<C.top||e.y<=C.bottom&&e.x<=(C.left+C.right)/2?v.posAtStart:v.posAtEnd}else return v.localPosFromDOM(y,b)+v.posAtStart}function fc(i,e,t,n,s){let r=Math.round((n-e.left)*i.defaultCharacterWidth);if(i.lineWrapping&&t.height>i.defaultLineHeight*1.5){let l=i.viewState.heightOracle.textHeight,a=Math.floor((s-t.top-(i.defaultLineHeight-l)*.5)/l);r+=a*i.viewState.heightOracle.lineLength}let o=i.state.sliceDoc(t.from,t.to);return t.from+Dl(o,r,i.state.tabSize)}function hp(i,e,t){let n,s=i;if(i.nodeType!=3||e!=(n=i.nodeValue.length))return!1;for(;;){let r=s.nextSibling;if(r){if(r.nodeName=="BR")break;return!1}else{let o=s.parentNode;if(!o||o.nodeName=="DIV")break;s=o}}return Bi(i,n-1,n).getBoundingClientRect().right>t}function lC(i,e,t){return hp(i,e,t)}function aC(i,e,t){if(e!=0)return hp(i,e,t);for(let s=i;;){let r=s.parentNode;if(!r||r.nodeType!=1||r.firstChild!=s)return!1;if(r.classList.contains("cm-line"))break;s=r}let n=i.nodeType==1?i.getBoundingClientRect():Bi(i,0,Math.max(i.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function Xl(i,e,t){let n=i.lineBlockAt(e);if(Array.isArray(n.type)){let s;for(let r of n.type){if(r.from>e)break;if(!(r.to<e)){if(r.from<e&&r.to>e)return r;(!s||r.type==qe.Text&&(s.type!=r.type||(t<0?r.from<e:r.to>e)))&&(s=r)}}return s||n}return n}function uC(i,e,t,n){let s=Xl(i,e.head,e.assoc||-1),r=!n||s.type!=qe.Text||!(i.lineWrapping||s.widgetLineBreaks)?null:i.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(r){let o=i.dom.getBoundingClientRect(),l=i.textDirectionAt(s.from),a=i.posAtCoords({x:t==(l==xe.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return T.cursor(a,t?-1:1)}return T.cursor(t?s.to:s.from,t?-1:1)}function pc(i,e,t,n){let s=i.state.doc.lineAt(e.head),r=i.bidiSpans(s),o=i.textDirectionAt(s.from);for(let l=e,a=null;;){let u=KS(s,r,o,l,t),c=Kf;if(!u){if(s.number==(t?i.state.doc.lines:1))return l;c=`
30
+ `,s=i.state.doc.line(s.number+(t?1:-1)),r=i.bidiSpans(s),u=i.visualLineSide(s,!t)}if(a){if(!a(c))return l}else{if(!n)return u;a=n(c)}l=u}}function cC(i,e,t){let n=i.state.charCategorizer(e),s=n(t);return r=>{let o=n(r);return s==ye.Space&&(s=o),s==o}}function hC(i,e,t,n){let s=e.head,r=t?1:-1;if(s==(t?i.state.doc.length:0))return T.cursor(s,e.assoc);let o=e.goalColumn,l,a=i.contentDOM.getBoundingClientRect(),u=i.coordsAtPos(s,e.assoc||-1),c=i.documentTop;if(u)o==null&&(o=u.left-a.left),l=r<0?u.top:u.bottom;else{let p=i.viewState.lineBlockAt(s);o==null&&(o=Math.min(a.right-a.left,i.defaultCharacterWidth*(s-p.from))),l=(r<0?p.top:p.bottom)+c}let h=a.left+o,d=n??i.viewState.heightOracle.textHeight>>1;for(let p=0;;p+=10){let g=l+(d+p)*r,m=cp(i,{x:h,y:g},!1,r);if(g<a.top||g>a.bottom||(r<0?m<s:m>s)){let x=i.docView.coordsForChar(m),y=!x||g<x.top?-1:1;return T.cursor(m,y,void 0,o)}}}function $n(i,e,t){for(;;){let n=0;for(let s of i)s.between(e-1,e+1,(r,o,l)=>{if(e>r&&e<o){let a=n||t||(e-r<o-e?-1:1);e=a<0?r:o,n=a}});if(!n)return e}}function dp(i,e){let t=null;for(let n=0;n<e.ranges.length;n++){let s=e.ranges[n],r=null;if(s.empty){let o=$n(i,s.from,0);o!=s.from&&(r=T.cursor(o,-1))}else{let o=$n(i,s.from,-1),l=$n(i,s.to,1);(o!=s.from||l!=s.to)&&(r=T.range(s.from==s.anchor?o:l,s.from==s.head?o:l))}r&&(t||(t=e.ranges.slice()),t[n]=r)}return t?T.create(t,e.mainIndex):e}function Ho(i,e,t){let n=$n(i.state.facet(fs).map(s=>s(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:T.cursor(n,n<t.from?1:-1)}const jn="￿";class dC{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(se.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=jn}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let s=e;;){this.findPointBefore(n,s);let r=this.text.length;this.readNode(s);let o=s.nextSibling;if(o==t)break;let l=de.get(s),a=de.get(o);(l&&a?l.breakAfter:(l?l.breakAfter:Cr(s))||Cr(o)&&(s.nodeName!="BR"||s.cmIgnore)&&this.text.length>r)&&!pC(o,t)&&this.lineBreak(),s=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(l=s.exec(t))&&(r=l.index,o=l[0].length),this.append(t.slice(n,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);n=r+o}}readNode(e){if(e.cmIgnore)return;let t=de.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let s=n.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(fC(e,n.node,n.offset)?t:0))}}function fC(i,e,t){for(;;){if(!e||t<Vt(e))return!1;if(e==i)return!0;t=Ni(e)+1,e=e.parentNode}}function pC(i,e){let t;for(;!(i==e||!i);i=i.nextSibling){let n=de.get(i);if(!(n!=null&&n.isWidget||i.cmIgnore))return!1;n&&(t||(t=[])).push(n)}if(t)for(let n of t){let s=n.overrideDOMText;if(s!=null&&s.length)return!1}return!0}class gc{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class gC{constructor(e,t,n,s){this.typeOver=s,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let l=r||o?[]:xC(e),a=new dC(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=yC(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!zl(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),u=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!zl(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),c=e.viewport;if((z.ios||z.chrome)&&e.state.selection.main.empty&&a!=u&&(c.from>0||c.to<e.state.doc.length)){let h=Math.min(a,u),d=Math.max(a,u),p=c.from-h,g=c.to-d;(p==0||p==1||h==0)&&(g==0||g==-1||d==e.state.doc.length)&&(a=0,u=e.state.doc.length)}this.newSel=T.single(u,a)}}}function fp(i,e){let t,{newSel:n}=e,s=i.state.selection.main,r=i.inputState.lastKeyTime>Date.now()-100?i.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=s.from,u=null;(r===8||z.android&&e.text.length<l-o)&&(a=s.to,u="end");let c=pp(i.state.doc.sliceString(o,l,jn),e.text,a-o,u);c&&(z.chrome&&r==13&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==jn+jn&&c.toB--,t={from:o+c.from,to:o+c.toA,insert:oe.of(e.text.slice(c.from,c.toB).split(jn))})}else n&&(!i.hasFocus&&i.state.facet(Kt)||n.main.eq(s))&&(n=null);if(!t&&!n)return!1;if(!t&&e.typeOver&&!s.empty&&n&&n.main.empty?t={from:s.from,to:s.to,insert:i.state.doc.slice(s.from,s.to)}:(z.mac||z.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())&&i.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=T.single(n.main.anchor-1,n.main.head-1)),t={from:t.from,to:t.to,insert:oe.of([t.insert.toString().replace("."," ")])}):t&&t.from>=s.from&&t.to<=s.to&&(t.from!=s.from||t.to!=s.to)&&s.to-s.from-(t.to-t.from)<=4?t={from:s.from,to:s.to,insert:i.state.doc.slice(s.from,t.from).append(t.insert).append(i.state.doc.slice(t.to,s.to))}:i.state.doc.lineAt(s.from).to<s.to&&i.docView.lineHasWidget(s.to)&&i.inputState.insertingTextAt>Date.now()-50?t={from:s.from,to:s.to,insert:i.state.toText(i.inputState.insertingText)}:z.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==`
31
+ `&&i.lineWrapping&&(n&&(n=T.single(n.main.anchor-1,n.main.head-1)),t={from:s.from,to:s.to,insert:oe.of([" "])}),t)return Qa(i,t,n,r);if(n&&!n.main.eq(s)){let o=!1,l="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(o=!0),l=i.inputState.lastSelectionOrigin,l=="select.pointer"&&(n=dp(i.state.facet(fs).map(a=>a(i)),n))),i.dispatch({selection:n,scrollIntoView:o,userEvent:l}),!0}else return!1}function Qa(i,e,t,n=-1){if(z.ios&&i.inputState.flushIOSKey(e))return!0;let s=i.state.selection.main;if(z.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&i.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&ln(i.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||n==8&&e.insert.length<e.to-e.from&&e.to>s.head)&&ln(i.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&ln(i.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let o,l=()=>o||(o=mC(i,e,t));return i.state.facet(Zf).some(a=>a(i,e.from,e.to,r,l))||i.dispatch(l()),!0}function mC(i,e,t){let n,s=i.state,r=s.selection.main,o=-1;if(e.from==e.to&&e.from<r.from||e.from>r.to){let a=e.from<r.from?-1:1,u=a<0?r.from:r.to,c=$n(s.facet(fs).map(h=>h(i)),u,a);e.from==c&&(o=c)}if(o>-1)n={changes:e,selection:T.cursor(e.from+e.insert.length,-1)};else if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&i.inputState.composing<0){let a=r.from<e.from?s.sliceDoc(r.from,e.from):"",u=r.to>e.to?s.sliceDoc(e.to,r.to):"";n=s.replaceSelection(i.state.toText(a+e.insert.sliceString(0,void 0,i.state.lineBreak)+u))}else{let a=s.changes(e),u=t&&t.main.to<=a.newLength?t.main:void 0;if(s.selection.ranges.length>1&&i.inputState.composing>=0&&e.to<=r.to+10&&e.to>=r.to-10){let c=i.state.sliceDoc(e.from,e.to),h,d=t&&up(i,t.main.head);if(d){let m=e.insert.length-(e.to-e.from);h={from:d.from,to:d.to-m}}else h=i.state.doc.lineAt(r.head);let p=r.to-e.to,g=r.to-r.from;n=s.changeByRange(m=>{if(m.from==r.from&&m.to==r.to)return{changes:a,range:u||m.map(a)};let x=m.to-p,y=x-c.length;if(m.to-m.from!=g||i.state.sliceDoc(y,x)!=c||m.to>=h.from&&m.from<=h.to)return{range:m};let b=s.changes({from:y,to:x,insert:e.insert}),v=m.to-r.to;return{changes:b,range:u?T.range(Math.max(0,u.anchor+v),Math.max(0,u.head+v)):m.map(b)}})}else n={changes:a,selection:u&&s.selection.replaceRange(u)}}let l="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,l+=".compose",i.inputState.compositionFirstChange&&(l+=".start",i.inputState.compositionFirstChange=!1)),s.update(n,{userEvent:l,scrollIntoView:!0})}function pp(i,e,t,n){let s=Math.min(i.length,e.length),r=0;for(;r<s&&i.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&i.length==e.length)return null;let o=i.length,l=e.length;for(;o>0&&l>0&&i.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(n=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o<r&&i.length<e.length){let a=t<=r&&t>=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l<r){let a=t<=r&&t>=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function xC(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:s,focusOffset:r}=i.observer.selectionRange;return t&&(e.push(new gc(t,n)),(s!=t||r!=n)&&e.push(new gc(s,r))),e}function yC(i,e){if(i.length==0)return null;let t=i[0].pos,n=i.length==2?i[1].pos:t;return t>-1&&n>-1?T.single(t+e,n+e):null}class bC{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,z.safari&&e.contentDOM.addEventListener("input",()=>null),z.gecko&&LC(e.contentDOM.ownerDocument)}handleEvent(e){!AC(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let s of n.observers)s(this.view,t);for(let s of n.handlers){if(t.defaultPrevented)break;if(s(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=vC(e),n=this.handlers,s=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,l=n[r];l&&o!=!l.handlers.length&&(s.removeEventListener(r,this.handleEvent),l=null),l||s.addEventListener(r,this.handleEvent,{passive:o})}for(let r in n)r!="scroll"&&!t[r]&&s.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&mp.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),z.android&&z.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return z.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=gp.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||SC.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,ln(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:z.safari&&!z.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function mc(i,e){return(t,n)=>{try{return e.call(i,n,t)}catch(s){Je(t.state,s)}}}function vC(i){let e=Object.create(null);function t(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of i){let s=n.spec,r=s&&s.plugin.domEventHandlers,o=s&&s.plugin.domEventObservers;if(r)for(let l in r){let a=r[l];a&&t(l).handlers.push(mc(n.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(mc(n.value,a))}}for(let n in Ct)t(n).handlers.push(Ct[n]);for(let n in gt)t(n).observers.push(gt[n]);return e}const gp=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],SC="dthko",mp=[16,17,18,20,91,92,224,225],Ls=6;function Fs(i){return Math.max(0,i)*.7+8}function CC(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}class wC{constructor(e,t,n,s){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=IS(e.contentDOM),this.atoms=e.state.facet(fs).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(se.allowMultipleSelections)&&EC(e,t),this.dragging=kC(e,t)&&bp(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&CC(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,s=0,r=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Xa(this.view);e.clientX-a.left<=s+Ls?t=-Fs(s-e.clientX):e.clientX+a.right>=o-Ls&&(t=Fs(e.clientX-o)),e.clientY-a.top<=r+Ls?n=-Fs(r-e.clientY):e.clientY+a.bottom>=l-Ls&&(n=Fs(e.clientY-l)),this.setScrollSpeed(t,n)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=dp(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function EC(i,e){let t=i.state.facet(Yf);return t.length?t[0](e):z.mac?e.metaKey:e.ctrlKey}function RC(i,e){let t=i.state.facet(Xf);return t.length?t[0](e):z.mac?!e.altKey:!e.ctrlKey}function kC(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let n=Zn(i.root);if(!n||n.rangeCount==0)return!0;let s=n.getRangeAt(0).getClientRects();for(let r=0;r<s.length;r++){let o=s[r];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function AC(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=i.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=de.get(t))&&n.ignoreEvent(e))return!1;return!0}const Ct=Object.create(null),gt=Object.create(null),xp=z.ie&&z.ie_version<15||z.ios&&z.webkit_version<604;function TC(i){let e=i.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{i.focus(),t.remove(),yp(i,t.value)},50)}function to(i,e,t){for(let n of i.facet(e))t=n(t,i);return t}function yp(i,e){e=to(i.state,qa,e);let{state:t}=i,n,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(Ql!=null&&t.selection.ranges.every(a=>a.empty)&&Ql==r.toString()){let a=-1;n=t.changeByRange(u=>{let c=t.doc.lineAt(u.from);if(c.from==a)return{range:u};a=c.from;let h=t.toText((o?r.line(s++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:h},range:T.cursor(u.from+h.length)}})}else o?n=t.changeByRange(a=>{let u=r.line(s++);return{changes:{from:a.from,to:a.to,insert:u.text},range:T.cursor(a.from+u.length)}}):n=t.replaceSelection(r);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}gt.scroll=i=>{i.inputState.lastScrollTop=i.scrollDOM.scrollTop,i.inputState.lastScrollLeft=i.scrollDOM.scrollLeft};Ct.keydown=(i,e)=>(i.inputState.setSelectionOrigin("select"),e.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);gt.touchstart=(i,e)=>{i.inputState.lastTouchTime=Date.now(),i.inputState.setSelectionOrigin("select.pointer")};gt.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};Ct.mousedown=(i,e)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let n of i.state.facet(Qf))if(t=n(i,e),t)break;if(!t&&e.button==0&&(t=IC(i,e)),t){let n=!i.hasFocus;i.inputState.startMouseSelection(new wC(i,e,t,n)),n&&i.observer.ignore(()=>{jf(i.contentDOM);let r=i.root.activeElement;r&&!r.contains(i.contentDOM)&&r.blur()});let s=i.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else i.inputState.setSelectionOrigin("select.pointer");return!1};function xc(i,e,t,n){if(n==1)return T.cursor(e,t);if(n==2)return sC(i.state,e,t);{let s=Ee.find(i.docView,e),r=i.state.doc.lineAt(s?s.posAtEnd:e),o=s?s.posAtStart:r.from,l=s?s.posAtEnd:r.to;return l<i.state.doc.length&&l==r.to&&l++,T.range(o,l)}}let yc=(i,e,t)=>e>=t.top&&e<=t.bottom&&i>=t.left&&i<=t.right;function MC(i,e,t,n){let s=Ee.find(i.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(r==0)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&yc(t,n,o))return-1;let l=s.coordsAt(r,1);return l&&yc(t,n,l)?1:o&&o.bottom>=n?-1:1}function bc(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:MC(i,t,e.clientX,e.clientY)}}const OC=z.ie&&z.ie_version<=11;let vc=null,Sc=0,Cc=0;function bp(i){if(!OC)return i.detail;let e=vc,t=Cc;return vc=i,Cc=Date.now(),Sc=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(Sc+1)%3:1}function IC(i,e){let t=bc(i,e),n=bp(e),s=i.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),s=s.map(r.changes))},get(r,o,l){let a=bc(i,r),u,c=xc(i,a.pos,a.bias,n);if(t.pos!=a.pos&&!o){let h=xc(i,t.pos,t.bias,n),d=Math.min(h.from,c.from),p=Math.max(h.to,c.to);c=d<c.from?T.range(d,p):T.range(p,d)}return o?s.replaceRange(s.main.extend(c.from,c.to)):l&&n==1&&s.ranges.length>1&&(u=jC(s,a.pos))?u:l?s.addRange(c):T.create([c])}}}function jC(i,e){for(let t=0;t<i.ranges.length;t++){let{from:n,to:s}=i.ranges[t];if(n<=e&&s>=e)return T.create(i.ranges.slice(0,t).concat(i.ranges.slice(t+1)),i.mainIndex==t?0:i.mainIndex-(i.mainIndex>t?1:0))}return null}Ct.dragstart=(i,e)=>{let{selection:{main:t}}=i.state;if(e.target.draggable){let s=i.docView.nearest(e.target);if(s&&s.isWidget){let r=s.posAtStart,o=r+s.length;(r>=t.to||o<=t.from)&&(t=T.range(r,o))}}let{inputState:n}=i;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",to(i.state,Ka,i.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Ct.dragend=i=>(i.inputState.draggedContent=null,!1);function wc(i,e,t,n){if(t=to(i.state,qa,t),!t)return;let s=i.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=i.inputState,o=n&&r&&RC(i,e)?{from:r.from,to:r.to}:null,l={from:s,insert:t},a=i.state.changes(o?[o,l]:l);i.focus(),i.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),i.inputState.draggedContent=null}Ct.drop=(i,e)=>{if(!e.dataTransfer)return!1;if(i.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let n=Array(t.length),s=0,r=()=>{++s==t.length&&wc(i,e,n.filter(o=>o!=null).join(i.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=r,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(n[o]=l.result),r()},l.readAsText(t[o])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return wc(i,e,n,!0),!0}return!1};Ct.paste=(i,e)=>{if(i.state.readOnly)return!0;i.observer.flush();let t=xp?null:e.clipboardData;return t?(yp(i,t.getData("text/plain")||t.getData("text/uri-list")),!0):(TC(i),!1)};function PC(i,e){let t=i.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),i.focus()},50)}function DC(i){let e=[],t=[],n=!1;for(let s of i.selection.ranges)s.empty||(e.push(i.sliceDoc(s.from,s.to)),t.push(s));if(!e.length){let s=-1;for(let{from:r}of i.selection.ranges){let o=i.doc.lineAt(r);o.number>s&&(e.push(o.text),t.push({from:o.from,to:Math.min(i.doc.length,o.to+1)})),s=o.number}n=!0}return{text:to(i,Ka,e.join(i.lineBreak)),ranges:t,linewise:n}}let Ql=null;Ct.copy=Ct.cut=(i,e)=>{let{text:t,ranges:n,linewise:s}=DC(i.state);if(!t&&!s)return!1;Ql=s?t:null,e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=xp?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(PC(i,t),!1)};const vp=$t.define();function Sp(i,e){let t=[];for(let n of i.facet(ep)){let s=n(i,e);s&&t.push(s)}return t.length?i.update({effects:t,annotations:vp.of(!0)}):null}function Cp(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=Sp(i.state,e);t?i.dispatch(t):i.update([])}},10)}gt.focus=i=>{i.inputState.lastFocusTime=Date.now(),!i.scrollDOM.scrollTop&&(i.inputState.lastScrollTop||i.inputState.lastScrollLeft)&&(i.scrollDOM.scrollTop=i.inputState.lastScrollTop,i.scrollDOM.scrollLeft=i.inputState.lastScrollLeft),Cp(i)};gt.blur=i=>{i.observer.clearSelectionRange(),Cp(i)};gt.compositionstart=gt.compositionupdate=i=>{i.observer.editContext||(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0))};gt.compositionend=i=>{i.observer.editContext||(i.inputState.composing=-1,i.inputState.compositionEndedAt=Date.now(),i.inputState.compositionPendingKey=!0,i.inputState.compositionPendingChange=i.observer.pendingRecords().length>0,i.inputState.compositionFirstChange=null,z.chrome&&z.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50))};gt.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};Ct.beforeinput=(i,e)=>{var t,n;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(i.inputState.insertingText=e.data,i.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&i.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let l=o[0],a=i.posAtDOM(l.startContainer,l.startOffset),u=i.posAtDOM(l.endContainer,l.endOffset);return Qa(i,{from:a,to:u,insert:i.state.toText(r)},null),!0}}let s;if(z.chrome&&z.android&&(s=gp.find(r=>r.inputType==e.inputType))&&(i.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let r=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}return z.ios&&e.inputType=="deleteContentForward"&&i.observer.flushSoon(),z.safari&&e.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>gt.compositionend(i,e),20),!1};const Ec=new Set;function LC(i){Ec.has(i)||(Ec.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}const Rc=["pre-wrap","normal","pre-line","break-spaces"];let mn=!1;function kc(){mn=!1}class FC{constructor(e){this.lineWrapping=e,this.doc=oe.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Rc.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let s=e[n];s<0?n++:this.heightSamples[Math.floor(s*10)]||(t=!0,this.heightSamples[Math.floor(s*10)]=!0)}return t}refresh(e,t,n,s,r,o){let l=Rc.indexOf(e)>-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=n,this.textHeight=s,this.lineLength=r,a){this.heightSamples={};for(let u=0;u<o.length;u++){let c=o[u];c<0?u++:this.heightSamples[Math.floor(c*10)]=!0}}return a}}class NC{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Dt{constructor(e,t,n,s,r){this.from=e,this.length=t,this.top=n,this.height=s,this._content=r}get type(){return typeof this._content=="number"?qe.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof vi?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Dt(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var me=(function(i){return i[i.ByPos=0]="ByPos",i[i.ByHeight=1]="ByHeight",i[i.ByPosNoHeight=2]="ByPosNoHeight",i})(me||(me={}));const nr=.001;class Ke{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>nr&&(mn=!0),this.height=e)}replace(e,t,n){return Ke.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,s){let r=this,o=n.doc;for(let l=s.length-1;l>=0;l--){let{fromA:a,toA:u,fromB:c,toB:h}=s[l],d=r.lineAt(a,me.ByPosNoHeight,n.setDoc(t),0,0),p=d.to>=u?d:r.lineAt(u,me.ByPosNoHeight,n,0,0);for(h+=p.to-u,u=p.to;l>0&&d.from<=s[l-1].toA;)a=s[l-1].fromA,c=s[l-1].fromB,l--,a<d.from&&(d=r.lineAt(a,me.ByPosNoHeight,n,0,0));c+=d.from-a,a=d.from;let g=Ja.build(n.setDoc(o),e,c,h);r=Rr(r,r.replace(a,u,g))}return r.updateHeight(n,0)}static empty(){return new ot(0,0)}static of(e){if(e.length==1)return e[0];let t=0,n=e.length,s=0,r=0;for(;;)if(t==n)if(s>r*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),n+=1+l.break,s-=l.size}else if(r>s*2){let l=e[n];l.break?e.splice(n,1,l.left,null,l.right):e.splice(n,1,l.left,l.right),n+=2+l.break,r-=l.size}else break;else if(s<r){let l=e[t++];l&&(s+=l.size)}else{let l=e[--n];l&&(r+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,n++),new BC(Ke.of(e.slice(0,t)),o,Ke.of(e.slice(n)))}}function Rr(i,e){return i==e?i:(i.constructor!=e.constructor&&(mn=!0),e)}Ke.prototype.size=1;class wp extends Ke{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,s){return new Dt(s,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,s,r){return this.blockAt(0,n,s,r)}forEachLine(e,t,n,s,r,o){e<=r+this.length&&t>=r&&o(this.blockAt(0,n,s,r))}updateHeight(e,t=0,n=!1,s){return s&&s.from<=t&&s.more&&this.setHeight(s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ot extends wp{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,s){return new Dt(s,this.length,n,this.height,this.breaks)}replace(e,t,n){let s=n[0];return n.length==1&&(s instanceof ot||s instanceof Pe&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof Pe?s=new ot(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):Ke.of(n)}updateHeight(e,t=0,n=!1,s){return s&&s.from<=t&&s.more?this.setHeight(s.heights[s.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Pe extends Ke{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,s=e.doc.lineAt(t+this.length).number,r=s-n+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:n,lastLine:s,perLine:o,perChar:l}}blockAt(e,t,n,s){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,s);if(t.lineWrapping){let u=s+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),c=t.doc.lineAt(u),h=l+c.length*a,d=Math.max(n,e-h/2);return new Dt(c.from,c.length,d,h,0)}else{let u=Math.max(0,Math.min(o-r,Math.floor((e-n)/l))),{from:c,length:h}=t.doc.line(r+u);return new Dt(c,h,n+l*u,l,0)}}lineAt(e,t,n,s,r){if(t==me.ByHeight)return this.blockAt(e,n,s,r);if(t==me.ByPosNoHeight){let{from:p,to:g}=n.doc.lineAt(e);return new Dt(p,g-p,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(n,r),u=n.doc.lineAt(e),c=l+u.length*a,h=u.number-o,d=s+l*h+a*(u.from-r-h);return new Dt(u.from,u.length,Math.max(s,Math.min(d,s+this.height-c)),c,0)}forEachLine(e,t,n,s,r,o){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:l,perLine:a,perChar:u}=this.heightMetrics(n,r);for(let c=e,h=s;c<=t;){let d=n.doc.lineAt(c);if(c==e){let g=d.number-l;h+=a*g+u*(e-r-g)}let p=a+u*d.length;o(new Dt(d.from,d.length,h,p,0)),h+=p,c=d.to+1}}replace(e,t,n){let s=this.length-t;if(s>0){let r=n[n.length-1];r instanceof Pe?n[n.length-1]=new Pe(r.length+s):n.push(null,new Pe(s-1))}if(e>0){let r=n[0];r instanceof Pe?n[0]=new Pe(e+r.length):n.unshift(new Pe(e-1),null)}return Ke.of(n)}decomposeLeft(e,t){t.push(new Pe(e-1),null)}decomposeRight(e,t){t.push(null,new Pe(this.length-e-1))}updateHeight(e,t=0,n=!1,s){let r=t+this.length;if(s&&s.from<=t+this.length&&s.more){let o=[],l=Math.max(t,s.from),a=-1;for(s.from>t&&o.push(new Pe(s.from-t-1).updateHeight(e,t));l<=r&&s.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let h=s.heights[s.index++];a==-1?a=h:Math.abs(h-a)>=nr&&(a=-2);let d=new ot(c,h);d.outdated=!1,o.push(d),l+=c+1}l<=r&&o.push(null,new Pe(r-l).updateHeight(e,l));let u=Ke.of(o);return(a<0||Math.abs(u.height-this.height)>=nr||Math.abs(a-this.heightMetrics(e,t).perLine)>=nr)&&(mn=!0),Rr(this,u)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class BC extends Ke{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,s){let r=n+this.left.height;return e<r?this.left.blockAt(e,t,n,s):this.right.blockAt(e,t,r,s+this.left.length+this.break)}lineAt(e,t,n,s,r){let o=s+this.left.height,l=r+this.left.length+this.break,a=t==me.ByHeight?e<o:e<l,u=a?this.left.lineAt(e,t,n,s,r):this.right.lineAt(e,t,n,o,l);if(this.break||(a?u.to<l:u.from>l))return u;let c=t==me.ByPosNoHeight?me.ByPosNoHeight:me.ByPos;return a?u.join(this.right.lineAt(l,c,n,o,l)):this.left.lineAt(l,c,n,s,r).join(u)}forEachLine(e,t,n,s,r,o){let l=s+this.left.height,a=r+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,s,r,o),t>=a&&this.right.forEachLine(e,t,n,l,a,o);else{let u=this.lineAt(a,me.ByPos,n,s,r);e<u.from&&this.left.forEachLine(e,u.from-1,n,s,r,o),u.to>=e&&u.from<=t&&o(u),t>u.to&&this.right.forEachLine(u.to+1,t,n,l,a,o)}}replace(e,t,n){let s=this.left.length+this.break;if(t<s)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-s,t-s,n));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of n)r.push(l);if(e>0&&Ac(r,o-1),t<this.length){let l=r.length;this.decomposeRight(t,r),Ac(r,l)}return Ke.of(r)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,s=n+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<s&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Ke.of(this.break?[e,null,t]:[e,t]):(this.left=Rr(this.left,e),this.right=Rr(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,s){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return s&&s.from<=t+r.length&&s.more?a=r=r.updateHeight(e,t,n,s):r.updateHeight(e,t,n),s&&s.from<=l+o.length&&s.more?a=o=o.updateHeight(e,l,n,s):o.updateHeight(e,l,n),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Ac(i,e){let t,n;i[e]==null&&(t=i[e-1])instanceof Pe&&(n=i[e+1])instanceof Pe&&i.splice(e-1,3,new Pe(t.length+1+n.length))}const VC=5;class Ja{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof ot?s.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new ot(n-this.pos,-1)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let s=n.widget?n.widget.estimatedHeight:0,r=n.widget?n.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new wp(o,s,n)):(o||r||s>=VC)&&this.addLineDeco(s,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new ot(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new Pe(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ot)return e;let t=new ot(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let s=this.ensureLine();s.length+=n,s.collapsed+=n,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof ot)&&!this.isCovered?this.nodes.push(new ot(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let s of this.nodes)s instanceof ot&&s.updateHeight(this.oracle,n),n+=s?s.length:1;return this.nodes}static build(e,t,n,s){let r=new Ja(n,e);return re.spans(t,n,s,r,0),r.finish(n)}}function _C(i,e,t){let n=new zC;return re.compare(i,e,t,n,0),n.changes}class zC{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,s){(e<t||n&&n.heightRelevant||s&&s.heightRelevant)&&ir(e,t,this.changes,5)}}function $C(i,e){let t=i.getBoundingClientRect(),n=i.ownerDocument,s=n.defaultView||window,r=Math.max(0,t.left),o=Math.min(s.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(s.innerHeight,t.bottom);for(let u=i.parentNode;u&&u!=n.body;)if(u.nodeType==1){let c=u,h=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&h.overflow!="visible"){let d=c.getBoundingClientRect();r=Math.max(r,d.left),o=Math.min(o,d.right),l=Math.max(l,d.top),a=Math.min(u==i.parentNode?s.innerHeight:a,d.bottom)}u=h.position=="absolute"||h.position=="fixed"?c.offsetParent:c.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function HC(i){let e=i.getBoundingClientRect(),t=i.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function GC(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Go{constructor(e,t,n,s){this.from=e,this.to=t,this.size=n,this.displaySize=s}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let s=e[n],r=t[n];if(s.from!=r.from||s.to!=r.to||s.size!=r.size)return!1}return!0}draw(e,t){return K.replace({widget:new WC(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class WC extends ii{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Tc{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Mc,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=xe.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Ya).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new FC(t),this.stateDeco=e.facet(es).filter(n=>typeof n!="function"),this.heightMap=Ke.empty().applyChanges(this.stateDeco,oe.empty,this.heightOracle.setDoc(e.doc),[new pt(0,0,0,e.doc.length)]);for(let n=0;n<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());n++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=K.set(this.lineGaps.map(n=>n.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let s=n?t.head:t.anchor;if(!e.some(({from:r,to:o})=>s>=r&&s<=o)){let{from:r,to:o}=this.lineBlockAt(s);e.push(new Ns(r,o))}}return this.viewports=e.sort((n,s)=>n.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Mc:new Za(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Pn(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(es).filter(c=>typeof c!="function");let s=e.changedRanges,r=pt.extendWithRanges(s,_C(n,this.stateDeco,e?e.changes:Ae.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);kc(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||mn)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let u=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(u||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(ip)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),s=this.heightOracle,r=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?xe.RTL:xe.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,c=0;if(l.width&&l.height){let{scaleX:C,scaleY:S}=If(t,l);(C>.005&&Math.abs(this.scaleX-C)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=C,this.scaleY=S,u|=16,o=a=!0)}let h=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=h||this.paddingBottom!=d)&&(this.paddingTop=h,this.paddingBottom=d,u|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=16);let p=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=p&&(this.scrollAnchorHeight=-1,this.scrollTop=p),this.scrolledToBottom=Df(e.scrollDOM);let g=(this.printing?GC:$C)(t,this.paddingTop),m=g.top-this.pixelViewport.top,x=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget&&!HC(e.dom))return 0;let b=l.width;if((this.contentDOMWidth!=b||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=16),a){let C=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(C)&&(o=!0),o||s.lineWrapping&&Math.abs(b-this.contentDOMWidth)>s.charWidth){let{lineHeight:S,charWidth:E,textHeight:A}=e.docView.measureTextSize();o=S>0&&s.refresh(r,S,E,A,Math.max(5,b/E),C),o&&(e.docView.minWidth=0,u|=16)}m>0&&x>0?c=Math.max(m,x):m<0&&x<0&&(c=Math.min(m,x)),kc();for(let S of this.viewports){let E=S.from==this.viewport.from?C:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?Ke.empty().applyChanges(this.stateDeco,oe.empty,this.heightOracle,[new pt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new NC(S.from,E))}mn&&(u|=2)}let v=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),u|=this.updateForViewport()),(u&2||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Ns(s.lineAt(o-n*1e3,me.ByHeight,r,0,0).from,s.lineAt(l+(1-n)*1e3,me.ByHeight,r,0,0).to);if(t){let{head:u}=t.range;if(u<a.from||u>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),h=s.lineAt(u,me.ByPos,r,0,0),d;t.y=="center"?d=(h.top+h.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&u<a.from?d=h.top:d=h.bottom-c,a=new Ns(s.lineAt(d-1e3/2,me.ByHeight,r,0,0).from,s.lineAt(d+c+1e3/2,me.ByHeight,r,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),s=t.mapPos(e.to,1);return new Ns(this.heightMap.lineAt(n,me.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,me.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(e,me.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,me.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||s<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||r>=l+Math.max(10,Math.min(n,250)))&&s>o-2*1e3&&r<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let s of e)t.touchesRange(s.from,s.to)||n.push(new Go(t.mapPos(s.from),t.mapPos(s.to),s.size,s.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,s=n?1e4:2e3,r=s>>1,o=s<<1;if(this.defaultTextDirection!=xe.LTR&&!n)return[];let l=[],a=(c,h,d,p)=>{if(h-c<r)return;let g=this.state.selection.main,m=[g.from];g.empty||m.push(g.to);for(let y of m)if(y>c&&y<h){a(c,y-10,d,p),a(y+10,h,d,p);return}let x=qC(e,y=>y.from>=d.from&&y.to<=d.to&&Math.abs(y.from-c)<r&&Math.abs(y.to-h)<r&&!m.some(b=>y.from<b&&y.to>b));if(!x){if(h<d.to&&t&&n&&t.visibleRanges.some(v=>v.from<=h&&v.to>=h)){let v=t.moveToLineBoundary(T.cursor(h),!1,!0).head;v>c&&(h=v)}let y=this.gapSize(d,c,h,p),b=n||y<2e6?y:2e6;x=new Go(c,h,y,b)}l.push(x)},u=c=>{if(c.length<o||c.type!=qe.Text)return;let h=UC(c.from,c.to,this.stateDeco);if(h.total<o)return;let d=this.scrollTarget?this.scrollTarget.range.head:null,p,g;if(n){let m=s/this.heightOracle.lineLength*this.heightOracle.lineHeight,x,y;if(d!=null){let b=Vs(h,d),v=((this.visibleBottom-this.visibleTop)/2+m)/c.height;x=b-v,y=b+v}else x=(this.visibleTop-c.top-m)/c.height,y=(this.visibleBottom-c.top+m)/c.height;p=Bs(h,x),g=Bs(h,y)}else{let m=h.total*this.heightOracle.charWidth,x=s*this.heightOracle.charWidth,y=0;if(m>2e6)for(let E of e)E.from>=c.from&&E.from<c.to&&E.size!=E.displaySize&&E.from*this.heightOracle.charWidth+y<this.pixelViewport.left&&(y=E.size-E.displaySize);let b=this.pixelViewport.left+y,v=this.pixelViewport.right+y,C,S;if(d!=null){let E=Vs(h,d),A=((v-b)/2+x)/m;C=E-A,S=E+A}else C=(b-x)/m,S=(v+x)/m;p=Bs(h,C),g=Bs(h,S)}p>c.from&&a(c.from,p,c,h),g<c.to&&a(g,c.to,c,h)};for(let c of this.viewportLines)Array.isArray(c.type)?c.type.forEach(u):u(c);return l}gapSize(e,t,n,s){let r=Vs(s,n)-Vs(s,t);return this.heightOracle.lineWrapping?e.height*r:s.total*this.heightOracle.charWidth*r}updateLineGaps(e){Go.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=K.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];re.spans(t,this.viewport.from,this.viewport.to,{span(r,o){n.push({from:r,to:o})},point(){}},20);let s=0;if(n.length!=this.visibleRanges.length)s=12;else for(let r=0;r<n.length&&!(s&8);r++){let o=this.visibleRanges[r],l=n[r];(o.from!=l.from||o.to!=l.to)&&(s|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(s|=8))}return this.visibleRanges=n,s}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Pn(this.heightMap.lineAt(e,me.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Pn(this.heightMap.lineAt(this.scaler.fromDOM(e),me.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Pn(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Ns{constructor(e,t){this.from=e,this.to=t}}function UC(i,e,t){let n=[],s=i,r=0;return re.spans(t,i,e,{span(){},point(o,l){o>s&&(n.push({from:s,to:o}),r+=o-s),s=l}},20),s<e&&(n.push({from:s,to:e}),r+=e-s),{total:r,ranges:n}}function Bs({total:i,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let n=Math.floor(i*t);for(let s=0;;s++){let{from:r,to:o}=e[s],l=o-r;if(n<=l)return r+n;n-=l}}function Vs(i,e){let t=0;for(let{from:n,to:s}of i.ranges){if(e<=s){t+=e-n;break}t+=s-n}return t/i.total}function qC(i,e){for(let t of i)if(e(t))return t}const Mc={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}};class Za{constructor(e,t,n){let s=0,r=0,o=0;this.viewports=n.map(({from:l,to:a})=>{let u=t.lineAt(l,me.ByPos,e,0,0).top,c=t.lineAt(a,me.ByPos,e,0,0).bottom;return s+=c-u,{from:l,to:a,top:u,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(t.height-s);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(e){for(let t=0,n=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return s+(e-n)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);n=r.bottom,s=r.domBottom}}fromDOM(e){for(let t=0,n=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return n+(e-s)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);n=r.bottom,s=r.domBottom}}eq(e){return e instanceof Za?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to):!1}}function Pn(i,e){if(e.scale==1)return i;let t=e.toDOM(i.top),n=e.toDOM(i.bottom);return new Dt(i.from,i.length,t,n-t,Array.isArray(i._content)?i._content.map(s=>Pn(s,e)):i._content)}const _s=$.define({combine:i=>i.join(" ")}),Jl=$.define({combine:i=>i.indexOf(!0)>-1}),Zl=yi.newName(),Ep=yi.newName(),Rp=yi.newName(),kp={"&light":"."+Ep,"&dark":"."+Rp};function ea(i,e,t){return new yi(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,s=>{if(s=="&")return i;if(!t||!t[s])throw new RangeError(`Unsupported selector: ${s}`);return t[s]}):i+" "+n}})}const KC=ea("."+Zl,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},kp),YC={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Wo=z.ie&&z.ie_version<=11;class XC{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new jS,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(z.ie&&z.ie_version<=11||z.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&z.android&&e.constructor.EDIT_CONTEXT!==!1&&!(z.chrome&&z.chrome_version<126)&&(this.editContext=new JC(e),e.state.facet(Kt)&&(e.contentDOM.editContext=this.editContext.editContext)),Wo&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,s=this.selectionRange;if(n.state.facet(Kt)?n.root.activeElement!=this.dom:!tr(this.dom,s))return;let r=s.anchorNode&&n.docView.nearest(s.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(z.ie&&z.ie_version<=11||z.android&&z.chrome)&&!n.state.selection.main.empty&&s.focusNode&&_n(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Zn(e.root);if(!t)return!1;let n=z.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&QC(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let s=tr(this.dom,n);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&DS(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),s&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,YC),Wo&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Wo&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let s=()=>{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&ln(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,s=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(s=!0),t==-1?{from:t,to:n}=o:(t=Math.min(o.from,t),n=Math.max(o.to,n)))}return{from:t,to:n,typeOver:s}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),s=this.selectionChanged&&tr(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new gC(this.view,e,t,n);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,s=fp(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),s}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let n=Oc(t,e.previousSibling||e.target.previousSibling,-1),s=Oc(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:s?t.posBefore(s):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Kt)!=e.state.facet(Kt)&&(e.view.contentDOM.editContext=e.state.facet(Kt)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Oc(i,e,t){for(;e;){let n=de.get(e);if(n&&n.parent==i)return n;let s=e.parentNode;e=s!=i.dom?s:t>0?e.nextSibling:e.previousSibling}return null}function Ic(i,e){let t=e.startContainer,n=e.startOffset,s=e.endContainer,r=e.endOffset,o=i.docView.domAtPos(i.state.selection.main.anchor);return _n(o.node,o.offset,s,r)&&([t,n,s,r]=[s,r,t,n]),{anchorNode:t,anchorOffset:n,focusNode:s,focusOffset:r}}function QC(i,e){if(e.getComposedRanges){let s=e.getComposedRanges(i.root)[0];if(s)return Ic(i,s)}let t=null;function n(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return i.contentDOM.addEventListener("beforeinput",n,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",n,!0),t?Ic(i,t):null}class JC{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let s=e.state.selection.main,{anchor:r,head:o}=s,l=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:l,drifted:!1});let u=a-l>n.text.length;l==this.from&&r<this.from?l=r:a==this.to&&r>this.to&&(a=r);let c=pp(e.state.sliceDoc(l,a),n.text,(u?s.from:s.to)-l,u?"end":null);if(!c){let d=T.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));d.main.eq(s)||e.dispatch({selection:d,userEvent:"select"});return}let h={from:c.from+l,to:c.toA+l,insert:oe.of(n.text.slice(c.from,c.toB).split(`
32
+ `))};if((z.mac||z.android)&&h.from==o-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(h={from:l,to:a,insert:oe.of([n.text.replace("."," ")])}),this.pendingContextChange=h,!e.state.readOnly){let d=this.to-this.from+(h.to-h.from+h.insert.length);Qa(e,h,T.single(this.toEditorPos(n.selectionStart,d),this.toEditorPos(n.selectionEnd,d)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),h.from<h.to&&!h.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let s=[],r=null;for(let o=this.toEditorPos(n.rangeStart),l=this.toEditorPos(n.rangeEnd);o<l;o++){let a=e.coordsForChar(o);r=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||r||new DOMRect,s.push(r)}t.updateCharacterBounds(n.rangeStart,s)},this.handlers.textformatupdate=n=>{let s=[];for(let r of n.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);if(a<u){let c=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;s.push(K.mark({attributes:{style:c}}).range(a,u))}}}e.dispatch({effects:sp.of(K.set(s))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:n}=this.composing;this.composing=null,n&&this.reset(e.state)}};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let s=Zn(n.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,s=this.pendingContextChange;return e.changes.iterChanges((r,o,l,a,u)=>{if(n)return;let c=u.length-(o-r);if(s&&o>=s.to)if(s.from==r&&s.to==o&&s.insert.eq(u)){s=this.pendingContextChange=null,t+=c,this.to+=c;return}else s=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=c,this.to+=c;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+u.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),u.toString()),this.to+=c}t+=c}),s&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),s=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(n,s)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class _{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(s=>s.forEach(r=>n(r,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||PS(e.parent)||document,this.viewState=new Tc(e.state||se.create(e)),e.scrollTo&&e.scrollTo.is(Ds)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Qi).map(s=>new zo(s));for(let s of this.plugins)s.update(this);this.observer=new XC(this),this.inputState=new bC(this),this.inputState.ensureHandlers(this.plugins),this.docView=new uc(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof Te?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,s,r=this.state;for(let d of e){if(d.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=d.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;e.some(d=>d.annotation(vp))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Sp(r,o),a||(l=1));let u=this.observer.delayedAndroidKey,c=null;if(u?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(se.phrases)!=this.state.facet(se.phrases))return this.setState(r);s=Er.create(this,r,e),s.flags|=l;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let d of e){if(h&&(h=h.map(d.changes)),d.scrollIntoView){let{main:p}=d.state.selection;h=new an(p.empty?p:T.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of d.effects)p.is(Ds)&&(h=p.value.clip(this.state))}this.viewState.update(s,h),this.bidiCache=kr.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(In)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(_s)!=s.state.facet(_s)&&(this.viewState.mustMeasureContent=!0),(t||n||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let d of this.state.facet(Kl))try{d(s)}catch(p){Je(this.state,p,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!fp(this,c)&&u.force&&ln(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new Tc(e),this.plugins=e.facet(Qi).map(n=>new zo(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new uc(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Qi),n=e.state.facet(Qi);if(t!=n){let s=[];for(let r of n){let o=t.indexOf(r);if(o<0)s.push(new zo(r));else{let l=this.plugins[o];l.mustUpdate=e,s.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s<this.plugins.length;s++)this.plugins[s].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(n){Je(this.state,n,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,s=n.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(s-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(Df(n))r=-1,o=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(s);r=p.from,o=p.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];a&4||([this.measureRequests,u]=[u,this.measureRequests]);let c=u.map(p=>{try{return p.read(this)}catch(g){return Je(this.state,g),jc}}),h=Er.create(this,this.state,[]),d=!1;h.flags|=a,t?t.flags|=a:t=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),d=this.docView.update(h),d&&this.docViewUpdate());for(let p=0;p<u.length;p++)if(c[p]!=jc)try{let g=u[p];g.write&&g.write(c[p],this)}catch(g){Je(this.state,g)}if(d&&this.docView.updateSelection(!0),!h.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let g=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-o;if(g>1||g<-1){s=s+g,n.scrollTop=s/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(Kl))l(t)}get themeClasses(){return Zl+" "+(this.state.facet(Jl)?Rp:Ep)+" "+this.state.facet(_s)}updateAttrs(){let e=Pc(this,rp,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Kt)?"true":"false",class:"cm-content",style:`${z.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Pc(this,Ya,t);let n=this.observer.ignore(()=>{let s=Hl(this.contentDOM,this.contentAttrs,t),r=Hl(this.dom,this.editorAttrs,e);return s||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let s of n.effects)if(s.is(_.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(In);let e=this.state.facet(_.cspNonce);yi.mount(this.root,this.styleModules.concat(KC).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(n=>n.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return Ho(this,e,pc(this,e,t,n))}moveByGroup(e,t){return Ho(this,e,pc(this,e,t,n=>cC(this,e.head,n)))}visualLineSide(e,t){let n=this.bidiSpans(e),s=this.textDirectionAt(e.from),r=n[t?n.length-1:0];return T.cursor(r.side(t,s)+e.from,r.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,n=!0){return uC(this,e,t,n)}moveVertically(e,t,n){return Ho(this,e,hC(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),cp(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let s=this.state.doc.lineAt(e),r=this.bidiSpans(s),o=r[fi.find(r,e-s.from,-1,t)];return cs(n,o.dir==xe.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(tp)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>ZC)return qf(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||Uf(r.isolates,n=ac(this,e))))return r.order;n||(n=ac(this,e));let s=qS(e.text,t,n);return this.bidiCache.push(new kr(e.from,e.to,t,n,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||z.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{jf(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Ds.of(new an(typeof e=="number"?T.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Ds.of(new an(T.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Ce.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Ce.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=yi.newName(),s=[_s.of(n),In.of(ea(`.${n}`,e))];return t&&t.dark&&s.push(Jl.of(!0)),s}static baseTheme(e){return $i.lowest(In.of(ea("."+Zl,e,kp)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),s=n&&de.get(n)||de.get(e);return((t=s==null?void 0:s.rootView)===null||t===void 0?void 0:t.view)||null}}_.styleModule=In;_.inputHandler=Zf;_.clipboardInputFilter=qa;_.clipboardOutputFilter=Ka;_.scrollHandler=np;_.focusChangeEffect=ep;_.perLineTextDirection=tp;_.exceptionSink=Jf;_.updateListener=Kl;_.editable=Kt;_.mouseSelectionStyle=Qf;_.dragMovesSelection=Xf;_.clickAddsSelectionRange=Yf;_.decorations=es;_.outerDecorations=op;_.atomicRanges=fs;_.bidiIsolatedRanges=lp;_.scrollMargins=ap;_.darkTheme=Jl;_.cspNonce=$.define({combine:i=>i.length?i[0]:""});_.contentAttributes=Ya;_.editorAttributes=rp;_.lineWrapping=_.contentAttributes.of({class:"cm-lineWrapping"});_.announce=J.define();const ZC=4096,jc={};class kr{constructor(e,t,n,s,r,o){this.from=e,this.to=t,this.dir=n,this.isolates=s,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let n=[],s=e.length?e[e.length-1].dir:xe.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let o=e[r];o.dir==s&&!t.touchesRange(o.from,o.to)&&n.push(new kr(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function Pc(i,e,t){for(let n=i.state.facet(e),s=n.length-1;s>=0;s--){let r=n[s],o=typeof r=="function"?r(i):r;o&&$l(o,t)}return t}const e1=z.mac?"mac":z.windows?"win":z.linux?"linux":"key";function t1(i,e){const t=i.split(/-(?!$)/);let n=t[t.length-1];n=="Space"&&(n=" ");let s,r,o,l;for(let a=0;a<t.length-1;++a){const u=t[a];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))s=!0;else if(/^(c|ctrl|control)$/i.test(u))r=!0;else if(/^s(hift)?$/i.test(u))o=!0;else if(/^mod$/i.test(u))e=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+u)}return s&&(n="Alt-"+n),r&&(n="Ctrl-"+n),l&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function zs(i,e,t){return e.altKey&&(i="Alt-"+i),e.ctrlKey&&(i="Ctrl-"+i),e.metaKey&&(i="Meta-"+i),t!==!1&&e.shiftKey&&(i="Shift-"+i),i}const i1=$i.default(_.domEventHandlers({keydown(i,e){return Tp(Ap(e.state),i,e,"editor")}})),io=$.define({enables:i1}),Dc=new WeakMap;function Ap(i){let e=i.facet(io),t=Dc.get(e);return t||Dc.set(e,t=r1(e.reduce((n,s)=>n.concat(s),[]))),t}function n1(i,e,t){return Tp(Ap(i.state),e,i,t)}let ui=null;const s1=4e3;function r1(i,e=e1){let t=Object.create(null),n=Object.create(null),s=(o,l)=>{let a=n[o];if(a==null)n[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,a,u,c)=>{var h,d;let p=t[o]||(t[o]=Object.create(null)),g=l.split(/ (?!$)/).map(y=>t1(y,e));for(let y=1;y<g.length;y++){let b=g.slice(0,y).join(" ");s(b,!0),p[b]||(p[b]={preventDefault:!0,stopPropagation:!1,run:[v=>{let C=ui={view:v,prefix:b,scope:o};return setTimeout(()=>{ui==C&&(ui=null)},s1),!0}]})}let m=g.join(" ");s(m,!1);let x=p[m]||(p[m]={preventDefault:!1,stopPropagation:!1,run:((d=(h=p._any)===null||h===void 0?void 0:h.run)===null||d===void 0?void 0:d.slice())||[]});a&&x.run.push(a),u&&(x.preventDefault=!0),c&&(x.stopPropagation=!0)};for(let o of i){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of l){let c=t[u]||(t[u]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:h}=o;for(let d in c)c[d].run.push(p=>h(p,ta))}let a=o[e]||o.key;if(a)for(let u of l)r(u,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(u,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}let ta=null;function Tp(i,e,t,n){ta=e;let s=AS(e),r=Xe(s,0),o=Pt(r)==s.length&&s!=" ",l="",a=!1,u=!1,c=!1;ui&&ui.view==t&&ui.scope==n&&(l=ui.prefix+" ",mp.indexOf(e.keyCode)<0&&(u=!0,ui=null));let h=new Set,d=x=>{if(x){for(let y of x.run)if(!h.has(y)&&(h.add(y),y(t)))return x.stopPropagation&&(c=!0),!0;x.preventDefault&&(x.stopPropagation&&(c=!0),u=!0)}return!1},p=i[n],g,m;return p&&(d(p[l+zs(s,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(z.windows&&e.ctrlKey&&e.altKey)&&!(z.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(g=bi[e.keyCode])&&g!=s?(d(p[l+zs(g,e,!0)])||e.shiftKey&&(m=Jn[e.keyCode])!=s&&m!=g&&d(p[l+zs(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&d(p[l+zs(s,e,!0)])&&(a=!0),!a&&d(p._any)&&(a=!0)),u&&(a=!0),a&&c&&e.stopPropagation(),ta=null,a}class ps{constructor(e,t,n,s,r){this.className=e,this.left=t,this.top=n,this.width=s,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let s=e.coordsAtPos(n.head,n.assoc||1);if(!s)return[];let r=Mp(e);return[new ps(t,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return o1(e,t,n)}}function Mp(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==xe.LTR?e.left:e.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:e.top-i.scrollDOM.scrollTop*i.scaleY}}function Lc(i,e,t,n){let s=i.coordsAtPos(e,t*2);if(!s)return n;let r=i.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,l=i.posAtCoords({x:r.left+1,y:o}),a=i.posAtCoords({x:r.right-1,y:o});return l==null||a==null?n:{from:Math.max(n.from,Math.min(l,a)),to:Math.min(n.to,Math.max(l,a))}}function o1(i,e,t){if(t.to<=i.viewport.from||t.from>=i.viewport.to)return[];let n=Math.max(t.from,i.viewport.from),s=Math.min(t.to,i.viewport.to),r=i.textDirection==xe.LTR,o=i.contentDOM,l=o.getBoundingClientRect(),a=Mp(i),u=o.querySelector(".cm-line"),c=u&&window.getComputedStyle(u),h=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),d=l.right-(c?parseInt(c.paddingRight):0),p=Xl(i,n,1),g=Xl(i,s,-1),m=p.type==qe.Text?p:null,x=g.type==qe.Text?g:null;if(m&&(i.lineWrapping||p.widgetLineBreaks)&&(m=Lc(i,n,1,m)),x&&(i.lineWrapping||g.widgetLineBreaks)&&(x=Lc(i,s,-1,x)),m&&x&&m.from==x.from&&m.to==x.to)return b(v(t.from,t.to,m));{let S=m?v(t.from,null,m):C(p,!1),E=x?v(null,t.to,x):C(g,!0),A=[];return(m||p).to<(x||g).from-(m&&x?1:0)||p.widgetLineBreaks>1&&S.bottom+i.defaultLineHeight/2<E.top?A.push(y(h,S.bottom,d,E.top)):S.bottom<E.top&&i.elementAtHeight((S.bottom+E.top)/2).type==qe.Text&&(S.bottom=E.top=(S.bottom+E.top)/2),b(S).concat(A).concat(b(E))}function y(S,E,A,I){return new ps(e,S-a.left,E-a.top,A-S,I-E)}function b({top:S,bottom:E,horizontal:A}){let I=[];for(let R=0;R<A.length;R+=2)I.push(y(A[R],S,A[R+1],E));return I}function v(S,E,A){let I=1e9,R=-1e9,H=[];function F(P,B,q,ne,ae){let ie=i.coordsAtPos(P,P==A.to?-2:2),ee=i.coordsAtPos(q,q==A.from?2:-2);!ie||!ee||(I=Math.min(ie.top,ee.top,I),R=Math.max(ie.bottom,ee.bottom,R),ae==xe.LTR?H.push(r&&B?h:ie.left,r&&ne?d:ee.right):H.push(!r&&ne?h:ee.left,!r&&B?d:ie.right))}let j=S??A.from,W=E??A.to;for(let P of i.visibleRanges)if(P.to>j&&P.from<W)for(let B=Math.max(P.from,j),q=Math.min(P.to,W);;){let ne=i.state.doc.lineAt(B);for(let ae of i.bidiSpans(ne)){let ie=ae.from+ne.from,ee=ae.to+ne.from;if(ie>=q)break;ee>B&&F(Math.max(ie,B),S==null&&ie<=j,Math.min(ee,q),E==null&&ee>=W,ae.dir)}if(B=ne.to+1,B>=q)break}return H.length==0&&F(j,S==null,W,E==null,i.textDirection),{top:I,bottom:R,horizontal:H}}function C(S,E){let A=l.top+(E?S.top:S.bottom);return{top:A,bottom:A,horizontal:[]}}}function l1(i,e){return i.constructor==e.constructor&&i.eq(e)}class a1{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(sr)!=e.state.facet(sr)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(sr);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,n)=>!l1(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[n].constructor&&s.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(s.draw(),t);for(;t;){let s=t.nextSibling;t.remove(),t=s}this.drawn=e,z.safari&&z.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const sr=$.define();function Op(i){return[Ce.define(e=>new a1(e,i)),sr.of(i)]}const ts=$.define({combine(i){return Ht(i,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function u1(i={}){return[ts.of(i),c1,h1,d1,ip.of(!0)]}function Ip(i){return i.startState.facet(ts)!=i.state.facet(ts)}const c1=Op({above:!0,markers(i){let{state:e}=i,t=e.facet(ts),n=[];for(let s of e.selection.ranges){let r=s==e.selection.main;if(s.empty||t.drawRangeCursor){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=s.empty?s:T.cursor(s.head,s.head>s.anchor?-1:1);for(let a of ps.forRange(i,o,l))n.push(a)}}return n},update(i,e){i.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Ip(i);return t&&Fc(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){Fc(e.state,i)},class:"cm-cursorLayer"});function Fc(i,e){e.style.animationDuration=i.facet(ts).cursorBlinkRate+"ms"}const h1=Op({above:!1,markers(i){return i.state.selection.ranges.map(e=>e.empty?[]:ps.forRange(i,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||Ip(i)},class:"cm-selectionLayer"}),d1=$i.highest(_.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),jp=J.define({map(i,e){return i==null?null:e.mapPos(i)}}),Dn=Fe.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(jp)?n.value:t,i)}}),f1=Ce.fromClass(class{constructor(i){this.view=i,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(i){var e;let t=i.state.field(Dn);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(i.startState.field(Dn)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:i}=this,e=i.state.field(Dn),t=e!=null&&i.coordsAtPos(e);if(!t)return null;let n=i.scrollDOM.getBoundingClientRect();return{left:t.left-n.left+i.scrollDOM.scrollLeft*i.scaleX,top:t.top-n.top+i.scrollDOM.scrollTop*i.scaleY,height:t.bottom-t.top}}drawCursor(i){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;i?(this.cursor.style.left=i.left/e+"px",this.cursor.style.top=i.top/t+"px",this.cursor.style.height=i.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(i){this.view.state.field(Dn)!=i&&this.view.dispatch({effects:jp.of(i)})}},{eventObservers:{dragover(i){this.setDropPos(this.view.posAtCoords({x:i.clientX,y:i.clientY}))},dragleave(i){(i.target==this.view.contentDOM||!this.view.contentDOM.contains(i.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function p1(){return[Dn,f1]}function Nc(i,e,t,n,s){e.lastIndex=0;for(let r=i.iterRange(t,n),o=t,l;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;l=e.exec(r.value);)s(o+l.index,l)}function g1(i,e){let t=i.visibleRanges;if(t.length==1&&t[0].from==i.viewport.from&&t[0].to==i.viewport.to)return t;let n=[];for(let{from:s,to:r}of t)s=Math.max(i.state.doc.lineAt(s).from,s-e),r=Math.min(i.state.doc.lineAt(r).to,r+e),n.length&&n[n.length-1].to>=s?n[n.length-1].to=r:n.push({from:s,to:r});return n}class m1{constructor(e){const{regexp:t,decoration:n,decorate:s,boundary:r,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,s)this.addMatch=(l,a,u,c)=>s(c,u,u+l[0].length,l,a);else if(typeof n=="function")this.addMatch=(l,a,u,c)=>{let h=n(l,a,u);h&&c(u,u+l[0].length,h)};else if(n)this.addMatch=(l,a,u,c)=>c(u,u+l[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(e){let t=new Zt,n=t.add.bind(t);for(let{from:s,to:r}of g1(e,this.maxLength))Nc(e.state.doc,this.regexp,s,r,(o,l)=>this.addMatch(l,e,o,n));return t.finish()}updateDeco(e,t){let n=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((r,o,l,a)=>{a>=e.view.viewport.from&&l<=e.view.viewport.to&&(n=Math.min(l,n),s=Math.max(a,s))}),e.viewportMoved||s-n>1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),n,s):t}updateRange(e,t,n,s){for(let r of e.visibleRanges){let o=Math.max(r.from,n),l=Math.min(r.to,s);if(l>=o){let a=e.state.doc.lineAt(o),u=a.to<l?e.state.doc.lineAt(l):a,c=Math.max(r.from,a.from),h=Math.min(r.to,u.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;l<u.to;l++)if(this.boundary.test(u.text[l-u.from])){h=l;break}}let d=[],p,g=(m,x,y)=>d.push(y.range(m,x));if(a==u)for(this.regexp.lastIndex=c-a.from;(p=this.regexp.exec(a.text))&&p.index<h-a.from;)this.addMatch(p,e,p.index+a.from,g);else Nc(e.state.doc,this.regexp,c,h,(m,x)=>this.addMatch(x,e,m,g));t=t.update({filterFrom:c,filterTo:h,filter:(m,x)=>m<c||x>h,add:d})}}return t}}const ia=/x/.unicode!=null?"gu":"g",x1=new RegExp(`[\0-\b
33
+ --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,ia),y1={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Uo=null;function b1(){var i;if(Uo==null&&typeof document<"u"&&document.body){let e=document.body.style;Uo=((i=e.tabSize)!==null&&i!==void 0?i:e.MozTabSize)!=null}return Uo||!1}const rr=$.define({combine(i){let e=Ht(i,{render:null,specialChars:x1,addSpecialChars:null});return(e.replaceTabs=!b1())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,ia)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,ia)),e}});function v1(i={}){return[rr.of(i),S1()]}let Bc=null;function S1(){return Bc||(Bc=Ce.fromClass(class{constructor(i){this.view=i,this.decorations=K.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(i.state.facet(rr)),this.decorations=this.decorator.createDeco(i)}makeDecorator(i){return new m1({regexp:i.specialChars,decoration:(e,t,n)=>{let{doc:s}=t.state,r=Xe(e[0],0);if(r==9){let o=s.lineAt(n),l=t.state.tabSize,a=vn(o.text,l,n-o.from);return K.replace({widget:new R1((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=K.replace({widget:new E1(i,r)}))},boundary:i.replaceTabs?void 0:/[^]/})}update(i){let e=i.state.facet(rr);i.startState.facet(rr)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(i.view)):this.decorations=this.decorator.updateDeco(i,this.decorations)}},{decorations:i=>i.decorations}))}const C1="•";function w1(i){return i>=32?C1:i==10?"␤":String.fromCharCode(9216+i)}class E1 extends ii{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=w1(this.code),n=e.state.phrase("Control character")+" "+(y1[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,n,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=n,r.setAttribute("aria-label",n),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class R1 extends ii{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function k1(){return T1}const A1=K.line({class:"cm-activeLine"}),T1=Ce.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.docChanged||i.selectionSet)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=-1,t=[];for(let n of i.state.selection.ranges){let s=i.lineBlockAt(n.head);s.from>e&&(t.push(A1.range(s.from)),e=s.from)}return K.set(t)}},{decorations:i=>i.decorations});class M1 extends ii{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?fn(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),s=cs(t[0],n.direction!="rtl"),r=parseInt(n.lineHeight);return s.bottom-s.top>r*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+r}:s}ignoreEvent(){return!1}}function O1(i){let e=Ce.fromClass(class{constructor(t){this.view=t,this.placeholder=i?K.set([K.widget({widget:new M1(i),side:1}).range(0)]):K.none}get decorations(){return this.view.state.doc.length?K.none:this.placeholder}},{decorations:t=>t.decorations});return typeof i=="string"?[e,_.contentAttributes.of({"aria-placeholder":i})]:e}const na=2e3;function I1(i,e,t){let n=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>na||t.off>na||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=n;a<=s;a++){let u=i.doc.line(a);u.length<=l&&r.push(T.range(u.from+o,u.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=n;a<=s;a++){let u=i.doc.line(a),c=Dl(u.text,o,i.tabSize,!0);if(c<0)r.push(T.cursor(u.to));else{let h=Dl(u.text,l,i.tabSize);r.push(T.range(u.from+c,u.from+h))}}}return r}function j1(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function Vc(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1),n=i.state.doc.lineAt(t),s=t-n.from,r=s>na?-1:s==n.length?j1(i,e.clientX):vn(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:r,off:s}}function P1(i,e){let t=Vc(i,e),n=i.state.selection;return t?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.doc.line(t.line).from),o=s.state.doc.lineAt(r);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},n=n.map(s.changes)}},get(s,r,o){let l=Vc(i,s);if(!l)return n;let a=I1(i.state,t,l);return a.length?o?T.create(a.concat(n.ranges)):T.create(a):n}}:null}function D1(i){let e=(t=>t.altKey&&t.button==0);return _.mouseSelectionStyle.of((t,n)=>e(n)?P1(t,n):null)}const L1={Alt:[18,i=>!!i.altKey],Control:[17,i=>!!i.ctrlKey],Shift:[16,i=>!!i.shiftKey],Meta:[91,i=>!!i.metaKey]},F1={style:"cursor: crosshair"};function N1(i={}){let[e,t]=L1[i.key||"Alt"],n=Ce.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventObservers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)},mousemove(s){this.set(t(s))}}});return[n,_.contentAttributes.of(s=>{var r;return!((r=s.plugin(n))===null||r===void 0)&&r.isDown?F1:null})]}const $s="-10000px";class Pp{constructor(e,t,n,s){this.facet=t,this.createTooltipView=n,this.removeTooltipView=s,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=n(o,r))}update(e,t){var n;let s=e.state.facet(this.facet),r=s.filter(a=>a);if(s===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;a<r.length;a++){let u=r[a],c=-1;if(u){for(let h=0;h<this.tooltips.length;h++){let d=this.tooltips[h];d&&d.create==u.create&&(c=h)}if(c<0)o[a]=this.createTooltipView(u,a?o[a-1]:null),l&&(l[a]=!!u.above);else{let h=o[a]=this.tooltipViews[c];l&&(l[a]=t[c]),h.update&&h.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(n=a.destroy)===null||n===void 0||n.call(a));return t&&(l.forEach((a,u)=>t[u]=a),t.length=l.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}}function B1(i){let e=i.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const qo=$.define({combine:i=>{var e,t,n;return{position:z.ios?"absolute":((e=i.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=i.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((n=i.find(s=>s.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||B1}}}),_c=new WeakMap,eu=Ce.fromClass(class{constructor(i){this.view=i,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=i.state.facet(qo);this.position=e.position,this.parent=e.parent,this.classes=i.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Pp(i,tu,(t,n)=>this.createTooltip(t,n),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),i.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let i of this.manager.tooltipViews)this.intersectionObserver.observe(i.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(i){i.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(i,this.above);e&&this.observeIntersection();let t=e||i.geometryChanged,n=i.state.facet(qo);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(i,e){let t=i.create(this.view),n=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),i.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",t.dom.appendChild(s)}return t.dom.style.position=this.position,t.dom.style.top=$s,t.dom.style.left="0px",this.container.insertBefore(t.dom,n),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var i,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(i=n.destroy)===null||i===void 0||i.call(n);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let i=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(z.safari){let o=r.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else t=!!r.offsetParent&&r.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(i=r.width/this.parent.offsetWidth,e=r.height/this.parent.offsetHeight)}else({scaleX:i,scaleY:e}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),s=Xa(this.view);return{visible:{left:n.left+s.left,top:n.top+s.top,right:n.right-s.right,bottom:n.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((r,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(qo).tooltipSpace(this.view),scaleX:i,scaleY:e,makeAbsolute:t}}writeMeasure(i){var e;if(i.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:t,space:n,scaleX:s,scaleY:r}=i,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],u=this.manager.tooltipViews[l],{dom:c}=u,h=i.pos[l],d=i.size[l];if(!h||a.clip!==!1&&(h.bottom<=Math.max(t.top,n.top)||h.top>=Math.min(t.bottom,n.bottom)||h.right<Math.max(t.left,n.left)-.1||h.left>Math.min(t.right,n.right)+.1)){c.style.top=$s;continue}let p=a.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,g=p?7:0,m=d.right-d.left,x=(e=_c.get(u))!==null&&e!==void 0?e:d.bottom-d.top,y=u.offset||_1,b=this.view.textDirection==xe.LTR,v=d.width>n.right-n.left?b?n.left:n.right-d.width:b?Math.max(n.left,Math.min(h.left-(p?14:0)+y.x,n.right-m)):Math.min(Math.max(n.left,h.left-m+(p?14:0)-y.x),n.right-m),C=this.above[l];!a.strictSide&&(C?h.top-x-g-y.y<n.top:h.bottom+x+g+y.y>n.bottom)&&C==n.bottom-h.bottom>h.top-n.top&&(C=this.above[l]=!C);let S=(C?h.top-n.top:n.bottom-h.bottom)-g;if(S<x&&u.resize!==!1){if(S<this.view.defaultLineHeight){c.style.top=$s;continue}_c.set(u,x),c.style.height=(x=S)/r+"px"}else c.style.height&&(c.style.height="");let E=C?h.top-x-g-y.y:h.bottom+g+y.y,A=v+m;if(u.overlap!==!0)for(let I of o)I.left<A&&I.right>v&&I.top<E+x&&I.bottom>E&&(E=C?I.top-x-2-g:I.bottom+g+2);if(this.position=="absolute"?(c.style.top=(E-i.parent.top)/r+"px",zc(c,(v-i.parent.left)/s)):(c.style.top=E/r+"px",zc(c,v/s)),p){let I=h.left+(b?y.x:-y.x)-(v+14-7);p.style.left=I/s+"px"}u.overlap!==!0&&o.push({left:v,top:E,right:A,bottom:E+x}),c.classList.toggle("cm-tooltip-above",C),c.classList.toggle("cm-tooltip-below",!C),u.positioned&&u.positioned(i.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let i of this.manager.tooltipViews)i.dom.style.top=$s}},{eventObservers:{scroll(){this.maybeMeasure()}}});function zc(i,e){let t=parseInt(i.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(i.style.left=e+"px")}const V1=_.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),_1={x:0,y:0},tu=$.define({enables:[eu,V1]}),Ar=$.define({combine:i=>i.reduce((e,t)=>e.concat(t),[])});class no{static create(e){return new no(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Pp(e,Ar,(t,n)=>this.createHostedView(t,n),t=>t.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let s=n[e];if(s!==void 0){if(t===void 0)t=s;else if(t!==s)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const z1=tu.compute([Ar],i=>{let e=i.facet(Ar);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var n;return(n=t.end)!==null&&n!==void 0?n:t.pos})),create:no.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class $1{constructor(e,t,n,s,r){this.view=e,this.source=t,this.field=n,this.setHover=s,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.nearest(t.target);if(!n)return;let s,r=1;if(n instanceof Yt)s=n.posAtStart;else{if(s=e.posAtCoords(t),s==null)return;let l=e.coordsAtPos(s);if(!l||t.y<l.top||t.y>l.bottom||t.x<l.left-e.defaultCharacterWidth||t.x>l.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(s)).find(c=>c.from<=s&&c.to>=s),u=a&&a.dir==xe.RTL?-1:1;r=t.x<l.left?-u:u}let o=this.source(e,s,r);if(o!=null&&o.then){let l=this.pending={pos:s};o.then(a=>{this.pending==l&&(this.pending=null,a&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])}))},a=>Je(e.state,a,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(eu),t=e?e.manager.tooltips.findIndex(n=>n.create==no.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:r}=this;if(s.length&&r&&!H1(r.dom,e)||this.pending){let{pos:o}=s[0]||this.pending,l=(n=(t=s[0])===null||t===void 0?void 0:t.end)!==null&&n!==void 0?n:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!G1(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:n}=this;n&&n.dom.contains(e.relatedTarget)?this.watchTooltipLeave(n.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Hs=4;function H1(i,e){let{left:t,right:n,top:s,bottom:r}=i.getBoundingClientRect(),o;if(o=i.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();s=Math.min(l.top,s),r=Math.max(l.bottom,r)}return e.clientX>=t-Hs&&e.clientX<=n+Hs&&e.clientY>=s-Hs&&e.clientY<=r+Hs}function G1(i,e,t,n,s,r){let o=i.scrollDOM.getBoundingClientRect(),l=i.documentTop+i.documentPadding.top+i.contentHeight;if(o.left>n||o.right<n||o.top>s||Math.min(o.bottom,l)<s)return!1;let a=i.posAtCoords({x:n,y:s},!1);return a>=e&&a<=t}function W1(i,e={}){let t=J.define(),n=Fe.define({create(){return[]},update(s,r){if(s.length&&(e.hideOnChange&&(r.docChanged||r.selection)?s=[]:e.hideOn&&(s=s.filter(o=>!e.hideOn(r,o))),r.docChanged)){let o=[];for(let l of s){let a=r.changes.mapPos(l.pos,-1,Ue.TrackDel);if(a!=null){let u=Object.assign(Object.create(null),l);u.pos=a,u.end!=null&&(u.end=r.changes.mapPos(u.end)),o.push(u)}}s=o}for(let o of r.effects)o.is(t)&&(s=o.value),o.is(U1)&&(s=[]);return s},provide:s=>Ar.from(s)});return{active:n,extension:[n,Ce.define(s=>new $1(s,i,n,t,e.hoverTime||300)),z1]}}function Dp(i,e){let t=i.plugin(eu);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}const U1=J.define(),$c=$.define({combine(i){let e,t;for(let n of i)e=e||n.topContainer,t=t||n.bottomContainer;return{topContainer:e,bottomContainer:t}}});function is(i,e){let t=i.plugin(Lp),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}const Lp=Ce.fromClass(class{constructor(i){this.input=i.state.facet(ns),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet($c);this.top=new Gs(i,!0,e.topContainer),this.bottom=new Gs(i,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(i){let e=i.state.facet($c);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Gs(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Gs(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(ns);if(t!=this.input){let n=t.filter(a=>a),s=[],r=[],o=[],l=[];for(let a of n){let u=this.specs.indexOf(a),c;u<0?(c=a(i.view),l.push(c)):(c=this.panels[u],c.update&&c.update(i)),s.push(c),(c.top?r:o).push(c)}this.specs=n,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let n of this.panels)n.update&&n.update(i)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i=>_.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Gs{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Hc(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Hc(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function Hc(i){let e=i.nextSibling;return i.remove(),e}const ns=$.define({enables:Lp});class ti extends Fi{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}ti.prototype.elementClass="";ti.prototype.toDOM=void 0;ti.prototype.mapMode=Ue.TrackBefore;ti.prototype.startSide=ti.prototype.endSide=-1;ti.prototype.point=!0;const or=$.define(),q1=$.define(),K1={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>re.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Hn=$.define();function Y1(i){return[Fp(),Hn.of({...K1,...i})]}const Gc=$.define({combine:i=>i.some(e=>e)});function Fp(i){return[X1]}const X1=Ce.fromClass(class{constructor(i){this.view=i,this.domAfter=null,this.prevViewport=i.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=i.state.facet(Hn).map(e=>new Uc(i,e)),this.fixed=!i.state.facet(Gc);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),i.scrollDOM.insertBefore(this.dom,i.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(i){if(this.updateGutters(i)){let e=this.prevViewport,t=i.view.viewport,n=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(n<(t.to-t.from)*.8)}if(i.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Gc)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=i.view.viewport}syncGutters(i){let e=this.dom.nextSibling;i&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=re.iter(this.view.state.facet(or),this.view.viewport.from),n=[],s=this.gutters.map(r=>new Q1(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==qe.Text&&o){sa(t,n,l.from);for(let a of s)a.line(this.view,l,n);o=!1}else if(l.widget)for(let a of s)a.widget(this.view,l)}else if(r.type==qe.Text){sa(t,n,r.from);for(let o of s)o.line(this.view,r,n)}else if(r.widget)for(let o of s)o.widget(this.view,r);for(let r of s)r.finish();i&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(i){let e=i.startState.facet(Hn),t=i.state.facet(Hn),n=i.docChanged||i.heightChanged||i.viewportChanged||!re.eq(i.startState.facet(or),i.state.facet(or),i.view.viewport.from,i.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(i)&&(n=!0);else{n=!0;let s=[];for(let r of t){let o=e.indexOf(r);o<0?s.push(new Uc(this.view,r)):(this.gutters[o].update(i),s.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=s}return n}destroy(){for(let i of this.gutters)i.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:i=>_.scrollMargins.of(e=>{let t=e.plugin(i);if(!t||t.gutters.length==0||!t.fixed)return null;let n=t.dom.offsetWidth*e.scaleX,s=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==xe.LTR?{left:n,right:s}:{right:n,left:s}})});function Wc(i){return Array.isArray(i)?i:[i]}function sa(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}class Q1{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=re.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:s}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==s.elements.length){let l=new Np(e,o,r,n);s.elements.push(l),s.dom.appendChild(l.dom)}else s.elements[this.i].update(e,o,r,n);this.height=t.bottom,this.i++}line(e,t,n){let s=[];sa(this.cursor,s,t.from),n.length&&(s=s.concat(n));let r=this.gutter.config.lineMarker(e,t,s);r&&s.unshift(r);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,s)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),s=n?[n]:null;for(let r of e.state.facet(q1)){let o=r(e,t.widget,t);o&&(s||(s=[])).push(o)}s&&this.addElement(e,t,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Uc{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,s=>{let r=s.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=s.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[n](e,l,s)&&s.preventDefault()});this.markers=Wc(t.markers(e)),t.initialSpacer&&(this.spacer=new Np(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Wc(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let n=e.view.viewport;return!re.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Np{constructor(e,t,n,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,s)}update(e,t,n,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),J1(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let n="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=r<t.length?t[r++]:null,u=!1;if(a){let c=a.elementClass;c&&(n+=" "+c);for(let h=o;h<this.markers.length;h++)if(this.markers[h].compare(a)){l=h,u=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(s);let h=s.nextSibling;s.remove(),s=h}}if(!a)break;a.toDOM&&(u?s=s.nextSibling:this.dom.insertBefore(a.toDOM(e),s)),u&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}}function J1(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(!i[t].compare(e[t]))return!1;return!0}const Z1=$.define(),ew=$.define(),Ji=$.define({combine(i){return Ht(i,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let s in t){let r=n[s],o=t[s];n[s]=r?(l,a,u)=>r(l,a,u)||o(l,a,u):o}return n}})}});class Ko extends ti{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Yo(i,e){return i.state.facet(Ji).formatNumber(e,i.state)}const tw=Hn.compute([Ji],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Z1)},lineMarker(e,t,n){return n.some(s=>s.toDOM)?null:new Ko(Yo(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let s of e.state.facet(ew)){let r=s(e,t,n);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(Ji)!=e.state.facet(Ji),initialSpacer(e){return new Ko(Yo(e,qc(e.state.doc.lines)))},updateSpacer(e,t){let n=Yo(t.view,qc(t.view.state.doc.lines));return n==e.number?e:new Ko(n)},domEventHandlers:i.facet(Ji).domEventHandlers,side:"before"}));function iw(i={}){return[Ji.of(i),Fp(),tw]}function qc(i){let e=9;for(;e<i;)e=e*10+9;return e}const nw=new class extends ti{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},sw=or.compute(["selection"],i=>{let e=[],t=-1;for(let n of i.selection.ranges){let s=i.doc.lineAt(n.head).from;s>t&&(t=s,e.push(nw.range(s)))}return re.of(e)});function rw(){return sw}var Xo;const Zi=new te;function ow(i){return $.define({combine:i?e=>e.concat(i):void 0})}const lw=new te;class yt{constructor(e,t,n=[],s=""){this.data=e,this.name=s,se.prototype.hasOwnProperty("tree")||Object.defineProperty(se.prototype,"tree",{get(){return $e(this)}}),this.parser=t,this.extension=[Si.of(this),se.languageData.of((r,o,l)=>{let a=Kc(r,o,l),u=a.type.prop(Zi);if(!u)return[];let c=r.facet(u),h=a.type.prop(lw);if(h){let d=a.resolve(o-a.from,l);for(let p of h)if(p.test(d,r)){let g=r.facet(p.facet);return p.type=="replace"?g:g.concat(c)}}return c})].concat(n)}isActiveAt(e,t,n=-1){return Kc(e,t,n).type.prop(Zi)==this.data}findRegions(e){let t=e.facet(Si);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],s=(r,o)=>{if(r.prop(Zi)==this.data){n.push({from:o,to:o+r.length});return}let l=r.prop(te.mounted);if(l){if(l.tree.prop(Zi)==this.data){if(l.overlay)for(let a of l.overlay)n.push({from:a.from+o,to:a.to+o});else n.push({from:o,to:o+r.length});return}else if(l.overlay){let a=n.length;if(s(l.tree,l.overlay[0].from+o),n.length>a)return}}for(let a=0;a<r.children.length;a++){let u=r.children[a];u instanceof Re&&s(u,r.positions[a]+o)}};return s($e(e),0),n}get allowsNesting(){return!0}}yt.setState=J.define();function Kc(i,e,t){let n=i.facet(Si),s=$e(i).topNode;if(!n||n.allowsNesting)for(let r=s;r;r=r.enter(e,t,Ie.ExcludeBuffers))r.type.isTop&&(s=r);return s}class Tr extends yt{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=ow(e.languageData);return new Tr(t,e.parser.configure({props:[Zi.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new Tr(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function $e(i){let e=i.field(yt.state,!1);return e?e.tree:Re.empty}class aw{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let Mn=null;class Mr{constructor(e,t,n=[],s,r,o,l,a){this.parser=e,this.state=t,this.fragments=n,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Mr(e,t,[],Re.empty,0,n,[],null)}startParse(){return this.parser.startParse(new aw(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Re.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(Di.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Di.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Mn;Mn=this;try{return e()}finally{Mn=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Yc(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((u,c,h,d)=>a.push({fromA:u,toA:c,fromB:h,toB:d})),n=Di.applyChanges(n,a),s=Re.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let c=e.mapPos(u.from,1),h=e.mapPos(u.to,-1);c<h&&l.push({from:c,to:h})}}}return new Mr(this.parser,t,n,s,r,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:s,to:r}=this.skipped[n];s<e.to&&r>e.from&&(this.fragments=Yc(this.fragments,s,r),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends lf{createParse(t,n,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=Mn;if(a){for(let u of s)a.tempSkipped.push(u);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Re(tt.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Mn}}function Yc(i,e,t){return Di.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}class xn{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new xn(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Mr.create(e.facet(Si).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new xn(n)}}yt.state=Fe.define({create:xn.init,update(i,e){for(let t of e.effects)if(t.is(yt.setState))return t.value;return e.startState.facet(Si)!=e.state.facet(Si)?xn.init(e.state):i.apply(e)}});let Bp=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Bp=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Qo=typeof navigator<"u"&&(!((Xo=navigator.scheduling)===null||Xo===void 0)&&Xo.isInputPending)?()=>navigator.scheduling.isInputPending():null,uw=Ce.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(yt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(yt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Bp(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:s}}=this.view,r=n.field(yt.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Qo?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<s&&n.doc.length>s+1e3,a=r.context.work(()=>Qo&&Qo()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:yt.setState.of(new xn(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Je(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Si=$.define({combine(i){return i.length?i[0]:null},enables:i=>[yt.state,uw,_.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});class cw{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const hw=$.define(),so=$.define({combine:i=>{if(!i.length)return" ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function Or(i){let e=i.facet(so);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function ss(i,e){let t="",n=i.tabSize,s=i.facet(so)[0];if(s==" "){for(;e>=n;)t+=" ",e-=n;s=" "}for(let r=0;r<e;r++)t+=s;return t}function iu(i,e){i instanceof se&&(i=new ro(i));for(let n of i.state.facet(hw)){let s=n(i,e);if(s!==void 0)return s}let t=$e(i.state);return t.length>=e?dw(i,t,e):null}class ro{constructor(e,t={}){this.state=e,this.options=t,this.unit=Or(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=n.from&&s<=n.to?r&&s==e?{text:"",from:e}:(t<0?s<e:s<=e)?{text:n.text.slice(s-n.from),from:s}:{text:n.text.slice(0,s-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:s}=this.lineAt(e,t);return n.slice(e-s,Math.min(n.length,e+100-s))}column(e,t=1){let{text:n,from:s}=this.lineAt(e,t),r=this.countColumn(n,e-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(r+=o-this.countColumn(n,n.search(/\S|$/))),r}countColumn(e,t=e.length){return vn(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Vp=new te;function dw(i,e,t){let n=e.resolveStack(t),s=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(s!=n.node){let r=[];for(let o=s;o&&!(o.from<n.node.from||o.to>n.node.to||o.from==n.node.from&&o.type==n.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)n={node:r[o],next:n}}return _p(n,i,t)}function _p(i,e,t){for(let n=i;n;n=n.next){let s=pw(n.node);if(s)return s(nu.create(e,t,n))}return 0}function fw(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function pw(i){let e=i.type.prop(Vp);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(te.closedBy))){let s=i.lastChild,r=s&&n.indexOf(s.name)>-1;return o=>yw(o,!0,1,void 0,r&&!fw(o)?s.from:void 0)}return i.parent==null?gw:null}function gw(){return 0}class nu extends ro{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new nu(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(mw(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return _p(this.context.next,this.base,this.pos)}}function mw(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function xw(i){let e=i.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let s=i.options.simulateBreak,r=i.state.doc.lineAt(t.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==n)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let u=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+u}}l=a.to}}function yw(i,e,t,n,s){let r=i.textAfter,o=r.match(/^\s*/)[0].length,l=n&&r.slice(o,o+n.length)==n||s==i.pos+o,a=xw(i);return a?l?i.column(a.from):i.column(a.to):i.baseIndent+(l?0:i.unit*t)}function Xc({except:i,units:e=1}={}){return t=>{let n=i&&i.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}const bw=200;function vw(){return se.transactionFilter.of(i=>{if(!i.docChanged||!i.isUserEvent("input.type")&&!i.isUserEvent("input.complete"))return i;let e=i.startState.languageDataAt("indentOnInput",i.startState.selection.main.head);if(!e.length)return i;let t=i.newDoc,{head:n}=i.newSelection.main,s=t.lineAt(n);if(n>s.from+bw)return i;let r=t.sliceString(s.from,n);if(!e.some(u=>u.test(r)))return i;let{state:o}=i,l=-1,a=[];for(let{head:u}of o.selection.ranges){let c=o.doc.lineAt(u);if(c.from==l)continue;l=c.from;let h=iu(o,c.from);if(h==null)continue;let d=/^\s*/.exec(c.text)[0],p=ss(o,h);d!=p&&a.push({from:c.from,to:c.from+d.length,insert:p})}return a.length?[i,{changes:a,sequential:!0}]:i})}const Sw=$.define(),zp=new te;function Cw(i){let e=i.firstChild,t=i.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?i.to:t.from}:null}function ww(i,e,t){let n=$e(i);if(n.length<t)return null;let s=n.resolveStack(t,1),r=null;for(let o=s;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(r&&l.from<e)break;let a=l.type.prop(zp);if(a&&(l.to<n.length-50||n.length==i.doc.length||!Ew(l))){let u=a(l,i);u&&u.from<=t&&u.from>=e&&u.to>t&&(r=u)}}return r}function Ew(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function Ir(i,e,t){for(let n of i.facet(Sw)){let s=n(i,e,t);if(s)return s}return ww(i,e,t)}function $p(i,e){let t=e.mapPos(i.from,1),n=e.mapPos(i.to,-1);return t>=n?void 0:{from:t,to:n}}const oo=J.define({map:$p}),gs=J.define({map:$p});function Hp(i){let e=[];for(let{head:t}of i.state.selection.ranges)e.some(n=>n.from<=t&&n.to>=t)||e.push(i.lineBlockAt(t));return e}const _i=Fe.define({create(){return K.none},update(i,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((t,n)=>i=Qc(i,t,n)),i=i.map(e.changes);for(let t of e.effects)if(t.is(oo)&&!Rw(i,t.value.from,t.value.to)){let{preparePlaceholder:n}=e.state.facet(Up),s=n?K.replace({widget:new jw(n(e.state,t.value))}):Jc;i=i.update({add:[s.range(t.value.from,t.value.to)]})}else t.is(gs)&&(i=i.update({filter:(n,s)=>t.value.from!=n||t.value.to!=s,filterFrom:t.value.from,filterTo:t.value.to}));return e.selection&&(i=Qc(i,e.selection.main.head)),i},provide:i=>_.decorations.from(i),toJSON(i,e){let t=[];return i.between(0,e.doc.length,(n,s)=>{t.push(n,s)}),t},fromJSON(i){if(!Array.isArray(i)||i.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<i.length;){let n=i[t++],s=i[t++];if(typeof n!="number"||typeof s!="number")throw new RangeError("Invalid JSON for fold state");e.push(Jc.range(n,s))}return K.set(e,!0)}});function Qc(i,e,t=e){let n=!1;return i.between(e,t,(s,r)=>{s<t&&r>e&&(n=!0)}),n?i.update({filterFrom:e,filterTo:t,filter:(s,r)=>s>=t||r<=e}):i}function jr(i,e,t){var n;let s=null;return(n=i.field(_i,!1))===null||n===void 0||n.between(e,t,(r,o)=>{(!s||s.from>r)&&(s={from:r,to:o})}),s}function Rw(i,e,t){let n=!1;return i.between(e,e,(s,r)=>{s==e&&r==t&&(n=!0)}),n}function Gp(i,e){return i.field(_i,!1)?e:e.concat(J.appendConfig.of(qp()))}const kw=i=>{for(let e of Hp(i)){let t=Ir(i.state,e.from,e.to);if(t)return i.dispatch({effects:Gp(i.state,[oo.of(t),Wp(i,t)])}),!0}return!1},Aw=i=>{if(!i.state.field(_i,!1))return!1;let e=[];for(let t of Hp(i)){let n=jr(i.state,t.from,t.to);n&&e.push(gs.of(n),Wp(i,n,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function Wp(i,e,t=!0){let n=i.state.doc.lineAt(e.from).number,s=i.state.doc.lineAt(e.to).number;return _.announce.of(`${i.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${i.state.phrase("to")} ${s}.`)}const Tw=i=>{let{state:e}=i,t=[];for(let n=0;n<e.doc.length;){let s=i.lineBlockAt(n),r=Ir(e,s.from,s.to);r&&t.push(oo.of(r)),n=(r?i.lineBlockAt(r.to):s).to+1}return t.length&&i.dispatch({effects:Gp(i.state,t)}),!!t.length},Mw=i=>{let e=i.state.field(_i,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,i.state.doc.length,(n,s)=>{t.push(gs.of({from:n,to:s}))}),i.dispatch({effects:t}),!0},Ow=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:kw},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Aw},{key:"Ctrl-Alt-[",run:Tw},{key:"Ctrl-Alt-]",run:Mw}],Iw={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Up=$.define({combine(i){return Ht(i,Iw)}});function qp(i){return[_i,Lw]}function Kp(i,e){let{state:t}=i,n=t.facet(Up),s=o=>{let l=i.lineBlockAt(i.posAtDOM(o.target)),a=jr(i.state,l.from,l.to);a&&i.dispatch({effects:gs.of(a)}),o.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(i,s,e);let r=document.createElement("span");return r.textContent=n.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const Jc=K.replace({widget:new class extends ii{toDOM(i){return Kp(i,null)}}});class jw extends ii{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Kp(e,this.value)}}const Pw={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Jo extends ti{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function Dw(i={}){let e={...Pw,...i},t=new Jo(e,!0),n=new Jo(e,!1),s=Ce.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Si)!=o.state.facet(Si)||o.startState.field(_i,!1)!=o.state.field(_i,!1)||$e(o.startState)!=$e(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new Zt;for(let a of o.viewportLineBlocks){let u=jr(o.state,a.from,a.to)?n:Ir(o.state,a.from,a.to)?t:null;u&&l.add(a.from,a.from,u)}return l.finish()}}),{domEventHandlers:r}=e;return[s,Y1({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(s))===null||l===void 0?void 0:l.markers)||re.empty},initialSpacer(){return new Jo(e,!1)},domEventHandlers:{...r,click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let u=jr(o.state,l.from,l.to);if(u)return o.dispatch({effects:gs.of(u)}),!0;let c=Ir(o.state,l.from,l.to);return c?(o.dispatch({effects:oo.of(c)}),!0):!1}}}),qp()]}const Lw=_.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class ms{constructor(e,t){this.specs=e;let n;function s(l){let a=yi.newName();return(n||(n=Object.create(null)))["."+a]=l,a}const r=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,o=t.scope;this.scope=o instanceof yt?l=>l.prop(Zi)==o.data:o?l=>l==o:void 0,this.style=cf(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=n?new yi(n):null,this.themeType=t.themeType}static define(e,t){return new ms(e,t||{})}}const ra=$.define(),Yp=$.define({combine(i){return i.length?[i[0]]:null}});function Zo(i){let e=i.facet(ra);return e.length?e:i.facet(Yp)}function Xp(i,e){let t=[Nw],n;return i instanceof ms&&(i.module&&t.push(_.styleModule.of(i.module)),n=i.themeType),e!=null&&e.fallback?t.push(Yp.of(i)):n?t.push(ra.computeN([_.darkTheme],s=>s.facet(_.darkTheme)==(n=="dark")?[i]:[])):t.push(ra.of(i)),t}class Fw{constructor(e){this.markCache=Object.create(null),this.tree=$e(e.state),this.decorations=this.buildDeco(e,Zo(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=$e(e.state),n=Zo(e.state),s=n!=Zo(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!s&&t.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return K.none;let n=new Zt;for(let{from:s,to:r}of e.visibleRanges)eS(this.tree,t,(o,l,a)=>{n.add(o,l,this.markCache[a]||(this.markCache[a]=K.mark({class:a})))},s,r);return n.finish()}}const Nw=$i.high(Ce.fromClass(Fw,{decorations:i=>i.decorations})),Bw=ms.define([{tag:k.meta,color:"#404740"},{tag:k.link,textDecoration:"underline"},{tag:k.heading,textDecoration:"underline",fontWeight:"bold"},{tag:k.emphasis,fontStyle:"italic"},{tag:k.strong,fontWeight:"bold"},{tag:k.strikethrough,textDecoration:"line-through"},{tag:k.keyword,color:"#708"},{tag:[k.atom,k.bool,k.url,k.contentSeparator,k.labelName],color:"#219"},{tag:[k.literal,k.inserted],color:"#164"},{tag:[k.string,k.deleted],color:"#a11"},{tag:[k.regexp,k.escape,k.special(k.string)],color:"#e40"},{tag:k.definition(k.variableName),color:"#00f"},{tag:k.local(k.variableName),color:"#30a"},{tag:[k.typeName,k.namespace],color:"#085"},{tag:k.className,color:"#167"},{tag:[k.special(k.variableName),k.macroName],color:"#256"},{tag:k.definition(k.propertyName),color:"#00c"},{tag:k.comment,color:"#940"},{tag:k.invalid,color:"#f00"}]),Vw=_.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Qp=1e4,Jp="()[]{}",Zp=$.define({combine(i){return Ht(i,{afterCursor:!0,brackets:Jp,maxScanDistance:Qp,renderMatch:$w})}}),_w=K.mark({class:"cm-matchingBracket"}),zw=K.mark({class:"cm-nonmatchingBracket"});function $w(i){let e=[],t=i.matched?_w:zw;return e.push(t.range(i.start.from,i.start.to)),i.end&&e.push(t.range(i.end.from,i.end.to)),e}const Hw=Fe.define({create(){return K.none},update(i,e){if(!e.docChanged&&!e.selection)return i;let t=[],n=e.state.facet(Zp);for(let s of e.state.selection.ranges){if(!s.empty)continue;let r=Lt(e.state,s.head,-1,n)||s.head>0&&Lt(e.state,s.head-1,1,n)||n.afterCursor&&(Lt(e.state,s.head,1,n)||s.head<e.state.doc.length&&Lt(e.state,s.head+1,-1,n));r&&(t=t.concat(n.renderMatch(r,e.state)))}return K.set(t,!0)},provide:i=>_.decorations.from(i)}),Gw=[Hw,Vw];function Ww(i={}){return[Zp.of(i),Gw]}const Uw=new te;function oa(i,e,t){let n=i.prop(e<0?te.openedBy:te.closedBy);if(n)return n;if(i.name.length==1){let s=t.indexOf(i.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function la(i){let e=i.type.prop(Uw);return e?e(i.node):i}function Lt(i,e,t,n={}){let s=n.maxScanDistance||Qp,r=n.brackets||Jp,o=$e(i),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let u=oa(a.type,t,r);if(u&&a.from<a.to){let c=la(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return qw(i,e,t,a,c,u,r)}}return Kw(i,e,t,o,l.type,s,r)}function qw(i,e,t,n,s,r,o){let l=n.parent,a={from:s.from,to:s.to},u=0,c=l==null?void 0:l.cursor();if(c&&(t<0?c.childBefore(n.from):c.childAfter(n.to)))do if(t<0?c.to<=n.from:c.from>=n.to){if(u==0&&r.indexOf(c.type.name)>-1&&c.from<c.to){let h=la(c);return{start:a,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}else if(oa(c.type,t,o))u++;else if(oa(c.type,-t,o)){if(u==0){let h=la(c);return{start:a,end:h&&h.from<h.to?{from:h.from,to:h.to}:void 0,matched:!1}}u--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function Kw(i,e,t,n,s,r,o){let l=t<0?i.sliceDoc(e-1,e):i.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let u={from:t<0?e-1:e,to:t>0?e+1:e},c=i.doc.iterRange(e,t>0?i.doc.length:0),h=0;for(let d=0;!c.next().done&&d<=r;){let p=c.value;t<0&&(d+=p.length);let g=e+d*t;for(let m=t>0?0:p.length-1,x=t>0?p.length:-1;m!=x;m+=t){let y=o.indexOf(p[m]);if(!(y<0||n.resolveInner(g+m,1).type!=s))if(y%2==0==t>0)h++;else{if(h==1)return{start:u,end:{from:g+m,to:g+m+1},matched:y>>1==a>>1};h--}}t>0&&(d+=p.length)}return c.done?{start:u,matched:!1}:null}const Yw=Object.create(null),Zc=[tt.none],eh=[],th=Object.create(null),Xw=Object.create(null);for(let[i,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Xw[i]=Qw(Yw,e);function el(i,e){eh.indexOf(i)>-1||(eh.push(i),console.warn(e))}function Qw(i,e){let t=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let c=i[u]||k[u];c?typeof c=="function"?a.length?a=a.map(c):el(u,`Modifier ${u} used at start of tag`):a.length?el(u,`Tag ${u} used as modifier`):a=Array.isArray(c)?c:[c]:el(u,`Unknown highlighting tag ${u}`)}for(let u of a)t.push(u)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+t.map(l=>l.id),r=th[s];if(r)return r.id;let o=th[s]=tt.define({id:Zc.length,name:n,props:[af({[n]:t})]});return Zc.push(o),o.id}xe.RTL,xe.LTR;const Jw=Tr.define({name:"json",parser:sS.configure({props:[Vp.add({Object:Xc({except:/^\s*\}/}),Array:Xc({except:/^\s*\]/})}),zp.add({"Object Array":Cw})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function Zw(){return new cw(Jw)}const eE=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=ru(i.state,t.from);return n.line?tE(i):n.block?nE(i):!1};function su(i,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let s=i(e,t);return s?(n(t.update(s)),!0):!1}}const tE=su(oE,0),iE=su(eg,0),nE=su((i,e)=>eg(i,e,rE(e)),0);function ru(i,e){let t=i.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const On=50;function sE(i,{open:e,close:t},n,s){let r=i.sliceDoc(n-On,n),o=i.sliceDoc(s,s+On),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,u=r.length-l;if(r.slice(u-e.length,u)==e&&o.slice(a,a+t.length)==t)return{open:{pos:n-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let c,h;s-n<=2*On?c=h=i.sliceDoc(n,s):(c=i.sliceDoc(n,n+On),h=i.sliceDoc(s-On,s));let d=/^\s*/.exec(c)[0].length,p=/\s*$/.exec(h)[0].length,g=h.length-p-t.length;return c.slice(d,d+e.length)==e&&h.slice(g,g+t.length)==t?{open:{pos:n+d+e.length,margin:/\s/.test(c.charAt(d+e.length))?1:0},close:{pos:s-p-t.length,margin:/\s/.test(h.charAt(g-1))?1:0}}:null}function rE(i){let e=[];for(let t of i.selection.ranges){let n=i.doc.lineAt(t.from),s=t.to<=n.to?n:i.doc.lineAt(t.to);s.from>n.from&&s.from==t.to&&(s=t.to==n.to+1?n:i.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>n.from?e[r].to=s.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:s.to})}return e}function eg(i,e,t=e.selection.ranges){let n=t.map(r=>ru(e,r.from).block);if(!n.every(r=>r))return null;let s=t.map((r,o)=>sE(e,n[o],r.from,r.to));if(i!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:n[o].open+" "},{from:r.to,insert:" "+n[o].close}]))};if(i!=1&&s.some(r=>r)){let r=[];for(let o=0,l;o<s.length;o++)if(l=s[o]){let a=n[o],{open:u,close:c}=l;r.push({from:u.pos-a.open.length,to:u.pos+u.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:r}}return null}function oE(i,e,t=e.selection.ranges){let n=[],s=-1;for(let{from:r,to:o}of t){let l=n.length,a=1e9,u=ru(e,r).line;if(u){for(let c=r;c<=o;){let h=e.doc.lineAt(c);if(h.from>s&&(r==o||o>h.from)){s=h.from;let d=/^\s*/.exec(h.text)[0].length,p=d==h.length,g=h.text.slice(d,d+u.length)==u?d:-1;d<h.text.length&&d<a&&(a=d),n.push({line:h,comment:g,token:u,indent:d,empty:p,single:!1})}c=h.to+1}if(a<1e9)for(let c=l;c<n.length;c++)n[c].indent<n[c].line.text.length&&(n[c].indent=a);n.length==l+1&&(n[l].single=!0)}}if(i!=2&&n.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:u,empty:c,single:h}of n)(h||!c)&&r.push({from:l.from+u,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(i!=1&&n.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of n)if(l>=0){let u=o.from+l,c=u+a.length;o.text[c-o.from]==" "&&c++,r.push({from:u,to:c})}return{changes:r}}return null}const aa=$t.define(),lE=$t.define(),aE=$.define(),tg=$.define({combine(i){return Ht(i,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,s)=>e(n,s)||t(n,s)})}}),ig=Fe.define({create(){return Ft.empty},update(i,e){let t=e.state.facet(tg),n=e.annotation(aa);if(n){let a=Ze.fromTransaction(e,n.selection),u=n.side,c=u==0?i.undone:i.done;return a?c=Pr(c,c.length,t.minDepth,a):c=rg(c,e.startState.selection),new Ft(u==0?n.rest:c,u==0?c:n.rest)}let s=e.annotation(lE);if((s=="full"||s=="before")&&(i=i.isolate()),e.annotation(Te.addToHistory)===!1)return e.changes.empty?i:i.addMapping(e.changes.desc);let r=Ze.fromTransaction(e),o=e.annotation(Te.time),l=e.annotation(Te.userEvent);return r?i=i.addChanges(r,o,l,t,e):e.selection&&(i=i.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(s=="full"||s=="after")&&(i=i.isolate()),i},toJSON(i){return{done:i.done.map(e=>e.toJSON()),undone:i.undone.map(e=>e.toJSON())}},fromJSON(i){return new Ft(i.done.map(Ze.fromJSON),i.undone.map(Ze.fromJSON))}});function uE(i={}){return[ig,tg.of(i),_.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?ng:e.inputType=="historyRedo"?ua:null;return n?(e.preventDefault(),n(t)):!1}})]}function lo(i,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let s=t.field(ig,!1);if(!s)return!1;let r=s.pop(i,t,e);return r?(n(r),!0):!1}}const ng=lo(0,!1),ua=lo(1,!1),cE=lo(0,!0),hE=lo(1,!0);class Ze{constructor(e,t,n,s,r){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new Ze(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new Ze(e.changes&&Ae.fromJSON(e.changes),[],e.mapped&&Bt.fromJSON(e.mapped),e.startSelection&&T.fromJSON(e.startSelection),e.selectionsAfter.map(T.fromJSON))}static fromTransaction(e,t){let n=ht;for(let s of e.startState.facet(aE)){let r=s(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new Ze(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,ht)}static selection(e){return new Ze(void 0,ht,void 0,void 0,e)}}function Pr(i,e,t,n){let s=e+1>t+20?e-t-1:0,r=i.slice(s,e);return r.push(n),r}function dE(i,e){let t=[],n=!1;return i.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,l)=>{for(let a=0;a<t.length;){let u=t[a++],c=t[a++];l>=u&&o<=c&&(n=!0)}}),n}function fE(i,e){return i.ranges.length==e.ranges.length&&i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function sg(i,e){return i.length?e.length?i.concat(e):i:e}const ht=[],pE=200;function rg(i,e){if(i.length){let t=i[i.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-pE));return n.length&&n[n.length-1].eq(e)?i:(n.push(e),Pr(i,i.length-1,1e9,t.setSelAfter(n)))}else return[Ze.selection([e])]}function gE(i){let e=i[i.length-1],t=i.slice();return t[i.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function tl(i,e){if(!i.length)return i;let t=i.length,n=ht;for(;t;){let s=mE(i[t-1],e,n);if(s.changes&&!s.changes.empty||s.effects.length){let r=i.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,n=s.selectionsAfter}return n.length?[Ze.selection(n)]:ht}function mE(i,e,t){let n=sg(i.selectionsAfter.length?i.selectionsAfter.map(l=>l.map(e)):ht,t);if(!i.changes)return Ze.selection(n);let s=i.changes.map(e),r=e.mapDesc(i.changes,!0),o=i.mapped?i.mapped.composeDesc(r):r;return new Ze(s,J.mapEffects(i.effects,e),o,i.startSelection.map(r),n)}const xE=/^(input\.type|delete)($|\.)/;class Ft{constructor(e,t,n=0,s=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=s}isolate(){return this.prevTime?new Ft(this.done,this.undone):this}addChanges(e,t,n,s,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!n||xE.test(n))&&(!l.selectionsAfter.length&&t-this.prevTime<s.newGroupDelay&&s.joinToEvent(r,dE(l.changes,e.changes))||n=="input.type.compose")?o=Pr(o,o.length-1,s.minDepth,new Ze(e.changes.compose(l.changes),sg(J.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,ht)):o=Pr(o,o.length,s.minDepth,e),new Ft(o,ht,t,n)}addSelection(e,t,n,s){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:ht;return r.length>0&&t-this.prevTime<s&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&fE(r[r.length-1],e)?this:new Ft(rg(this.done,e),this.undone,t,n)}addMapping(e){return new Ft(tl(this.done,e),tl(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let s=e==0?this.done:this.undone;if(s.length==0)return null;let r=s[s.length-1],o=r.selectionsAfter[0]||t.selection;if(n&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:aa.of({side:e,rest:gE(s),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=s.length==1?ht:s.slice(0,s.length-1);return r.mapped&&(l=tl(l,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:aa.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}Ft.empty=new Ft(ht,ht);const yE=[{key:"Mod-z",run:ng,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:ua,preventDefault:!0},{linux:"Ctrl-Shift-z",run:ua,preventDefault:!0},{key:"Mod-u",run:cE,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:hE,preventDefault:!0}];function Sn(i,e){return T.create(i.ranges.map(e),i.mainIndex)}function wt(i,e){return i.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Et({state:i,dispatch:e},t){let n=Sn(i.selection,t);return n.eq(i.selection,!0)?!1:(e(wt(i,n)),!0)}function ao(i,e){return T.cursor(e?i.to:i.from)}function og(i,e){return Et(i,t=>t.empty?i.moveByChar(t,e):ao(t,e))}function He(i){return i.textDirectionAt(i.state.selection.main.head)==xe.LTR}const lg=i=>og(i,!He(i)),ag=i=>og(i,He(i));function ug(i,e){return Et(i,t=>t.empty?i.moveByGroup(t,e):ao(t,e))}const bE=i=>ug(i,!He(i)),vE=i=>ug(i,He(i));function SE(i,e,t){if(e.type.prop(t))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(i.sliceDoc(e.from,e.to)))||e.firstChild}function uo(i,e,t){let n=$e(i).resolveInner(e.head),s=t?te.closedBy:te.openedBy;for(let a=e.head;;){let u=t?n.childAfter(a):n.childBefore(a);if(!u)break;SE(i,u,s)?n=u:a=t?u.to:u.from}let r=n.type.prop(s),o,l;return r&&(o=t?Lt(i,n.from,1):Lt(i,n.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?n.to:n.from,T.cursor(l,t?-1:1)}const CE=i=>Et(i,e=>uo(i.state,e,!He(i))),wE=i=>Et(i,e=>uo(i.state,e,He(i)));function cg(i,e){return Et(i,t=>{if(!t.empty)return ao(t,e);let n=i.moveVertically(t,e);return n.head!=t.head?n:i.moveToLineBoundary(t,e)})}const hg=i=>cg(i,!1),dg=i=>cg(i,!0);function fg(i){let e=i.scrollDOM.clientHeight<i.scrollDOM.scrollHeight-2,t=0,n=0,s;if(e){for(let r of i.state.facet(_.scrollMargins)){let o=r(i);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(n=Math.max(o==null?void 0:o.bottom,n))}s=i.scrollDOM.clientHeight-t-n}else s=(i.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:n,selfScroll:e,height:Math.max(i.defaultLineHeight,s-5)}}function pg(i,e){let t=fg(i),{state:n}=i,s=Sn(n.selection,o=>o.empty?i.moveVertically(o,e,t.height):ao(o,e));if(s.eq(n.selection))return!1;let r;if(t.selfScroll){let o=i.coordsAtPos(n.selection.main.head),l=i.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,u=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<u&&(r=_.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-a}))}return i.dispatch(wt(n,s),{effects:r}),!0}const ih=i=>pg(i,!1),ca=i=>pg(i,!0);function Ci(i,e,t){let n=i.lineBlockAt(e.head),s=i.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?n.to:n.from)&&(s=i.moveToLineBoundary(e,t,!1)),!t&&s.head==n.from&&n.length){let r=/^\s*/.exec(i.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;r&&e.head!=n.from+r&&(s=T.cursor(n.from+r))}return s}const EE=i=>Et(i,e=>Ci(i,e,!0)),RE=i=>Et(i,e=>Ci(i,e,!1)),kE=i=>Et(i,e=>Ci(i,e,!He(i))),AE=i=>Et(i,e=>Ci(i,e,He(i))),TE=i=>Et(i,e=>T.cursor(i.lineBlockAt(e.head).from,1)),ME=i=>Et(i,e=>T.cursor(i.lineBlockAt(e.head).to,-1));function OE(i,e,t){let n=!1,s=Sn(i.selection,r=>{let o=Lt(i,r.head,-1)||Lt(i,r.head,1)||r.head>0&&Lt(i,r.head-1,1)||r.head<i.doc.length&&Lt(i,r.head+1,-1);if(!o||!o.end)return r;n=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return T.cursor(l)});return n?(e(wt(i,s)),!0):!1}const IE=({state:i,dispatch:e})=>OE(i,e);function mt(i,e){let t=Sn(i.state.selection,n=>{let s=e(n);return T.range(n.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return t.eq(i.state.selection)?!1:(i.dispatch(wt(i.state,t)),!0)}function gg(i,e){return mt(i,t=>i.moveByChar(t,e))}const mg=i=>gg(i,!He(i)),xg=i=>gg(i,He(i));function yg(i,e){return mt(i,t=>i.moveByGroup(t,e))}const jE=i=>yg(i,!He(i)),PE=i=>yg(i,He(i)),DE=i=>mt(i,e=>uo(i.state,e,!He(i))),LE=i=>mt(i,e=>uo(i.state,e,He(i)));function bg(i,e){return mt(i,t=>i.moveVertically(t,e))}const vg=i=>bg(i,!1),Sg=i=>bg(i,!0);function Cg(i,e){return mt(i,t=>i.moveVertically(t,e,fg(i).height))}const nh=i=>Cg(i,!1),sh=i=>Cg(i,!0),FE=i=>mt(i,e=>Ci(i,e,!0)),NE=i=>mt(i,e=>Ci(i,e,!1)),BE=i=>mt(i,e=>Ci(i,e,!He(i))),VE=i=>mt(i,e=>Ci(i,e,He(i))),_E=i=>mt(i,e=>T.cursor(i.lineBlockAt(e.head).from)),zE=i=>mt(i,e=>T.cursor(i.lineBlockAt(e.head).to)),rh=({state:i,dispatch:e})=>(e(wt(i,{anchor:0})),!0),oh=({state:i,dispatch:e})=>(e(wt(i,{anchor:i.doc.length})),!0),lh=({state:i,dispatch:e})=>(e(wt(i,{anchor:i.selection.main.anchor,head:0})),!0),ah=({state:i,dispatch:e})=>(e(wt(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),$E=({state:i,dispatch:e})=>(e(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),HE=({state:i,dispatch:e})=>{let t=co(i).map(({from:n,to:s})=>T.range(n,Math.min(s+1,i.doc.length)));return e(i.update({selection:T.create(t),userEvent:"select"})),!0},GE=({state:i,dispatch:e})=>{let t=Sn(i.selection,n=>{let s=$e(i),r=s.resolveStack(n.from,1);if(n.empty){let o=s.resolveStack(n.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:l}=o;if((l.from<n.from&&l.to>=n.to||l.to>n.to&&l.from<=n.from)&&o.next)return T.range(l.to,l.from)}return n});return t.eq(i.selection)?!1:(e(wt(i,t)),!0)};function wg(i,e){let{state:t}=i,n=t.selection,s=t.selection.ranges.slice();for(let r of t.selection.ranges){let o=t.doc.lineAt(r.head);if(e?o.to<i.state.doc.length:o.from>0)for(let l=r;;){let a=i.moveVertically(l,e);if(a.head<o.from||a.head>o.to){s.some(u=>u.head==a.head)||s.push(a);break}else{if(a.head==l.head)break;l=a}}}return s.length==n.ranges.length?!1:(i.dispatch(wt(t,T.create(s,s.length-1))),!0)}const WE=i=>wg(i,!1),UE=i=>wg(i,!0),qE=({state:i,dispatch:e})=>{let t=i.selection,n=null;return t.ranges.length>1?n=T.create([t.main]):t.main.empty||(n=T.create([T.cursor(t.main.head)])),n?(e(wt(i,n)),!0):!1};function xs(i,e){if(i.state.readOnly)return!1;let t="delete.selection",{state:n}=i,s=n.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);a<o?(t="delete.backward",a=Ws(i,a,!1)):a>o&&(t="delete.forward",a=Ws(i,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Ws(i,o,!1),l=Ws(i,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:T.cursor(o,o<r.head?-1:1)}});return s.changes.empty?!1:(i.dispatch(n.update(s,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?_.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function Ws(i,e,t){if(i instanceof _)for(let n of i.state.facet(_.atomicRanges).map(s=>s(i)))n.between(e,e,(s,r)=>{s<e&&r>e&&(e=t?r:s)});return e}const Eg=(i,e,t)=>xs(i,n=>{let s=n.from,{state:r}=i,o=r.doc.lineAt(s),l,a;if(t&&!e&&s>o.from&&s<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,s-o.from))){if(l[l.length-1]==" ")return s-1;let u=vn(l,r.tabSize),c=u%Or(r)||Or(r);for(let h=0;h<c&&l[l.length-1-h]==" ";h++)s--;a=s}else a=Le(o.text,s-o.from,e,e)+o.from,a==s&&o.number!=(e?r.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,s-o.from))&&(a=Le(o.text,a-o.from,!1,!1)+o.from);return a}),ha=i=>Eg(i,!1,!0),Rg=i=>Eg(i,!0,!1),kg=(i,e)=>xs(i,t=>{let n=t.head,{state:s}=i,r=s.doc.lineAt(n),o=s.charCategorizer(n);for(let l=null;;){if(n==(e?r.to:r.from)){n==t.head&&r.number!=(e?s.doc.lines:1)&&(n+=e?1:-1);break}let a=Le(r.text,n-r.from,e)+r.from,u=r.text.slice(Math.min(n,a)-r.from,Math.max(n,a)-r.from),c=o(u);if(l!=null&&c!=l)break;(u!=" "||n!=t.head)&&(l=c),n=a}return n}),Ag=i=>kg(i,!1),KE=i=>kg(i,!0),YE=i=>xs(i,e=>{let t=i.lineBlockAt(e.head).to;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)}),XE=i=>xs(i,e=>{let t=i.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),QE=i=>xs(i,e=>{let t=i.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)}),JE=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:oe.of(["",""])},range:T.cursor(n.from)}));return e(i.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},ZE=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>{if(!n.empty||n.from==0||n.from==i.doc.length)return{range:n};let s=n.from,r=i.doc.lineAt(s),o=s==r.from?s-1:Le(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:Le(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:i.doc.slice(s,l).append(i.doc.slice(o,s))},range:T.cursor(l)}});return t.changes.empty?!1:(e(i.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function co(i){let e=[],t=-1;for(let n of i.selection.ranges){let s=i.doc.lineAt(n.from),r=i.doc.lineAt(n.to);if(!n.empty&&n.to==r.from&&(r=i.doc.lineAt(n.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(n)}else e.push({from:s.from,to:r.to,ranges:[n]});t=r.number+1}return e}function Tg(i,e,t){if(i.readOnly)return!1;let n=[],s=[];for(let r of co(i)){if(t?r.to==i.doc.length:r.from==0)continue;let o=i.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){n.push({from:r.to,to:o.to},{from:r.from,insert:o.text+i.lineBreak});for(let a of r.ranges)s.push(T.range(Math.min(i.doc.length,a.anchor+l),Math.min(i.doc.length,a.head+l)))}else{n.push({from:o.from,to:r.from},{from:r.to,insert:i.lineBreak+o.text});for(let a of r.ranges)s.push(T.range(a.anchor-l,a.head-l))}}return n.length?(e(i.update({changes:n,scrollIntoView:!0,selection:T.create(s,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}const eR=({state:i,dispatch:e})=>Tg(i,e,!1),tR=({state:i,dispatch:e})=>Tg(i,e,!0);function Mg(i,e,t){if(i.readOnly)return!1;let n=[];for(let s of co(i))t?n.push({from:s.from,insert:i.doc.slice(s.from,s.to)+i.lineBreak}):n.push({from:s.to,insert:i.lineBreak+i.doc.slice(s.from,s.to)});return e(i.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const iR=({state:i,dispatch:e})=>Mg(i,e,!1),nR=({state:i,dispatch:e})=>Mg(i,e,!0),sR=i=>{if(i.state.readOnly)return!1;let{state:e}=i,t=e.changes(co(e).map(({from:s,to:r})=>(s>0?s--:r<e.doc.length&&r++,{from:s,to:r}))),n=Sn(e.selection,s=>{let r;if(i.lineWrapping){let o=i.lineBlockAt(s.head),l=i.coordsAtPos(s.head,s.assoc||1);l&&(r=o.bottom+i.documentTop-l.bottom+i.defaultLineHeight/2)}return i.moveVertically(s,!0,r)}).map(t);return i.dispatch({changes:t,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function rR(i,e){if(/\(\)|\[\]|\{\}/.test(i.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=$e(i).resolveInner(e),n=t.childBefore(e),s=t.childAfter(e),r;return n&&s&&n.to<=e&&s.from>=e&&(r=n.type.prop(te.closedBy))&&r.indexOf(s.name)>-1&&i.doc.lineAt(n.to).from==i.doc.lineAt(s.from).from&&!/\S/.test(i.sliceDoc(n.to,s.from))?{from:n.to,to:s.from}:null}const uh=Og(!1),oR=Og(!0);function Og(i){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(s=>{let{from:r,to:o}=s,l=e.doc.lineAt(r),a=!i&&r==o&&rR(e,r);i&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new ro(e,{simulateBreak:r,simulateDoubleBreak:!!a}),c=iu(u,r);for(c==null&&(c=vn(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let h=["",ss(e,c)];return a&&h.push(ss(e,u.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:oe.of(h)},range:T.cursor(r+1+h[1].length)}});return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function ou(i,e){let t=-1;return i.changeByRange(n=>{let s=[];for(let o=n.from;o<=n.to;){let l=i.doc.lineAt(o);l.number>t&&(n.empty||n.to>l.from)&&(e(l,s,n),t=l.number),o=l.to+1}let r=i.changes(s);return{changes:s,range:T.range(r.mapPos(n.anchor,1),r.mapPos(n.head,1))}})}const lR=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=Object.create(null),n=new ro(i,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=ou(i,(r,o,l)=>{let a=iu(n,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let u=/^\s*/.exec(r.text)[0],c=ss(i,a);(u!=c||l.from<r.from+u.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+u.length,insert:c}))});return s.changes.empty||e(i.update(s,{userEvent:"indent"})),!0},Ig=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(ou(i,(t,n)=>{n.push({from:t.from,insert:i.facet(so)})}),{userEvent:"input.indent"})),!0),jg=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(ou(i,(t,n)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=vn(s,i.tabSize),o=0,l=ss(i,Math.max(0,r-Or(i)));for(;o<s.length&&o<l.length&&s.charCodeAt(o)==l.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+s.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),aR=i=>(i.setTabFocusMode(),!0),uR=[{key:"Ctrl-b",run:lg,shift:mg,preventDefault:!0},{key:"Ctrl-f",run:ag,shift:xg},{key:"Ctrl-p",run:hg,shift:vg},{key:"Ctrl-n",run:dg,shift:Sg},{key:"Ctrl-a",run:TE,shift:_E},{key:"Ctrl-e",run:ME,shift:zE},{key:"Ctrl-d",run:Rg},{key:"Ctrl-h",run:ha},{key:"Ctrl-k",run:YE},{key:"Ctrl-Alt-h",run:Ag},{key:"Ctrl-o",run:JE},{key:"Ctrl-t",run:ZE},{key:"Ctrl-v",run:ca}],cR=[{key:"ArrowLeft",run:lg,shift:mg,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:bE,shift:jE,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:kE,shift:BE,preventDefault:!0},{key:"ArrowRight",run:ag,shift:xg,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:vE,shift:PE,preventDefault:!0},{mac:"Cmd-ArrowRight",run:AE,shift:VE,preventDefault:!0},{key:"ArrowUp",run:hg,shift:vg,preventDefault:!0},{mac:"Cmd-ArrowUp",run:rh,shift:lh},{mac:"Ctrl-ArrowUp",run:ih,shift:nh},{key:"ArrowDown",run:dg,shift:Sg,preventDefault:!0},{mac:"Cmd-ArrowDown",run:oh,shift:ah},{mac:"Ctrl-ArrowDown",run:ca,shift:sh},{key:"PageUp",run:ih,shift:nh},{key:"PageDown",run:ca,shift:sh},{key:"Home",run:RE,shift:NE,preventDefault:!0},{key:"Mod-Home",run:rh,shift:lh},{key:"End",run:EE,shift:FE,preventDefault:!0},{key:"Mod-End",run:oh,shift:ah},{key:"Enter",run:uh,shift:uh},{key:"Mod-a",run:$E},{key:"Backspace",run:ha,shift:ha,preventDefault:!0},{key:"Delete",run:Rg,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Ag,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:KE,preventDefault:!0},{mac:"Mod-Backspace",run:XE,preventDefault:!0},{mac:"Mod-Delete",run:QE,preventDefault:!0}].concat(uR.map(i=>({mac:i.key,run:i.run,shift:i.shift}))),hR=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:CE,shift:DE},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:wE,shift:LE},{key:"Alt-ArrowUp",run:eR},{key:"Shift-Alt-ArrowUp",run:iR},{key:"Alt-ArrowDown",run:tR},{key:"Shift-Alt-ArrowDown",run:nR},{key:"Mod-Alt-ArrowUp",run:WE},{key:"Mod-Alt-ArrowDown",run:UE},{key:"Escape",run:qE},{key:"Mod-Enter",run:oR},{key:"Alt-l",mac:"Ctrl-l",run:HE},{key:"Mod-i",run:GE,preventDefault:!0},{key:"Mod-[",run:jg},{key:"Mod-]",run:Ig},{key:"Mod-Alt-\\",run:lR},{key:"Shift-Mod-k",run:sR},{key:"Shift-Mod-\\",run:IE},{key:"Mod-/",run:eE},{key:"Alt-A",run:iE},{key:"Ctrl-m",mac:"Shift-Alt-m",run:aR}].concat(cR),dR={key:"Tab",run:Ig,shift:jg},ch=typeof String.prototype.normalize=="function"?i=>i.normalize("NFKD"):i=>i;class yn{constructor(e,t,n=0,s=e.length,r,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,s),this.bufferStart=n,this.normalize=r?l=>r(ch(l)):ch,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Xe(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=za(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Pt(e);let s=this.normalize(t);if(s.length)for(let r=0,o=n;;r++){let l=s.charCodeAt(r),a=this.match(l,o,this.bufferPos+this.bufferStart);if(r==s.length-1){if(a)return this.value=a,this;break}o==n&&r<t.length&&t.charCodeAt(r)==l&&o++}}}match(e,t,n){let s=null;for(let r=0;r<this.matches.length;r+=2){let o=this.matches[r],l=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?s={from:this.matches[r+1],to:n}:(this.matches[r]++,l=!0)),l||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:t,to:n}:this.matches.push(1,t)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(yn.prototype[Symbol.iterator]=function(){return this});const Pg={from:-1,to:-1,match:/.*/.exec("")},lu="gm"+(/x/.unicode==null?"":"u");class Dg{constructor(e,t,n,s=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=Pg,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Lg(e,t,n,s,r);this.re=new RegExp(t,lu+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.iter=e.iter();let o=e.lineAt(s);this.curLineStart=o.from,this.matchPos=Dr(e,s),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,s=n+t[0].length;if(this.matchPos=Dr(this.text,s+(n==s?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<s||n>this.value.to)&&(!this.test||this.test(n,s,t)))return this.value={from:n,to:s,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const il=new WeakMap;class un{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let s=il.get(e);if(!s||s.from>=n||s.to<=t){let l=new un(t,e.sliceString(t,n));return il.set(e,l),l}if(s.from==t&&s.to==n)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.to<n&&(r+=e.sliceString(s.to,n)),il.set(e,new un(o,r)),new un(t,r.slice(t-o,n-o))}}class Lg{constructor(e,t,n,s,r){this.text=e,this.to=r,this.done=!1,this.value=Pg,this.matchPos=Dr(e,s),this.re=new RegExp(t,lu+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.flat=un.get(e,s,this.chunkEnd(s+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let n=this.flat.from+t.index,s=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,s,t)))return this.value={from:n,to:s,match:t},this.matchPos=Dr(this.text,s+(n==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=un.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Dg.prototype[Symbol.iterator]=Lg.prototype[Symbol.iterator]=function(){return this});function fR(i){try{return new RegExp(i,lu),!0}catch{return!1}}function Dr(i,e){if(e>=i.length)return e;let t=i.lineAt(e),n;for(;e<t.to&&(n=t.text.charCodeAt(e-t.from))>=56320&&n<57344;)e++;return e}function da(i){let e=String(i.state.doc.lineAt(i.state.selection.main.head).number),t=fe("input",{class:"cm-textfield",name:"line",value:e}),n=fe("form",{class:"cm-gotoLine",onkeydown:r=>{r.keyCode==27?(r.preventDefault(),i.dispatch({effects:Gn.of(!1)}),i.focus()):r.keyCode==13&&(r.preventDefault(),s())},onsubmit:r=>{r.preventDefault(),s()}},fe("label",i.state.phrase("Go to line"),": ",t)," ",fe("button",{class:"cm-button",type:"submit"},i.state.phrase("go")),fe("button",{name:"close",onclick:()=>{i.dispatch({effects:Gn.of(!1)}),i.focus()},"aria-label":i.state.phrase("close"),type:"button"},["×"]));function s(){let r=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!r)return;let{state:o}=i,l=o.doc.lineAt(o.selection.main.head),[,a,u,c,h]=r,d=c?+c.slice(1):0,p=u?+u:l.number;if(u&&h){let x=p/100;a&&(x=x*(a=="-"?-1:1)+l.number/o.doc.lines),p=Math.round(o.doc.lines*x)}else u&&a&&(p=p*(a=="-"?-1:1)+l.number);let g=o.doc.line(Math.max(1,Math.min(o.doc.lines,p))),m=T.cursor(g.from+Math.max(0,Math.min(d,g.length)));i.dispatch({effects:[Gn.of(!1),_.scrollIntoView(m.from,{y:"center"})],selection:m}),i.focus()}return{dom:n}}const Gn=J.define(),hh=Fe.define({create(){return!0},update(i,e){for(let t of e.effects)t.is(Gn)&&(i=t.value);return i},provide:i=>ns.from(i,e=>e?da:null)}),pR=i=>{let e=is(i,da);if(!e){let t=[Gn.of(!0)];i.state.field(hh,!1)==null&&t.push(J.appendConfig.of([hh,gR])),i.dispatch({effects:t}),e=is(i,da)}return e&&e.dom.querySelector("input").select(),!0},gR=_.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),mR={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},xR=$.define({combine(i){return Ht(i,mR,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function yR(i){return[wR,CR]}const bR=K.mark({class:"cm-selectionMatch"}),vR=K.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function dh(i,e,t,n){return(t==0||i(e.sliceDoc(t-1,t))!=ye.Word)&&(n==e.doc.length||i(e.sliceDoc(n,n+1))!=ye.Word)}function SR(i,e,t,n){return i(e.sliceDoc(t,t+1))==ye.Word&&i(e.sliceDoc(n-1,n))==ye.Word}const CR=Ce.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.selectionSet||i.docChanged||i.viewportChanged)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=i.state.facet(xR),{state:t}=i,n=t.selection;if(n.ranges.length>1)return K.none;let s=n.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return K.none;let a=t.wordAt(s.head);if(!a)return K.none;o=t.charCategorizer(s.head),r=t.sliceDoc(a.from,a.to)}else{let a=s.to-s.from;if(a<e.minSelectionLength||a>200)return K.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(dh(o,t,s.from,s.to)&&SR(o,t,s.from,s.to)))return K.none}else if(r=t.sliceDoc(s.from,s.to),!r)return K.none}let l=[];for(let a of i.visibleRanges){let u=new yn(t.doc,r,a.from,a.to);for(;!u.next().done;){let{from:c,to:h}=u.value;if((!o||dh(o,t,c,h))&&(s.empty&&c<=s.from&&h>=s.to?l.push(vR.range(c,h)):(c>=s.to||h<=s.from)&&l.push(bR.range(c,h)),l.length>e.maxMatches))return K.none}}return K.set(l)}},{decorations:i=>i.decorations}),wR=_.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),ER=({state:i,dispatch:e})=>{let{selection:t}=i,n=T.create(t.ranges.map(s=>i.wordAt(s.head)||T.cursor(s.head)),t.mainIndex);return n.eq(t)?!1:(e(i.update({selection:n})),!0)};function RR(i,e){let{main:t,ranges:n}=i.selection,s=i.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=!1,l=new yn(i.doc,e,n[n.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new yn(i.doc,e,0,Math.max(0,n[n.length-1].from-1)),o=!0}else{if(o&&n.some(a=>a.from==l.value.from))continue;if(r){let a=i.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const kR=({state:i,dispatch:e})=>{let{ranges:t}=i.selection;if(t.some(r=>r.from===r.to))return ER({state:i,dispatch:e});let n=i.sliceDoc(t[0].from,t[0].to);if(i.selection.ranges.some(r=>i.sliceDoc(r.from,r.to)!=n))return!1;let s=RR(i,n);return s?(e(i.update({selection:i.selection.addRange(T.range(s.from,s.to),!1),effects:_.scrollIntoView(s.to)})),!0):!1},Cn=$.define({combine(i){return Ht(i,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new BR(e),scrollToMatch:e=>_.scrollIntoView(e)})}});class Fg{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||fR(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,n)=>n=="n"?`
34
+ `:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new OR(this):new TR(this)}getCursor(e,t=0,n){let s=e.doc?e:se.create({doc:e});return n==null&&(n=s.doc.length),this.regexp?Ki(this,s,t,n):qi(this,s,t,n)}}class Ng{constructor(e){this.spec=e}}function qi(i,e,t,n){return new yn(e.doc,i.unquoted,t,n,i.caseSensitive?void 0:s=>s.toLowerCase(),i.wholeWord?AR(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function AR(i,e){return(t,n,s,r)=>((r>t||r+s.length<n)&&(r=Math.max(0,t-2),s=i.sliceString(r,Math.min(i.length,n+2))),(e(Lr(s,t-r))!=ye.Word||e(Fr(s,t-r))!=ye.Word)&&(e(Fr(s,n-r))!=ye.Word||e(Lr(s,n-r))!=ye.Word))}class TR extends Ng{constructor(e){super(e)}nextMatch(e,t,n){let s=qi(this.spec,e,n,e.doc.length).nextOverlapping();if(s.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);s=qi(this.spec,e,0,r).nextOverlapping()}return s.done||s.value.from==t&&s.value.to==n?null:s.value}prevMatchInRange(e,t,n){for(let s=n;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=qi(this.spec,e,r,s),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;s-=1e4}}prevMatch(e,t,n){let s=this.prevMatchInRange(e,0,t);return s||(s=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),s&&(s.from!=t||s.to!=n)?s:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=qi(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let r=qi(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function Ki(i,e,t,n){return new Dg(e.doc,i.search,{ignoreCase:!i.caseSensitive,test:i.wholeWord?MR(e.charCategorizer(e.selection.main.head)):void 0},t,n)}function Lr(i,e){return i.slice(Le(i,e,!1),e)}function Fr(i,e){return i.slice(e,Le(i,e))}function MR(i){return(e,t,n)=>!n[0].length||(i(Lr(n.input,n.index))!=ye.Word||i(Fr(n.input,n.index))!=ye.Word)&&(i(Fr(n.input,n.index+n[0].length))!=ye.Word||i(Lr(n.input,n.index+n[0].length))!=ye.Word)}class OR extends Ng{nextMatch(e,t,n){let s=Ki(this.spec,e,n,e.doc.length).next();return s.done&&(s=Ki(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,n){for(let s=1;;s++){let r=Math.max(t,n-s*1e4),o=Ki(this.spec,e,r,n),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let s=n.length;s>0;s--){let r=+n.slice(0,s);if(r>0&&r<e.match.length)return e.match[r]+n.slice(s)}return t})}matchAll(e,t){let n=Ki(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let r=Ki(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const rs=J.define(),au=J.define(),pi=Fe.define({create(i){return new nl(fa(i).create(),null)},update(i,e){for(let t of e.effects)t.is(rs)?i=new nl(t.value.create(),i.panel):t.is(au)&&(i=new nl(i.query,t.value?uu:null));return i},provide:i=>ns.from(i,e=>e.panel)});class nl{constructor(e,t){this.query=e,this.panel=t}}const IR=K.mark({class:"cm-searchMatch"}),jR=K.mark({class:"cm-searchMatch cm-searchMatch-selected"}),PR=Ce.fromClass(class{constructor(i){this.view=i,this.decorations=this.highlight(i.state.field(pi))}update(i){let e=i.state.field(pi);(e!=i.startState.field(pi)||i.docChanged||i.selectionSet||i.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:i,panel:e}){if(!e||!i.spec.valid)return K.none;let{view:t}=this,n=new Zt;for(let s=0,r=t.visibleRanges,o=r.length;s<o;s++){let{from:l,to:a}=r[s];for(;s<o-1&&a>r[s+1].from-500;)a=r[++s].to;i.highlight(t.state,l,a,(u,c)=>{let h=t.state.selection.ranges.some(d=>d.from==u&&d.to==c);n.add(u,c,h?jR:IR)})}return n.finish()}},{decorations:i=>i.decorations});function ys(i){return e=>{let t=e.state.field(pi,!1);return t&&t.query.spec.valid?i(e,t):_g(e)}}const Nr=ys((i,{query:e})=>{let{to:t}=i.state.selection.main,n=e.nextMatch(i.state,t,t);if(!n)return!1;let s=T.single(n.from,n.to),r=i.state.facet(Cn);return i.dispatch({selection:s,effects:[cu(i,n),r.scrollToMatch(s.main,i)],userEvent:"select.search"}),Vg(i),!0}),Br=ys((i,{query:e})=>{let{state:t}=i,{from:n}=t.selection.main,s=e.prevMatch(t,n,n);if(!s)return!1;let r=T.single(s.from,s.to),o=i.state.facet(Cn);return i.dispatch({selection:r,effects:[cu(i,s),o.scrollToMatch(r.main,i)],userEvent:"select.search"}),Vg(i),!0}),DR=ys((i,{query:e})=>{let t=e.matchAll(i.state,1e3);return!t||!t.length?!1:(i.dispatch({selection:T.create(t.map(n=>T.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),LR=({state:i,dispatch:e})=>{let t=i.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:n,to:s}=t.main,r=[],o=0;for(let l=new yn(i.doc,i.sliceDoc(n,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==n&&(o=r.length),r.push(T.range(l.value.from,l.value.to))}return e(i.update({selection:T.create(r,o),userEvent:"select.search.matches"})),!0},fh=ys((i,{query:e})=>{let{state:t}=i,{from:n,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,n,n);if(!r)return!1;let o=r,l=[],a,u,c=[];o.from==n&&o.to==s&&(u=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:u}),o=e.nextMatch(t,o.from,o.to),c.push(_.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(n).number)+".")));let h=i.state.changes(l);return o&&(a=T.single(o.from,o.to).map(h),c.push(cu(i,o)),c.push(t.facet(Cn).scrollToMatch(a.main,i))),i.dispatch({changes:h,selection:a,effects:c,userEvent:"input.replace"}),!0}),FR=ys((i,{query:e})=>{if(i.state.readOnly)return!1;let t=e.matchAll(i.state,1e9).map(s=>{let{from:r,to:o}=s;return{from:r,to:o,insert:e.getReplacement(s)}});if(!t.length)return!1;let n=i.state.phrase("replaced $ matches",t.length)+".";return i.dispatch({changes:t,effects:_.announce.of(n),userEvent:"input.replace.all"}),!0});function uu(i){return i.state.facet(Cn).createPanel(i)}function fa(i,e){var t,n,s,r,o;let l=i.selection.main,a=l.empty||l.to>l.from+100?"":i.sliceDoc(l.from,l.to);if(e&&!a)return e;let u=i.facet(Cn);return new Fg({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:u.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:u.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:u.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:u.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:u.wholeWord})}function Bg(i){let e=is(i,uu);return e&&e.dom.querySelector("[main-field]")}function Vg(i){let e=Bg(i);e&&e==i.root.activeElement&&e.select()}const _g=i=>{let e=i.state.field(pi,!1);if(e&&e.panel){let t=Bg(i);if(t&&t!=i.root.activeElement){let n=fa(i.state,e.query.spec);n.valid&&i.dispatch({effects:rs.of(n)}),t.focus(),t.select()}}else i.dispatch({effects:[au.of(!0),e?rs.of(fa(i.state,e.query.spec)):J.appendConfig.of(_R)]});return!0},zg=i=>{let e=i.state.field(pi,!1);if(!e||!e.panel)return!1;let t=is(i,uu);return t&&t.dom.contains(i.root.activeElement)&&i.focus(),i.dispatch({effects:au.of(!1)}),!0},NR=[{key:"Mod-f",run:_g,scope:"editor search-panel"},{key:"F3",run:Nr,shift:Br,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Nr,shift:Br,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:zg,scope:"editor search-panel"},{key:"Mod-Shift-l",run:LR},{key:"Mod-Alt-g",run:pR},{key:"Mod-d",run:kR,preventDefault:!0}];class BR{constructor(e){this.view=e;let t=this.query=e.state.field(pi).query.spec;this.commit=this.commit.bind(this),this.searchField=fe("input",{value:t.search,placeholder:st(e,"Find"),"aria-label":st(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=fe("input",{value:t.replace,placeholder:st(e,"Replace"),"aria-label":st(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=fe("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=fe("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=fe("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(s,r,o){return fe("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=fe("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,n("next",()=>Nr(e),[st(e,"next")]),n("prev",()=>Br(e),[st(e,"previous")]),n("select",()=>DR(e),[st(e,"all")]),fe("label",null,[this.caseField,st(e,"match case")]),fe("label",null,[this.reField,st(e,"regexp")]),fe("label",null,[this.wordField,st(e,"by word")]),...e.state.readOnly?[]:[fe("br"),this.replaceField,n("replace",()=>fh(e),[st(e,"replace")]),n("replaceAll",()=>FR(e),[st(e,"replace all")])],fe("button",{name:"close",onclick:()=>zg(e),"aria-label":st(e,"close"),type:"button"},["×"])])}commit(){let e=new Fg({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:rs.of(e)}))}keydown(e){n1(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Br:Nr)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),fh(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(rs)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Cn).top}}function st(i,e){return i.state.phrase(e)}const Us=30,qs=/[\s\.,:;?!]/;function cu(i,{from:e,to:t}){let n=i.state.doc.lineAt(e),s=i.state.doc.lineAt(t).to,r=Math.max(n.from,e-Us),o=Math.min(s,t+Us),l=i.state.sliceDoc(r,o);if(r!=n.from){for(let a=0;a<Us;a++)if(!qs.test(l[a+1])&&qs.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-Us;a--)if(!qs.test(l[a-1])&&qs.test(l[a])){l=l.slice(0,a);break}}return _.announce.of(`${i.state.phrase("current match")}. ${l} ${i.state.phrase("on line")} ${n.number}.`)}const VR=_.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),_R=[pi,$i.low(PR),VR];class $g{constructor(e,t,n,s){this.state=e,this.pos=t,this.explicit=n,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=$e(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),s=t.text.slice(n-t.from,this.pos-t.from),r=s.search(Hg(e,!1));return r<0?null:{from:n+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function ph(i){let e=Object.keys(i).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function zR(i){let e=Object.create(null),t=Object.create(null);for(let{label:s}of i){e[s[0]]=!0;for(let r=1;r<s.length;r++)t[s[r]]=!0}let n=ph(e)+ph(t)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function $R(i){let e=i.map(s=>typeof s=="string"?{label:s}:s),[t,n]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:zR(e);return s=>{let r=s.matchBefore(n);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}class gh{constructor(e,t,n,s){this.completion=e,this.source=t,this.match=n,this.score=s}}function Li(i){return i.selection.main.from}function Hg(i,e){var t;let{source:n}=i,s=e&&n[0]!="^",r=n[n.length-1]!="$";return!s&&!r?i:new RegExp(`${s?"^":""}(?:${n})${r?"$":""}`,(t=i.flags)!==null&&t!==void 0?t:i.ignoreCase?"i":"")}const Gg=$t.define();function HR(i,e,t,n){let{main:s}=i.selection,r=t-s.from,o=n-s.from;return{...i.changeByRange(l=>{if(l!=s&&t!=n&&i.sliceDoc(l.from+r,l.from+o)!=i.sliceDoc(t,n))return{range:l};let a=i.toText(e);return{changes:{from:l.from+r,to:n==s.from?l.to:l.from+o,insert:a},range:T.cursor(l.from+r+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const mh=new WeakMap;function GR(i){if(!Array.isArray(i))return i;let e=mh.get(i);return e||mh.set(i,e=$R(i)),e}const Vr=J.define(),os=J.define();class WR{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=Xe(e,t),s=Pt(n);this.chars.push(n);let r=e.slice(t,t+s),o=r.toUpperCase();this.folded.push(Xe(o==r?r.toLowerCase():o,0)),t+=s}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:s,precise:r,byWord:o}=this;if(t.length==1){let b=Xe(e,0),v=Pt(b),C=v==e.length?0:-100;if(b!=t[0])if(b==n[0])C+=-200;else return null;return this.ret(C,[0,v])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,u=0;if(l<0){for(let b=0,v=Math.min(e.length,200);b<v&&u<a;){let C=Xe(e,b);(C==t[u]||C==n[u])&&(s[u++]=b),b+=Pt(C)}if(u<a)return null}let c=0,h=0,d=!1,p=0,g=-1,m=-1,x=/[a-z]/.test(e),y=!0;for(let b=0,v=Math.min(e.length,200),C=0;b<v&&h<a;){let S=Xe(e,b);l<0&&(c<a&&S==t[c]&&(r[c++]=b),p<a&&(S==t[p]||S==n[p]?(p==0&&(g=b),m=b+1,p++):p=0));let E,A=S<255?S>=48&&S<=57||S>=97&&S<=122?2:S>=65&&S<=90?1:0:(E=za(S))!=E.toLowerCase()?1:E!=E.toUpperCase()?2:0;(!b||A==1&&x||C==0&&A!=0)&&(t[h]==S||n[h]==S&&(d=!0)?o[h++]=b:o.length&&(y=!1)),C=A,b+=Pt(S)}return h==a&&o[0]==0&&y?this.result(-100+(d?-200:0),o,e):p==a&&g==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):p==a?this.ret(-900-e.length,[g,m]):h==a?this.result(-100+(d?-200:0)+-700+(y?0:-1100),o,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,n){let s=[],r=0;for(let o of t){let l=o+(this.astral?Pt(Xe(n,o)):1);r&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return this.ret(e-n.length,s)}}class UR{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const je=$.define({combine(i){return Ht(i,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:qR,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>xh(e(n),t(n)),optionClass:(e,t)=>n=>xh(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function xh(i,e){return i?e?i+" "+e:i:e}function qR(i,e,t,n,s,r){let o=i.textDirection==xe.RTL,l=o,a=!1,u="top",c,h,d=e.left-s.left,p=s.right-e.right,g=n.right-n.left,m=n.bottom-n.top;if(l&&d<Math.min(g,p)?l=!1:!l&&p<Math.min(g,d)&&(l=!0),g<=(l?d:p))c=Math.max(s.top,Math.min(t.top,s.bottom-m))-e.top,h=Math.min(400,l?d:p);else{a=!0,h=Math.min(400,(o?e.right:s.right-e.left)-30);let b=s.bottom-e.bottom;b>=m||b>e.top?c=t.bottom-e.top:(u="bottom",c=e.bottom-t.top)}let x=(e.bottom-e.top)/r.offsetHeight,y=(e.right-e.left)/r.offsetWidth;return{style:`${u}: ${c/x}px; max-width: ${h/y}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function KR(i){let e=i.addToOptions.slice();return i.icons&&e.push({render(t){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),t.type&&n.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(t,n,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let u=0;u<r.length;){let c=r[u++],h=r[u++];c>a&&o.appendChild(document.createTextNode(l.slice(a,c)));let d=o.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(l.slice(c,h))),d.className="cm-completionMatchedText",a=h}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let n=document.createElement("span");return n.className="cm-completionDetail",n.textContent=t.detail,n},position:80}),e.sort((t,n)=>t.position-n.position).map(t=>t.render)}function sl(i,e,t){if(i<=t)return{from:0,to:i};if(e<0&&(e=0),e<=i>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let n=Math.floor((i-e)/t);return{from:i-(n+1)*t,to:i-n*t}}class YR{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:r,selected:o}=s.open,l=e.state.facet(je);this.optionContent=KR(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=sl(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:u}=e.state.field(t).open;for(let c=a.target,h;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(h=/-(\d+)$/.exec(c.id))&&+h[1]<u.length){this.applyCompletion(e,u[+h[1]]),a.preventDefault();return}}),this.dom.addEventListener("focusout",a=>{let u=e.state.field(this.stateField,!1);u&&u.tooltip&&e.state.facet(je).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:os.of(null)})}),this.showOptions(r,s.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=s){let{options:r,selected:o,disabled:l}=n.open;(!s.open||s.open.options!=r)&&(this.range=sl(r.length,o,e.state.facet(je).maxRenderedOptions),this.showOptions(r,n.id)),this.updateSel(),l!=((t=s.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of t.split(" "))n&&this.dom.classList.add(n);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=sl(t.options.length,t.selected,this.view.state.facet(je).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:s}=t.options[t.selected],{info:r}=s;if(!r)return;let o=typeof r=="string"?document.createTextNode(r):r(s);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,s)}).catch(l=>Je(this.view.state,l,"completion info")):(this.addInfoPane(o,s),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;n.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,s=this.range.from;n;n=n.nextSibling,s++)n.nodeName!="LI"||!n.id?s--:s==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby"));return t&&QR(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return s.top>Math.min(r.bottom,t.bottom)-10||s.bottom<Math.max(r.top,t.top)+10?null:this.view.state.facet(je).positionInfo(this.view,t,s,n,r,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions")),s.addEventListener("mousedown",o=>{o.target==s&&o.preventDefault()});let r=null;for(let o=n.from;o<n.to;o++){let{completion:l,match:a}=e[o],{section:u}=l;if(u){let d=typeof u=="string"?u:u.name;if(d!=r&&(o>n.from||n.from==0))if(r=d,typeof u!="string"&&u.header)s.appendChild(u.header(u));else{let p=s.appendChild(document.createElement("completion-section"));p.textContent=d}}const c=s.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let h=this.optionClass(l);h&&(c.className=h);for(let d of this.optionContent){let p=d(l,this.view.state,this.view,a);p&&c.appendChild(p)}}return n.from&&s.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function XR(i,e){return t=>new YR(t,i,e)}function QR(i,e){let t=i.getBoundingClientRect(),n=e.getBoundingClientRect(),s=t.height/i.offsetHeight;n.top<t.top?i.scrollTop-=(t.top-n.top)/s:n.bottom>t.bottom&&(i.scrollTop+=(n.bottom-t.bottom)/s)}function yh(i){return(i.boost||0)*100+(i.apply?10:0)+(i.info?5:0)+(i.type?1:0)}function JR(i,e){let t=[],n=null,s=null,r=c=>{t.push(c);let{section:h}=c.completion;if(h){n||(n=[]);let d=typeof h=="string"?h:h.name;n.some(p=>p.name==d)||n.push(typeof h=="string"?{name:d}:h)}},o=e.facet(je);for(let c of i)if(c.hasResult()){let h=c.result.getMatch;if(c.result.filter===!1)for(let d of c.result.options)r(new gh(d,c.source,h?h(d):[],1e9-t.length));else{let d=e.sliceDoc(c.from,c.to),p,g=o.filterStrict?new UR(d):new WR(d);for(let m of c.result.options)if(p=g.match(m.label)){let x=m.displayLabel?h?h(m,p.matched):[]:p.matched,y=p.score+(m.boost||0);if(r(new gh(m,c.source,x,y)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:b}=m.section;s||(s=Object.create(null)),s[b]=Math.max(y,s[b]||-1e9)}}}}if(n){let c=Object.create(null),h=0,d=(p,g)=>(p.rank==="dynamic"&&g.rank==="dynamic"?s[g.name]-s[p.name]:0)||(typeof p.rank=="number"?p.rank:1e9)-(typeof g.rank=="number"?g.rank:1e9)||(p.name<g.name?-1:1);for(let p of n.sort(d))h-=1e5,c[p.name]=h;for(let p of t){let{section:g}=p.completion;g&&(p.score+=c[typeof g=="string"?g:g.name])}}let l=[],a=null,u=o.compareCompletions;for(let c of t.sort((h,d)=>d.score-h.score||u(h.completion,d.completion))){let h=c.completion;!a||a.label!=h.label||a.detail!=h.detail||a.type!=null&&h.type!=null&&a.type!=h.type||a.apply!=h.apply||a.boost!=h.boost?l.push(c):yh(c.completion)>yh(a)&&(l[l.length-1]=c),a=c.completion}return l}class en{constructor(e,t,n,s,r,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new en(this.options,bh(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,s,r,o){if(s&&!o&&e.some(u=>u.isPending))return s.setDisabled();let l=JR(e,t);if(!l.length)return s&&e.some(u=>u.isPending)?s.setDisabled():null;let a=t.facet(je).selectOnOpen?0:-1;if(s&&s.selected!=a&&s.selected!=-1){let u=s.options[s.selected].completion;for(let c=0;c<l.length;c++)if(l[c].completion==u){a=c;break}}return new en(l,bh(n,a),{pos:e.reduce((u,c)=>c.hasResult()?Math.min(u,c.from):u,1e8),create:sk,above:r.aboveCursor},s?s.timestamp:Date.now(),a,!1)}map(e){return new en(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new en(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class _r{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new _r(ik,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(je),r=(n.override||t.languageDataAt("autocomplete",Li(t)).map(GR)).map(a=>(this.active.find(c=>c.source==a)||new dt(a,this.active.some(c=>c.state!=0)?1:0)).update(e,n));r.length==this.active.length&&r.every((a,u)=>a==this.active[u])&&(r=this.active);let o=this.open,l=e.effects.some(a=>a.is(hu));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!ZR(r,this.active)||l?o=en.build(r,t,this.id,o,n,l):o&&o.disabled&&!r.some(a=>a.isPending)&&(o=null),!o&&r.every(a=>!a.isPending)&&r.some(a=>a.hasResult())&&(r=r.map(a=>a.hasResult()?new dt(a.source,0):a));for(let a of e.effects)a.is(Ug)&&(o=o&&o.setSelected(a.value,this.id));return r==this.active&&o==this.open?this:new _r(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?ek:tk}}function ZR(i,e){if(i==e)return!0;for(let t=0,n=0;;){for(;t<i.length&&!i[t].hasResult();)t++;for(;n<e.length&&!e[n].hasResult();)n++;let s=t==i.length,r=n==e.length;if(s||r)return s==r;if(i[t++].result!=e[n++].result)return!1}}const ek={"aria-autocomplete":"list"},tk={};function bh(i,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":i};return e>-1&&(t["aria-activedescendant"]=i+"-"+e),t}const ik=[];function Wg(i,e){if(i.isUserEvent("input.complete")){let n=i.annotation(Gg);if(n&&e.activateOnCompletion(n))return 12}let t=i.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:i.isUserEvent("delete.backward")?2:i.selection?8:i.docChanged?16:0}class dt{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let n=Wg(e,t),s=this;(n&8||n&16&&this.touches(e))&&(s=new dt(s.source,0)),n&4&&s.state==0&&(s=new dt(this.source,1)),s=s.updateFor(e,n);for(let r of e.effects)if(r.is(Vr))s=new dt(s.source,1,r.value);else if(r.is(os))s=new dt(s.source,0);else if(r.is(hu))for(let o of r.value)o.source==s.source&&(s=o);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Li(e.state))}}class cn extends dt{constructor(e,t,n,s,r,o){super(e,3,t),this.limit=n,this.result=s,this.from=r,this.to=o}hasResult(){return!0}updateFor(e,t){var n;if(!(t&3))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=Li(e.state);if(l>o||!s||t&2&&(Li(e.startState)==this.from||l<this.limit))return new dt(this.source,t&4?1:0);let a=e.changes.mapPos(this.limit);return nk(s.validFor,e.state,r,o)?new cn(this.source,this.explicit,a,s,r,o):s.update&&(s=s.update(s,r,o,new $g(e.state,l,!1)))?new cn(this.source,this.explicit,a,s,s.from,(n=s.to)!==null&&n!==void 0?n:Li(e.state)):new dt(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new cn(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new dt(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function nk(i,e,t,n){if(!i)return!1;let s=e.sliceDoc(t,n);return typeof i=="function"?i(s,t,n,e):Hg(i,!0).test(s)}const hu=J.define({map(i,e){return i.map(t=>t.map(e))}}),Ug=J.define(),Qe=Fe.define({create(){return _r.start()},update(i,e){return i.update(e)},provide:i=>[tu.from(i,e=>e.tooltip),_.contentAttributes.from(i,e=>e.attrs)]});function du(i,e){const t=e.completion.apply||e.completion.label;let n=i.state.field(Qe).active.find(s=>s.source==e.source);return n instanceof cn?(typeof t=="string"?i.dispatch({...HR(i.state,t,n.from,n.to),annotations:Gg.of(e.completion)}):t(i,e.completion,n.from,n.to),!0):!1}const sk=XR(Qe,du);function Ks(i,e="option"){return t=>{let n=t.state.field(Qe,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<t.state.facet(je).interactionDelay)return!1;let s=1,r;e=="page"&&(r=Dp(t,n.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=n.open.options,l=n.open.selected>-1?n.open.selected+s*(i?1:-1):i?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:Ug.of(l)}),!0}}const rk=i=>{let e=i.state.field(Qe,!1);return i.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<i.state.facet(je).interactionDelay?!1:du(i,e.open.options[e.open.selected])},rl=i=>i.state.field(Qe,!1)?(i.dispatch({effects:Vr.of(!0)}),!0):!1,ok=i=>{let e=i.state.field(Qe,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(i.dispatch({effects:os.of(null)}),!0)};class lk{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const ak=50,uk=1e3,ck=Ce.fromClass(class{constructor(i){this.view=i,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of i.state.field(Qe).active)e.isPending&&this.startQuery(e)}update(i){let e=i.state.field(Qe),t=i.state.facet(je);if(!i.selectionSet&&!i.docChanged&&i.startState.field(Qe)==e)return;let n=i.transactions.some(r=>{let o=Wg(r,t);return o&8||(r.selection||r.docChanged)&&!(o&3)});for(let r=0;r<this.running.length;r++){let o=this.running[r];if(n||o.context.abortOnDocChange&&i.docChanged||o.updates.length+i.transactions.length>ak&&Date.now()-o.time>uk){for(let l of o.context.abortListeners)try{l()}catch(a){Je(this.view.state,a)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...i.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),i.transactions.some(r=>r.effects.some(o=>o.is(Vr)))&&(this.pendingStart=!0);let s=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.isPending&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let r of i.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:i}=this.view,e=i.field(Qe);for(let t of e.active)t.isPending&&!this.running.some(n=>n.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(je).updateSyncTime))}startQuery(i){let{state:e}=this.view,t=Li(e),n=new $g(e,t,i.explicit,this.view),s=new lk(i,n);this.running.push(s),Promise.resolve(i.source(n)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:os.of(null)}),Je(this.view.state,r)})}scheduleAccept(){this.running.every(i=>i.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(je).updateSyncTime))}accept(){var i;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(je),n=this.view.state.field(Qe);for(let s=0;s<this.running.length;s++){let r=this.running[s];if(r.done===void 0)continue;if(this.running.splice(s--,1),r.done){let l=Li(r.updates.length?r.updates[0].startState:this.view.state),a=Math.min(l,r.done.from+(r.active.explicit?0:1)),u=new cn(r.active.source,r.active.explicit,a,r.done,r.done.from,(i=r.done.to)!==null&&i!==void 0?i:l);for(let c of r.updates)u=u.update(c,t);if(u.hasResult()){e.push(u);continue}}let o=n.active.find(l=>l.source==r.active.source);if(o&&o.isPending)if(r.done==null){let l=new dt(r.active.source,0);for(let a of r.updates)l=l.update(a,t);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:hu.of(e)})}},{eventHandlers:{blur(i){let e=this.view.state.field(Qe,!1);if(e&&e.tooltip&&this.view.state.facet(je).closeOnBlur){let t=e.open&&Dp(this.view,e.open.tooltip);(!t||!t.dom.contains(i.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:os.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Vr.of(!1)}),20),this.composing=0}}}),hk=typeof navigator=="object"&&/Win/.test(navigator.platform),dk=$i.highest(_.domEventHandlers({keydown(i,e){let t=e.state.field(Qe,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||i.key.length>1||i.ctrlKey&&!(hk&&i.altKey)||i.metaKey)return!1;let n=t.open.options[t.open.selected],s=t.active.find(o=>o.source==n.source),r=n.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(i.key)>-1&&du(e,n),!1}})),fk=_.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),ls={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},ji=J.define({map(i,e){let t=e.mapPos(i,-1,Ue.TrackAfter);return t??void 0}}),fu=new class extends Fi{};fu.startSide=1;fu.endSide=-1;const qg=Fe.define({create(){return re.empty},update(i,e){if(i=i.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);i=i.update({filter:n=>n>=t.from&&n<=t.to})}for(let t of e.effects)t.is(ji)&&(i=i.update({add:[fu.range(t.value,t.value+1)]}));return i}});function pk(){return[mk,qg]}const ol="()[]{}<>«»»«[]{}";function Kg(i){for(let e=0;e<ol.length;e+=2)if(ol.charCodeAt(e)==i)return ol.charAt(e+1);return za(i<128?i:i+1)}function Yg(i,e){return i.languageDataAt("closeBrackets",e)[0]||ls}const gk=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),mk=_.inputHandler.of((i,e,t,n)=>{if((gk?i.composing:i.compositionStarted)||i.state.readOnly)return!1;let s=i.state.selection.main;if(n.length>2||n.length==2&&Pt(Xe(n,0))==1||e!=s.from||t!=s.to)return!1;let r=bk(i.state,n);return r?(i.dispatch(r),!0):!1}),xk=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let n=Yg(i,i.selection.main.head).brackets||ls.brackets,s=null,r=i.changeByRange(o=>{if(o.empty){let l=vk(i.doc,o.head);for(let a of n)if(a==l&&ho(i.doc,o.head)==Kg(Xe(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:T.cursor(o.head-a.length)}}return{range:s=o}});return s||e(i.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},yk=[{key:"Backspace",run:xk}];function bk(i,e){let t=Yg(i,i.selection.main.head),n=t.brackets||ls.brackets;for(let s of n){let r=Kg(Xe(s,0));if(e==s)return r==s?wk(i,s,n.indexOf(s+s+s)>-1,t):Sk(i,s,r,t.before||ls.before);if(e==r&&Xg(i,i.selection.main.from))return Ck(i,s,r)}return null}function Xg(i,e){let t=!1;return i.field(qg).between(0,i.doc.length,n=>{n==e&&(t=!0)}),t}function ho(i,e){let t=i.sliceString(e,e+2);return t.slice(0,Pt(Xe(t,0)))}function vk(i,e){let t=i.sliceString(e-2,e);return Pt(Xe(t,0))==t.length?t:t.slice(1)}function Sk(i,e,t,n){let s=null,r=i.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:ji.of(o.to+e.length),range:T.range(o.anchor+e.length,o.head+e.length)};let l=ho(i.doc,o.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:ji.of(o.head+e.length),range:T.cursor(o.head+e.length)}:{range:s=o}});return s?null:i.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Ck(i,e,t){let n=null,s=i.changeByRange(r=>r.empty&&ho(i.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:T.cursor(r.head+t.length)}:n={range:r});return n?null:i.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function wk(i,e,t,n){let s=n.stringPrefixes||ls.stringPrefixes,r=null,o=i.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:ji.of(l.to+e.length),range:T.range(l.anchor+e.length,l.head+e.length)};let a=l.head,u=ho(i.doc,a),c;if(u==e){if(vh(i,a))return{changes:{insert:e+e,from:a},effects:ji.of(a+e.length),range:T.cursor(a+e.length)};if(Xg(i,a)){let d=t&&i.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+d.length,insert:d},range:T.cursor(a+d.length)}}}else{if(t&&i.sliceDoc(a-2*e.length,a)==e+e&&(c=Sh(i,a-2*e.length,s))>-1&&vh(i,c))return{changes:{insert:e+e+e+e,from:a},effects:ji.of(a+e.length),range:T.cursor(a+e.length)};if(i.charCategorizer(a)(u)!=ye.Word&&Sh(i,a,s)>-1&&!Ek(i,a,e,s))return{changes:{insert:e+e,from:a},effects:ji.of(a+e.length),range:T.cursor(a+e.length)}}return{range:r=l}});return r?null:i.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function vh(i,e){let t=$e(i).resolveInner(e+1);return t.parent&&t.from==e}function Ek(i,e,t,n){let s=$e(i).resolveInner(e,-1),r=n.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=i.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&n.indexOf(l.slice(0,a))>-1){let c=s.firstChild;for(;c&&c.from==s.from&&c.to-c.from>t.length+a;){if(i.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let u=s.to==e&&s.parent;if(!u)break;s=u}return!1}function Sh(i,e,t){let n=i.charCategorizer(e);if(n(i.sliceDoc(e-1,e))!=ye.Word)return e;for(let s of t){let r=e-s.length;if(i.sliceDoc(r,e)==s&&n(i.sliceDoc(r-1,r))!=ye.Word)return r}return-1}function Rk(i={}){return[dk,Qe,je.of(i),ck,kk,fk]}const Qg=[{key:"Ctrl-Space",run:rl},{mac:"Alt-`",run:rl},{mac:"Alt-i",run:rl},{key:"Escape",run:ok},{key:"ArrowDown",run:Ks(!0)},{key:"ArrowUp",run:Ks(!1)},{key:"PageDown",run:Ks(!0,"page")},{key:"PageUp",run:Ks(!1,"page")},{key:"Enter",run:rk}],kk=$i.highest(io.computeN([je],i=>i.facet(je).defaultKeymap?[Qg]:[]));class Ch{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class Mi{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let s=n.facet(as).markerFilter;s&&(e=s(e,n));let r=e.slice().sort((p,g)=>p.from-g.from||p.to-g.to),o=new Zt,l=[],a=0,u=n.doc.iter(),c=0,h=n.doc.length;for(let p=0;;){let g=p==r.length?null:r[p];if(!g&&!l.length)break;let m,x;if(l.length)m=a,x=l.reduce((v,C)=>Math.min(v,C.to),g&&g.from>m?g.from:1e8);else{if(m=g.from,m>h)break;x=g.to,l.push(g),p++}for(;p<r.length;){let v=r[p];if(v.from==m&&(v.to>v.from||v.to==m))l.push(v),p++,x=Math.min(v.to,x);else{x=Math.min(v.from,x);break}}x=Math.min(x,h);let y=!1;if(l.some(v=>v.from==m&&(v.to==x||x==h))&&(y=m==x,!y&&x-m<10)){let v=m-(c+u.value.length);v>0&&(u.next(v),c=m);for(let C=m;;){if(C>=x){y=!0;break}if(!u.lineBreak&&c+u.value.length>C)break;C=c+u.value.length,c+=u.value.length,u.next()}}let b=Vk(l);if(y)o.add(m,m,K.widget({widget:new Lk(b),diagnostics:l.slice()}));else{let v=l.reduce((C,S)=>S.markClass?C+" "+S.markClass:C,"");o.add(m,x,K.mark({class:"cm-lintRange cm-lintRange-"+b+v,diagnostics:l.slice(),inclusiveEnd:l.some(C=>C.to>x)}))}if(a=x,a==h)break;for(let v=0;v<l.length;v++)l[v].to<=a&&l.splice(v--,1)}let d=o.finish();return new Mi(d,t,bn(d))}}function bn(i,e=null,t=0){let n=null;return i.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!n)n=new Ch(s,r,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new Ch(n.from,r,n.diagnostic)}}),n}function Ak(i,e){let t=e.pos,n=e.end||t,s=i.state.facet(as).hideOn(i,t,n);if(s!=null)return s;let r=i.startState.doc.lineAt(e.pos);return!!(i.effects.some(o=>o.is(Jg))||i.changes.touchesRange(r.from,Math.max(r.to,n)))}function Tk(i,e){return i.field(lt,!1)?e:e.concat(J.appendConfig.of(_k))}const Jg=J.define(),pu=J.define(),Zg=J.define(),lt=Fe.define({create(){return new Mi(K.none,null,null)},update(i,e){if(e.docChanged&&i.diagnostics.size){let t=i.diagnostics.map(e.changes),n=null,s=i.panel;if(i.selected){let r=e.changes.mapPos(i.selected.from,1);n=bn(t,i.selected.diagnostic,r)||bn(t,null,r)}!t.size&&s&&e.state.facet(as).autoPanel&&(s=null),i=new Mi(t,s,n)}for(let t of e.effects)if(t.is(Jg)){let n=e.state.facet(as).autoPanel?t.value.length?us.open:null:i.panel;i=Mi.init(t.value,n,e.state)}else t.is(pu)?i=new Mi(i.diagnostics,t.value?us.open:null,i.selected):t.is(Zg)&&(i=new Mi(i.diagnostics,i.panel,t.value));return i},provide:i=>[ns.from(i,e=>e.panel),_.decorations.from(i,e=>e.diagnostics)]}),Mk=K.mark({class:"cm-lintRange cm-lintRange-active"});function Ok(i,e,t){let{diagnostics:n}=i.state.field(lt),s,r=-1,o=-1;n.between(e-(t<0?1:0),e+(t>0?1:0),(a,u,{spec:c})=>{if(e>=a&&e<=u&&(a==u||(e>a||t>0)&&(e<u||t<0)))return s=c.diagnostics,r=a,o=u,!1});let l=i.state.facet(as).tooltipFilter;return s&&l&&(s=l(s,i.state)),s?{pos:r,end:o,above:i.state.doc.lineAt(r).to<o,create(){return{dom:Ik(i,s)}}}:null}function Ik(i,e){return fe("ul",{class:"cm-tooltip-lint"},e.map(t=>tm(i,t,!1)))}const jk=i=>{let e=i.state.field(lt,!1);(!e||!e.panel)&&i.dispatch({effects:Tk(i.state,[pu.of(!0)])});let t=is(i,us.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},wh=i=>{let e=i.state.field(lt,!1);return!e||!e.panel?!1:(i.dispatch({effects:pu.of(!1)}),!0)},Pk=i=>{let e=i.state.field(lt,!1);if(!e)return!1;let t=i.state.selection.main,n=e.diagnostics.iter(t.to+1);return!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==t.from&&n.to==t.to)?!1:(i.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)},Dk=[{key:"Mod-Shift-m",run:jk,preventDefault:!0},{key:"F8",run:Pk}],as=$.define({combine(i){return{sources:i.map(e=>e.source).filter(e=>e!=null),...Ht(i.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Eh,tooltipFilter:Eh,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,s,r)=>e(n,s,r)||t(n,s,r):e:t,autoPanel:(e,t)=>e||t})}}});function Eh(i,e){return i?e?(t,n)=>e(i(t,n),n):i:e}function em(i){let e=[];if(i)e:for(let{name:t}of i){for(let n=0;n<t.length;n++){let s=t[n];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function tm(i,e,t){var n;let s=t?em(e.actions):[];return fe("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},fe("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(i):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((r,o)=>{let l=!1,a=p=>{if(p.preventDefault(),l)return;l=!0;let g=bn(i.state.field(lt).diagnostics,e);g&&r.apply(i,g.from,g.to)},{name:u}=r,c=s[o]?u.indexOf(s[o]):-1,h=c<0?u:[u.slice(0,c),fe("u",u.slice(c,c+1)),u.slice(c+1)],d=r.markClass?" "+r.markClass:"";return fe("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:a,onmousedown:a,"aria-label":` Action: ${u}${c<0?"":` (access key "${s[o]})"`}.`},h)}),e.source&&fe("div",{class:"cm-diagnosticSource"},e.source))}class Lk extends ii{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return fe("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Rh{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=tm(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class us{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)wh(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=em(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=bn(this.view.state.field(lt).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()},n=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=fe("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:n}),this.dom=fe("div",{class:"cm-panel-lint"},this.list,fe("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>wh(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(lt).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(lt),n=0,s=!1,r=null,o=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:u})=>{for(let c of u.diagnostics){if(o.has(c))continue;o.add(c);let h=-1,d;for(let p=n;p<this.items.length;p++)if(this.items[p].diagnostic==c){h=p;break}h<0?(d=new Rh(this.view,c),this.items.splice(n,0,d),s=!0):(d=this.items[h],h>n&&(this.items.splice(n,h-n),s=!0)),t&&d.diagnostic==t.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),r=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new Rh(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let u=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/u:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(lt),n=bn(t.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:Zg.of(n)})}static open(e){return new us(e)}}function Fk(i,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(i)}</svg>')`}function Ys(i){return Fk(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${i}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Nk=_.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Ys("#d11")},".cm-lintRange-warning":{backgroundImage:Ys("orange")},".cm-lintRange-info":{backgroundImage:Ys("#999")},".cm-lintRange-hint":{backgroundImage:Ys("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function Bk(i){return i=="error"?4:i=="warning"?3:i=="info"?2:1}function Vk(i){let e="hint",t=1;for(let n of i){let s=Bk(n.severity);s>t&&(t=s,e=n.severity)}return e}const _k=[lt,_.decorations.compute([lt],i=>{let{selected:e,panel:t}=i.field(lt);return!e||!t||e.from==e.to?K.none:K.set([Mk.range(e.from,e.to)])}),W1(Ok,{hideOn:Ak}),Nk];var kh=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(yk)),e.defaultKeymap!==!1&&(n=n.concat(hR)),e.searchKeymap!==!1&&(n=n.concat(NR)),e.historyKeymap!==!1&&(n=n.concat(yE)),e.foldKeymap!==!1&&(n=n.concat(Ow)),e.completionKeymap!==!1&&(n=n.concat(Qg)),e.lintKeymap!==!1&&(n=n.concat(Dk));var s=[];return e.lineNumbers!==!1&&s.push(iw()),e.highlightActiveLineGutter!==!1&&s.push(rw()),e.highlightSpecialChars!==!1&&s.push(v1()),e.history!==!1&&s.push(uE()),e.foldGutter!==!1&&s.push(Dw()),e.drawSelection!==!1&&s.push(u1()),e.dropCursor!==!1&&s.push(p1()),e.allowMultipleSelections!==!1&&s.push(se.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&s.push(vw()),e.syntaxHighlighting!==!1&&s.push(Xp(Bw,{fallback:!0})),e.bracketMatching!==!1&&s.push(Ww()),e.closeBrackets!==!1&&s.push(pk()),e.autocompletion!==!1&&s.push(Rk()),e.rectangularSelection!==!1&&s.push(D1()),t!==!1&&s.push(N1()),e.highlightActiveLine!==!1&&s.push(k1()),e.highlightSelectionMatches!==!1&&s.push(yR()),e.tabSize&&typeof e.tabSize=="number"&&s.push(so.of(" ".repeat(e.tabSize))),s.concat([io.of(n.flat())]).filter(Boolean)};const zk="#e5c07b",Ah="#e06c75",$k="#56b6c2",Hk="#ffffff",lr="#abb2bf",pa="#7d8799",Gk="#61afef",Wk="#98c379",Th="#d19a66",Uk="#c678dd",qk="#21252b",Mh="#2c313a",Oh="#282c34",ll="#353a42",Kk="#3E4451",Ih="#528bff",Yk=_.theme({"&":{color:lr,backgroundColor:Oh},".cm-content":{caretColor:Ih},".cm-cursor, .cm-dropCursor":{borderLeftColor:Ih},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Kk},".cm-panels":{backgroundColor:qk,color:lr},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Oh,color:pa,border:"none"},".cm-activeLineGutter":{backgroundColor:Mh},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:ll},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:ll,borderBottomColor:ll},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Mh,color:lr}}},{dark:!0}),Xk=ms.define([{tag:k.keyword,color:Uk},{tag:[k.name,k.deleted,k.character,k.propertyName,k.macroName],color:Ah},{tag:[k.function(k.variableName),k.labelName],color:Gk},{tag:[k.color,k.constant(k.name),k.standard(k.name)],color:Th},{tag:[k.definition(k.name),k.separator],color:lr},{tag:[k.typeName,k.className,k.number,k.changed,k.annotation,k.modifier,k.self,k.namespace],color:zk},{tag:[k.operator,k.operatorKeyword,k.url,k.escape,k.regexp,k.link,k.special(k.string)],color:$k},{tag:[k.meta,k.comment],color:pa},{tag:k.strong,fontWeight:"bold"},{tag:k.emphasis,fontStyle:"italic"},{tag:k.strikethrough,textDecoration:"line-through"},{tag:k.link,color:pa,textDecoration:"underline"},{tag:k.heading,fontWeight:"bold",color:Ah},{tag:[k.atom,k.bool,k.special(k.variableName)],color:Th},{tag:[k.processingInstruction,k.string,k.inserted],color:Wk},{tag:k.invalid,color:Hk}]),Qk=[Yk,Xp(Xk)];var Jk=_.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Zk=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:s=!1,theme:r="light",placeholder:o="",basicSetup:l=!0}=e,a=[];switch(t&&a.unshift(io.of([dR])),l&&(typeof l=="boolean"?a.unshift(kh()):a.unshift(kh(l))),o&&a.unshift(O1(o)),r){case"light":a.push(Jk);break;case"dark":a.push(Qk);break;case"none":break;default:a.push(r);break}return n===!1&&a.push(_.editable.of(!1)),s&&a.push(se.readOnly.of(!0)),[...a]},eA=i=>({line:i.state.doc.lineAt(i.state.selection.main.from),lineCount:i.state.doc.lines,lineBreak:i.state.lineBreak,length:i.state.doc.length,readOnly:i.state.readOnly,tabSize:i.state.tabSize,selection:i.state.selection,selectionAsSingle:i.state.selection.asSingle().main,ranges:i.state.selection.ranges,selectionCode:i.state.sliceDoc(i.state.selection.main.from,i.state.selection.main.to),selections:i.state.selection.ranges.map(e=>i.state.sliceDoc(e.from,e.to)),selectedText:i.state.selection.ranges.some(e=>!e.empty)});class tA{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(t=>{try{t()}catch(n){console.error("TimeoutLatch callback error:",n)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class jh{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var al=null,iA=()=>typeof window>"u"?new jh:(al||(al=new jh),al),Ph=$t.define(),nA=200,sA=[];function rA(i){var{value:e,selection:t,onChange:n,onStatistics:s,onCreateEditor:r,onUpdate:o,extensions:l=sA,autoFocus:a,theme:u="light",height:c=null,minHeight:h=null,maxHeight:d=null,width:p=null,minWidth:g=null,maxWidth:m=null,placeholder:x="",editable:y=!0,readOnly:b=!1,indentWithTab:v=!0,basicSetup:C=!0,root:S,initialState:E}=i,[A,I]=M.useState(),[R,H]=M.useState(),[F,j]=M.useState(),W=M.useState(()=>({current:null}))[0],P=M.useState(()=>({current:null}))[0],B=_.theme({"&":{height:c,minHeight:h,maxHeight:d,width:p,minWidth:g,maxWidth:m},"& .cm-scroller":{height:"100% !important"}}),q=_.updateListener.of(ie=>{if(ie.docChanged&&typeof n=="function"&&!ie.transactions.some(w=>w.annotation(Ph))){W.current?W.current.reset():(W.current=new tA(()=>{if(P.current){var w=P.current;P.current=null,w()}W.current=null},nA),iA().add(W.current));var ee=ie.state.doc,U=ee.toString();n(U,ie)}s&&s(eA(ie))}),ne=Zk({theme:u,editable:y,readOnly:b,placeholder:x,indentWithTab:v,basicSetup:C}),ae=[q,B,...ne];return o&&typeof o=="function"&&ae.push(_.updateListener.of(o)),ae=ae.concat(l),M.useLayoutEffect(()=>{if(A&&!F){var ie={doc:e,selection:t,extensions:ae},ee=E?se.fromJSON(E.json,ie,E.fields):se.create(ie);if(j(ee),!R){var U=new _({state:ee,parent:A,root:S});H(U),r&&r(U,ee)}}return()=>{R&&(j(void 0),H(void 0))}},[A,F]),M.useEffect(()=>{i.container&&I(i.container)},[i.container]),M.useEffect(()=>()=>{R&&(R.destroy(),H(void 0)),W.current&&(W.current.cancel(),W.current=null)},[R]),M.useEffect(()=>{a&&R&&R.focus()},[a,R]),M.useEffect(()=>{R&&R.dispatch({effects:J.reconfigure.of(ae)})},[u,l,c,h,d,p,g,m,x,y,b,v,C,n,o]),M.useEffect(()=>{if(e!==void 0){var ie=R?R.state.doc.toString():"";if(R&&e!==ie){var ee=W.current&&!W.current.isDone,U=()=>{R&&e!==R.state.doc.toString()&&R.dispatch({changes:{from:0,to:R.state.doc.toString().length,insert:e||""},annotations:[Ph.of(!0)]})};ee?P.current=U:U()}}},[e,R]),{state:F,setState:j,view:R,setView:H,container:A,setContainer:I}}var oA=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],im=M.forwardRef((i,e)=>{var{className:t,value:n="",selection:s,extensions:r=[],onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:u,autoFocus:c,theme:h="light",height:d,minHeight:p,maxHeight:g,width:m,minWidth:x,maxWidth:y,basicSetup:b,placeholder:v,indentWithTab:C,editable:S,readOnly:E,root:A,initialState:I}=i,R=qr(i,oA),H=M.useRef(null),{state:F,view:j,container:W,setContainer:P}=rA({root:A,value:n,autoFocus:c,theme:h,height:d,minHeight:p,maxHeight:g,width:m,minWidth:x,maxWidth:y,basicSetup:b,placeholder:v,indentWithTab:C,editable:S,readOnly:E,selection:s,onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:u,extensions:r,initialState:I});M.useImperativeHandle(e,()=>({editor:H.current,state:F,view:j}),[H,W,F,j]);var B=M.useCallback(ne=>{H.current=ne,P(ne)},[P]);if(typeof n!="string")throw new Error("value must be typeof string but got "+typeof n);var q=typeof h=="string"?"cm-theme-"+h:"cm-theme";return f.jsxRuntimeExports.jsx("div",be({ref:B,className:""+q+(t?" "+t:"")},R))});im.displayName="CodeMirror";function lA({value:i,language:e,readOnly:t=!1,height:n="300px",onChange:s}){const[r]=D.useStyletron(),o=e==="json"?[Zw()]:[],l=_.theme({"&":{fontSize:"14px",fontFamily:"monospace"},".cm-content":{padding:"12px"},".cm-editor":{backgroundColor:t?"#F8F8F8":"#FFFFFF"},".cm-editor.cm-focused":{outline:"none"}});return f.jsxRuntimeExports.jsx("div",{className:r({border:"1px solid #E0E0E0",borderRadius:"4px",overflow:"hidden",height:n}),children:f.jsxRuntimeExports.jsx(im,{value:i,height:n,extensions:[...o,l],onChange:s,editable:!t,basicSetup:{lineNumbers:!0,foldGutter:!1,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!1,bracketMatching:!0,closeBrackets:!1,autocompletion:!1,highlightSelectionMatches:!1,searchKeymap:!1}})})}const Gi={boolValue:"boolValue",listValue:"listValue",nullValue:"nullValue",numberValue:"numberValue",stringValue:"stringValue",structValue:"structValue"};function nm(i){return!!i&&typeof i=="object"&&"fields"in i&&typeof i.fields=="object"&&!Array.isArray(i.fields)}function aA(i){const e=Object.entries(i),[t,n]=e[0]||[];return{kind:t,kindValue:n}}function uA(i){const e={};for(const[t,n]of Object.entries(i))e[t]=zr(n);return e}function zr(i){if(i==null)return i;if(nm(i))return uA(i.fields);if(typeof i=="object"&&i!==null){const e=i,{kind:t,kindValue:n}=aA(e);switch(t){case Gi.listValue:return n&&typeof n=="object"&&"values"in n?n.values.map(r=>zr(r)):[];case Gi.nullValue:return null;case Gi.structValue:return n?zr(n):{};case Gi.boolValue:case Gi.numberValue:case Gi.stringValue:return n;default:return i}}return i}function cA(i){const{label:e,value:t}=i,n=nm(t)?zr(t):t,s=JSON.stringify(n,null,2);return f.jsxRuntimeExports.jsx(Ma,{title:f.jsxRuntimeExports.jsx(ze.LabelSmall,{children:e}),children:f.jsxRuntimeExports.jsx(lA,{readOnly:!0,language:"json",value:s,onChange:()=>null})})}function hA(i){const[e,t]=D.useStyletron(),{label:n,value:s,markdown:r=!0,error:o=!1}=i;if(!s)return null;const l=s.substring(0,1e4);return f.jsxRuntimeExports.jsxs("div",{className:e({backgroundColor:o?t.colors.backgroundNegativeLight:t.colors.backgroundSecondary,borderRadius:t.borders.radius300,minHeight:t.sizing.scale1600,overflow:"auto",padding:t.sizing.scale600,resize:"vertical"}),children:[f.jsxRuntimeExports.jsx(ze.LabelSmall,{id:"textarea-title",children:n}),f.jsxRuntimeExports.jsx(ze.ParagraphSmall,{"aria-labelledby":"textarea-title",className:e({marginBottom:0,marginTop:t.sizing.scale100}),children:r?f.jsxRuntimeExports.jsx(f.Markdown,{children:l}):l})]})}function dA(i){const[e,t]=D.useStyletron(),{task:n,bodySchema:s,overrides:r,metadata:o}=i,{subTasks:l}=n,a=f.useInterpolationResolver();if(l!=null&&l.length){const u=La(l,n);return f.jsxRuntimeExports.jsxs(Nn,{children:[f.jsxRuntimeExports.jsx(f.Box,{children:f.jsxRuntimeExports.jsx(tf,{matrix:u,onTaskClick:Qd,overrides:{TaskListRenderer:r==null?void 0:r.TaskListRenderer,SubTaskListRenderer:r==null?void 0:r.SubTaskListRenderer}})}),l.map((c,h)=>f.jsxRuntimeExports.jsx(sm,{task:c,bodySchema:s,overrides:r,metadata:o},h))]})}if(s!=null&&s.length){const u=a(s,{row:n});return f.jsxRuntimeExports.jsx("div",{className:e({display:"flex",flexDirection:"column",gap:t.sizing.scale600}),children:u.map((c,h)=>{const{label:d}=c;if(c.type==="struct"){const p=f.getObjectValue(n.record,c.accessor);return f.jsxRuntimeExports.jsx(cA,{label:d,value:p},h)}if(c.type==="textarea"){const p=f.getObjectValue(n.record,c.accessor),{error:g,markdown:m}=c;return f.jsxRuntimeExports.jsx(hA,{label:d,value:p,error:g,markdown:m},h)}if(c.type==="metadata"){const{cells:p}=c;return f.jsxRuntimeExports.jsx(jv,{label:d,value:n.record,cells:p},h)}return null})})}return f.jsxRuntimeExports.jsxs("div",{children:["No subtasks, no body schema for ",n.name]})}function Dh(i){const[e,t]=D.useStyletron(),{task:n,id:s,metadata:r}=i,{name:o,state:l}=n;return f.jsxRuntimeExports.jsxs(Nn,{id:s,children:[f.jsxRuntimeExports.jsxs("div",{className:e({display:"flex",gap:t.sizing.scale500}),children:[f.jsxRuntimeExports.jsx("div",{className:e({marginTop:"2px"}),children:f.jsxRuntimeExports.jsx(Fa,{state:l})}),f.jsxRuntimeExports.jsx("div",{className:e({...t.typography.LabelLarge,marginBottom:t.sizing.scale100}),children:o})]}),r&&f.jsxRuntimeExports.jsx(f.Row,{items:r,record:n.record})]})}function sm(i){var o;const{task:e,metadata:t,bodySchema:n,overrides:s}=i,r=Xd(e);return(o=e.subTasks)!=null&&o.length||n!=null&&n.length?f.jsxRuntimeExports.jsx(Yd,{id:r,title:f.jsxRuntimeExports.jsx(Dh,{task:e,metadata:t}),defaultExpanded:e.focused,state:e.state,children:f.jsxRuntimeExports.jsx(dA,{task:e,bodySchema:n,metadata:t,overrides:s})}):f.jsxRuntimeExports.jsx(Dh,{id:r,task:e,metadata:t})}function fA(i,e){const{tasks:t}=i,{accessor:n,subTasksAccessor:s}=t;function r(l,a,u){const c=u.findIndex((p,g)=>{const m=i.tasks.stateBuilder(p,g,u,e);return m!==le.SUCCESS&&m!==le.SKIPPED}),h=f.getObjectValue(l,t.header.heading),d=f.getObjectValue(l,"name");return{name:h!=null&&h.trim()?h:d,state:i.tasks.stateBuilder(l,a,u,e),subTasks:s?f.getObjectValue(l,s,[]).map(r):[],record:l,focused:c===a||c===-1&&a===u.length-1}}return f.getObjectValue(e,n,[]).map(r)}function pA(i){var e;return i.length?i.some(({state:t})=>t===le.RUNNING)?le.RUNNING:i.some(({state:t})=>t===le.ERROR)?le.ERROR:((e=i.at(-1))==null?void 0:e.state)??le.PENDING:le.PENDING}function rm(i){const{schema:e,data:t,overrides:n}=i,[s,r]=D.useStyletron(),o=(n==null?void 0:n.taskList)??fA(e,t);if(!o.length)return f.jsxRuntimeExports.jsx(Jt,{illustration:f.jsxRuntimeExports.jsx(mi,{height:"64px",width:"64px",kind:vt.PRIMARY}),title:e.emptyState.title,description:e.emptyState.description});const l=La(o);return f.jsxRuntimeExports.jsxs(Nn,{children:[f.jsxRuntimeExports.jsx(f.Box,{title:f.jsxRuntimeExports.jsxs("div",{className:s({display:"flex",alignItems:"center",gap:r.sizing.scale500}),children:[f.jsxRuntimeExports.jsx(Fa,{state:pA(o)}),"Overview"]}),children:f.jsxRuntimeExports.jsx(Nn,{children:f.jsxRuntimeExports.jsx(tf,{matrix:l,onTaskClick:a=>{Qd(a)},overrides:{TaskListRenderer:n==null?void 0:n.TaskListRenderer,SubTaskListRenderer:n==null?void 0:n.SubTaskListRenderer}})})}),f.jsxRuntimeExports.jsx(Nn,{children:o.map((a,u)=>f.jsxRuntimeExports.jsx(sm,{task:a,metadata:e.tasks.header.metadata,bodySchema:e.tasks.body,overrides:n},u))})]})}function gA(i,e){try{localStorage.setItem(i,JSON.stringify(e))}catch{}}function mA(i,e){try{const t=localStorage.getItem(i);return t===null?e:JSON.parse(t)??e}catch{return e}}const xA={};function om(){return mA(Xh,xA)}function yA(i,e){const t=om();return f.lodashExports.isEqual(f.lodashExports.get(t,i),e)?!1:(gA(Xh,f.lodashExports.set(f.lodashExports.cloneDeep(t),i,e)),!0)}function Wi(i,e){const t=om(),[n,s]=M.useState(f.getObjectValue(t,i,e)??e);return[n,o=>{const l=o instanceof Function?o(n):o;yA(i,l),s(l)}]}function gu({tableSettingsId:i,filterSettingsId:e,initialState:t}){var I;const n=e??i,[s,r]=Wi(`${n}.globalFilter`,(t==null?void 0:t.globalFilter)??oi.globalFilter),[o,l]=Wi(`${n}.columnFilters`,(t==null?void 0:t.columnFilters)??oi.columnFilters),[a,u]=Wi(`${i}.pageSize`,((I=t==null?void 0:t.pagination)==null?void 0:I.pageSize)??oi.pagination.pageSize),[c,h]=Wi(`${i}.sorting`,(t==null?void 0:t.sorting)??oi.sorting),[d,p]=Wi(`${i}.columnOrder`,(t==null?void 0:t.columnOrder)??oi.columnOrder),[g,m]=Wi(`${i}.columnVisibility`,(t==null?void 0:t.columnVisibility)??oi.columnVisibility),[x,y]=M.useState(0),[b,v]=M.useState({}),[C,S]=M.useState((t==null?void 0:t.rowSelectionEnabled)??oi.rowSelectionEnabled),[E,A]=M.useState((t==null?void 0:t.grouping)??oi.grouping);return{globalFilter:s,setGlobalFilter:r,columnFilters:o,setColumnFilters:l,pagination:{pageIndex:x,pageSize:a},setPagination:R=>{const F=typeof R=="function"?R({pageIndex:x,pageSize:a}):R;y(F.pageIndex),u(F.pageSize)},sorting:c,setSorting:h,columnOrder:d,setColumnOrder:p,columnVisibility:g,setColumnVisibility:m,rowSelection:b,setRowSelection:v,rowSelectionEnabled:C,setRowSelectionEnabled:S,grouping:E,setGrouping:A}}const bA=({isOpen:i,onDismiss:e,heading:t,onConfirm:n,confirmLabel:s="Confirm",destructive:r=!1,children:o,size:l=cr.SIZE.small})=>{const[a,u]=M.useState(!1),[c,h]=M.useState(null);M.useEffect(()=>{i||(u(!1),h(null))},[i]);const d=async()=>{u(!0);try{await n(),e()}catch(p){h(p instanceof Error?p.message:"An unexpected error occurred."),u(!1)}};return f.jsxRuntimeExports.jsxs(f.Dialog,{isOpen:i,onDismiss:e,heading:t,size:l,placement:cr.PLACEMENT.topCenter,buttonDock:{primaryAction:f.jsxRuntimeExports.jsx(G.Button,{isLoading:a,onClick:d,overrides:r?{BaseButton:{style:({$theme:p})=>({backgroundColor:p.colors.backgroundNegative})}}:void 0,children:s}),dismissiveAction:f.jsxRuntimeExports.jsx(G.Button,{kind:G.KIND.tertiary,onClick:e,disabled:a,children:"Cancel"})},children:[o,c&&f.jsxRuntimeExports.jsx(Wn.Banner,{kind:Wn.KIND.negative,children:c})]})};function vA({action:i,record:e,onClose:t}){const n=Ge.useNavigate(),s=f.useStudioMutation(i.operation.type==="mutation"?i.operation.mutation:null),r=async()=>{i.operation.type==="mutation"?await s.mutateAsync(e):n(i.operation.route)},{modal:o}=i;return f.jsxRuntimeExports.jsxs(bA,{isOpen:!0,onDismiss:t,onConfirm:r,heading:o.header.title,confirmLabel:o.button.label,destructive:o.destructive,size:o.size,children:[o.banner&&f.jsxRuntimeExports.jsx(f.Banner,{kind:o.banner.kind,artwork:o.banner.icon?{type:Wn.ARTWORK_TYPE.icon,icon:()=>f.jsxRuntimeExports.jsx(f.Icon,{name:o.banner.icon})}:void 0,children:o.banner.content}),o.body&&f.jsxRuntimeExports.jsx(f.Markdown,{children:o.body})]})}function lm({action:i,record:e,onClose:t}){var n;if(((n=i.modal)==null?void 0:n.type)==="custom"){const s=i.modal.component;return f.jsxRuntimeExports.jsx(s,{record:e,onClose:t})}return SA(i)?f.jsxRuntimeExports.jsx(vA,{action:i,record:e,onClose:t}):null}function SA(i){var e;return((e=i.modal)==null?void 0:e.type)==="confirm"}const am=M.forwardRef((i,e)=>{const{item:t,onSelectAction:n,onClose:s,hoveredItem:r,setHoveredItem:o,keyboardActive:l,setKeyboardActive:a,...u}=i,c=r===t,h=t.disabled?void 0:()=>n(t),d=f.jsxRuntimeExports.jsx(po.MenuAdapter,{...u,ref:e,role:"option",artwork:t.display.icon?({size:p})=>f.jsxRuntimeExports.jsx(f.Icon,{name:t.display.icon,size:`${p}px`}):void 0,artworkSize:po.ARTWORK_SIZES.MEDIUM,overrides:{Root:{style:{height:"44px",opacity:t.disabled?.4:1}}},$disabled:t.disabled,onClick:h,children:f.jsxRuntimeExports.jsx(po.ListItemLabel,{children:t.display.label})});return!t.disabled||!t.disabledMessage?d:f.jsxRuntimeExports.jsx(Pi.Tooltip,{content:t.disabledMessage,autoFocus:!1,accessibilityType:Pi.ACCESSIBILITY_TYPE.tooltip,showArrow:!0,placement:Pi.PLACEMENT.left,isOpen:!!u.$isHighlighted&&l||c,popperOptions:{modifiers:{flip:{enabled:!1},preventOverflow:{enabled:!0,boundariesElement:"window",padding:8}}},onEsc:s,onMouseEnterDelay:0,onMouseLeaveDelay:0,onMouseEnter:()=>{o(t),a(!1)},onMouseLeave:()=>o(null),children:d})});am.displayName="ActionMenuItem";function CA({actions:i,onSelectAction:e,onClose:t}){const[n,s]=M.useState(null),[r,o]=M.useState(!1);return f.jsxRuntimeExports.jsx("div",{onKeyDown:()=>{s(null),o(!0)},children:f.jsxRuntimeExports.jsx(Om.StatefulMenu,{items:i,onItemSelect:({item:l})=>{l.disabled||e(l)},overrides:{Option:{component:am,props:{onSelectAction:e,onClose:t,hoveredItem:n,setHoveredItem:s,keyboardActive:r,setKeyboardActive:o}},List:{style:({$theme:l})=>({padding:l.sizing.scale600})}}})})}function wA(i,e){return M.useMemo(()=>i.map(t=>{var s;const n=(s=t.disabled)==null?void 0:s.find(r=>r.condition);return{display:t.display,hierarchy:t.hierarchy,disabled:!!n,disabledMessage:n==null?void 0:n.message,onClick:()=>e(t)}}),[i,e])}function um({actions:i,buttonProps:e,record:t,popoverProps:n}){const s=M.useRef(!1),[r,o]=M.useState(null),l=Ge.useNavigate(),[,a]=D.useStyletron(),u=wA(i,d=>{var p;d.modal?o(d):((p=d.operation)==null?void 0:p.type)==="route"&&l(d.operation.route)}),c=()=>{document.body.style.overflow="hidden",s.current=!0},h=()=>{document.body.style.overflow="",s.current=!1};return M.useEffect(()=>()=>{s.current&&(document.body.style.overflow="")},[]),f.jsxRuntimeExports.jsxs(f.jsxRuntimeExports.Fragment,{children:[f.jsxRuntimeExports.jsx(Nt.StatefulPopover,{focusLock:!0,placement:Nt.PLACEMENT.bottomLeft,popperOptions:{modifiers:{preventOverflow:{enabled:!0,boundariesElement:"window",padding:8}}},...n,content:({close:d})=>f.jsxRuntimeExports.jsx(CA,{actions:u,onSelectAction:p=>{p.onClick(),d()},onClose:d}),onClose:h,onOpen:c,children:f.jsxRuntimeExports.jsx(G.Button,{kind:G.KIND.tertiary,shape:G.SHAPE.pill,overrides:{BaseButton:{style:{paddingLeft:a.sizing.scale100,paddingRight:a.sizing.scale100}}},...e,size:G.SIZE.compact,title:"Actions","data-tracking-name":"actions-popover-button",children:f.jsxRuntimeExports.jsx(f.Icon,{name:"overflowMenu"})})}),r&&f.jsxRuntimeExports.jsx(lm,{action:r,record:t,onClose:()=>o(null)})]})}function EA({actions:i,record:e,...t}){const n=f.useInterpolationResolver(),s=M.useMemo(()=>n(i,{row:e}),[n,i,e]);return f.jsxRuntimeExports.jsx(um,{actions:s,record:e,...t})}function cm(i,e){const t={enableSearch:!i.disableSearch,enableFilters:!i.disableFilters};return{data:e.data,loading:e.loading,error:e.error,columns:i.columns,emptyState:i.emptyState,actions:"actions"in i&&i.actions?({row:n})=>f.jsxRuntimeExports.jsx(EA,{actions:i.actions,record:n.record}):void 0,actionBarConfig:t,disablePagination:i.disablePagination,disableSorting:i.disableSorting,pageSizes:i.pageSizes,enableStickySides:i.enableStickySides}}function RA({isDetailViewLoading:i=!1,queryConfig:e,tableConfig:t,pageId:n}){var d,p;const{projectId:s,phase:r,entity:o}=f.useStudioParams("detail"),{data:l,isLoading:a,error:u}=f.useStudioQuery({queryName:`List${f.capitalizeFirstLetter(e.service)}`,serviceOptions:{namespace:s,...e.serviceOptions},clientOptions:{...e.clientOptions,enabled:!i&&((d=e.clientOptions)==null?void 0:d.enabled)}}),c=gu({tableSettingsId:`${r}/${o}/${n}`,filterSettingsId:`${s}/${r}/${o}/${n}`}),h=cm(t,{data:((p=l==null?void 0:l[`${e.service}List`])==null?void 0:p.items)??[],loading:a||i,error:u??void 0});return f.jsxRuntimeExports.jsx(Ur,{...h,state:c})}function kA({page:i,data:e,isLoading:t}){switch(i.type){case"custom":return M.createElement(i.component,{data:e,isLoading:t});case"execution":return f.jsxRuntimeExports.jsx(rm,{schema:i,data:e??{}});case"table":{const n=i;return f.jsxRuntimeExports.jsx(RA,{isDetailViewLoading:t,queryConfig:n.queryConfig,tableConfig:n.tableConfig,pageId:n.id})}default:return f.jsxRuntimeExports.jsxs("div",{children:["Page type '",i.type,"' not yet supported"]})}}function AA(i){const e=D.mergeOverrides(i.overrides,{Root:{style:{transform:"unset"}},TabBorder:{style:{zIndex:-1}},TabHighlight:{style:{zIndex:0}}});return f.jsxRuntimeExports.jsx(hr.Tabs,{...i,overrides:e})}function TA(i){const e=D.mergeOverrides(i.overrides,{TabPanel:{style:({$theme:t})=>({paddingTop:t.sizing.scale950,paddingLeft:0,paddingRight:0})}});return f.jsxRuntimeExports.jsx(hr.Tab,{...i,overrides:e})}function hm({tabs:i,activeTabId:e,onTabSelect:t}){var s;const n=e??((s=i[0])==null?void 0:s.id);return!i||i.length===0?f.jsxRuntimeExports.jsx("div",{children:"No tabs available"}):f.jsxRuntimeExports.jsx(AA,{activeKey:n,onChange:({activeKey:r})=>t==null?void 0:t(r),children:i.map(r=>f.jsxRuntimeExports.jsx(TA,{title:r.label,children:r.content},r.id))})}function Lh({action:i,onClick:e,loading:t,kind:n,shape:s,overrides:r}){var c;const[o,l]=D.useStyletron(),a=(c=i.disabled)==null?void 0:c.find(h=>h.condition),u=f.jsxRuntimeExports.jsx(G.Button,{kind:n,shape:s,size:G.SIZE.compact,isLoading:t,disabled:!!a,overrides:r,startEnhancer:i.display.icon?()=>f.jsxRuntimeExports.jsx(f.Icon,{name:i.display.icon,size:l.sizing.scale550,color:"inherit"}):void 0,onClick:e,children:i.display.label});return a!=null&&a.message?f.jsxRuntimeExports.jsx(Pi.StatefulTooltip,{content:a.message,accessibilityType:Pi.ACCESSIBILITY_TYPE.tooltip,placement:Pi.PLACEMENT.bottom,showArrow:!0,children:f.jsxRuntimeExports.jsx("span",{className:o({display:"inline-flex"}),children:u})}):u}function MA(i){return{primary:i.find(e=>e.hierarchy===Xt.PRIMARY),secondary:i.filter(e=>e.hierarchy===Xt.SECONDARY),tertiary:i.filter(e=>!e.hierarchy||e.hierarchy===Xt.TERTIARY)}}function OA({actions:i,record:e,loading:t}){const[n,s]=D.useStyletron(),[r,o]=M.useState(null),l=Ge.useNavigate();if(i.length===0)return null;const{primary:a,secondary:u,tertiary:c}=MA(i),h=d=>{var p;d.modal?o(d):((p=d.operation)==null?void 0:p.type)==="route"&&l(d.operation.route)};return f.jsxRuntimeExports.jsxs(f.jsxRuntimeExports.Fragment,{children:[f.jsxRuntimeExports.jsxs("div",{className:n({display:"flex",gap:s.sizing.scale300}),children:[a&&f.jsxRuntimeExports.jsx(Lh,{action:a,onClick:()=>h(a),loading:t,kind:G.KIND.primary,overrides:{Root:{style:{width:"200px"}}}}),u.map(d=>f.jsxRuntimeExports.jsx(Lh,{action:d,onClick:()=>h(d),loading:t,kind:G.KIND.secondary,shape:G.SHAPE.pill},d.display.label)),c.length>0&&f.jsxRuntimeExports.jsx(um,{actions:c,record:e,popoverProps:{placement:Nt.PLACEMENT.bottomRight}})]}),r&&f.jsxRuntimeExports.jsx(lm,{action:r,record:e,onClose:()=>o(null)})]})}const IA=D.styled("div",({$theme:i})=>({...i.borders.border200,backgroundColor:i.colors.backgroundSecondary,borderRadius:i.borders.radius400,display:"flex",flexDirection:"column",gap:i.sizing.scale600,padding:i.sizing.scale800}));function jA({subtitle:i,title:e,titleEnhancer:t,onGoBack:n,children:s,actions:r,record:o,loading:l}){const[a,u]=D.useStyletron(),c=f.useInterpolationResolver(),h=M.useMemo(()=>r?c(r,{page:o}):void 0,[c,r,o]);return f.jsxRuntimeExports.jsxs(IA,{children:[f.jsxRuntimeExports.jsxs("div",{className:a({display:"flex",gap:u.sizing.scale800,justifyContent:"flex-start",alignItems:"flex-end"}),children:[f.jsxRuntimeExports.jsxs("h5",{className:a({margin:0,maxWidth:"50%"}),children:[i&&f.jsxRuntimeExports.jsx("div",{className:a({...u.typography.LabelSmall,color:u.colors.contentTertiary,marginBottom:u.sizing.scale300}),children:i}),f.jsxRuntimeExports.jsxs("div",{className:a({display:"flex",alignItems:"center",gap:u.sizing.scale300}),children:[n&&f.jsxRuntimeExports.jsx(G.Button,{"aria-label":"Go back",onClick:n,kind:G.KIND.tertiary,shape:G.SHAPE.circle,size:G.SIZE.compact,overrides:{BaseButton:{style:({$theme:d})=>({flexShrink:0,":hover":{backgroundColor:d.colors.contentInverseSecondary}})}},children:f.jsxRuntimeExports.jsx(f.Icon,{name:"arrowLeft",size:u.sizing.scale700})}),f.jsxRuntimeExports.jsx("div",{className:a({...u.typography.HeadingSmall,...Zd}),children:e})]})]}),t,h&&f.jsxRuntimeExports.jsx("div",{className:a({marginLeft:"auto",flexShrink:0}),children:f.jsxRuntimeExports.jsx(OA,{actions:h,record:o??{},loading:l})})]}),s]})}function dm({title:i,subtitle:e,onGoBack:t,headerContent:n,children:s,actions:r,record:o,loading:l,titleEnhancer:a}){const[u,c]=D.useStyletron();return f.jsxRuntimeExports.jsxs("div",{className:u({display:"flex",flexDirection:"column",gap:c.sizing.scale800}),children:[f.jsxRuntimeExports.jsx(jA,{title:i,subtitle:e,titleEnhancer:a,onGoBack:t,actions:r,record:o,loading:l,children:n}),s]})}function PA({phases:i=Da}){const[,e]=D.useStyletron(),{phase:t,entity:n,entityId:s,projectId:r,entityTab:o}=f.useStudioParams("detail"),l=Ge.useNavigate(),a=i[t].entities.find(b=>b.id===n),u=f.useInterpolationResolver(),{data:c,isLoading:h,error:d}=f.useStudioQuery({queryName:`Get${f.capitalizeFirstLetter((a==null?void 0:a.service)??"")}`,serviceOptions:{namespace:r,name:s},clientOptions:{enabled:!!(a!=null&&a.service)&&!!s}}),p=M.useCallback((b,v)=>{l(`/${r}/${t}/${n}/${s}/${b}`,v)},[l,r,t,n,s]),g=()=>{l(`/${r}/${t}/${n}`)},m=((a==null?void 0:a.views)??[]).find(b=>b.type==="detail")??void 0;if(M.useEffect(()=>{var C;if(d||h||!s||!((C=m==null?void 0:m.pages)!=null&&C.length))return;const b=m.pages.map(S=>S.id),v=b[0];o?b.includes(o)||p(v,{replace:!0}):p(v,{replace:!0})},[o,m,h,d,p]),d)return f.jsxRuntimeExports.jsx(Jt,{title:"Entity not found",description:`Could not load ${n} "${s}". ${d.message}`,illustration:f.jsxRuntimeExports.jsx(mi,{kind:vt.ERROR,width:e.sizing.scale1600,height:e.sizing.scale1600}),buttonConfig:{onClick:()=>l(`/${r}/${t}/${n}`),content:"Back to list"}});const x=c==null?void 0:c[a.service],y=u(m,{page:x});return f.jsxRuntimeExports.jsx(dm,{subtitle:a.name,title:s,onGoBack:g,actions:a.actions,record:x,loading:h,headerContent:f.jsxRuntimeExports.jsx(f.Row,{items:y.metadata,record:x,loading:h}),children:f.jsxRuntimeExports.jsx(hm,{tabs:y.pages.map(b=>({id:b.id,label:b.label,content:f.jsxRuntimeExports.jsx(kA,{page:b,data:x,isLoading:h})})),activeTabId:o,onTabSelect:p})})}function DA({icon:i,docUrl:e,label:t,description:n}){const[s,r]=D.useStyletron();return f.jsxRuntimeExports.jsx("div",{className:s({display:"flex",justifyContent:"space-between",alignItems:"center"}),children:f.jsxRuntimeExports.jsxs("div",{className:s({display:"grid",gridTemplateColumns:i?"auto 1fr":"1fr",gridTemplateRows:"auto auto",columnGap:r.sizing.scale500,rowGap:r.sizing.scale100,alignItems:"center"}),children:[i&&f.jsxRuntimeExports.jsx(f.Icon,{name:i,size:r.sizing.scale600}),f.jsxRuntimeExports.jsx(ze.HeadingSmall,{as:"h2",className:s({margin:0}),children:t}),n&&i&&f.jsxRuntimeExports.jsx("div",{}),n&&f.jsxRuntimeExports.jsxs(f.DescriptionText,{children:[n,e&&f.jsxRuntimeExports.jsx(G.Button,{"aria-label":"Learn more",kind:G.KIND.tertiary,onClick:()=>window.open(e,"_blank"),shape:G.SHAPE.circle,size:G.SIZE.mini,overrides:{BaseButton:{style:{height:r.typography.ParagraphSmall.lineHeight,width:r.typography.ParagraphSmall.lineHeight}}},children:f.jsxRuntimeExports.jsx(f.Icon,{name:"arrowLaunch",size:r.sizing.scale500})})]})]})})}function LA(i,e){if(e!=null&&e.length&&i==="pipeline")return{fieldSelector:`pipeline_type in (${e.join(",")})`}}function FA({service:i,tableConfig:e,tableSettingsId:t,pipelineTypes:n}){var h;const{projectId:s}=f.useStudioParams("base"),r=LA(i,n),{data:o,isLoading:l,error:a}=f.useStudioQuery({queryName:`List${f.capitalizeFirstLetter(i)}`,serviceOptions:{namespace:s,...r&&{listOptions:r}}}),u=gu({filterSettingsId:`${s}/${t}`,tableSettingsId:t}),c=cm(e,{data:((h=o==null?void 0:o[`${i}List`])==null?void 0:h.items)??[],loading:l,error:a??void 0});return f.jsxRuntimeExports.jsx(Ur,{...c,state:u})}function NA({phaseConfig:i,entities:e}){const[t,n]=D.useStyletron(),s=Ge.useNavigate(),{projectId:r,entity:o}=f.useStudioParams("list");M.useEffect(()=>{o||s(`/${r}/${i.id}/${e[0].id}`)},[o,s,r,i.id,e]);const l=e.findIndex(h=>h.id===o),a=l>=0?l.toString():"0",u=({activeKey:h})=>{const d=e[Number(h)];d&&s(`/${r}/${i.id}/${d.id}`)},c=e.find(h=>h.id===o);return c?f.jsxRuntimeExports.jsxs("div",{className:t({marginTop:n.sizing.scale800}),children:[f.jsxRuntimeExports.jsx(DA,{icon:i.icon,label:i.name,description:i.description,docUrl:i.docUrl}),f.jsxRuntimeExports.jsx(hr.Tabs,{activeKey:a,onChange:u,overrides:{Root:{style:({$theme:h})=>({marginTop:h.sizing.scale600})}},children:e.map((h,d)=>f.jsxRuntimeExports.jsx(hr.Tab,{title:h.name,children:String(d)===a&&f.jsxRuntimeExports.jsx(FA,{service:h.service,tableConfig:{...c.views[0].tableConfig,actions:h.actions},tableSettingsId:`${i.id}/${h.id}`,pipelineTypes:i.pipelineTypes})},String(d)))})]}):o?f.jsxRuntimeExports.jsx(Jt,{buttonConfig:{onClick:()=>s(`/${r}`),content:"Go home"},description:`Entity "${o}" not found`,illustration:f.jsxRuntimeExports.jsx(mi,{kind:vt.ERROR,width:n.sizing.scale1600,height:n.sizing.scale1600}),title:"Entity not found"}):null}function BA(i){return i.state==="active"&&i.views.some(e=>e.type==="list")}function VA({phases:i=Da}={}){const[,e]=D.useStyletron(),{phase:t,projectId:n}=f.useStudioParams("list"),s=Ge.useNavigate();if(!(t in i))return f.jsxRuntimeExports.jsx(Jt,{title:"Phase not found",description:`Phase "${t}" configuration not found. Available phases: ${Object.keys(i).join(", ")}`,illustration:f.jsxRuntimeExports.jsx(mi,{kind:vt.ERROR,width:e.sizing.scale1600,height:e.sizing.scale1600}),buttonConfig:{onClick:()=>s(`/${n}`),content:"Go home"}});const r=i[t].entities.filter(BA);return r.length===0?f.jsxRuntimeExports.jsx(Jt,{title:"Phase has no active entities",description:`Phase "${t}" has no active entities with list views configured.`,illustration:f.jsxRuntimeExports.jsx(mi,{kind:vt.ERROR,width:e.sizing.scale1600,height:e.sizing.scale1600}),buttonConfig:{onClick:()=>s(`/${n}`),content:"Go home"}}):f.jsxRuntimeExports.jsx(NA,{phaseConfig:i[t],entities:r})}function _A({categories:i,topLevelLinks:e}){return f.jsxRuntimeExports.jsxs(f.jsxRuntimeExports.Fragment,{children:[f.jsxRuntimeExports.jsx(f.BreadcrumbBar,{categories:i,topLevelLinks:e}),f.jsxRuntimeExports.jsx(Ge.Outlet,{})]})}const zA=[Nd,Kd,zd,qd,$d];function $A(){return f.jsxRuntimeExports.jsxs(Ge.Routes,{children:[f.jsxRuntimeExports.jsx(Ge.Route,{index:!0,element:f.jsxRuntimeExports.jsx(Ui,{children:f.jsxRuntimeExports.jsx(Kx,{})})}),f.jsxRuntimeExports.jsx(Ge.Route,{path:"sandbox",element:f.jsxRuntimeExports.jsx(Ui,{children:f.jsxRuntimeExports.jsx(Wb,{})})}),f.jsxRuntimeExports.jsxs(Ge.Route,{element:f.jsxRuntimeExports.jsx(_A,{categories:Av}),children:[f.jsxRuntimeExports.jsx(Ge.Route,{path:":projectId",element:f.jsxRuntimeExports.jsx(Ui,{children:f.jsxRuntimeExports.jsx(Fm,{phases:zA})})}),f.jsxRuntimeExports.jsx(Ge.Route,{path:":projectId/:phase/:entity/:entityId/:entityTab?",element:f.jsxRuntimeExports.jsx(Ui,{children:f.jsxRuntimeExports.jsx(PA,{})})}),f.jsxRuntimeExports.jsx(Ge.Route,{path:":projectId/:phase/:entity?",element:f.jsxRuntimeExports.jsx(Ui,{children:f.jsxRuntimeExports.jsx(VA,{})})})]})]})}function mu(i){return i instanceof f.Interpolation||f.StringInterpolation.isInterpolation(i)}function ga(i){return mu(i)?!0:f.lodashExports.isArray(i)?i.some(ga):f.isRecord(i)?f.lodashExports.values(i).some(ga):!1}function fm(i){return f.lodashExports.mapValues(i,e=>{if(f.lodashExports.isNil(e)||Array.isArray(e))return e;if(!mu(e))return f.isRecord(e)?fm(e):e})}function HA({children:i,value:e}){return f.jsxRuntimeExports.jsx(f.InterpolationContext.Provider,{value:e,children:i})}function xu({children:i,...e}){return f.jsxRuntimeExports.jsx(f.RepeatedLayoutContext.Provider,{value:e,children:i})}function GA(){const{fieldRegistry:i}=Aa(),e=Kr();return{fieldRegistry:i,change:e.change,submit:e.submit}}const WA=({children:i})=>{const[e]=D.useStyletron();return f.jsxRuntimeExports.jsx("div",{className:e({boxSizing:"border-box"}),children:i})},UA=({title:i,kind:e="info",dismissible:t=!1,content:n})=>{const[s,r]=M.useState(!1),[o,l]=D.useStyletron();return s?null:f.jsxRuntimeExports.jsx(f.Banner,{title:i,artwork:{type:Wn.ARTWORK_TYPE.icon,icon:()=>f.jsxRuntimeExports.jsx(f.Icon,{name:e==="info"?"circleI":"circleExclamation",size:l.sizing.scale800})},kind:e,action:t?{label:"Dismiss",icon:()=>f.jsxRuntimeExports.jsx(f.Icon,{name:"x-filled"}),onClick:()=>r(!0)}:void 0,children:typeof n=="string"?f.jsxRuntimeExports.jsx(f.Markdown,{children:n}):n})},qA=({name:i,description:e,children:t})=>{const[n,s]=D.useStyletron();return f.jsxRuntimeExports.jsxs("section",{children:[f.jsxRuntimeExports.jsxs("div",{className:n({display:"flex",alignItems:"flex-start",flexDirection:"column",gap:s.sizing.scale300,marginBottom:s.sizing.scale600}),children:[f.jsxRuntimeExports.jsx(ze.HeadingSmall,{margin:0,children:i}),e&&f.jsxRuntimeExports.jsx(ze.ParagraphSmall,{margin:0,children:f.jsxRuntimeExports.jsx(f.Markdown,{children:e})})]}),t]})};function $r(){return $r=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},$r.apply(null,arguments)}function Fh(i,e){if(i==null)return{};var t={};for(var n in i)if({}.hasOwnProperty.call(i,n)){if(e.indexOf(n)!==-1)continue;t[n]=i[n]}return t}var KA=function(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&!e.some(function(n,s){return n!==t[s]})};function YA(i){var e=M.useRef();return e.current||(e.current=i()),e.current}var XA=["length"],QA=["meta","input"],JA=wa.reduce(function(i,e){return i[e]=!0,i},{}),ZA=function(e,t){var n={},s=n.subscription,r=s===void 0?JA:s,o=n.defaultValue,l=n.initialValue,a=n.isEqual,u=a===void 0?KA:a,c=n.validate,h=Kr("useFieldArray"),d=h.mutators,p=!!(d&&d.push&&d.pop);if(!p)throw new Error("Array mutators not found. You need to provide the mutators from final-form-arrays to your form");var g=M.useMemo(function(){return Object.keys(d).reduce(function(I,R){return I[R]=function(){for(var H=arguments.length,F=new Array(H),j=0;j<H;j++)F[j]=arguments[j];return d[R].apply(d,[e].concat(F))},I},{})},[e,d]),m=YA(function(){return function(I,R,H){if(c){var F=c(I,R,H);if(!F||Array.isArray(F))return F;var j=[];return j[nn]=F,j}}}),x=Ea(e,{subscription:$r({},r,{length:!0}),defaultValue:o,initialValue:l,isEqual:u,validate:m,format:function(R){return R}}),y=x.meta,b=y.length,v=Fh(y,XA),C=x.input,S=Fh(x,QA),E=function(R){for(var H=b||0,F=0;F<H;F++)R(e+"["+F+"]",F)},A=function(R){for(var H=b||0,F=[],j=0;j<H;j++)F.push(R(e+"["+j+"]",j));return F};return{fields:$r({name:e,forEach:E,length:b||0,map:A},g,S,{value:C.value}),meta:v}};function pm(i,{minItems:e=0,readOnly:t=!1}={}){const{fields:n}=ZA(i),s=M.useRef(Array.from({length:n.length??0},()=>crypto.randomUUID()));M.useEffect(()=>{const a=n.length??0;if(a<e)for(let u=a;u<e;u++)s.current.push(crypto.randomUUID()),n.push({})},[n,e]);const r=(n.length??0)>e&&!t,o=()=>{s.current.push(crypto.randomUUID()),n.push({})},l=a=>{r&&(s.current.splice(a,1),n.remove(a))};return{entries:n.map((a,u)=>({id:s.current[u],indexedFieldPath:a})),handleItemAdd:o,remove:l,isRemovable:r}}function eT({rootFieldPath:i,minItems:e=0,readOnly:t=!1,children:n,name:s,span:r,addLabel:o="Add more"}){const[l,a]=D.useStyletron(),{entries:u,handleItemAdd:c,remove:h,isRemovable:d}=pm(i,{minItems:e,readOnly:t});return f.jsxRuntimeExports.jsxs(f.jsxRuntimeExports.Fragment,{children:[u.map(({id:p,indexedFieldPath:g},m)=>{const x=n(g,m),y=M.isValidElement(x)&&x.type===M.Fragment?x.props.children:x;return f.jsxRuntimeExports.jsx(xu,{index:m,rootFieldPath:i,children:f.jsxRuntimeExports.jsxs("div",{className:l({display:"flex",alignItems:"end",gap:a.sizing.scale300}),children:[f.jsxRuntimeExports.jsx(Ia,{name:s,span:r,children:y}),d&&f.jsxRuntimeExports.jsx(G.Button,{type:"button",kind:G.KIND.tertiary,shape:G.SHAPE.circle,size:G.SIZE.default,"aria-label":"Remove",onClick:()=>h(m),children:f.jsxRuntimeExports.jsx(f.Icon,{name:"deleteAlt",kind:f.IconKind.SECONDARY})})]})},p)}),!t&&f.jsxRuntimeExports.jsx(Xr,{label:o,onClick:c})]})}function tT({rootFieldPath:i,groupLabel:e,addLabel:t,minItems:n=0,readOnly:s=!1,children:r,description:o,tooltip:l,collapsible:a}){const{entries:u,handleItemAdd:c,remove:h,isRemovable:d}=pm(i,{minItems:n,readOnly:s}),p=t??(e?`Add ${e.toLowerCase()}`:"Add more"),[g,m]=D.useStyletron();return f.jsxRuntimeExports.jsxs("div",{className:g({display:"flex",flexDirection:"column",gap:m.sizing.scale800}),children:[u.map(({id:x,indexedFieldPath:y},b)=>f.jsxRuntimeExports.jsx(xu,{index:b,rootFieldPath:i,children:f.jsxRuntimeExports.jsx(Oa,{title:e?`${e} ${b+1}`:void 0,description:o,tooltip:l,collapsible:a,endEnhancer:d&&f.jsxRuntimeExports.jsx(G.Button,{type:"button",kind:G.KIND.secondary,shape:G.SHAPE.pill,size:G.SIZE.compact,startEnhancer:f.jsxRuntimeExports.jsx(f.Icon,{name:"trashCan",kind:f.IconKind.PRIMARY}),"aria-label":"Remove",onClick:()=>h(b),children:"Remove"}),overrides:{BoxContainer:{style:{marginBottom:0}}},children:r(y,b)})},x)),!s&&f.jsxRuntimeExports.jsx(Xr,{label:p,shape:G.SHAPE.pill,onClick:c})]})}var gm=(i=>(i.Admin="admin",i.Viewer="viewer",i))(gm||{});function iT({dependencies:i}){var e,t;return f.jsxRuntimeExports.jsx(f.ThemeProvider,{icons:i.theme.icons,children:f.jsxRuntimeExports.jsx(bm.LayersManager,{zIndex:200,children:f.jsxRuntimeExports.jsx(vm.SnackbarProvider,{children:f.jsxRuntimeExports.jsx(f.ServiceProvider,{...i.service,children:f.jsxRuntimeExports.jsx(f.ErrorProvider,{...i.error,children:f.jsxRuntimeExports.jsx(f.IconProvider,{icons:i.theme.icons,children:f.jsxRuntimeExports.jsxs(f.UserProvider,{...i.user??{timeZone:f.TimeZone.Local},children:[f.jsxRuntimeExports.jsx(Dm,{links:(e=i.navigationBar)==null?void 0:e.links,onSignOut:(t=i.navigationBar)==null?void 0:t.onSignOut}),f.jsxRuntimeExports.jsx($A,{})]})})})})})})})}exports.ApplicationError=f.ApplicationError;exports.BooleanCell=f.BooleanCell;exports.CellType=f.CellType;exports.DateCell=f.DateCell;exports.DefaultCellRenderer=f.DefaultCellRenderer;exports.DescriptionCell=f.DescriptionCell;exports.DescriptionHierarchy=f.DescriptionHierarchy;exports.GrpcStatusCode=f.GrpcStatusCode;exports.Interpolation=f.Interpolation;exports.LinkCell=f.LinkCell;exports.MultiCell=f.MultiCell;exports.Phase=f.Phase;exports.StateCell=f.StateCell;exports.StringInterpolation=f.StringInterpolation;exports.TagCell=f.TagCell;exports.TextCell=f.TextCell;exports.TimeZone=f.TimeZone;exports.TypeCell=f.TypeCell;exports.capitalizeFirstLetter=f.capitalizeFirstLetter;exports.cellTooltipHoc=f.cellTooltipHoc;exports.getDateFromEpochSeconds=f.getDateFromEpochSeconds;exports.getEpochSecondsFromDate=f.getEpochSecondsFromDate;exports.getObjectSymbols=f.getObjectSymbols;exports.getObjectValue=f.getObjectValue;exports.isAbsoluteUrl=f.isAbsoluteUrl;exports.isNavigableUrl=f.isNavigableUrl;exports.isRecord=f.isRecord;exports.parseIsoString=f.parseIsoString;exports.safeStringify=f.safeStringify;exports.sentenceCaseEnumValue=f.sentenceCaseEnumValue;exports.timestampToString=f.timestampToString;exports.toFlatDotPathMap=f.toFlatDotPathMap;exports.useCellStyles=f.useCellStyles;exports.useCellToString=f.useCellToString;exports.useErrorNormalizer=f.useErrorNormalizer;exports.useGetCellRenderer=f.useGetCellRenderer;exports.useInterpolationResolver=f.useInterpolationResolver;exports.useRepeatedLayoutContext=f.useRepeatedLayoutContext;exports.useStudioMutation=f.useStudioMutation;exports.useStudioParams=f.useStudioParams;exports.useStudioQuery=f.useStudioQuery;exports.useSuccessOperations=f.useSuccessOperations;exports.useUrlQueryString=f.useUrlQueryString;exports.ActionHierarchy=Xt;exports.AddButton=Xr;exports.ArrayFormGroup=tT;exports.ArrayFormRow=eT;exports.BooleanField=bd;exports.CheckboxField=vd;exports.CoreApp=iT;exports.DateField=Sd;exports.DateFormat=sn;exports.DetailView=dm;exports.DetailViewPages=hm;exports.Execution=rm;exports.FilterMode=Wr;exports.Form=Yr;exports.FormBanner=UA;exports.FormColumn=WA;exports.FormControl=Ye;exports.FormDialog=Pd;exports.FormErrorBanner=jd;exports.FormGroup=Oa;exports.FormRow=Ia;exports.FormStep=qA;exports.FunctionInterpolation=Id;exports.InterpolationProvider=HA;exports.MarkdownField=Cd;exports.NumberField=wd;exports.RadioField=Ed;exports.RepeatedLayoutProvider=xu;exports.SelectField=Rd;exports.StringField=Qr;exports.SubmitButton=ka;exports.TASK_STATE=le;exports.Table=Ur;exports.TaskListRenderer=bl;exports.TaskStepCard=ef;exports.TextareaField=Ta;exports.UrlField=kd;exports.UserRole=gm;exports.clearUnresolvedInterpolations=fm;exports.hasInterpolationProperty=ga;exports.interpolate=Fn;exports.isInterpolation=mu;exports.useField=it;exports.useForm=GA;exports.useFormState=Ra;exports.useLocalStorageTableState=gu;exports.useTableSelectionContext=Sx;