@michelangelo-ai/core 0.10.0 → 0.11.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/breadcrumb-bar/breadcrumb-bar.d.ts.map +1 -1
- package/dist/components/breadcrumb-bar/phase-entity-list.d.ts.map +1 -1
- package/dist/components/form/fields/map/key-value-row.d.ts.map +1 -1
- package/dist/components/form/fields/map/types.d.ts +12 -2
- package/dist/components/form/fields/map/types.d.ts.map +1 -1
- package/dist/components/form/fields/select/build-select-overrides.d.ts.map +1 -1
- package/dist/components/form/fields/types.d.ts +9 -2
- package/dist/components/form/fields/types.d.ts.map +1 -1
- package/dist/components/row/components/row-label.d.ts +1 -0
- package/dist/components/row/components/row-label.d.ts.map +1 -1
- package/dist/components/row/types.d.ts +4 -0
- package/dist/components/row/types.d.ts.map +1 -1
- package/dist/components/table/components/table-header/table-header.d.ts +1 -1
- package/dist/components/table/components/table-header/table-header.d.ts.map +1 -1
- package/dist/components/table/components/table-header/types.d.ts +5 -0
- package/dist/components/table/components/table-header/types.d.ts.map +1 -1
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/types/table-types.d.ts +9 -0
- package/dist/components/table/types/table-types.d.ts.map +1 -1
- package/dist/components/views/phase-entity-view/entity-table.d.ts +4 -1
- package/dist/components/views/phase-entity-view/entity-table.d.ts.map +1 -1
- package/dist/components/views/phase-entity-view/phase-entity-view.d.ts.map +1 -1
- package/dist/components/views/phase-entity-view/types.d.ts +6 -1
- package/dist/components/views/phase-entity-view/types.d.ts.map +1 -1
- package/dist/components/views/phase-entity-view/utils/inject-list-options.d.ts +3 -0
- package/dist/components/views/phase-entity-view/utils/inject-list-options.d.ts.map +1 -1
- package/dist/components/views/project/components/phase-card.d.ts.map +1 -1
- package/dist/components/views/project/constants.d.ts +10 -0
- package/dist/components/views/project/constants.d.ts.map +1 -1
- package/dist/components/views/types.d.ts +28 -0
- package/dist/components/views/types.d.ts.map +1 -1
- package/dist/components/views/utils/table-view-adapter.d.ts.map +1 -1
- package/dist/config/entities/deployment/create-deployment-form.d.ts +1 -0
- package/dist/config/entities/deployment/create-deployment-form.d.ts.map +1 -1
- package/dist/config/entities/deployment/deployment-form.d.ts +21 -0
- package/dist/config/entities/deployment/deployment-form.d.ts.map +1 -0
- package/dist/config/entities/deployment/deployment.d.ts.map +1 -1
- package/dist/config/entities/deployment/list.d.ts.map +1 -1
- package/dist/config/entities/deployment/model-family-revision-fields.d.ts +5 -1
- package/dist/config/entities/deployment/model-family-revision-fields.d.ts.map +1 -1
- package/dist/config/entities/deployment/shared.d.ts +2 -0
- package/dist/config/entities/deployment/shared.d.ts.map +1 -1
- package/dist/config/entities/deployment/types.d.ts +18 -2
- package/dist/config/entities/deployment/types.d.ts.map +1 -1
- package/dist/config/entities/deployment/update-deployment-form.d.ts +4 -0
- package/dist/config/entities/deployment/update-deployment-form.d.ts.map +1 -0
- package/dist/config/entities/model/model-deployments-table.d.ts +13 -0
- package/dist/config/entities/model/model-deployments-table.d.ts.map +1 -0
- package/dist/config/entities/model/model-info-page.d.ts.map +1 -1
- package/dist/config/entities/model/types.d.ts +1 -0
- package/dist/config/entities/model/types.d.ts.map +1 -1
- package/dist/config/entities/pipeline/create-pipeline-run-form.d.ts.map +1 -1
- package/dist/config/entities/pipeline/list.d.ts.map +1 -1
- package/dist/config/entities/pipeline/resume-run-fields.d.ts.map +1 -1
- package/dist/config/entities/pipeline/revision-list.d.ts +12 -0
- package/dist/config/entities/pipeline/revision-list.d.ts.map +1 -0
- package/dist/config/entities/pipeline/run-trigger-form.d.ts.map +1 -1
- package/dist/config/entities/pipeline/types.d.ts +36 -0
- package/dist/config/entities/pipeline/types.d.ts.map +1 -1
- package/dist/config/entities/run/run-configuration-page.d.ts.map +1 -1
- package/dist/config/entities/run/run-info-page.d.ts.map +1 -1
- package/dist/config/entities/run/shared.d.ts +8 -0
- package/dist/config/entities/run/shared.d.ts.map +1 -1
- package/dist/config/entities/run/types.d.ts +27 -8
- package/dist/config/entities/run/types.d.ts.map +1 -1
- package/dist/config/entities/targets/__tests__/create-inference-server-form.test.d.ts +2 -0
- package/dist/config/entities/targets/__tests__/create-inference-server-form.test.d.ts.map +1 -0
- package/dist/config/entities/targets/__tests__/inference-server-cluster-fields.test.d.ts +2 -0
- package/dist/config/entities/targets/__tests__/inference-server-cluster-fields.test.d.ts.map +1 -0
- package/dist/config/entities/targets/create-inference-server-form.d.ts.map +1 -1
- package/dist/config/entities/targets/inference-server-cluster-fields.d.ts +17 -0
- package/dist/config/entities/targets/inference-server-cluster-fields.d.ts.map +1 -0
- package/dist/config/entities/targets/shared.d.ts +6 -2
- package/dist/config/entities/targets/shared.d.ts.map +1 -1
- package/dist/config/entities/targets/types.d.ts +46 -0
- package/dist/config/entities/targets/types.d.ts.map +1 -1
- package/dist/michelangelo-core.cjs +18 -16
- package/dist/michelangelo-core.js +9445 -9032
- package/dist/primitives.cjs +1 -1
- package/dist/primitives.js +7 -7
- package/dist/test/wrappers/get-service-provider-wrapper.d.ts +7 -1
- package/dist/test/wrappers/get-service-provider-wrapper.d.ts.map +1 -1
- package/dist/{theme-provider-BLwt8TXI.js → theme-provider-B4ovzOEb.js} +1136 -1126
- package/dist/{theme-provider-OUbecRuK.cjs → theme-provider-jFjyiivT.cjs} +62 -62
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/common/studio-types.d.ts +6 -4
- package/dist/types/common/studio-types.d.ts.map +1 -1
- package/dist/utils/string-utils.d.ts +14 -0
- package/dist/utils/string-utils.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./theme-provider-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./theme-provider-jFjyiivT.cjs"),fx=require("baseui/layer"),px=require("baseui/snackbar"),mx=require("baseui/app-nav-bar"),U=require("baseui/button"),A=require("react"),Ke=require("react-router-dom-v5-compat"),Tr=require("baseui/layout-grid"),M=require("baseui"),ge=require("baseui/typography"),zt=require("baseui/popover"),vn=require("baseui/tag"),zi=require("baseui/tooltip"),za=require("baseui/data-table"),Qe=require("baseui/input"),Wt=require("baseui/table-semantic"),Bi=require("baseui/checkbox"),pr=require("baseui/dnd-list"),Si=require("baseui/skeleton"),gx=require("baseui/pagination"),dn=require("baseui/select"),Bs=require("baseui/block"),xx=require("baseui/helpers/overrides"),yx=require("baseui/form-control"),bx=require("baseui/datepicker"),Ed=require("baseui/textarea"),Pi=require("baseui/tile"),Lo=require("baseui/radio"),Sx=require("baseui/icon"),vx=require("baseui/accordion"),Ar=require("baseui/dialog"),Ex=require("baseui/link"),ns=require("baseui/banner"),Cx=require("baseui/spinner"),Rx=require("baseui/menu"),No=require("baseui/list"),jr=require("baseui/tabs-motion"),iu=require("baseui/segmented-control");function wx(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 ve=wx(A),kx=A.forwardRef(function(e,t){const{children:n,...s}=e;return h.jsxRuntimeExports.jsx(U.Button,{...s,ref:t,children:A.Children.map(n,(r,o)=>o===1&&A.isValidElement(r)?A.cloneElement(r,{overrides:{Svg:{style:{paddingLeft:0}}}}):r)})}),Tx=[{label:"Sign out"}];function Ax({links:i,onSignOut:e}){const t=h.useUserProvider(),n=(i==null?void 0:i.map(s=>({label:s.label,info:{href:s.href}})))??[];return h.jsxRuntimeExports.jsx(mx.AppNavBar,{title:h.jsxRuntimeExports.jsx(h.Link,{href:"/",overrides:{Link:{style:{":hover":{textDecoration:"unset"}}}},children:"Michelangelo Studio"}),mainItems:n,mapItemToNode:s=>{const r=s.info;return r!=null&&r.href?h.jsxRuntimeExports.jsx(U.Button,{href:r.href,target:"_blank",rel:"noopener noreferrer",kind:U.KIND.tertiary,size:U.SIZE.compact,overrides:{BaseButton:{style:{display:"flex",alignItems:"flex-start",whiteSpace:"nowrap"}}},children:s.label}):h.jsxRuntimeExports.jsx(h.jsxRuntimeExports.Fragment,{children:s.label})},username:t.name,usernameSubtitle:t.email,userImgUrl:t.avatarUrl,userItems:Tx,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:kx,props:{overrides:{BaseButton:{style:({$theme:s})=>({gap:s.sizing.scale200})}}}}}})}const tn=({children:i})=>h.jsxRuntimeExports.jsx(Tr.Grid,{gridColumns:1,gridGutters:0,gridGaps:0,children:h.jsxRuntimeExports.jsx(Tr.Cell,{children:i})});function jx(i){const{id:e,icon:t,name:n,description:s,docUrl:r,state:o,entities:l,projectId:a}=i,c=Ke.useNavigate(),[u,d]=M.useStyletron(),f=o==="disabled"||o==="comingSoon",p=o==="comingSoon";return h.jsxRuntimeExports.jsxs(h.Box,{overrides:{BoxContainer:{style:{backgroundColor:d.colors.backgroundAccentLight,minHeight:"220px"}}},title:h.jsxRuntimeExports.jsxs("div",{className:u({display:"flex",alignItems:"center",gap:d.sizing.scale400}),children:[h.jsxRuntimeExports.jsx(h.Icon,{name:t,size:d.sizing.scale500}),n,p&&h.jsxRuntimeExports.jsx(h.Tag,{color:h.TAG_COLOR.gray,size:h.TAG_SIZE.xSmall,closeable:!1,children:"Coming soon"})]}),description:s&&h.jsxRuntimeExports.jsxs("div",{className:u({display:"flex",alignItems:"center"}),children:[s,r&&h.jsxRuntimeExports.jsx(U.Button,{"aria-label":"Learn more",kind:U.KIND.tertiary,onClick:()=>window.open(r,"_blank"),shape:U.SHAPE.circle,size:U.SIZE.mini,children:h.jsxRuntimeExports.jsx(h.Icon,{name:"arrowLaunch",size:d.sizing.scale500})})]}),children:[h.jsxRuntimeExports.jsx("div",{className:u({display:"flex",flexDirection:"column"}),children:l.map(m=>f||m.state==="disabled"?h.jsxRuntimeExports.jsx("span",{className:u({...d.typography.ParagraphSmall,cursor:"default",color:d.colors.contentTertiary}),children:h.formatEntityName(m.name,"nav")},m.id):h.jsxRuntimeExports.jsx(h.Link,{href:`/${a}/${e}/${m.id}`,overrides:{Link:{style:d.typography.ParagraphSmall}},children:h.formatEntityName(m.name,"nav")},m.id))}),l.some(m=>m.state==="active")&&!f&&h.jsxRuntimeExports.jsx(U.Button,{"aria-label":`Go to ${n}`,kind:U.KIND.secondary,onClick:()=>{const m=l.find(g=>g.state==="active");c(`/${a}/${e}/${m.id}`)},shape:U.SHAPE.circle,overrides:{BaseButton:{style:{marginTop:"auto",backgroundColor:d.colors.accent,":hover":{backgroundColor:d.colors.accent600}}}},children:h.jsxRuntimeExports.jsx(h.Icon,{name:"chevronRight",size:d.sizing.scale700,color:d.colors.white})})]})}class Cd extends h.Interpolation{execute(e){return this.interpolator(e)}}function He(i){return typeof i=="function"?new Cd(i):new h.StringInterpolation(i)}const Fo=i=>{var e;return(e=i==null?void 0:i.spec)==null?void 0:e.owner},Ml=[{id:"metadata.name",label:"Name",url:"${row.metadata.name}"},{id:"metadata.creationTimestamp.seconds",label:"Created",type:h.CellType.DATE},{id:"spec.owner.owningTeam",label:"Owner",accessor:i=>{var e,t,n;return((t=(e=Fo(i))==null?void 0:e.team)==null?void 0:t.displayName)??((n=Fo(i))==null?void 0:n.owningTeam)},url:He(({row:i})=>{var e,t;return(t=(e=Fo(i))==null?void 0:e.team)==null?void 0:t.url})},{id:"spec.tier",label:"Tier",description:"The tier identifies this project's criticality.",type:h.CellType.TAG}];function Ix({phases:i}){var l,a,c,u,d,f;const[e,t]=M.useStyletron(),{projectId:n}=h.useStudioParams("base"),{data:s}=h.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?[...Ml,{id:"spec.gitRepo",label:"Source Code",type:h.CellType.LINK,url:r,accessor:()=>"Link"}]:Ml;return h.jsxRuntimeExports.jsxs("div",{className:e({display:"flex",flexDirection:"column",gridGap:t.sizing.scale600,padding:t.sizing.scale400}),children:[h.jsxRuntimeExports.jsx(h.Box,{description:(u=(c=s==null?void 0:s.project)==null?void 0:c.spec)==null?void 0:u.description,title:(f=(d=s==null?void 0:s.project)==null?void 0:d.metadata)==null?void 0:f.name,overrides:{BoxContainer:{style:({$theme:p})=>({backgroundColor:p.colors.backgroundSecondary})}},children:h.jsxRuntimeExports.jsx(h.Row,{items:o,record:s==null?void 0:s.project})}),h.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,m)=>h.jsxRuntimeExports.jsx(jx,{...p,projectId:n},`${p.name}-${m}`))})]})}function Rd({icon:i,docUrl:e,label:t,description:n}){const[s,r]=M.useStyletron();return h.jsxRuntimeExports.jsx("div",{className:s({display:"flex",justifyContent:"space-between",alignItems:"center"}),children:h.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&&h.jsxRuntimeExports.jsx(h.Icon,{name:i,size:r.sizing.scale600}),h.jsxRuntimeExports.jsx(ge.HeadingSmall,{as:"h2",className:s({margin:0}),children:t}),n&&i&&h.jsxRuntimeExports.jsx("div",{}),n&&h.jsxRuntimeExports.jsxs(h.DescriptionText,{children:[n,e&&h.jsxRuntimeExports.jsx(U.Button,{"aria-label":"Learn more",kind:U.KIND.tertiary,onClick:()=>window.open(e,"_blank"),shape:U.SHAPE.circle,size:U.SIZE.mini,overrides:{BaseButton:{style:{height:r.typography.ParagraphSmall.lineHeight,width:r.typography.ParagraphSmall.lineHeight}}},children:h.jsxRuntimeExports.jsx(h.Icon,{name:"arrowLaunch",size:r.sizing.scale500})})]})]})})}/**
|
|
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
|
|
10
|
+
*/function gi(i,e){return typeof i=="function"?i(e):i}function ht(i,e){return t=>{e.setState(n=>({...n,[i]:gi(t,n[i])}))}}function ho(i){return i instanceof Function}function Ox(i){return Array.isArray(i)&&i.every(e=>typeof e=="number")}function wd(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((u,d)=>n[d]!==u)))return s;n=l;let c;if(t.key&&t.debug&&(c=Date.now()),s=e(...l),t==null||t.onChange==null||t.onChange(s),t.key&&t.debug&&t!=null&&t.debug()){const u=Math.round((Date.now()-o)*100)/100,d=Math.round((Date.now()-c)*100)/100,f=d/16,p=(m,g)=>{for(m=String(m);m.length<g;)m=" "+m;return m};console.info(`%c⏱ ${p(d,5)} /${p(u,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 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 Rx(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 kx(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 g of a.split(".")){var m;p=(m=p)==null?void 0:m[g],process.env.NODE_ENV!=="production"&&p===void 0&&console.warn(`"${g}" 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 d={id:`${String(u)}`,accessorFn:c,parent:n,depth:t,columnDef:l,columns:[],getFlatColumns:Y(()=>[!0],()=>{var f;return[d,...(f=d.columns)==null?void 0:f.flatMap(p=>p.getFlatColumns())]},X(i.options,"debugColumns","column.getFlatColumns")),getLeafColumns:Y(()=>[i._getOrderColumnsFn()],f=>{var p;if((p=d.columns)!=null&&p.length){let m=d.columns.flatMap(g=>g.getLeafColumns());return f(m)}return[d]},X(i.options,"debugColumns","column.getLeafColumns"))};for(const f of i._features)f.createColumn==null||f.createColumn(d,i);return d}const _e="debugHeaders";function Ku(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 Tx={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(d=>t.find(f=>f.id===d)).filter(Boolean))!=null?r:[],a=(o=s==null?void 0:s.map(d=>t.find(f=>f.id===d)).filter(Boolean))!=null?o:[],u=t.filter(d=>!(n!=null&&n.includes(d.id))&&!(s!=null&&s.includes(d.id)));return Ps(e,[...l,...u,...a],i)},X(i.options,_e,"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))),Ps(e,t,i,"center")),X(i.options,_e,"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 Ps(e,r,i,"left")},X(i.options,_e,"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 Ps(e,r,i,"right")},X(i.options,_e,"getRightHeaderGroups")),i.getFooterGroups=Y(()=>[i.getHeaderGroups()],e=>[...e].reverse(),X(i.options,_e,"getFooterGroups")),i.getLeftFooterGroups=Y(()=>[i.getLeftHeaderGroups()],e=>[...e].reverse(),X(i.options,_e,"getLeftFooterGroups")),i.getCenterFooterGroups=Y(()=>[i.getCenterHeaderGroups()],e=>[...e].reverse(),X(i.options,_e,"getCenterFooterGroups")),i.getRightFooterGroups=Y(()=>[i.getRightHeaderGroups()],e=>[...e].reverse(),X(i.options,_e,"getRightFooterGroups")),i.getFlatHeaders=Y(()=>[i.getHeaderGroups()],e=>e.map(t=>t.headers).flat(),X(i.options,_e,"getFlatHeaders")),i.getLeftFlatHeaders=Y(()=>[i.getLeftHeaderGroups()],e=>e.map(t=>t.headers).flat(),X(i.options,_e,"getLeftFlatHeaders")),i.getCenterFlatHeaders=Y(()=>[i.getCenterHeaderGroups()],e=>e.map(t=>t.headers).flat(),X(i.options,_e,"getCenterFlatHeaders")),i.getRightFlatHeaders=Y(()=>[i.getRightHeaderGroups()],e=>e.map(t=>t.headers).flat(),X(i.options,_e,"getRightFlatHeaders")),i.getCenterLeafHeaders=Y(()=>[i.getCenterFlatHeaders()],e=>e.filter(t=>{var n;return!((n=t.subHeaders)!=null&&n.length)}),X(i.options,_e,"getCenterLeafHeaders")),i.getLeftLeafHeaders=Y(()=>[i.getLeftFlatHeaders()],e=>e.filter(t=>{var n;return!((n=t.subHeaders)!=null&&n.length)}),X(i.options,_e,"getLeftLeafHeaders")),i.getRightLeafHeaders=Y(()=>[i.getRightFlatHeaders()],e=>e.filter(t=>{var n;return!((n=t.subHeaders)!=null&&n.length)}),X(i.options,_e,"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,_e,"getLeafHeaders"))}};function Ps(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(m=>m.getIsVisible()).forEach(m=>{var g;(g=m.columns)!=null&&g.length&&l(m.columns,p+1)},0)};l(i);let a=[];const u=(f,p)=>{const m={depth:p,id:[n,`${p}`].filter(Boolean).join("_"),headers:[]},g=[];f.forEach(x=>{const y=[...g].reverse()[0],b=x.column.depth===m.depth;let S,E=!1;if(b&&x.column.parent?S=x.column.parent:(S=x.column,E=!0),y&&(y==null?void 0:y.column)===S)y.subHeaders.push(x);else{const v=Ku(t,S,{id:[n,p,S.id,x==null?void 0:x.id].filter(Boolean).join("_"),isPlaceholder:E,placeholderId:E?`${g.filter(C=>C.column===S).length}`:void 0,depth:p,index:g.length});v.subHeaders.push(x),g.push(v)}m.headers.push(x),x.headerGroup=m}),a.push(m),p>0&&u(g,p-1)},c=e.map((f,p)=>Ku(t,f,{depth:o,index:p}));u(c,o-1),a.reverse();const d=f=>f.filter(m=>m.column.getIsVisible()).map(m=>{let g=0,x=0,y=[0];m.subHeaders&&m.subHeaders.length?(y=[],d(m.subHeaders).forEach(S=>{let{colSpan:E,rowSpan:v}=S;g+=E,y.push(v)})):g=1;const b=Math.min(...y);return x=x+b,m.colSpan=g,m.rowSpan=x,{colSpan:g,rowSpan:x}});return d((s=(r=a[0])==null?void 0:r.headers)!=null?s:[]),a}const oo=(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:()=>gd(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=>Rx(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},Ax={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()}}},xd=(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))};xd.autoRemove=i=>Et(i);const yd=(i,e,t)=>{var n;return!!(!((n=i.getValue(e))==null||(n=n.toString())==null)&&n.includes(t))};yd.autoRemove=i=>Et(i);const bd=(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())};bd.autoRemove=i=>Et(i);const Sd=(i,e,t)=>{var n;return(n=i.getValue(e))==null?void 0:n.includes(t)};Sd.autoRemove=i=>Et(i);const vd=(i,e,t)=>!t.some(n=>{var s;return!((s=i.getValue(e))!=null&&s.includes(n))});vd.autoRemove=i=>Et(i)||!(i!=null&&i.length);const Ed=(i,e,t)=>t.some(n=>{var s;return(s=i.getValue(e))==null?void 0:s.includes(n)});Ed.autoRemove=i=>Et(i)||!(i!=null&&i.length);const Cd=(i,e,t)=>i.getValue(e)===t;Cd.autoRemove=i=>Et(i);const wd=(i,e,t)=>i.getValue(e)==t;wd.autoRemove=i=>Et(i);const Va=(i,e,t)=>{let[n,s]=t;const r=i.getValue(e);return r>=n&&r<=s};Va.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]};Va.autoRemove=i=>Et(i)||Et(i[0])&&Et(i[1]);const Qt={includesString:xd,includesStringSensitive:yd,equalsString:bd,arrIncludes:Sd,arrIncludesAll:vd,arrIncludesSome:Ed,equals:Cd,weakEquals:wd,inNumberRange:Va};function Et(i){return i==null||i===""}const jx={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:i=>({columnFilters:[],...i}),getDefaultOptions:i=>({onColumnFiltersChange:ut("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"?Qt.includesString:typeof n=="number"?Qt.inNumberRange:typeof n=="boolean"||n!==null&&typeof n=="object"?Qt.equals:Array.isArray(n)?Qt.arrIncludes:Qt.weakEquals},i.getFilterFn=()=>{var t,n;return ro(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:Qt[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=pi(t,r?r.value:void 0);if(Yu(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=pi(e,s))==null?void 0:r.filter(o=>{const l=t.find(a=>a.id===o.id);if(l){const a=l.getFilterFn();if(Yu(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 Yu(i,e,t){return(i&&i.autoRemove?i.autoRemove(e,t):!1)||typeof e>"u"||typeof e=="string"&&!e}const Ox=(i,e,t)=>t.reduce((n,s)=>{const r=s.getValue(i);return n+(typeof r=="number"?r:0)},0),Ix=(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},Mx=(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},Px=(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]},Dx=(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},Lx=(i,e)=>{if(!e.length)return;const t=e.map(r=>r.getValue(i));if(!wx(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},Nx=(i,e)=>Array.from(new Set(e.map(t=>t.getValue(i))).values()),Fx=(i,e)=>new Set(e.map(t=>t.getValue(i))).size,Bx=(i,e)=>e.length,Do={sum:Ox,min:Ix,max:Mx,extent:Px,mean:Dx,median:Lx,unique:Nx,uniqueCount:Fx,count:Bx},Vx={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:ut("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 Do.sum;if(Object.prototype.toString.call(n)==="[object Date]")return Do.extent},i.getAggregationFn=()=>{var t,n;if(!i)throw new Error;return ro(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:Do[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 _x(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 zx={getInitialState:i=>({columnOrder:[],...i}),getDefaultOptions:i=>({onColumnOrderChange:ut("columnOrder",i)}),createColumn:(i,e)=>{i.getIndex=Y(t=>[Wn(e,t)],t=>t.findIndex(n=>n.id===i.id),X(e.options,"debugColumns","getIndex")),i.getIsFirstColumn=t=>{var n;return((n=Wn(e,t)[0])==null?void 0:n.id)===i.id},i.getIsLastColumn=t=>{var n;const s=Wn(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 _x(r,t,n)},X(i.options,"debugTable","_getOrderColumnsFn"))}},Lo=()=>({left:[],right:[]}),$x={getInitialState:i=>({columnPinning:Lo(),...i}),getDefaultOptions:i=>({onColumnPinningChange:ut("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(d=>!(n!=null&&n.includes(d))),right:[...((a=s==null?void 0:s.right)!=null?a:[]).filter(d=>!(n!=null&&n.includes(d))),...n]}}if(t==="left"){var u,c;return{left:[...((u=s==null?void 0:s.left)!=null?u:[]).filter(d=>!(n!=null&&n.includes(d))),...n],right:((c=s==null?void 0:s.right)!=null?c:[]).filter(d=>!(n!=null&&n.includes(d)))}}return{left:((r=s==null?void 0:s.left)!=null?r:[]).filter(d=>!(n!=null&&n.includes(d))),right:((o=s==null?void 0:s.right)!=null?o:[]).filter(d=>!(n!=null&&n.includes(d)))}})},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?Lo():(t=(n=i.initialState)==null?void 0:n.columnPinning)!=null?t:Lo())},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 Hx(i){return i||(typeof document<"u"?document:null)}const Ds={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},No=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),Gx={getDefaultColumnDef:()=>Ds,getInitialState:i=>({columnSizing:{},columnSizingInfo:No(),...i}),getDefaultOptions:i=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:ut("columnSizing",i),onColumnSizingInfoChange:ut("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:Ds.minSize,(n=r??i.columnDef.size)!=null?n:Ds.size),(s=i.columnDef.maxSize)!=null?s:Ds.maxSize)},i.getStart=Y(t=>[t,Wn(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,Wn(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(),Fo(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=Fo(r)?Math.round(r.touches[0].clientX):r.clientX,u={},c=(y,b)=>{typeof b=="number"&&(e.setColumnSizingInfo(S=>{var E,v;const C=e.options.columnResizeDirection==="rtl"?-1:1,k=(b-((E=S==null?void 0:S.startOffset)!=null?E:0))*C,j=Math.max(k/((v=S==null?void 0:S.startSize)!=null?v:0),-.999999);return S.columnSizingStart.forEach(R=>{let[H,N]=R;u[H]=Math.round(Math.max(N+N*j,0)*100)/100}),{...S,deltaOffset:k,deltaPercentage:j}}),(e.options.columnResizeMode==="onChange"||y==="end")&&e.setColumnSizing(S=>({...S,...u})))},d=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=Hx(t),m={moveHandler:y=>d(y.clientX),upHandler:y=>{p==null||p.removeEventListener("mousemove",m.moveHandler),p==null||p.removeEventListener("mouseup",m.upHandler),f(y.clientX)}},g={moveHandler:y=>(y.cancelable&&(y.preventDefault(),y.stopPropagation()),d(y.touches[0].clientX),!1),upHandler:y=>{var b;p==null||p.removeEventListener("touchmove",g.moveHandler),p==null||p.removeEventListener("touchend",g.upHandler),y.cancelable&&(y.preventDefault(),y.stopPropagation()),f((b=y.touches[0])==null?void 0:b.clientX)}},x=Ux()?{passive:!1}:!1;Fo(r)?(p==null||p.addEventListener("touchmove",g.moveHandler,x),p==null||p.addEventListener("touchend",g.upHandler,x)):(p==null||p.addEventListener("mousemove",m.moveHandler,x),p==null||p.addEventListener("mouseup",m.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?No():(t=i.initialState.columnSizingInfo)!=null?t:No())},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 Ls=null;function Ux(){if(typeof Ls=="boolean")return Ls;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 Ls=i,Ls}function Fo(i){return i.type==="touchstart"}const Wx={getInitialState:i=>({columnVisibility:{},...i}),getDefaultOptions:i=>({onColumnVisibilityChange:ut("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 Wn(i,e){return e?e==="center"?i.getCenterVisibleLeafColumns():e==="left"?i.getLeftVisibleLeafColumns():i.getRightVisibleLeafColumns():i.getVisibleLeafColumns()}const qx={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()}}},Kx={getInitialState:i=>({globalFilter:void 0,...i}),getDefaultOptions:i=>({onGlobalFilterChange:ut("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=()=>Qt.includesString,i.getGlobalFilterFn=()=>{var e,t;const{globalFilterFn:n}=i.options;return ro(n)?n:n==="auto"?i.getGlobalAutoFilterFn():(e=(t=i.options.filterFns)==null?void 0:t[n])!=null?e:Qt[n]},i.setGlobalFilter=e=>{i.options.onGlobalFilterChange==null||i.options.onGlobalFilterChange(e)},i.resetGlobalFilter=e=>{i.setGlobalFilter(e?void 0:i.initialState.globalFilter)}}},Yx={getInitialState:i=>({expanded:{},...i}),getDefaultOptions:i=>({onExpandedChange:ut("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()}}}},jl=0,Ol=10,Bo=()=>({pageIndex:jl,pageSize:Ol}),Xx={getInitialState:i=>({...i,pagination:{...Bo(),...i==null?void 0:i.pagination}}),getDefaultOptions:i=>({onPaginationChange:ut("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=>pi(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=pi(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?jl:(s=(r=i.initialState)==null||(r=r.pagination)==null?void 0:r.pageIndex)!=null?s:jl)},i.resetPageSize=n=>{var s,r;i.setPageSize(n?Ol:(s=(r=i.initialState)==null||(r=r.pagination)==null?void 0:r.pageSize)!=null?s:Ol)},i.setPageSize=n=>{i.setPagination(s=>{const r=Math.max(1,pi(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=pi(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:[]}),Qx={getInitialState:i=>({rowPinning:Vo(),...i}),getDefaultOptions:i=>({onRowPinningChange:ut("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 d,f;return{top:((d=a==null?void 0:a.top)!=null?d:[]).filter(g=>!(l!=null&&l.has(g))),bottom:[...((f=a==null?void 0:a.bottom)!=null?f:[]).filter(g=>!(l!=null&&l.has(g))),...Array.from(l)]}}if(t==="top"){var p,m;return{top:[...((p=a==null?void 0:a.top)!=null?p:[]).filter(g=>!(l!=null&&l.has(g))),...Array.from(l)],bottom:((m=a==null?void 0:a.bottom)!=null?m:[]).filter(g=>!(l!=null&&l.has(g)))}}return{top:((u=a==null?void 0:a.top)!=null?u:[]).filter(g=>!(l!=null&&l.has(g))),bottom:((c=a==null?void 0:a.bottom)!=null?c:[]).filter(g=>!(l!=null&&l.has(g)))}})},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"))}},Jx={getInitialState:i=>({rowSelection:{},...i}),getDefaultOptions:i=>({onRowSelectionChange:ut("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=>{Il(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?_o(i,t):{rows:[],flatRows:[],rowsById:{}},X(i.options,"debugTable","getSelectedRowModel")),i.getFilteredSelectedRowModel=Y(()=>[i.getState().rowSelection,i.getFilteredRowModel()],(e,t)=>Object.keys(e).length?_o(i,t):{rows:[],flatRows:[],rowsById:{}},X(i.options,"debugTable","getFilteredSelectedRowModel")),i.getGroupedSelectedRowModel=Y(()=>[i.getState().rowSelection,i.getSortedRowModel()],(e,t)=>Object.keys(e).length?_o(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 Il(l,i.id,t,(o=n==null?void 0:n.selectChildren)!=null?o:!0,e),l})},i.getIsSelected=()=>{const{rowSelection:t}=e.getState();return _a(i,t)},i.getIsSomeSelected=()=>{const{rowSelection:t}=e.getState();return Ml(i,t)==="some"},i.getIsAllSubRowsSelected=()=>{const{rowSelection:t}=e.getState();return Ml(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)}}}},Il=(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=>Il(i,l.id,t,n,s))};function _o(i,e){const t=i.getState().rowSelection,n=[],s={},r=function(o,l){return o.map(a=>{var u;const c=_a(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 _a(i,e){var t;return(t=e[i.id])!=null?t:!1}function Ml(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()&&(_a(o,e)?r=!0:s=!1),o.subRows&&o.subRows.length)){const l=Ml(o,e);l==="all"?r=!0:(l==="some"&&(r=!0),s=!1)}}),s?"all":r?"some":!1}const Pl=/([0-9]+)/gm,Zx=(i,e,t)=>Rd(vi(i.getValue(t)).toLowerCase(),vi(e.getValue(t)).toLowerCase()),e0=(i,e,t)=>Rd(vi(i.getValue(t)),vi(e.getValue(t))),t0=(i,e,t)=>za(vi(i.getValue(t)).toLowerCase(),vi(e.getValue(t)).toLowerCase()),i0=(i,e,t)=>za(vi(i.getValue(t)),vi(e.getValue(t))),n0=(i,e,t)=>{const n=i.getValue(t),s=e.getValue(t);return n>s?1:n<s?-1:0},s0=(i,e,t)=>za(i.getValue(t),e.getValue(t));function za(i,e){return i===e?0:i>e?1:-1}function vi(i){return typeof i=="number"?isNaN(i)||i===1/0||i===-1/0?"":String(i):typeof i=="string"?i:""}function Rd(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 Dn={alphanumeric:Zx,alphanumericCaseSensitive:e0,text:t0,textCaseSensitive:i0,datetime:n0,basic:s0},r0={getInitialState:i=>({sorting:[],...i}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:i=>({onSortingChange:ut("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 Dn.datetime;if(typeof r=="string"&&(n=!0,r.split(Pl).length>1))return Dn.alphanumeric}return n?Dn.text:Dn.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 ro(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:Dn[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,d=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:d}],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:d}:p):c==="remove"?u=o.filter(p=>p.id!==i.id):u=[{id:i.id,desc:d}];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())}},o0=[Tx,Wx,zx,$x,Ax,jx,qx,Kx,r0,Vx,Yx,Xx,Qx,Jx,Gx];function l0(i){var e,t;process.env.NODE_ENV!=="production"&&(i.debugAll||i.debugTable)&&console.info("Creating Table Instance...");const n=[...o0,...(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 d={_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=pi(f,s.options);s.options=o(p)},getState:()=>s.options.state,setState:f=>{s.options.onStateChange==null||s.options.onStateChange(f)},_getRowId:(f,p,m)=>{var g;return(g=s.options.getRowId==null?void 0:s.options.getRowId(f,p,m))!=null?g:`${m?[m.id,p].join("."):p}`},getCoreRowModel:()=>(s._getCoreRowModel||(s._getCoreRowModel=s.options.getCoreRowModel(s)),s._getCoreRowModel()),getRowModel:()=>s.getPaginationRowModel(),getRow:(f,p)=>{let m=(p?s.getPrePaginationRowModel():s.getRowModel()).rowsById[f];if(!m&&(m=s.getCoreRowModel().rowsById[f],!m))throw process.env.NODE_ENV!=="production"?new Error(`getRow could not find row with ID: ${f}`):new Error;return m},_getDefaultColumnDef:Y(()=>[s.options.defaultColumn],f=>{var p;return f=(p=f)!=null?p:{},{header:m=>{const g=m.header.column.columnDef;return g.accessorKey?g.accessorKey:g.accessorFn?g.id:null},cell:m=>{var g,x;return(g=(x=m.renderValue())==null||x.toString==null?void 0:x.toString())!=null?g:null},...s._features.reduce((m,g)=>Object.assign(m,g.getDefaultColumnDef==null?void 0:g.getDefaultColumnDef()),{}),...f}},X(i,"debugColumns","_getDefaultColumnDef")),_getColumnDefs:()=>s.options.columns,getAllColumns:Y(()=>[s._getColumnDefs()],f=>{const p=function(m,g,x){return x===void 0&&(x=0),m.map(y=>{const b=kx(s,y,x,g),S=y;return b.columns=S.columns?p(S.columns,b,x+1):[],b})};return p(f)},X(i,"debugColumns","getAllColumns")),getAllFlatColumns:Y(()=>[s.getAllColumns()],f=>f.flatMap(p=>p.getFlatColumns()),X(i,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:Y(()=>[s.getAllFlatColumns()],f=>f.reduce((p,m)=>(p[m.id]=m,p),{}),X(i,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:Y(()=>[s.getAllColumns(),s._getOrderColumnsFn()],(f,p)=>{let m=f.flatMap(g=>g.getLeafColumns());return p(m)},X(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,d);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 a0(){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=oo(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 Xu(){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:kd(t),X(i.options,"debugTable","getExpandedRowModel"))}function kd(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 u0(i,e,t){return t.options.filterFromLeafRows?c0(i,e,t):h0(i,e,t)}function c0(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 d;let p=a[f];const m=oo(t,p.id,p.original,p.index,p.depth,void 0,p.parentId);if(m.columnFilters=p.columnFilters,(d=p.subRows)!=null&&d.length&&u<o){if(m.subRows=l(p.subRows,u+1),p=m,e(p)&&!m.subRows.length){c.push(p),r[p.id]=p,s.push(p);continue}if(e(p)||m.subRows.length){c.push(p),r[p.id]=p,s.push(p);continue}}else p=m,e(p)&&(c.push(p),r[p.id]=p,s.push(p))}return c};return{rows:l(i),flatRows:s,rowsById:r}}function h0(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 d;if((d=p.subRows)!=null&&d.length&&u<o){const g=oo(t,p.id,p.original,p.index,p.depth,void 0,p.parentId);g.subRows=l(p.subRows,u+1),p=g}c.push(p),s.push(p),r[p.id]=p}}return c};return{rows:l(i),flatRows:s,rowsById:r}}function d0(){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 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 m=i.getColumn(f.id);if(!m)return;const g=m.getFilterFn();if(!g){process.env.NODE_ENV!=="production"&&console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${m.id}.`);return}s.push({id:f.id,filterFn:g,resolvedValue:(p=g.resolveFilterValue==null?void 0:g.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 m=0;m<s.length;m++){u=s[m];const g=u.id;p.columnFilters[g]=u.filterFn(p,g,u.resolvedValue,x=>{p.columnFiltersMeta[g]=x})}if(r.length){for(let m=0;m<r.length;m++){c=r[m];const g=c.id;if(c.filterFn(p,g,c.resolvedValue,x=>{p.columnFiltersMeta[g]=x})){p.columnFilters.__global__=!0;break}}p.columnFilters.__global__!==!0&&(p.columnFilters.__global__=!1)}}const d=f=>{for(let p=0;p<o.length;p++)if(f.columnFilters[o[p]]===!1)return!1;return!0};return u0(e.rows,d,i)},X(i.options,"debugTable","getFilteredRowModel",()=>i._autoResetPageIndex()))}function f0(){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(m=>(m.depth=u,s.push(m),r[m.id]=m,m.subRows&&(m.subRows=o(m.subRows,u+1,m.id)),m));const d=n[u],f=p0(a,d);return Array.from(f.entries()).map((m,g)=>{let[x,y]=m,b=`${d}:${x}`;b=c?`${c}>${b}`:b;const S=o(y,u+1,b);S.forEach(C=>{C.parentId=b});const E=u?gd(y,C=>C.subRows):y,v=oo(i,b,E[0].original,g,u,void 0,c);return Object.assign(v,{groupingColumnId:d,groupingValue:x,subRows:S,leafRows:E,getValue:C=>{if(n.includes(C)){if(v._valuesCache.hasOwnProperty(C))return v._valuesCache[C];if(y[0]){var k;v._valuesCache[C]=(k=y[0].getValue(C))!=null?k:void 0}return v._valuesCache[C]}if(v._groupingValuesCache.hasOwnProperty(C))return v._groupingValuesCache[C];const j=i.getColumn(C),R=j==null?void 0:j.getAggregationFn();if(R)return v._groupingValuesCache[C]=R(C,E,y),v._groupingValuesCache[C]}}),S.forEach(C=>{s.push(C),r[C.id]=C}),v})},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 p0(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 m0(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 d;e.options.paginateExpandedRows?d={rows:o,flatRows:l,rowsById:a}:d=kd({rows:o,flatRows:l,rowsById:a}),d.flatRows=[];const f=p=>{d.flatRows.push(p),p.subRows.length&&p.subRows.forEach(f)};return d.rows.forEach(f),d},X(e.options,"debugTable","getPaginationRowModel"))}function g0(){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,d)=>{for(let p=0;p<r.length;p+=1){var f;const m=r[p],g=o[m.id],x=g.sortUndefined,y=(f=m==null?void 0:m.desc)!=null?f:!1;let b=0;if(x){const S=c.getValue(m.id),E=d.getValue(m.id),v=S===void 0,C=E===void 0;if(v||C){if(x==="first")return v?-1:1;if(x==="last")return v?1:-1;b=v&&C?0:v?x:-x}}if(b===0&&(b=g.sortingFn(c,d,m.id)),b!==0)return y&&(b*=-1),g.invertSorting&&(b*=-1),b}return c.index-d.index}),u.forEach(c=>{var d;s.push(c),(d=c.subRows)!=null&&d.length&&(c.subRows=l(c.subRows))}),u};return{rows:l(t.rows),flatRows:s,rowsById:t.rowsById}},X(i.options,"debugTable","getSortedRowModel",()=>i._autoResetPageIndex()))}/**
|
|
13
|
+
color: hsl(${Math.max(0,Math.min(120-120*f,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 Mx(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,c)=>({table:o,column:l,row:a,cell:c,getValue:c.getValue,renderValue:c.renderValue}),X(i.options,"debugCells","cell.getContext"))};return i._features.forEach(o=>{o.createCell==null||o.createCell(r,t,e,i)},{}),r}function Px(i,e,t,n){var s,r;const l={...i._getDefaultColumnDef(),...e},a=l.accessorKey;let c=(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,u;if(l.accessorFn?u=l.accessorFn:a&&(a.includes(".")?u=f=>{let p=f;for(const g of a.split(".")){var m;p=(m=p)==null?void 0:m[g],process.env.NODE_ENV!=="production"&&p===void 0&&console.warn(`"${g}" in deeply nested key "${a}" returned undefined.`)}return p}:u=f=>f[l.accessorKey]),!c)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 d={id:`${String(c)}`,accessorFn:u,parent:n,depth:t,columnDef:l,columns:[],getFlatColumns:Y(()=>[!0],()=>{var f;return[d,...(f=d.columns)==null?void 0:f.flatMap(p=>p.getFlatColumns())]},X(i.options,"debugColumns","column.getFlatColumns")),getLeafColumns:Y(()=>[i._getOrderColumnsFn()],f=>{var p;if((p=d.columns)!=null&&p.length){let m=d.columns.flatMap(g=>g.getLeafColumns());return f(m)}return[d]},X(i.options,"debugColumns","column.getLeafColumns"))};for(const f of i._features)f.createColumn==null||f.createColumn(d,i);return d}const $e="debugHeaders";function nu(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 Dx={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(d=>t.find(f=>f.id===d)).filter(Boolean))!=null?r:[],a=(o=s==null?void 0:s.map(d=>t.find(f=>f.id===d)).filter(Boolean))!=null?o:[],c=t.filter(d=>!(n!=null&&n.includes(d.id))&&!(s!=null&&s.includes(d.id)));return Vs(e,[...l,...c,...a],i)},X(i.options,$e,"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,$e,"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,$e,"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,$e,"getRightHeaderGroups")),i.getFooterGroups=Y(()=>[i.getHeaderGroups()],e=>[...e].reverse(),X(i.options,$e,"getFooterGroups")),i.getLeftFooterGroups=Y(()=>[i.getLeftHeaderGroups()],e=>[...e].reverse(),X(i.options,$e,"getLeftFooterGroups")),i.getCenterFooterGroups=Y(()=>[i.getCenterHeaderGroups()],e=>[...e].reverse(),X(i.options,$e,"getCenterFooterGroups")),i.getRightFooterGroups=Y(()=>[i.getRightHeaderGroups()],e=>[...e].reverse(),X(i.options,$e,"getRightFooterGroups")),i.getFlatHeaders=Y(()=>[i.getHeaderGroups()],e=>e.map(t=>t.headers).flat(),X(i.options,$e,"getFlatHeaders")),i.getLeftFlatHeaders=Y(()=>[i.getLeftHeaderGroups()],e=>e.map(t=>t.headers).flat(),X(i.options,$e,"getLeftFlatHeaders")),i.getCenterFlatHeaders=Y(()=>[i.getCenterHeaderGroups()],e=>e.map(t=>t.headers).flat(),X(i.options,$e,"getCenterFlatHeaders")),i.getRightFlatHeaders=Y(()=>[i.getRightHeaderGroups()],e=>e.map(t=>t.headers).flat(),X(i.options,$e,"getRightFlatHeaders")),i.getCenterLeafHeaders=Y(()=>[i.getCenterFlatHeaders()],e=>e.filter(t=>{var n;return!((n=t.subHeaders)!=null&&n.length)}),X(i.options,$e,"getCenterLeafHeaders")),i.getLeftLeafHeaders=Y(()=>[i.getLeftFlatHeaders()],e=>e.filter(t=>{var n;return!((n=t.subHeaders)!=null&&n.length)}),X(i.options,$e,"getLeftLeafHeaders")),i.getRightLeafHeaders=Y(()=>[i.getRightFlatHeaders()],e=>e.filter(t=>{var n;return!((n=t.subHeaders)!=null&&n.length)}),X(i.options,$e,"getRightLeafHeaders")),i.getLeafHeaders=Y(()=>[i.getLeftHeaderGroups(),i.getCenterHeaderGroups(),i.getRightHeaderGroups()],(e,t,n)=>{var s,r,o,l,a,c;return[...(s=(r=e[0])==null?void 0:r.headers)!=null?s:[],...(o=(l=t[0])==null?void 0:l.headers)!=null?o:[],...(a=(c=n[0])==null?void 0:c.headers)!=null?a:[]].map(u=>u.getLeafHeaders()).flat()},X(i.options,$e,"getLeafHeaders"))}};function Vs(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(m=>m.getIsVisible()).forEach(m=>{var g;(g=m.columns)!=null&&g.length&&l(m.columns,p+1)},0)};l(i);let a=[];const c=(f,p)=>{const m={depth:p,id:[n,`${p}`].filter(Boolean).join("_"),headers:[]},g=[];f.forEach(x=>{const y=[...g].reverse()[0],b=x.column.depth===m.depth;let S,E=!1;if(b&&x.column.parent?S=x.column.parent:(S=x.column,E=!0),y&&(y==null?void 0:y.column)===S)y.subHeaders.push(x);else{const v=nu(t,S,{id:[n,p,S.id,x==null?void 0:x.id].filter(Boolean).join("_"),isPlaceholder:E,placeholderId:E?`${g.filter(C=>C.column===S).length}`:void 0,depth:p,index:g.length});v.subHeaders.push(x),g.push(v)}m.headers.push(x),x.headerGroup=m}),a.push(m),p>0&&c(g,p-1)},u=e.map((f,p)=>nu(t,f,{depth:o,index:p}));c(u,o-1),a.reverse();const d=f=>f.filter(m=>m.column.getIsVisible()).map(m=>{let g=0,x=0,y=[0];m.subHeaders&&m.subHeaders.length?(y=[],d(m.subHeaders).forEach(S=>{let{colSpan:E,rowSpan:v}=S;g+=E,y.push(v)})):g=1;const b=Math.min(...y);return x=x+b,m.colSpan=g,m.rowSpan=x,{colSpan:g,rowSpan:x}});return d((s=(r=a[0])==null?void 0:r.headers)!=null?s:[]),a}const fo=(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 c=i.getColumn(a);if(c!=null&&c.accessorFn)return l._valuesCache[a]=c.accessorFn(l.original,n),l._valuesCache[a]},getUniqueValues:a=>{if(l._uniqueValuesCache.hasOwnProperty(a))return l._uniqueValuesCache[a];const c=i.getColumn(a);if(c!=null&&c.accessorFn)return c.columnDef.getUniqueValues?(l._uniqueValuesCache[a]=c.columnDef.getUniqueValues(l.original,n),l._uniqueValuesCache[a]):(l._uniqueValuesCache[a]=[l.getValue(a)],l._uniqueValuesCache[a])},renderValue:a=>{var c;return(c=l.getValue(a))!=null?c:i.options.renderFallbackValue},subRows:r??[],getLeafRows:()=>wd(l.subRows,a=>a.subRows),getParentRow:()=>l.parentId?i.getRow(l.parentId,!0):void 0,getParentRows:()=>{let a=[],c=l;for(;;){const u=c.getParentRow();if(!u)break;a.push(u),c=u}return a.reverse()},getAllCells:Y(()=>[i.getAllLeafColumns()],a=>a.map(c=>Mx(i,l,c,c.id)),X(i.options,"debugRows","getAllCells")),_getAllCellsByColumnId:Y(()=>[l.getAllCells()],a=>a.reduce((c,u)=>(c[u.column.id]=u,c),{}),X(i.options,"debugRows","getAllCellsByColumnId"))};for(let a=0;a<i._features.length;a++){const c=i._features[a];c==null||c.createRow==null||c.createRow(l,i)}return l},Lx={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()}}},kd=(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))};kd.autoRemove=i=>wt(i);const Td=(i,e,t)=>{var n;return!!(!((n=i.getValue(e))==null||(n=n.toString())==null)&&n.includes(t))};Td.autoRemove=i=>wt(i);const Ad=(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())};Ad.autoRemove=i=>wt(i);const jd=(i,e,t)=>{var n;return(n=i.getValue(e))==null?void 0:n.includes(t)};jd.autoRemove=i=>wt(i);const Id=(i,e,t)=>!t.some(n=>{var s;return!((s=i.getValue(e))!=null&&s.includes(n))});Id.autoRemove=i=>wt(i)||!(i!=null&&i.length);const Od=(i,e,t)=>t.some(n=>{var s;return(s=i.getValue(e))==null?void 0:s.includes(n)});Od.autoRemove=i=>wt(i)||!(i!=null&&i.length);const Md=(i,e,t)=>i.getValue(e)===t;Md.autoRemove=i=>wt(i);const Pd=(i,e,t)=>i.getValue(e)==t;Pd.autoRemove=i=>wt(i);const Ha=(i,e,t)=>{let[n,s]=t;const r=i.getValue(e);return r>=n&&r<=s};Ha.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]};Ha.autoRemove=i=>wt(i)||wt(i[0])&&wt(i[1]);const Jt={includesString:kd,includesStringSensitive:Td,equalsString:Ad,arrIncludes:jd,arrIncludesAll:Id,arrIncludesSome:Od,equals:Md,weakEquals:Pd,inNumberRange:Ha};function wt(i){return i==null||i===""}const Nx={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:i=>({columnFilters:[],...i}),getDefaultOptions:i=>({onColumnFiltersChange:ht("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"?Jt.includesString:typeof n=="number"?Jt.inNumberRange:typeof n=="boolean"||n!==null&&typeof n=="object"?Jt.equals:Array.isArray(n)?Jt.arrIncludes:Jt.weakEquals},i.getFilterFn=()=>{var t,n;return ho(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:Jt[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(u=>u.id===i.id),o=gi(t,r?r.value:void 0);if(su(s,o,i)){var l;return(l=n==null?void 0:n.filter(u=>u.id!==i.id))!=null?l:[]}const a={id:i.id,value:o};if(r){var c;return(c=n==null?void 0:n.map(u=>u.id===i.id?a:u))!=null?c:[]}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=gi(e,s))==null?void 0:r.filter(o=>{const l=t.find(a=>a.id===o.id);if(l){const a=l.getFilterFn();if(su(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 su(i,e,t){return(i&&i.autoRemove?i.autoRemove(e,t):!1)||typeof e>"u"||typeof e=="string"&&!e}const Fx=(i,e,t)=>t.reduce((n,s)=>{const r=s.getValue(i);return n+(typeof r=="number"?r:0)},0),Bx=(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},Vx=(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},_x=(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]},$x=(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},zx=(i,e)=>{if(!e.length)return;const t=e.map(r=>r.getValue(i));if(!Ox(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},Hx=(i,e)=>Array.from(new Set(e.map(t=>t.getValue(i))).values()),Gx=(i,e)=>new Set(e.map(t=>t.getValue(i))).size,Ux=(i,e)=>e.length,Bo={sum:Fx,min:Bx,max:Vx,extent:_x,mean:$x,median:zx,unique:Hx,uniqueCount:Gx,count:Ux},Wx={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:ht("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 Bo.sum;if(Object.prototype.toString.call(n)==="[object Date]")return Bo.extent},i.getAggregationFn=()=>{var t,n;if(!i)throw new Error;return ho(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:Bo[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 qx(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 Kx={getInitialState:i=>({columnOrder:[],...i}),getDefaultOptions:i=>({onColumnOrderChange:ht("columnOrder",i)}),createColumn:(i,e)=>{i.getIndex=Y(t=>[Kn(e,t)],t=>t.findIndex(n=>n.id===i.id),X(e.options,"debugColumns","getIndex")),i.getIsFirstColumn=t=>{var n;return((n=Kn(e,t)[0])==null?void 0:n.id)===i.id},i.getIsLastColumn=t=>{var n;const s=Kn(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(),c=l.findIndex(u=>u.id===a);c>-1&&r.push(l.splice(c,1)[0])}r=[...r,...l]}return qx(r,t,n)},X(i.options,"debugTable","_getOrderColumnsFn"))}},Vo=()=>({left:[],right:[]}),Yx={getInitialState:i=>({columnPinning:Vo(),...i}),getDefaultOptions:i=>({onColumnPinningChange:ht("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(d=>!(n!=null&&n.includes(d))),right:[...((a=s==null?void 0:s.right)!=null?a:[]).filter(d=>!(n!=null&&n.includes(d))),...n]}}if(t==="left"){var c,u;return{left:[...((c=s==null?void 0:s.left)!=null?c:[]).filter(d=>!(n!=null&&n.includes(d))),...n],right:((u=s==null?void 0:s.right)!=null?u:[]).filter(d=>!(n!=null&&n.includes(d)))}}return{left:((r=s==null?void 0:s.left)!=null?r:[]).filter(d=>!(n!=null&&n.includes(d))),right:((o=s==null?void 0:s.right)!=null?o:[]).filter(d=>!(n!=null&&n.includes(d)))}})},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?Vo():(t=(n=i.initialState)==null?void 0:n.columnPinning)!=null?t:Vo())},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 Xx(i){return i||(typeof document<"u"?document:null)}const _s={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},_o=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),Qx={getDefaultColumnDef:()=>_s,getInitialState:i=>({columnSizing:{},columnSizingInfo:_o(),...i}),getDefaultOptions:i=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:ht("columnSizing",i),onColumnSizingInfoChange:ht("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:_s.minSize,(n=r??i.columnDef.size)!=null?n:_s.size),(s=i.columnDef.maxSize)!=null?s:_s.maxSize)},i.getStart=Y(t=>[t,Kn(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,Kn(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(),$o(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=$o(r)?Math.round(r.touches[0].clientX):r.clientX,c={},u=(y,b)=>{typeof b=="number"&&(e.setColumnSizingInfo(S=>{var E,v;const C=e.options.columnResizeDirection==="rtl"?-1:1,k=(b-((E=S==null?void 0:S.startOffset)!=null?E:0))*C,O=Math.max(k/((v=S==null?void 0:S.startSize)!=null?v:0),-.999999);return S.columnSizingStart.forEach(w=>{let[D,N]=w;c[D]=Math.round(Math.max(N+N*O,0)*100)/100}),{...S,deltaOffset:k,deltaPercentage:O}}),(e.options.columnResizeMode==="onChange"||y==="end")&&e.setColumnSizing(S=>({...S,...c})))},d=y=>u("move",y),f=y=>{u("end",y),e.setColumnSizingInfo(b=>({...b,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},p=Xx(t),m={moveHandler:y=>d(y.clientX),upHandler:y=>{p==null||p.removeEventListener("mousemove",m.moveHandler),p==null||p.removeEventListener("mouseup",m.upHandler),f(y.clientX)}},g={moveHandler:y=>(y.cancelable&&(y.preventDefault(),y.stopPropagation()),d(y.touches[0].clientX),!1),upHandler:y=>{var b;p==null||p.removeEventListener("touchmove",g.moveHandler),p==null||p.removeEventListener("touchend",g.upHandler),y.cancelable&&(y.preventDefault(),y.stopPropagation()),f((b=y.touches[0])==null?void 0:b.clientX)}},x=Jx()?{passive:!1}:!1;$o(r)?(p==null||p.addEventListener("touchmove",g.moveHandler,x),p==null||p.addEventListener("touchend",g.upHandler,x)):(p==null||p.addEventListener("mousemove",m.moveHandler,x),p==null||p.addEventListener("mouseup",m.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?_o():(t=i.initialState.columnSizingInfo)!=null?t:_o())},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 $s=null;function Jx(){if(typeof $s=="boolean")return $s;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 $s=i,$s}function $o(i){return i.type==="touchstart"}const Zx={getInitialState:i=>({columnVisibility:{},...i}),getDefaultOptions:i=>({onColumnVisibilityChange:ht("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 Kn(i,e){return e?e==="center"?i.getCenterVisibleLeafColumns():e==="left"?i.getLeftVisibleLeafColumns():i.getRightVisibleLeafColumns():i.getVisibleLeafColumns()}const e0={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()}}},t0={getInitialState:i=>({globalFilter:void 0,...i}),getDefaultOptions:i=>({onGlobalFilterChange:ht("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=()=>Jt.includesString,i.getGlobalFilterFn=()=>{var e,t;const{globalFilterFn:n}=i.options;return ho(n)?n:n==="auto"?i.getGlobalAutoFilterFn():(e=(t=i.options.filterFns)==null?void 0:t[n])!=null?e:Jt[n]},i.setGlobalFilter=e=>{i.options.onGlobalFilterChange==null||i.options.onGlobalFilterChange(e)},i.resetGlobalFilter=e=>{i.setGlobalFilter(e?void 0:i.initialState.globalFilter)}}},i0={getInitialState:i=>({expanded:{},...i}),getDefaultOptions:i=>({onExpandedChange:ht("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()}}}},Pl=0,Dl=10,zo=()=>({pageIndex:Pl,pageSize:Dl}),n0={getInitialState:i=>({...i,pagination:{...zo(),...i==null?void 0:i.pagination}}),getDefaultOptions:i=>({onPaginationChange:ht("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=>gi(n,r);return i.options.onPaginationChange==null?void 0:i.options.onPaginationChange(s)},i.resetPagination=n=>{var s;i.setPagination(n?zo():(s=i.initialState.pagination)!=null?s:zo())},i.setPageIndex=n=>{i.setPagination(s=>{let r=gi(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?Pl:(s=(r=i.initialState)==null||(r=r.pagination)==null?void 0:r.pageIndex)!=null?s:Pl)},i.resetPageSize=n=>{var s,r;i.setPageSize(n?Dl:(s=(r=i.initialState)==null||(r=r.pagination)==null?void 0:r.pageSize)!=null?s:Dl)},i.setPageSize=n=>{i.setPagination(s=>{const r=Math.max(1,gi(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=gi(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}}},Ho=()=>({top:[],bottom:[]}),s0={getInitialState:i=>({rowPinning:Ho(),...i}),getDefaultOptions:i=>({onRowPinningChange:ht("rowPinning",i)}),createRow:(i,e)=>{i.pin=(t,n,s)=>{const r=n?i.getLeafRows().map(a=>{let{id:c}=a;return c}):[],o=s?i.getParentRows().map(a=>{let{id:c}=a;return c}):[],l=new Set([...o,i.id,...r]);e.setRowPinning(a=>{var c,u;if(t==="bottom"){var d,f;return{top:((d=a==null?void 0:a.top)!=null?d:[]).filter(g=>!(l!=null&&l.has(g))),bottom:[...((f=a==null?void 0:a.bottom)!=null?f:[]).filter(g=>!(l!=null&&l.has(g))),...Array.from(l)]}}if(t==="top"){var p,m;return{top:[...((p=a==null?void 0:a.top)!=null?p:[]).filter(g=>!(l!=null&&l.has(g))),...Array.from(l)],bottom:((m=a==null?void 0:a.bottom)!=null?m:[]).filter(g=>!(l!=null&&l.has(g)))}}return{top:((c=a==null?void 0:a.top)!=null?c:[]).filter(g=>!(l!=null&&l.has(g))),bottom:((u=a==null?void 0:a.bottom)!=null?u:[]).filter(g=>!(l!=null&&l.has(g)))}})},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?Ho():(t=(n=i.initialState)==null?void 0:n.rowPinning)!=null?t:Ho())},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"))}},r0={getInitialState:i=>({rowSelection:{},...i}),getDefaultOptions:i=>({onRowSelectionChange:ht("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=>{Ll(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?Go(i,t):{rows:[],flatRows:[],rowsById:{}},X(i.options,"debugTable","getSelectedRowModel")),i.getFilteredSelectedRowModel=Y(()=>[i.getState().rowSelection,i.getFilteredRowModel()],(e,t)=>Object.keys(e).length?Go(i,t):{rows:[],flatRows:[],rowsById:{}},X(i.options,"debugTable","getFilteredSelectedRowModel")),i.getGroupedSelectedRowModel=Y(()=>[i.getState().rowSelection,i.getSortedRowModel()],(e,t)=>Object.keys(e).length?Go(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 Ll(l,i.id,t,(o=n==null?void 0:n.selectChildren)!=null?o:!0,e),l})},i.getIsSelected=()=>{const{rowSelection:t}=e.getState();return Ga(i,t)},i.getIsSomeSelected=()=>{const{rowSelection:t}=e.getState();return Nl(i,t)==="some"},i.getIsAllSubRowsSelected=()=>{const{rowSelection:t}=e.getState();return Nl(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)}}}},Ll=(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=>Ll(i,l.id,t,n,s))};function Go(i,e){const t=i.getState().rowSelection,n=[],s={},r=function(o,l){return o.map(a=>{var c;const u=Ga(a,t);if(u&&(n.push(a),s[a.id]=a),(c=a.subRows)!=null&&c.length&&(a={...a,subRows:r(a.subRows)}),u)return a}).filter(Boolean)};return{rows:r(e.rows),flatRows:n,rowsById:s}}function Ga(i,e){var t;return(t=e[i.id])!=null?t:!1}function Nl(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()&&(Ga(o,e)?r=!0:s=!1),o.subRows&&o.subRows.length)){const l=Nl(o,e);l==="all"?r=!0:(l==="some"&&(r=!0),s=!1)}}),s?"all":r?"some":!1}const Fl=/([0-9]+)/gm,o0=(i,e,t)=>Dd(Ci(i.getValue(t)).toLowerCase(),Ci(e.getValue(t)).toLowerCase()),l0=(i,e,t)=>Dd(Ci(i.getValue(t)),Ci(e.getValue(t))),a0=(i,e,t)=>Ua(Ci(i.getValue(t)).toLowerCase(),Ci(e.getValue(t)).toLowerCase()),c0=(i,e,t)=>Ua(Ci(i.getValue(t)),Ci(e.getValue(t))),u0=(i,e,t)=>{const n=i.getValue(t),s=e.getValue(t);return n>s?1:n<s?-1:0},h0=(i,e,t)=>Ua(i.getValue(t),e.getValue(t));function Ua(i,e){return i===e?0:i>e?1:-1}function Ci(i){return typeof i=="number"?isNaN(i)||i===1/0||i===-1/0?"":String(i):typeof i=="string"?i:""}function Dd(i,e){const t=i.split(Fl).filter(Boolean),n=e.split(Fl).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 Nn={alphanumeric:o0,alphanumericCaseSensitive:l0,text:a0,textCaseSensitive:c0,datetime:u0,basic:h0},d0={getInitialState:i=>({sorting:[],...i}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:i=>({onSortingChange:ht("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 Nn.datetime;if(typeof r=="string"&&(n=!0,r.split(Fl).length>1))return Nn.alphanumeric}return n?Nn.text:Nn.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 ho(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:Nn[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 c=[],u,d=r?t:s==="desc";if(o!=null&&o.length&&i.getCanMultiSort()&&n?l?u="toggle":u="add":o!=null&&o.length&&a!==o.length-1?u="replace":l?u="toggle":u="replace",u==="toggle"&&(r||s||(u="remove")),u==="add"){var f;c=[...o,{id:i.id,desc:d}],c.splice(0,c.length-((f=e.options.maxMultiSortColCount)!=null?f:Number.MAX_SAFE_INTEGER))}else u==="toggle"?c=o.map(p=>p.id===i.id?{...p,desc:d}:p):u==="remove"?c=o.filter(p=>p.id!==i.id):c=[{id:i.id,desc:d}];return c})},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())}},f0=[Dx,Zx,Kx,Yx,Lx,Nx,e0,t0,d0,Wx,i0,n0,s0,r0,Qx];function p0(i){var e,t;process.env.NODE_ENV!=="production"&&(i.debugAll||i.debugTable)&&console.info("Creating Table Instance...");const n=[...f0,...(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 c=[];let u=!1;const d={_features:n,options:{...r,...i},initialState:a,_queue:f=>{c.push(f),u||(u=!0,Promise.resolve().then(()=>{for(;c.length;)c.shift()();u=!1}).catch(p=>setTimeout(()=>{throw p})))},reset:()=>{s.setState(s.initialState)},setOptions:f=>{const p=gi(f,s.options);s.options=o(p)},getState:()=>s.options.state,setState:f=>{s.options.onStateChange==null||s.options.onStateChange(f)},_getRowId:(f,p,m)=>{var g;return(g=s.options.getRowId==null?void 0:s.options.getRowId(f,p,m))!=null?g:`${m?[m.id,p].join("."):p}`},getCoreRowModel:()=>(s._getCoreRowModel||(s._getCoreRowModel=s.options.getCoreRowModel(s)),s._getCoreRowModel()),getRowModel:()=>s.getPaginationRowModel(),getRow:(f,p)=>{let m=(p?s.getPrePaginationRowModel():s.getRowModel()).rowsById[f];if(!m&&(m=s.getCoreRowModel().rowsById[f],!m))throw process.env.NODE_ENV!=="production"?new Error(`getRow could not find row with ID: ${f}`):new Error;return m},_getDefaultColumnDef:Y(()=>[s.options.defaultColumn],f=>{var p;return f=(p=f)!=null?p:{},{header:m=>{const g=m.header.column.columnDef;return g.accessorKey?g.accessorKey:g.accessorFn?g.id:null},cell:m=>{var g,x;return(g=(x=m.renderValue())==null||x.toString==null?void 0:x.toString())!=null?g:null},...s._features.reduce((m,g)=>Object.assign(m,g.getDefaultColumnDef==null?void 0:g.getDefaultColumnDef()),{}),...f}},X(i,"debugColumns","_getDefaultColumnDef")),_getColumnDefs:()=>s.options.columns,getAllColumns:Y(()=>[s._getColumnDefs()],f=>{const p=function(m,g,x){return x===void 0&&(x=0),m.map(y=>{const b=Px(s,y,x,g),S=y;return b.columns=S.columns?p(S.columns,b,x+1):[],b})};return p(f)},X(i,"debugColumns","getAllColumns")),getAllFlatColumns:Y(()=>[s.getAllColumns()],f=>f.flatMap(p=>p.getFlatColumns()),X(i,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:Y(()=>[s.getAllFlatColumns()],f=>f.reduce((p,m)=>(p[m.id]=m,p),{}),X(i,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:Y(()=>[s.getAllColumns(),s._getOrderColumnsFn()],(f,p)=>{let m=f.flatMap(g=>g.getLeafColumns());return p(m)},X(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,d);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 m0(){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 c=0;c<s.length;c++){const u=fo(i,i._getRowId(s[c],c,o),s[c],c,r,void 0,o==null?void 0:o.id);if(t.flatRows.push(u),t.rowsById[u.id]=u,l.push(u),i.options.getSubRows){var a;u.originalSubRows=i.options.getSubRows(s[c],c),(a=u.originalSubRows)!=null&&a.length&&(u.subRows=n(u.originalSubRows,r+1,u))}}return l};return t.rows=n(e),t},X(i.options,"debugTable","getRowModel",()=>i._autoResetPageIndex()))}function ru(){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:Ld(t),X(i.options,"debugTable","getExpandedRowModel"))}function Ld(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 g0(i,e,t){return t.options.filterFromLeafRows?x0(i,e,t):y0(i,e,t)}function x0(i,e,t){var n;const s=[],r={},o=(n=t.options.maxLeafRowFilterDepth)!=null?n:100,l=function(a,c){c===void 0&&(c=0);const u=[];for(let f=0;f<a.length;f++){var d;let p=a[f];const m=fo(t,p.id,p.original,p.index,p.depth,void 0,p.parentId);if(m.columnFilters=p.columnFilters,(d=p.subRows)!=null&&d.length&&c<o){if(m.subRows=l(p.subRows,c+1),p=m,e(p)&&!m.subRows.length){u.push(p),r[p.id]=p,s.push(p);continue}if(e(p)||m.subRows.length){u.push(p),r[p.id]=p,s.push(p);continue}}else p=m,e(p)&&(u.push(p),r[p.id]=p,s.push(p))}return u};return{rows:l(i),flatRows:s,rowsById:r}}function y0(i,e,t){var n;const s=[],r={},o=(n=t.options.maxLeafRowFilterDepth)!=null?n:100,l=function(a,c){c===void 0&&(c=0);const u=[];for(let f=0;f<a.length;f++){let p=a[f];if(e(p)){var d;if((d=p.subRows)!=null&&d.length&&c<o){const g=fo(t,p.id,p.original,p.index,p.depth,void 0,p.parentId);g.subRows=l(p.subRows,c+1),p=g}u.push(p),s.push(p),r[p.id]=p}}return u};return{rows:l(i),flatRows:s,rowsById:r}}function b0(){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 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 m=i.getColumn(f.id);if(!m)return;const g=m.getFilterFn();if(!g){process.env.NODE_ENV!=="production"&&console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${m.id}.`);return}s.push({id:f.id,filterFn:g,resolvedValue:(p=g.resolveFilterValue==null?void 0:g.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 c,u;for(let f=0;f<e.flatRows.length;f++){const p=e.flatRows[f];if(p.columnFilters={},s.length)for(let m=0;m<s.length;m++){c=s[m];const g=c.id;p.columnFilters[g]=c.filterFn(p,g,c.resolvedValue,x=>{p.columnFiltersMeta[g]=x})}if(r.length){for(let m=0;m<r.length;m++){u=r[m];const g=u.id;if(u.filterFn(p,g,u.resolvedValue,x=>{p.columnFiltersMeta[g]=x})){p.columnFilters.__global__=!0;break}}p.columnFilters.__global__!==!0&&(p.columnFilters.__global__=!1)}}const d=f=>{for(let p=0;p<o.length;p++)if(f.columnFilters[o[p]]===!1)return!1;return!0};return g0(e.rows,d,i)},X(i.options,"debugTable","getFilteredRowModel",()=>i._autoResetPageIndex()))}function S0(){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,c,u){if(c===void 0&&(c=0),c>=n.length)return a.map(m=>(m.depth=c,s.push(m),r[m.id]=m,m.subRows&&(m.subRows=o(m.subRows,c+1,m.id)),m));const d=n[c],f=v0(a,d);return Array.from(f.entries()).map((m,g)=>{let[x,y]=m,b=`${d}:${x}`;b=u?`${u}>${b}`:b;const S=o(y,c+1,b);S.forEach(C=>{C.parentId=b});const E=c?wd(y,C=>C.subRows):y,v=fo(i,b,E[0].original,g,c,void 0,u);return Object.assign(v,{groupingColumnId:d,groupingValue:x,subRows:S,leafRows:E,getValue:C=>{if(n.includes(C)){if(v._valuesCache.hasOwnProperty(C))return v._valuesCache[C];if(y[0]){var k;v._valuesCache[C]=(k=y[0].getValue(C))!=null?k:void 0}return v._valuesCache[C]}if(v._groupingValuesCache.hasOwnProperty(C))return v._groupingValuesCache[C];const O=i.getColumn(C),w=O==null?void 0:O.getAggregationFn();if(w)return v._groupingValuesCache[C]=w(C,E,y),v._groupingValuesCache[C]}}),S.forEach(C=>{s.push(C),r[C.id]=C}),v})},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 v0(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 E0(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 c=s*r,u=c+s;o=o.slice(c,u);let d;e.options.paginateExpandedRows?d={rows:o,flatRows:l,rowsById:a}:d=Ld({rows:o,flatRows:l,rowsById:a}),d.flatRows=[];const f=p=>{d.flatRows.push(p),p.subRows.length&&p.subRows.forEach(f)};return d.rows.forEach(f),d},X(e.options,"debugTable","getPaginationRowModel"))}function C0(){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 c;return(c=i.getColumn(a.id))==null?void 0:c.getCanSort()}),o={};r.forEach(a=>{const c=i.getColumn(a.id);c&&(o[a.id]={sortUndefined:c.columnDef.sortUndefined,invertSorting:c.columnDef.invertSorting,sortingFn:c.getSortingFn()})});const l=a=>{const c=a.map(u=>({...u}));return c.sort((u,d)=>{for(let p=0;p<r.length;p+=1){var f;const m=r[p],g=o[m.id],x=g.sortUndefined,y=(f=m==null?void 0:m.desc)!=null?f:!1;let b=0;if(x){const S=u.getValue(m.id),E=d.getValue(m.id),v=S===void 0,C=E===void 0;if(v||C){if(x==="first")return v?-1:1;if(x==="last")return v?1:-1;b=v&&C?0:v?x:-x}}if(b===0&&(b=g.sortingFn(u,d,m.id)),b!==0)return y&&(b*=-1),g.invertSorting&&(b*=-1),b}return u.index-d.index}),c.forEach(u=>{var d;s.push(u),(d=u.subRows)!=null&&d.length&&(u.subRows=l(u.subRows))}),c};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,18 @@
|
|
|
19
19
|
* LICENSE.md file in the root directory of this source tree.
|
|
20
20
|
*
|
|
21
21
|
* @license MIT
|
|
22
|
-
*/function zo(i,e){return i?x0(i)?ve.createElement(i,e):i:null}function x0(i){return y0(i)||typeof i=="function"||b0(i)}function y0(i){return typeof i=="function"&&(()=>{const e=Object.getPrototypeOf(i);return e.prototype&&e.prototype.isReactComponent})()}function b0(i){return typeof i=="object"&&typeof i.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(i.$$typeof.description)}function S0(i){const e={state:{},onStateChange:()=>{},renderFallbackValue:null,...i},[t]=ve.useState(()=>({current:l0(e)})),[n,s]=ve.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 v0(i){const[e,t]=A.useState(-1),n=A.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 A.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 lo=(i=>(i.NONE="none",i.CLIENT="client",i.SERVER="server",i))(lo||{});const E0=15,Qu=15,C0=[{id:Qu,label:String(Qu)},{id:25,label:String(25)},{id:50,label:String(50)}],Dl="__JOIN__",ci={globalFilter:"",columnFilters:[],pagination:{pageSize:E0},sorting:[],grouping:[],columnOrder:[],columnVisibility:{},rowSelectionEnabled:!1},Td="ma-studio-table-settings";function $a(i,e){var n;const t=((n=e==null?void 0:e.typeMeta)==null?void 0:n.kind)??"";return t in i?{...h.lodashExports.omit(i,t),...i[t]}:i}function Ha(i,e,t){const n="original"in e?e.original:e.record,s=$a(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),h.safeStringify(o).split(Dl).at(0)??""):o.split(Dl).at(0)??"":o}function w0({preFilteredRows:i,column:e}){const t=h.useCellToString();return A.useMemo(()=>{const n={},s={};return i.forEach(r=>{const o=Ha(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=h.safeStringify(o);n[a]=o,s[u]=a}),[s,n]},[i,t,e])}function R0({column:i,close:e,getFilterValue:t,setFilterValue:n,preFilteredRows:s}){const r=Ba.CategoricalColumn({title:"",mapDataToValue:()=>""}).renderFilter,[o,l]=w0({preFilteredRows:s,column:i}),a=Object.keys(l),u=(t()??[]).map(f=>o[h.safeStringify(f)]).filter(Boolean),c=a.sort((f,p)=>{const m=u.includes(f),g=u.includes(p);return m===g?f.localeCompare(p):m?-1:1}),d=({selection:f,exclude:p})=>{const g=(p?a.filter(x=>!f.has(x)):Array.from(f)).map(x=>l[x]);n(g.length>0?g:void 0),e()};return h.jsxRuntimeExports.jsx(r,{data:c,setFilter:d,close:e,filterParams:{description:"",selection:new Set(u),exclude:!1}})}const k0=new Date("2022-01-01T00:00:00"),T0=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 A0({close:i,getFilterValue:e,setFilterValue:t}){const n=Ba.DatetimeColumn({title:"",mapDataToValue:()=>new Date}).renderFilter,s=[k0,new Date],r=T0(e());return h.jsxRuntimeExports.jsx(n,{data:s,setFilter:t,close:i,filterParams:r})}function Ad(i){switch(i){case h.CellType.DATE:return A0;default:return R0}}function j0(){const i=h.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(Ha(e,l,a));return o.autoRemove=t,o}}}}function O0(){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,d=Ha(i,l,a),f=h.getDateFromEpochSeconds(typeof d=="number"?d:parseFloat(String(d)));return Ba.DatetimeColumn({title:"",mapDataToValue:()=>new Date}).buildFilter(c)(f)};return o.autoRemove=t,o}}}}function jd(){const i=j0(),e=O0();return t=>t.type===h.CellType.DATE?e(t):i(t)}function I0(i){const{column:e,preFilteredRows:t}=i,[n,s]=M.useStyletron(),[r,o]=A.useState(!1),[l,a]=A.useState(!1),[u,c]=A.useState(null),f=jd()({id:e.id,type:e.type,label:e.label}),p=()=>{c(setTimeout(()=>a(!0),1e3))},m=()=>{u&&clearTimeout(u),a(!1)},g=Ad(e.type);return h.jsxRuntimeExports.jsx(zt.StatefulPopover,{placement:zt.PLACEMENT.bottomLeft,content:({close:x})=>h.jsxRuntimeExports.jsx(g,{column:e,close:x,getFilterValue:e.getFilterValue,setFilterValue:e.setFilterValue,preFilteredRows:t}),onOpen:()=>o(!0),onClose:()=>o(!1),children:h.jsxRuntimeExports.jsx(bn.Tag,{kind:bn.KIND.blue,overrides:r?{Root:{style:({$theme:x})=>({borderColor:x.colors.accent,borderWidth:"2px"})}}:{},onActionClick:()=>e.setFilterValue(void 0),children:h.jsxRuntimeExports.jsx(Bi.Tooltip,{content:()=>h.jsxRuntimeExports.jsx("div",{className:n({maxWidth:s.sizing.scale4800,overflowWrap:"break-word"}),children:f.getActiveFilter(e.getFilterValue())}),placement:zt.PLACEMENT.top,isOpen:l,onMouseEnter:p,onMouseLeave:m,showArrow:!0,children:h.jsxRuntimeExports.jsx(h.TruncatedText,{children:f.getFilterSummary(e.getFilterValue())})})})})}function M0(i){const{filterableColumns:e,preFilteredRows:t}=i,[n,s]=M.useStyletron(),r=e.filter(o=>{const l=o.getFilterValue();return l!=null});return r.length===0?null:h.jsxRuntimeExports.jsx("div",{className:n({display:"flex",flexWrap:"wrap",gap:s.sizing.scale300}),children:r.map(o=>h.jsxRuntimeExports.jsx(I0,{column:o,preFilteredRows:t},o.id))})}const P0=M.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":D0(i.colors.borderOpaque)}));function D0(i){return{position:"absolute",width:"85%",content:'""',borderTop:"1px solid",borderColor:i,top:0,left:"7.5%"}}function L0({label:i,onClick:e}){return h.jsxRuntimeExports.jsxs(P0,{onClick:e,role:"option","aria-label":i,"data-testid":`filter-option-${i}`,children:[i,h.jsxRuntimeExports.jsx(h.Icon,{name:"chevronRight"})]})}const N0=M.styled("ul",{margin:0,padding:0,listStyle:"none",maxHeight:"340px",overflowY:"auto"});function F0({filterableColumns:i,setSelectedColumn:e}){const[t,n]=M.useStyletron();return h.jsxRuntimeExports.jsxs("div",{className:t({backgroundColor:n.colors.backgroundPrimary,borderRadius:n.borders.radius300,width:"214px",display:"flex",flexDirection:"column"}),children:[h.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"}),h.jsxRuntimeExports.jsx(N0,{role:"listbox",children:i.map(s=>h.jsxRuntimeExports.jsx(L0,{label:s.label,onClick:()=>e(s)},s.id))})]})}function B0(i){const{columnFilters:e,filterableColumns:t,onClose:n,preFilteredRows:s,selectedColumn:r,setColumnFilters:o,setSelectedColumn:l}=i,[a,u]=M.useStyletron();if(r){const c=Ad(r.type);return h.jsxRuntimeExports.jsxs("div",{className:a({backgroundColor:u.colors.backgroundPrimary}),children:[h.jsxRuntimeExports.jsx(U.Button,{onClick:()=>l(void 0),kind:U.KIND.tertiary,size:U.SIZE.compact,children:h.jsxRuntimeExports.jsx(h.Icon,{name:"arrowLeft",size:u.sizing.scale650})}),h.jsxRuntimeExports.jsx(c,{column:r,close:n,getFilterValue:()=>{const d=e.find(f=>f.id===r.id);return d==null?void 0:d.value},setFilterValue:d=>{const f=e.filter(p=>p.id!==r.id);d!==void 0&&f.push({id:r.id,value:d}),o(f)},preFilteredRows:s})]})}return h.jsxRuntimeExports.jsx(F0,{filterableColumns:t,setSelectedColumn:l})}function V0(i){const{filterableColumns:e,columnFilters:t,setColumnFilters:n,preFilteredRows:s}=i,[r,o]=A.useState(),[l,a]=A.useState(!1),u=A.useCallback(()=>{o(void 0),a(!1)},[]);return h.jsxRuntimeExports.jsx(zt.StatefulPopover,{placement:zt.PLACEMENT.rightTop,onClose:u,onOpen:()=>a(!0),overrides:{Body:{style:{overflow:"hidden"}}},content:({close:c})=>h.jsxRuntimeExports.jsx(B0,{columnFilters:t,filterableColumns:e,onClose:()=>{u(),c()},preFilteredRows:s,selectedColumn:r,setColumnFilters:n,setSelectedColumn:o}),children:h.jsxRuntimeExports.jsx(U.Button,{shape:U.SHAPE.pill,size:U.SIZE.compact,kind:l||t.length>0?U.KIND.primary:U.KIND.secondary,startEnhancer:h.jsxRuntimeExports.jsx(h.Icon,{name:"plus"}),overrides:{BaseButton:{style:{textWrap:"nowrap"}}},children:"Add filter"})})}function _0({value:i,onChange:e}){const[t,n]=A.useState(i);A.useEffect(()=>{n(o=>o===i?o:i)},[i]);const s=A.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 h.jsxRuntimeExports.jsx(it.Input,{clearable:!0,type:"search",value:t,onChange:r,size:it.SIZE.compact,overrides:{Root:{style:{width:"250px"}}},placeholder:"Search...",startEnhancer:h.jsxRuntimeExports.jsx(h.Icon,{name:"search"})})}const z0=M.styled("div",({$theme:i})=>({display:"flex",flexDirection:"column",gap:i.sizing.scale300})),$0=M.styled("div",({$theme:i})=>({alignItems:"center",display:"flex",gap:i.sizing.scale300})),H0=M.styled("div",({$theme:i})=>({display:"flex",alignItems:"center",gap:i.sizing.scale300,marginLeft:"auto"}));function G0({globalFilter:i,setGlobalFilter:e,columnFilters:t,setColumnFilters:n,preFilteredRows:s,configuration:r,filterableColumns:o=[]}){return h.jsxRuntimeExports.jsxs(z0,{children:[h.jsxRuntimeExports.jsxs($0,{children:[r.enableSearch&&h.jsxRuntimeExports.jsx(_0,{value:i,onChange:e}),r.enableFilters&&o.length>0&&h.jsxRuntimeExports.jsx(V0,{filterableColumns:o,columnFilters:t,setColumnFilters:n,preFilteredRows:s}),r.middle,r.trailing&&h.jsxRuntimeExports.jsx(H0,{children:r.trailing})]}),r.enableFilters&&o.length>0&&h.jsxRuntimeExports.jsx(M0,{filterableColumns:o,preFilteredRows:s})]})}function U0({expanded:i}){const[,e]=M.useStyletron(),t=i?"chevronDown":"chevronRight",n=i?"Collapse":"Expand";return h.jsxRuntimeExports.jsx(h.Icon,{name:t,title:n,size:e.sizing.scale600})}function W0({cell:i,row:e,columnIndex:t}){const[n,s]=M.useStyletron();return i.getIsGrouped()||e.getCanExpand()&&t===0?h.jsxRuntimeExports.jsxs("div",{className:n({display:"flex",alignItems:"center",cursor:"pointer",gap:s.sizing.scale600}),onClick:e.getToggleExpandedHandler(),children:[h.jsxRuntimeExports.jsx(U0,{expanded:e.getIsExpanded()}),zo(i.column.columnDef.cell,i.getContext())]}):i.getIsAggregated()?zo(i.column.columnDef.aggregatedCell??i.column.columnDef.cell,i.getContext()):i.getIsPlaceholder()?null:zo(i.column.columnDef.cell,i.getContext())}function wr(i){return i.map(e=>({id:e.id,cells:e.getAllCells().map((t,n)=>({id:t.id,content:A.createElement(W0,{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 q0=M.styled("div",({$theme:i})=>({textAlign:"center",margin:"90px auto",maxWidth:"450px",display:"flex",flexDirection:"column",alignItems:"center",gap:i.sizing.scale600}));function Ht(i){const[e]=M.useStyletron(),{illustration:t,title:n,description:s,buttonConfig:r}=i;return h.jsxRuntimeExports.jsxs(q0,{children:[t,h.jsxRuntimeExports.jsx(be.HeadingXSmall,{className:e({margin:0}),children:n}),s&&h.jsxRuntimeExports.jsx(be.ParagraphMedium,{className:e({margin:0}),children:s}),r&&h.jsxRuntimeExports.jsx(U.Button,{...h.lodashExports.omit(r,"content"),kind:U.KIND.secondary,shape:U.SHAPE.pill,children:r.content})]})}const K0=Ut.StyledTable,Ga=M.withStyle(Ut.StyledTableBody,({$theme:i})=>({backgroundColor:i.colors.tableHeadBackgroundColor})),Od=Ut.StyledTableBodyRow,rn=M.withStyle(Ut.StyledTableBodyCell,({$columnNumber:i,$enableRowSelection:e})=>({fontWeight:i===(e?1:0)?500:"normal",verticalAlign:"middle"})),Id=M.styled("div",{display:"flex",justifyContent:"center"});function Rr({children:i}){const[e,t]=M.useStyletron();return h.jsxRuntimeExports.jsx(Ga,{children:h.jsxRuntimeExports.jsx(Od,{children:h.jsxRuntimeExports.jsx(rn,{colSpan:100,children:h.jsxRuntimeExports.jsx("div",{className:e({padding:t.sizing.scale600}),children:i})})})})}function Y0({emptyState:i}){return h.jsxRuntimeExports.jsx(Rr,{children:h.jsxRuntimeExports.jsx(Ht,{illustration:i.icon,title:i.title,description:i.content})})}var gt=(i=>(i[i.ERROR=0]="ERROR",i[i.PRIMARY=1]="PRIMARY",i))(gt||{});function ii({width:i="64",height:e="64",kind:t=gt.ERROR}){const[,n]=M.useStyletron(),s=t===gt.ERROR?n.colors.contentNegative:n.colors.contentStateDisabled;return h.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:[h.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}),h.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"}),h.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 X0({error:i}){switch(i.code){case h.GrpcStatusCode.DEADLINE_EXCEEDED:return h.jsxRuntimeExports.jsx(Rr,{children:h.jsxRuntimeExports.jsx(Ht,{illustration:h.jsxRuntimeExports.jsx(ii,{kind:gt.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 h.GrpcStatusCode.INVALID_ARGUMENT:default:return h.jsxRuntimeExports.jsx(Rr,{children:h.jsxRuntimeExports.jsx(Ht,{illustration:h.jsxRuntimeExports.jsx(ii,{kind:gt.ERROR,height:"64px",width:"64px"}),title:"Unable to fetch data for the table",description:"Try reloading the table and retrying the request."})})}}var kr=(i=>(i[i.DEFAULT=0]="DEFAULT",i[i.GREY=1]="GREY",i))(kr||{});const Q0={[kr.DEFAULT]:{outlineColor:"safety",questionMarkColor:"white",backgroundColor:"black"},[kr.GREY]:{outlineColor:"tableFilter",questionMarkColor:"white",backgroundColor:"black"}};function J0(i){const[,e]=M.useStyletron(),{kind:t=kr.DEFAULT,height:n="64",width:s="64"}=i,{outlineColor:r,questionMarkColor:o,backgroundColor:l}=Q0[t];return h.jsxRuntimeExports.jsxs("svg",{width:s,height:n,viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[h.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]}),h.jsxRuntimeExports.jsx("path",{d:"M11.2 29.875L4.43863 18L11.2 6.125H24.8L31.5614 18L24.8 29.875H11.2Z",fill:e.colors[l]}),h.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 Z0({clearFilters:i}){return h.jsxRuntimeExports.jsx(Rr,{children:h.jsxRuntimeExports.jsx(Ht,{illustration:h.jsxRuntimeExports.jsx(J0,{}),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 ey(i){if(typeof i.column.tooltip.content=="function"){const e=i.column.tooltip.content;return h.jsxRuntimeExports.jsx(e,{...i})}return h.jsxRuntimeExports.jsx(h.Markdown,{children:i.column.tooltip.content})}function ty(i,e){return i?Array.isArray(i)?i.length===1&&i[0]===e:i===e:!1}function iy(i,e,t,n){return function(r){const{column:o,value:l}=r,{action:a}=o.tooltip;if(a==="filter"&&ty(t,l))return h.jsxRuntimeExports.jsx(i,{...r});const u=()=>{a==="filter"&&n&&n([l])};return h.jsxRuntimeExports.jsx(h.CellTooltipWrapper,{actionHandler:u,content:h.jsxRuntimeExports.jsx(ey,{...r,row:e}),children:h.jsxRuntimeExports.jsx(i,{...r})})}}const ny=150;function sy(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:`${ny*(n+1)}px`}}return e}const Ll=i=>{const[e,t]=M.useStyletron(),{row:n,record:s,value:r,columnFilterValue:o,setColumnFilterValue:l}=i,u=h.useInterpolationResolver()($a(i.column,s),{row:s}),c=h.useCellStyles({record:s,style:u.style}),f=h.useGetCellRenderer()({column:u,record:s,value:r}),p=u.tooltip?iy(f,n,o,l):f;return h.jsxRuntimeExports.jsxs(h.CellContainer,{children:[h.jsxRuntimeExports.jsx("div",{className:e({...sy(t),...c}),children:h.jsxRuntimeExports.jsx(p,{column:u,record:s,value:r,CellComponent:Ll})}),h.jsxRuntimeExports.jsx(h.CellEnhancer,{endEnhancer:u.endEnhancer})]})};function ry(i){return e=>{const t=$a(i,e);return"items"in t?t.items.map(n=>h.getObjectValue(e,n.accessor??n.id)).join(Dl):h.getObjectValue(e,t.accessor??t.id)}}function oy(i){const e=jd();return A.useMemo(()=>i.map(t=>{const n=e(t);return{id:t.id,meta:t,accessorFn:ry(t),header:t.label,cell:s=>h.jsxRuntimeExports.jsx(Ll,{column:s.column.columnDef.meta,row:wr([s.row])[0],record:s.row.original,value:s.getValue(),columnFilterValue:s.column.getFilterValue(),setColumnFilterValue:s.column.setFilterValue}),aggregatedCell:s=>t.aggregatedCell?h.jsxRuntimeExports.jsx(t.aggregatedCell,{column:s.column.columnDef.meta,record:s.row.original,value:s.getValue()}):h.jsxRuntimeExports.jsx(Ll,{column:s.column.columnDef.meta,row:wr([s.row])[0],record:s.row.original,value:s.getValue(),columnFilterValue:s.column.getFilterValue(),setColumnFilterValue:s.column.setFilterValue}),filterFn:n.buildTableFilterFn(),enableColumnFilters:t.filterMode!==lo.NONE,enableSorting:t.enableSorting??!0,enableGrouping:t.enableGrouping??!1,aggregationFn:t.aggregationFn,sortingFn:t.sortingFn??"auto",sortUndefined:"last"}}),[i,e])}function ly(i){const{paginationState:e,pageCount:t,gotoPage:n}=i,{pageIndex:s}=e,[r,o]=A.useState(!1);A.useEffect(()=>{const a=s+1>t;s!==0&&a&&(o(!0),n(0))},[s,t,n]),A.useEffect(()=>{r&&s===0&&o(!1)},[r,s]);const l=s+1>t&&s!==0;return{isResetting:r||l}}const Md=ve.createContext({selectedRows:[],selectionEnabled:!1,setSelectionEnabled:()=>null,toggleAllRowsSelected:()=>null,getIsAllRowsSelected:()=>!1,getIsSomeRowsSelected:()=>!1}),ay=()=>ve.useContext(Md);function uy({children:i,value:e}){return h.jsxRuntimeExports.jsx(Md.Provider,{value:e,children:i})}function cy({state:i,initialState:e}){const[t,n]=A.useState(e.rowSelectionEnabled);return{enableRowSelection:(i.setRowSelectionEnabled?i.rowSelectionEnabled:t)??!1,setRowSelectionEnabled:i.setRowSelectionEnabled??n}}const Pd=i=>({width:i.sizing.scale900,minWidth:i.sizing.scale900,maxWidth:i.sizing.scale900});function Dd({canSelect:i,isSelected:e,onToggleSelection:t}){if(!i)return null;const n=s=>{s.stopPropagation(),t(s.target.checked)};return h.jsxRuntimeExports.jsx(Li.Checkbox,{checked:e,onChange:n,overrides:{Root:{style:{alignItems:"center"}}}})}function hy(i){const[e,t]=A.useState(!1);return A.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 dy={left:{right:"auto",left:"-7px",getOpacity:i=>i===-1?0:1-i},right:{right:"-7px",left:"auto",getOpacity:i=>i===-1?0:i}};function fy(i,e){if(i==="none")return{};const{getOpacity:t,...n}=dy[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 py=56;function my(i,e){const t={};return i?(t[0]={stickySide:"left",position:0,shadowSide:"none"},t[1]={stickySide:"left",position:py,shadowSide:"right"}):t[1]={stickySide:"left",position:0,shadowSide:"right"},t[e]={stickySide:"right",position:0,shadowSide:"left"},t}function Ld(i){return function(t){const{enableStickySides:n,enableRowSelection:s,lastColumnIndex:r,scrollRatio:o=-1,role:l,children:a,...u}=t,[c,d]=M.useStyletron(),f=A.useRef(null),p=hy(f);if(!n)return h.jsxRuntimeExports.jsx(i,{...u,children:a});const g={position:"sticky !important",backgroundColor:`${p&&l==="row"?d.colors.tableStripedBackground:d.colors.tableHeadBackgroundColor} !important`},x=my(s,r);return h.jsxRuntimeExports.jsx(i,{...u,ref:f,children:A.Children.map(a,(y,b)=>{const S=x[b];if(!S||!A.isValidElement(y))return y;const E={...g,[S.stickySide]:`${S.position}px !important`};return A.cloneElement(y,{className:`${c(E)} ${c(fy(S.shadowSide,o))}`,"data-testid":`sticky-cell-${S.stickySide}-sticky`})})})}}const gy=Ld(Ut.StyledTableBodyRow),xy=({rows:i,enableRowSelection:e,enableStickySides:t,scrollRatio:n,subRow:s,actions:r})=>{const[o,l]=M.useStyletron(),a=i[0].cells.filter(u=>u.isVisible).length+1;return h.jsxRuntimeExports.jsx(Ga,{children:i.map(u=>h.jsxRuntimeExports.jsxs(A.Fragment,{children:[h.jsxRuntimeExports.jsxs(gy,{enableStickySides:t,enableRowSelection:e,lastColumnIndex:a,scrollRatio:n,role:"row",children:[e&&h.jsxRuntimeExports.jsx(rn,{className:o(Pd(l)),children:h.jsxRuntimeExports.jsx(Dd,{canSelect:u.canSelect??!1,isSelected:u.isSelected??!1,onToggleSelection:u.onToggleSelection??(()=>{})})}),u.cells.filter(c=>c.isVisible).map((c,d)=>h.jsxRuntimeExports.jsx(rn,{$columnNumber:d,$enableRowSelection:e,children:c.content},c.id)),h.jsxRuntimeExports.jsx(rn,{children:h.jsxRuntimeExports.jsx(Id,{children:r&&A.createElement(r,{row:u})})})]}),s&&u.isExpanded&&h.jsxRuntimeExports.jsx(Ut.StyledTableBodyRow,{children:h.jsxRuntimeExports.jsx(rn,{colSpan:u.cells.filter(c=>c.isVisible).length+(e?2:1),children:A.createElement(s,{row:u})})})]},u.id))})};function yy(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(ar.arrayMove(i.map(l=>l.id),r,o))}}function by({columns:i,setColumnOrder:e,setColumnVisibility:t}){const[n,s]=M.useStyletron(),r=yy(i,e,t);return h.jsxRuntimeExports.jsx(zt.StatefulPopover,{placement:zt.PLACEMENT.bottomRight,content:()=>h.jsxRuntimeExports.jsx("div",{className:n({backgroundColor:s.colors.backgroundPrimary,borderRadius:s.borders.radius300,width:"214px",display:"flex",flexDirection:"column"}),children:h.jsxRuntimeExports.jsx(ar.List,{removable:!0,overrides:{Item:{style:{height:s.sizing.scale800}},Label:{component:o=>h.jsxRuntimeExports.jsx(ar.StyledLabel,{...o,children:o.$value.label})},CloseHandle:{component:o=>h.jsxRuntimeExports.jsx(ar.StyledCloseHandle,{...o,children:h.jsxRuntimeExports.jsx(Li.Checkbox,{checked:o.$value.isVisible,disabled:!o.$value.canHide,title:`Toggle ${o.$value.label}`})})}},onChange:r,items:i.slice(1)})}),children:h.jsxRuntimeExports.jsx(U.Button,{title:"Configure columns",size:U.SIZE.mini,kind:U.KIND.tertiary,children:h.jsxRuntimeExports.jsx(h.Icon,{name:"settings"})})})}function Sy(i){const{column:e}=i,t=e.getIsSorted(),n=t==="desc"?"sortDescending":"sortAscending",s=t?h.IconKind.ACCENT:h.IconKind.TERTIARY;return h.jsxRuntimeExports.jsx(h.Icon,{name:n,kind:s,title:"Toggle Sort"})}const Nl=M.withStyle(Ut.StyledTableHeadCell,({$theme:i})=>({zIndex:"unset",position:"inherit",...i.typography.LabelSmall})),vy=M.withStyle(Ut.StyledTableHeadCellSortable,({$theme:i})=>({zIndex:"unset",position:"inherit",...i.typography.LabelSmall})),Ey=M.withStyle(Nl,{padding:0}),Cy=Ld(Ut.StyledTableHeadRow),wy=({columns:i,setColumnOrder:e,setColumnVisibility:t,enableRowSelection:n,isSelected:s,onToggleSelection:r,enableStickySides:o,scrollRatio:l})=>{const[a,u]=M.useStyletron();return h.jsxRuntimeExports.jsx(Ut.StyledTableHead,{children:h.jsxRuntimeExports.jsxs(Cy,{enableStickySides:o,enableRowSelection:n,lastColumnIndex:i.filter(c=>c.isVisible).length+1,scrollRatio:l,role:"header",children:[n&&h.jsxRuntimeExports.jsx(Nl,{role:"columnheader",className:a(Pd(u)),children:h.jsxRuntimeExports.jsx(Dd,{canSelect:n,isSelected:s,onToggleSelection:r})}),i.filter(c=>c.isVisible).map(c=>c.canSort?h.jsxRuntimeExports.jsx(vy,{$isFocusVisible:!1,onClick:c.onToggleSort,role:"columnheader",children:h.jsxRuntimeExports.jsxs("div",{className:a({display:"flex",alignItems:"center",gap:u.sizing.scale300}),children:[h.jsxRuntimeExports.jsx("div",{children:c.label}),h.jsxRuntimeExports.jsx(Sy,{column:{getIsSorted:()=>c.sortDirection??!1}})]})},c.id):h.jsxRuntimeExports.jsx(Nl,{role:"columnheader",children:c.label},c.id)),e&&t&&h.jsxRuntimeExports.jsx(Ey,{role:"columnheader",children:h.jsxRuntimeExports.jsx(Id,{children:h.jsxRuntimeExports.jsx(by,{columns:i,setColumnOrder:e,setColumnVisibility:t})})})]})})};function Ry(){return h.jsxRuntimeExports.jsx(Ga,{"aria-label":"Loading",children:[1,2,3].map(i=>h.jsxRuntimeExports.jsx(Od,{children:h.jsxRuntimeExports.jsx(rn,{colSpan:100,children:h.jsxRuntimeExports.jsx(Vi.Skeleton,{animation:!0,width:"100%",height:"22px"})})},i))})}function ky(i){const{pageSizes:e,state:t,setPageSize:n}=i,{pageSize:s}=t,[r,o]=M.useStyletron(),l=e.find(a=>a.id===s);return h.jsxRuntimeExports.jsxs("div",{className:r({...o.typography.LabelMedium,display:"flex",gap:o.sizing.scale600,alignItems:"center"}),children:[h.jsxRuntimeExports.jsx("div",{className:r({minWidth:"fit-content",paddingLeft:o.sizing.scale600}),children:"Rows per page"}),h.jsxRuntimeExports.jsx(hn.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 Ty(i){const{state:e,pageCount:t,gotoPage:n,fetchPlugin:s}=i,{pageIndex:r}=e,[o]=M.useStyletron(),l=Math.min(r+1,t);return h.jsxRuntimeExports.jsxs("div",{className:o({display:"flex",justifyContent:"space-between",width:"100%",alignItems:"center"}),children:[h.jsxRuntimeExports.jsx(ky,{pageSizes:i.pageSizes,state:i.state,setPageSize:i.setPageSize}),h.jsxRuntimeExports.jsx(ux.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:Ay}:{}}})]})}function Ay(){return h.jsxRuntimeExports.jsx(U.Button,{isLoading:!0,kind:U.KIND.tertiary,children:"Next"})}function jy(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 Oy(i){const e=i.disablePagination??!1,t=i.disableSorting??!1,n=i.pageSizes??C0;return{...i,emptyState:i.emptyState??{icon:h.jsxRuntimeExports.jsx(ii,{kind:gt.PRIMARY,height:"64px",width:"64px"}),title:"No data",content:"No data is present."},loading:i.loading??!1,loadingView:i.loadingView??Ry,error:i.error??void 0,actionBarConfig:{enableSearch:!0,enableFilters:!0,...i.actionBarConfig},disablePagination:e,disableSorting:t,pageSizes:n,state:Iy(i.state,e,n),pagination:i.pagination??Ty,enableStickySides:i.enableStickySides??!0,body:i.body??xy,header:i.header??wy,unFilteredData:i.unFilteredData??i.data}}function Iy(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=jy(s,t);return{...n,pagination:{pageIndex:0,...n==null?void 0:n.pagination,pageSize:r}}}const Ju={globalFilter:"setGlobalFilter",columnFilters:"setColumnFilters",pagination:"setPagination",sorting:"setSorting",columnOrder:"setColumnOrder",columnVisibility:"setColumnVisibility",rowSelection:"setRowSelection",rowSelectionEnabled:"setRowSelectionEnabled",grouping:"setGrouping"};function My(i){const e={},t={},n=Object.keys(Ju);for(const s of n){const r=Ju[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 Py(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 Nd(i,e,t){return i.getValue(e)?h.safeStringify(i.getValue(e)).toLowerCase().includes(t.toLowerCase()):!1}Nd.autoRemove=i=>i==null;function Dy(i){return i.map(e=>{const t=e.columnDef.meta,n=t.label??e.id;return{...t,label:n,type:t.type??h.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 ao(i){var y,b,S,E;const e=Oy(i),t=oy(e.columns),[n,s]=M.useStyletron(),{state:r,initialState:o}=My(e.state??{}),{enableRowSelection:l,setRowSelectionEnabled:a}=cy({state:r,initialState:o}),{scrollRatio:u,tableRef:c,handleScrollRatioUpdate:d}=v0(t),f=S0({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:a0(),getFilteredRowModel:d0(),...e.disableSorting?{enableSorting:!1}:{getSortedRowModel:g0()},...e.disablePagination?{}:{getPaginationRowModel:m0()},...(y=o.grouping)!=null&&y.length||(b=r.grouping)!=null&&b.length?{getGroupedRowModel:f0(),getExpandedRowModel:Xu()}:{},...e.subRow?{getExpandedRowModel:Xu(),getRowCanExpand:()=>!0}:{},enableRowSelection:l,getColumnCanGlobalFilter:()=>!0,globalFilterFn:Nd,autoResetPageIndex:!1}),p=Dy(f.getAllLeafColumns()),{isResetting:m}=ly({gotoPage:f.setPageIndex,pageCount:f.getPageCount(),paginationState:f.getState().pagination}),g=Py({dataLength:e.data.length,error:e.error,loading:e.loading||m,hasFiltersApplied:((S=f.getState().globalFilter)==null?void 0:S.length)>0||(((E=f.getState().columnFilters)==null?void 0:E.length)??0)>0,filteredLength:f.getRowModel().rows.length,columnsLength:t.length}),x=e.unFilteredData.map(v=>({getValue:C=>{const k=t.find(j=>j.id===C);if(k)return k.accessorFn(v)},record:v}));return h.jsxRuntimeExports.jsx("div",{className:n({display:"flex",flexDirection:"column",gap:s.sizing.scale400}),children:h.jsxRuntimeExports.jsxs(uy,{value:{selectedRows:wr(f.getSelectedRowModel().flatRows),selectionEnabled:l,setSelectionEnabled:a,toggleAllRowsSelected:v=>f.toggleAllRowsSelected(v),getIsAllRowsSelected:()=>f.getIsAllRowsSelected(),getIsSomeRowsSelected:()=>f.getIsSomeRowsSelected()},children:[h.jsxRuntimeExports.jsx(G0,{globalFilter:f.getState().globalFilter,setGlobalFilter:f.setGlobalFilter,columnFilters:f.getState().columnFilters,setColumnFilters:f.setColumnFilters,preFilteredRows:x,configuration:e.actionBarConfig,filterableColumns:p.filter(v=>v.canFilter&&v.filterMode!==lo.NONE)}),h.jsxRuntimeExports.jsx("div",{className:n({overflow:"auto",position:"relative"}),ref:c,onScroll:d,children:h.jsxRuntimeExports.jsxs(K0,{children:[g==="loading"&&h.jsxRuntimeExports.jsx(e.loadingView,{}),g==="error"&&h.jsxRuntimeExports.jsx(X0,{error:e.error}),(g==="empty"||g==="no-columns")&&h.jsxRuntimeExports.jsx(Y0,{emptyState:e.emptyState}),g==="filtered-empty"&&h.jsxRuntimeExports.jsx(Z0,{clearFilters:()=>{f.setGlobalFilter(""),f.setColumnFilters([])}}),g!=="error"&&g!=="no-columns"&&h.jsxRuntimeExports.jsx(e.header,{columns:p,setColumnOrder:f.setColumnOrder,setColumnVisibility:f.setColumnVisibility,enableRowSelection:l,isSelected:f.getIsAllRowsSelected(),onToggleSelection:v=>f.toggleAllRowsSelected(v),enableStickySides:e.enableStickySides,scrollRatio:u}),g==="ready"&&h.jsxRuntimeExports.jsx(e.body,{rows:wr(f.getRowModel().rows),enableRowSelection:l,enableStickySides:e.enableStickySides,scrollRatio:u,subRow:e.subRow,actions:e.actions})]})}),!e.disablePagination&&g==="ready"&&f.getPreFilteredRowModel().rows.length>Math.min(...e.pageSizes.map(v=>v.id))&&h.jsxRuntimeExports.jsx(e.pagination,{gotoPage:f.setPageIndex,pageCount:f.getPageCount(),setPageSize:f.setPageSize,state:f.getState().pagination,pageSizes:e.pageSizes,fetchPlugin:e.fetchPlugin})]})})}function Ly(){const[i,e]=M.useStyletron(),{data:t,isLoading:n}=h.useStudioQuery({queryName:"ListProject",serviceOptions:{namespace:""}});return h.jsxRuntimeExports.jsxs("div",{className:i({marginTop:e.sizing.scale400}),children:[h.jsxRuntimeExports.jsx("div",{className:i({paddingTop:e.sizing.scale400,paddingBottom:e.sizing.scale400}),children:h.jsxRuntimeExports.jsx(md,{label:"All Projects"})}),h.jsxRuntimeExports.jsx(ao,{data:(t==null?void 0:t.projectList.items)??[],columns:Al,loading:n})]})}function me(){return me=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},me.apply(null,arguments)}function Ss(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 Ny=46,Fy=/\\(\\)?/g,By=RegExp(`[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,"g"),Vy=function(e){var t=[];return e.charCodeAt(0)===Ny&&t.push(""),e.replace(By,function(n,s,r,o){var l=n;r?l=o.replace(Fy,"$1"):s&&(l=s.trim()),t.push(l)}),t},Ns={},_y=/[.[\]]+/,Fd=function(e){if(e==null||!e.length)return[];if(typeof e!="string")throw new Error("toPath() expects a string");return Ns[e]==null&&(e.endsWith("[]")?Ns[e]=e.split(_y).filter(Boolean):Ns[e]=Vy(e)),Ns[e]},ge=function(e,t){for(var n=Fd(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 zy(i){var e=$y(i,"string");return typeof e=="symbol"?e:String(e)}function $y(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 Hy=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 d=Object.keys(e).length;if(e[o]===void 0&&d===0)return;if(e[o]!==void 0&&d<=1)return!isNaN(n[t-1])&&!r?{}:void 0;e[o];var f=Ss(e,[o].map(zy));return f}return me({},e,(l={},l[o]=c,l))}var p=Number(o);if(e==null){var m=i(void 0,t+1,n,s,r);if(m===void 0)return;var g=[];return g[p]=m,g}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},ct=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 Hy(e,0,Fd(t),n,s)},is="FINAL_FORM/form-error",dn="FINAL_FORM/array-error";function Zu(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,d=e.blur,f=e.change,p=e.data,m=e.focus,g=e.modified,x=e.modifiedSinceLastSubmit,y=e.name,b=e.touched,S=e.validating,E=e.visited,v=ge(u,y),C=ge(t,y);C&&C[dn]&&(C=C[dn]);var k=r&&ge(r,y),j=n&&ge(n,y),R=e.isEqual(j,v),H=!!(s&&!e.isEqual(ge(s,y),v)),N=!C&&!k;return{active:c,blur:d,change:f,data:p,dirty:!R,dirtySinceLastSubmit:H,error:C,focus:m,initial:j,invalid:!N,length:Array.isArray(v)?v.length:void 0,modified:g,modifiedSinceLastSubmit:x,name:y,pristine:R,submitError:k,submitFailed:o,submitSucceeded:l,submitting:a,touched:b,valid:N,value:v,visited:E,validating:S}}var Ua=["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","modified","modifiedSinceLastSubmit","pristine","submitError","submitFailed","submitSucceeded","submitting","touched","valid","value","visited","validating"],Lt=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 Bd(i,e,t,n,s,r){var o=!1;return s.forEach(function(l){n[l]&&(i[l]=e[l],(!t||(~r.indexOf(l)?!Lt(e[l],t[l]):e[l]!==t[l]))&&(o=!0))}),o}var Gy=["data"],Uy=function(e,t,n,s){var r={blur:e.blur,change:e.change,focus:e.focus,name:e.name},o=Bd(r,e,t,n,Ua,Gy)||!t;return o||s?r:void 0},Vd=["active","dirty","dirtyFields","dirtyFieldsSinceLastSubmit","dirtySinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","modified","modifiedSinceLastSubmit","pristine","submitting","submitError","submitErrors","submitFailed","submitSucceeded","touched","valid","validating","values","visited"],Wy=["touched","visited"];function ec(i,e,t,n){var s={},r=Bd(s,i,e,t,Vd,Wy)||!e;return r||n?s:void 0}var tc=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!Lt(t[a],l)}))&&(t=r,n=e.apply(void 0,r)),n}},$o=(function(i){return!!i&&(typeof i=="object"||typeof i=="function")&&typeof i.then=="function"}),qy="4.20.10",Ky=function(e,t){return e===t},on=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 Yy(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,d=i.submitError,f=i.submitErrors,p=i.valid,m=i.validating,g=i.values;return{active:e,dirty:!l,dirtySinceLastSubmit:t,modifiedSinceLastSubmit:n,error:s,errors:r,hasSubmitErrors:!!(d||f&&on(f)),hasValidationErrors:!!(s||on(r)),invalid:!p,initialValues:o,pristine:l,submitting:a,submitFailed:u,submitSucceeded:c,submitError:d,submitErrors:f,valid:p,validating:m>0,values:g}}function _d(i,e,t,n,s,r){var o=s(t,n,e,r);return o?(i(o),!0):!1}function ic(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;_d(u,a,e,t,n,s||!c)&&(l.notified=!0)}})}function Xy(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&&me({},s),invalid:!1,pristine:!0,submitting:!1,submitFailed:!1,submitSucceeded:!1,resetWhileSubmitting:!1,valid:!0,validating:0,values:s?me({},s):{}},lastFormState:void 0},c=0,d=!1,f=!1,p=!1,m=0,g={},x=function(w){return function(I){return delete g[w],I}},y=function(w,I,D){var F=ge(w.formState.values,I),Q=D(F);w.formState.values=ct(w.formState.values,I,Q)||{}},b=function(w,I,D){if(w.fields[I]){var F,Q;w.fields=me({},w.fields,(F={},F[D]=me({},w.fields[I],{name:D,blur:function(){return te.blur(D)},change:function(he){return te.change(D,he)},focus:function(){return te.focus(D)},lastFieldState:void 0}),F)),delete w.fields[I],w.fieldSubscribers=me({},w.fieldSubscribers,(Q={},Q[D]=w.fieldSubscribers[I],Q)),delete w.fieldSubscribers[I];var Z=ge(w.formState.values,I);w.formState.values=ct(w.formState.values,I,void 0)||{},w.formState.values=ct(w.formState.values,D,Z),delete w.lastFormState}},S=function(w){return function(){if(r){for(var I={formState:u.formState,fields:u.fields,fieldSubscribers:u.fieldSubscribers,lastFormState:u.lastFormState},D=arguments.length,F=new Array(D),Q=0;Q<D;Q++)F[Q]=arguments[Q];var Z=r[w](F,I,{changeValue:y,getIn:ge,renameField:b,resetFieldState:te.resetFieldState,setIn:ct,shallowEqual:Lt});return u.formState=I.formState,u.fields=I.fields,u.fieldSubscribers=I.fieldSubscribers,u.lastFormState=I.lastFormState,j(void 0,function(){R(),W()}),Z}}},E=r?Object.keys(r).reduce(function(q,w){return q[w]=S(w),q},{}):{},v=function(w){var I=[];if(l){var D=l(me({},u.formState.values));$o(D)?I.push(D.then(function(F){return w(F,!0)})):w(D,!1)}return I},C=function(w){return Object.keys(w.validators).reduce(function(I,D){var F=w.validators[Number(D)]();return F&&I.push(F),I},[])},k=function(w,I){var D=[],F=C(w);if(F.length){var Q;F.forEach(function(Z){var ce=Z(ge(u.formState.values,w.name),u.formState.values,Z.length===0||Z.length===3?Zu(u.formState,u.fields[w.name]):void 0);if(ce&&$o(ce)){w.validating=!0;var he=ce.then(function(ue){u.fields[w.name]&&(u.fields[w.name].validating=!1,I(ue))});D.push(he)}else Q||(Q=ce)}),I(Q)}return D},j=function(w,I){if(d){f=!0,I();return}var D=u.fields,F=u.formState,Q=me({},D),Z=Object.keys(Q);if(!l&&!Z.some(function(ai){return C(Q[ai]).length})){I();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 Ae={},Ve={},bt={},li=[].concat(v(function(ai,Ai){Ai?Ve=ai||{}:Ae=ai||{}}),Z.reduce(function(ai,Ai){return ai.concat(k(D[Ai],function(jt){bt[Ai]=jt}))},[])),Ie=li.length>0,we=++m,Qi=Promise.all(li).then(x(we));Ie&&(g[we]=Qi);var Uu=function(Ai){var jt=me({},ce?F.errors:{},Ae,Ai?Ve:F.asyncErrors),qu=function(ji){Z.forEach(function(ui){if(D[ui]){var Pn=ge(Ae,ui),nx=ge(jt,ui),sx=C(Q[ui]).length,rx=bt[ui];ji(ui,sx&&rx||l&&Pn||(!Pn&&!ce?nx:void 0))}})};qu(function(Mn,ji){jt=ct(jt,Mn,ji)||{}}),qu(function(Mn,ji){if(ji&&ji[dn]){var ui=ge(jt,Mn),Pn=[].concat(ui);Pn[dn]=ji[dn],jt=ct(jt,Mn,Pn)}}),Lt(F.errors,jt)||(F.errors=jt),Ai&&(F.asyncErrors=Ve),F.error=Ae[is]};if(Ie&&(u.formState.validating++,I()),Uu(!1),I(),Ie){var Wu=function(){u.formState.validating--,I(),u.formState.validating===0&&u.lastFormState.validating&&W()};Qi.then(function(){m>we||Uu(!0)}).then(Wu,Wu)}},R=function(w){if(!c){var I=u.fields,D=u.fieldSubscribers,F=u.formState,Q=me({},I),Z=function(he){var ue=Q[he],Ae=Zu(F,ue),Ve=ue.lastFieldState;ue.lastFieldState=Ae;var bt=D[he];bt&&ic(bt,Ae,Ve,Uy,Ve===void 0)};w?Z(w):Object.keys(Q).forEach(Z)}},H=function(){Object.keys(u.fields).forEach(function(w){u.fields[w].touched=!0})},N=function(){return!!(u.formState.error||on(u.formState.errors))},B=function(){var w=u.fields,I=u.formState,D=u.lastFormState,F=me({},w),Q=Object.keys(F),Z=!1,ce=Q.reduce(function(Ie,we){var Qi=!F[we].isEqual(ge(I.values,we),ge(I.initialValues||{},we));return Qi&&(Z=!0,Ie[we]=!0),Ie},{}),he=Q.reduce(function(Ie,we){var Qi=I.lastSubmittedValues||{};return F[we].isEqual(ge(I.values,we),ge(Qi,we))||(Ie[we]=!0),Ie},{});I.pristine=!Z,I.dirtySinceLastSubmit=!!(I.lastSubmittedValues&&Object.values(he).some(function(Ie){return Ie})),I.modifiedSinceLastSubmit=!!(I.lastSubmittedValues&&Object.keys(F).some(function(Ie){return F[Ie].modifiedSinceLastSubmit})),I.valid=!I.error&&!I.submitError&&!on(I.errors)&&!(I.submitErrors&&on(I.submitErrors));var ue=Yy(I),Ae=Q.reduce(function(Ie,we){return Ie.modified[we]=F[we].modified,Ie.touched[we]=F[we].touched,Ie.visited[we]=F[we].visited,Ie},{modified:{},touched:{},visited:{}}),Ve=Ae.modified,bt=Ae.touched,li=Ae.visited;return ue.dirtyFields=D&&Lt(D.dirtyFields,ce)?D.dirtyFields:ce,ue.dirtyFieldsSinceLastSubmit=D&&Lt(D.dirtyFieldsSinceLastSubmit,he)?D.dirtyFieldsSinceLastSubmit:he,ue.modified=D&&Lt(D.modified,Ve)?D.modified:Ve,ue.touched=D&&Lt(D.touched,bt)?D.touched:bt,ue.visited=D&&Lt(D.visited,li)?D.visited:li,D&&Lt(D,ue)?D:ue},$=function(){return e&&!0&&e(B(),Object.keys(u.fields).reduce(function(w,I){return w[I]=u.fields[I],w},{}))},P=!1,L=!1,W=function q(){if(P)L=!0;else{if(P=!0,$(),!c&&!(d&&p)){var w=u.lastFormState,I=B();I!==w&&(u.lastFormState=I,ic(u.subscribers,I,w,ec))}P=!1,L&&(L=!1,q())}},ee=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()})},ne=function(){return Object.keys(u.fields).forEach(function(w){return u.fields[w].modifiedSinceLastSubmit=!1})};j(void 0,function(){W()});var te={batch:function(w){c++,w(),c--,R(),W()},blur:function(w){var I=u.fields,D=u.formState,F=I[w];F&&(delete D.active,I[w]=me({},F,{active:!1,touched:!0}),a?j(w,function(){R(),W()}):(R(),W()))},change:function(w,I){var D=u.fields,F=u.formState;if(ge(F.values,w)!==I){y(u,w,function(){return I});var Q=D[w];Q&&(D[w]=me({},Q,{modified:!0,modifiedSinceLastSubmit:!!F.lastSubmittedValues})),a?(R(),W()):j(w,function(){R(),W()})}},get destroyOnUnregister(){return!!t},set destroyOnUnregister(q){t=q},focus:function(w){var I=u.fields[w];I&&!I.active&&(u.formState.active=w,I.active=!0,I.visited=!0,R(),W())},mutators:E,getFieldState:function(w){var I=u.fields[w];return I&&I.lastFieldState},getRegisteredFields:function(){return Object.keys(u.fields)},getState:function(){return B()},initialize:function(w){var I=u.fields,D=u.formState,F=me({},I),Q=typeof w=="function"?w(D.values):w;n||(D.values=Q);var Z=n?Object.keys(F).reduce(function(ce,he){var ue=F[he],Ae=ue.isEqual(ge(D.values,he),ge(D.initialValues||{},he));return Ae||(ce[he]=ge(D.values,he)),ce},{}):{};D.initialValues=Q,D.values=Q,Object.keys(Z).forEach(function(ce){D.values=ct(D.values,ce,Z[ce])||{}}),j(void 0,function(){R(),W()})},isValidationPaused:function(){return d},pauseValidation:function(w){w===void 0&&(w=!0),d=!0,p=w},registerField:function(w,I,D,F){D===void 0&&(D={}),u.fieldSubscribers[w]||(u.fieldSubscribers[w]={index:0,entries:{}});var Q=u.fieldSubscribers[w].index++;u.fieldSubscribers[w].entries[Q]={subscriber:tc(I),subscription:D,notified:!1};var Z=u.fields[w]||{active:!1,afterSubmit:F&&F.afterSubmit,beforeSubmit:F&&F.beforeSubmit,data:F&&F.data||{},isEqual:F&&F.isEqual||Ky,lastFieldState:void 0,modified:!1,modifiedSinceLastSubmit:!1,name:w,touched:!1,valid:!0,validateFields:F&&F.validateFields,validators:{},validating:!1,visited:!1};Z.blur=Z.blur||function(){return te.blur(w)},Z.change=Z.change||function(Ve){return te.change(w,Ve)},Z.focus=Z.focus||function(){return te.focus(w)},u.fields[w]=Z;var ce=!1,he=F&&F.silent,ue=function(){he&&u.fields[w]?R(w):(W(),R())};if(F){ce=!!(F.getValidator&&F.getValidator()),F.getValidator&&(u.fields[w].validators[Q]=F.getValidator);var Ae=ge(u.formState.values,w)===void 0;F.initialValue!==void 0&&(Ae||ge(u.formState.values,w)===ge(u.formState.initialValues,w))&&(u.formState.initialValues=ct(u.formState.initialValues||{},w,F.initialValue),u.formState.values=ct(u.formState.values,w,F.initialValue),j(void 0,ue)),F.defaultValue!==void 0&&F.initialValue===void 0&&ge(u.formState.initialValues,w)===void 0&&Ae&&(u.formState.values=ct(u.formState.values,w,F.defaultValue))}return ce?j(void 0,ue):ue(),function(){var Ve=!1;u.fields[w]&&(Ve=!!(u.fields[w].validators[Q]&&u.fields[w].validators[Q]()),delete u.fields[w].validators[Q]);var bt=!!u.fieldSubscribers[w];bt&&delete u.fieldSubscribers[w].entries[Q];var li=bt&&!Object.keys(u.fieldSubscribers[w].entries).length;li&&(delete u.fieldSubscribers[w],delete u.fields[w],Ve&&(u.formState.errors=ct(u.formState.errors,w,void 0)||{}),t&&(u.formState.values=ct(u.formState.values,w,void 0,!0)||{})),he||(Ve?j(void 0,function(){W(),R()}):li&&W())}},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,te.initialize(w||{})},resetFieldState:function(w){u.fields[w]=me({},u.fields[w],{active:!1,lastFieldState:void 0,modified:!1,touched:!1,valid:!0,validating:!1,visited:!1}),j(void 0,function(){R(),W()})},restart:function(w){w===void 0&&(w=u.formState.initialValues),te.batch(function(){for(var I in u.fields)te.resetFieldState(I),u.fields[I]=me({},u.fields[I],{active:!1,lastFieldState:void 0,modified:!1,modifiedSinceLastSubmit:!1,touched:!1,valid:!0,validating:!1,visited:!1});te.reset(w)})},resumeValidation:function(){d=!1,p=!1,f&&j(void 0,function(){R(),W()}),f=!1},setConfig:function(w,I){switch(w){case"debug":e=I;break;case"destroyOnUnregister":t=I;break;case"initialValues":te.initialize(I);break;case"keepDirtyOnReinitialize":n=I;break;case"mutators":r=I,I?(Object.keys(E).forEach(function(D){D in I||delete E[D]}),Object.keys(I).forEach(function(D){E[D]=S(D)})):Object.keys(E).forEach(function(D){delete E[D]});break;case"onSubmit":o=I;break;case"validate":l=I,j(void 0,function(){R(),W()});break;case"validateOnBlur":a=I;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=me({},w.values),N()){H(),ne(),u.formState.submitFailed=!0,W(),R();return}var I=Object.keys(g);if(I.length){Promise.all(I.map(function(he){return g[Number(he)]})).then(te.submit,console.error);return}var D=ee();if(!D){var F,Q=!1,Z=function(ue){w.submitting=!1;var Ae=w.resetWhileSubmitting;return Ae&&(w.resetWhileSubmitting=!1),ue&&on(ue)?(w.submitFailed=!0,w.submitSucceeded=!1,w.submitErrors=ue,w.submitError=ue[is],H()):(Ae||(w.submitFailed=!1,w.submitSucceeded=!0),ae()),W(),R(),Q=!0,F&&F(ue),ue};w.submitting=!0,w.submitFailed=!1,w.submitSucceeded=!1,w.lastSubmittedValues=me({},w.values),ne();var ce=o(w.values,te,Z);if(!Q){if(ce&&$o(ce))return W(),R(),ce.then(Z,function(he){throw Z(),he});if(o.length>=3)return W(),R(),new Promise(function(he){F=he});Z(ce)}}}},subscribe:function(w,I){if(!w)throw new Error("No callback given.");if(!I)throw new Error("No subscription provided. What values do you want to listen to?");var D=tc(w),F=u.subscribers,Q=F.index++;F.entries[Q]={subscriber:D,subscription:I,notified:!1};var Z=B();return _d(D,I,Z,Z,ec,!0),function(){delete F.entries[Q]}}};return te}var Qy=["render","children","component"];function zd(i,e,t){var n=i.render,s=i.children,r=i.component,o=Ss(i,Qy);if(r)return ve.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 Yt(i,e,t){t===void 0&&(t=function(r,o){return r===o});var n=A.useRef(i);A.useEffect(function(){t(i,n.current)||(e(),n.current=i)})}function Jy(i){var e=A.useRef();return e.current||(e.current=i()),e.current}var Ho=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},Zy=function(e){return!!(e&&typeof e.stopPropagation=="function")},$d=ve.createContext();function Hd(i){var e=A.useRef(i);return A.useEffect(function(){e.current=i}),e}var eb="6.5.8",Gd=function(e,t,n){n.forEach(function(s){Object.defineProperty(e,s,{get:function(){return t[s]},enumerable:!0})})},Ud=function(e,t){return Gd(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"])},tb=function(e,t){return Gd(e,t,["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","modified","modifiedSinceLastSubmit","pristine","submitError","submitFailed","submitSucceeded","submitting","touched","valid","validating","visited"])},ib=["debug","decorators","destroyOnUnregister","form","initialValues","initialValuesEqual","keepDirtyOnReinitialize","mutators","onSubmit","subscription","validate","validateOnBlur"],nb={"final-form":qy,"react-final-form":eb},Wd=Vd.reduce(function(i,e){return i[e]=!0,i},{});function sb(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,d=i.subscription,f=d===void 0?Wd:d,p=i.validate,m=i.validateOnBlur,g=Ss(i,ib),x={debug:e,destroyOnUnregister:s,initialValues:o,keepDirtyOnReinitialize:a,mutators:u,onSubmit:c,validate:p,validateOnBlur:m},y=Jy(function(){var j=r||Xy(x);return j.pauseValidation(),j}),b=ve.useState(function(){var j={};return y.subscribe(function(R){j=R},f)(),j}),S=b[0],E=b[1],v=Hd(S);ve.useEffect(function(){y.isValidationPaused()&&y.resumeValidation();var j=[y.subscribe(function(R){Ho(R,v.current)||E(R)},f)].concat(n?n.map(function(R){return R(y)}):[]);return function(){y.pauseValidation(),j.reverse().forEach(function(R){return R()})}},n),process.env.NODE_ENV!=="production"&&Yt(n,function(){console.error("Form decorators should not change from one render to the next as new values will be ignored")},Ho),Yt(e,function(){y.setConfig("debug",e)}),Yt(s,function(){y.destroyOnUnregister=!!s}),Yt(a,function(){y.setConfig("keepDirtyOnReinitialize",a)}),Yt(o,function(){y.setConfig("initialValues",o)},l||Ho),Yt(u,function(){y.setConfig("mutators",u)}),Yt(c,function(){y.setConfig("onSubmit",c)}),Yt(p,function(){y.setConfig("validate",p)}),Yt(m,function(){y.setConfig("validateOnBlur",m)});var C=function(R){return R&&(typeof R.preventDefault=="function"&&R.preventDefault(),typeof R.stopPropagation=="function"&&R.stopPropagation()),y.submit()},k={form:me({},y,{reset:function(R){Zy(R)?y.reset():y.reset(R)}}),handleSubmit:C};return Ud(k,S),ve.createElement($d.Provider,{value:y},zd(me({},g,{__versions:nb}),k,"ReactFinalForm"))}function vs(i){var e=ve.useContext($d);if(!e)throw new Error((i||"useForm")+" must be used inside of a <Form> component");return e}function rb(i){var e=i===void 0?{}:i,t=e.onChange,n=e.subscription,s=n===void 0?Wd:n,r=vs("useFormState"),o=ve.useRef(!0),l=ve.useRef(t);l.current=t;var a=ve.useState(function(){var f={};return r.subscribe(function(p){f=p},s)(),t&&t(f),f}),u=a[0],c=a[1];ve.useEffect(function(){return r.subscribe(function(f){o.current?o.current=!1:(c(f),l.current&&l.current(f))},s)},[]);var d={};return Ud(d,u),d}var ob=typeof window<"u"&&window.navigator&&window.navigator.product&&window.navigator.product==="ReactNative",lb=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},ab=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 lb(e.target.options);default:return a}};function Go(i){var e=ve.useRef(i);return ve.useEffect(function(){e.current=i}),ve.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 ub=Ua.reduce(function(i,e){return i[e]=!0,i},{}),Uo=function(e,t){return e===void 0?"":e},cb=function(e,t){return e===""?void 0:e},hb=function(e,t){return e===t};function uo(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?Uo:a,c=t.formatOnBlur,d=t.initialValue,f=t.multiple,p=t.parse,m=p===void 0?cb:p,g=t.subscription,x=g===void 0?ub:g,y=t.type,b=t.validateFields,S=t.value,E=vs("useField"),v=Hd(e),C=function(L,W){return E.registerField(i,L,x,{afterSubmit:n,beforeSubmit:function(){var ae=v.current,ne=ae.beforeSubmit,te=ae.formatOnBlur,q=ae.format,w=q===void 0?Uo:q;if(te){var I=E.getFieldState(i),D=I.value,F=w(D,i);F!==D&&E.change(i,F)}return ne&&ne()},data:o,defaultValue:l,getValidator:function(){return v.current.validate},initialValue:d,isEqual:function(ae,ne){return(v.current.isEqual||hb)(ae,ne)},silent:W,validateFields:b})},k=ve.useRef(!0),j=ve.useState(function(){var P={},L=E.destroyOnUnregister;return E.destroyOnUnregister=!1,C(function(W){P=W},!0)(),E.destroyOnUnregister=L,P}),R=j[0],H=j[1];ve.useEffect(function(){return C(function(P){k.current?k.current=!1:H(P)},!1)},[i,o,l,d]);var N={};tb(N,R);var B={name:i,get value(){var P=R.value;return c?r==="input"&&(P=Uo(P)):P=u(P,i),P===null&&!s&&(P=""),y==="checkbox"||y==="radio"?S:r==="select"&&f?P||[]:P},get checked(){var P=R.value;if(y==="checkbox")return P=u(P,i),S===void 0?!!P:!!(Array.isArray(P)&&~P.indexOf(S));if(y==="radio")return u(P,i)===S},onBlur:Go(function(P){if(R.blur(),c){var L=E.getFieldState(R.name);R.change(u(L.value,R.name))}}),onChange:Go(function(P){if(process.env.NODE_ENV!=="production"&&P&&P.target){var L=P.target.type,W=~["checkbox","radio","select-multiple"].indexOf(L)&&!y&&r!=="select",ee=L==="select-multiple"?R.value:S;W&&console.error('You must pass `type="'+(L==="select-multiple"?"select":L)+'"` prop to your Field('+i+`) component.
|
|
23
|
-
`+("Without it we don't know how to unpack your `value` prop - "+(Array.isArray(ee)?"["+ee+"]":'"'+ee+'"')+"."))}var ae=P&&P.target?ab(P,R.value,S,ob):P;R.change(m(ae,i))}),onFocus:Go(function(P){return R.focus()})};f&&(B.multiple=f),y!==void 0&&(B.type=y);var $={input:B,meta:N};return $}var db=["afterSubmit","allowNull","beforeSubmit","children","component","data","defaultValue","format","formatOnBlur","initialValue","isEqual","multiple","name","parse","subscription","type","validate","validateFields","value"],fb=ve.forwardRef(function(e,t){var n=e.afterSubmit,s=e.allowNull,r=e.beforeSubmit,o=e.children,l=e.component,a=e.data,u=e.defaultValue,c=e.format,d=e.formatOnBlur,f=e.initialValue,p=e.isEqual,m=e.multiple,g=e.name,x=e.parse,y=e.subscription,b=e.type,S=e.validate,E=e.validateFields,v=e.value,C=Ss(e,db),k=uo(g,{afterSubmit:n,allowNull:s,beforeSubmit:r,children:o,component:l,data:a,defaultValue:u,format:c,formatOnBlur:d,initialValue:f,isEqual:p,multiple:m,parse:x,subscription:y,type:b,validate:S,validateFields:E,value:v});if(typeof o=="function")return o(me({},k,C));if(typeof l=="string")return ve.createElement(l,me({},k.input,{children:o,ref:t},C));if(!g)throw new Error("prop name cannot be undefined in <Field> component");return zd(me({children:o,component:l,ref:t},C),k,"Field("+g+")")});function co(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=rb({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 Wa=({children:i,formId:e,kind:t=U.KIND.primary,disabled:n,overrides:s,...r})=>{const{submitting:o}=co({submitting:!0});return h.jsxRuntimeExports.jsx(U.Button,{type:"submit",kind:t,form:e,disabled:n,isLoading:o,overrides:cx.mergeOverrides({BaseButton:{style:{minWidth:"200px"}}},s),...r,children:i})};function Sn(){return Sn=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},Sn.apply(this,arguments)}var qd=function(e,t,n){var s=e[0],r=e[1],o=e[2],l=n.changeValue;l(t,s,function(c){var d=[].concat(c||[]);return d.splice(r,0,o),d});var a=new RegExp("^"+s+"\\[(\\d+)\\](.*)"),u={};Object.keys(t.fields).forEach(function(c){var d=a.exec(c);if(d){var f=Number(d[1]);if(f>=r){var p=s+"["+(f+1)+"]"+d[2];u[p]=t.fields[c],u[p].name=p}f===r&&delete t.fields[c]}}),t.fields=Sn({},t.fields,u)},pb=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})},mb=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 d=[].concat(c||[]),f=d[r];return d.splice(r,1),d.splice(o,0,f),d});var a=s+"["+r+"]";Object.keys(t.fields).forEach(function(c){if(c.substring(0,a.length)===a){var d=c.substring(a.length),f=a+d,p=t.fields[f];if(r<o)for(var m=r;m<o;m++){var g=s+"["+m+"]"+d;u({destKey:g,source:t.fields[s+"["+(m+1)+"]"+d]})}else for(var x=r;x>o;x--){var y=s+"["+x+"]"+d;u({destKey:y,source:t.fields[s+"["+(x-1)+"]"+d]})}var b=s+"["+o+"]"+d;u({destKey:b,source:p})}});function u(c){var d=c.destKey,f=c.source;t.fields[d]=Sn({},f,{name:d,change:t.fields[d]&&t.fields[d].change,blur:t.fields[d]&&t.fields[d].blur,focus:t.fields[d]&&t.fields[d].focus,lastFieldState:void 0})}},gb=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},xb=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]})},Kd=function(e,t,n){var s=e[0],r=e[1],o=n.changeValue,l;o(t,s,function(c){var d=[].concat(c||[]);return l=d[r],d.splice(r,1),d});var a=new RegExp("^"+s+"\\[(\\d+)\\](.*)"),u=Sn({},t.fields);return Object.keys(t.fields).forEach(function(c){var d=a.exec(c);if(d){var f=Number(d[1]);if(f===r)delete t.fields[c];else if(f>r){delete t.fields[c];var p=s+"["+(f-1)+"]"+d[2];t.fields[p]=u[c],t.fields[p].name=p}}}),l},yb=function(e,t){return e.reduce(function(n,s){return s<t?n+1:n},0)},bb=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(g){return f&&f[g]}),!f||!l.length)return f;var p=[].concat(f),m=[];return l.forEach(function(g){p.splice(g-m.length,1),m.push(f&&f[g])}),p});var c=new RegExp("^"+s+"\\[(\\d+)\\](.*)"),d={};return Object.keys(t.fields).forEach(function(f){var p=c.exec(f);if(p){var m=Number(p[1]);if(!~l.indexOf(m)){var g=s+"["+(m-yb(l,m))+"]"+p[2];d[g]=t.fields[f],d[g].name=g}}else d[f]=t.fields[f]}),t.fields=d,u},Sb=function(e,t,n){var s=e[0];return Kd([s,0],t,n)},vb=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(d){var f=[].concat(d||[]),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(d){if(d.substring(0,a.length)===a){var f=d.substring(a.length),p=a+f,m=u+f,g=t.fields[p];c({destKey:p,source:t.fields[m]}),c({destKey:m,source:g})}});function c(d){var f=d.destKey,p=d.source;t.fields[f]=Sn({},p,{name:f,change:t.fields[f].change,blur:t.fields[f].blur,focus:t.fields[f].focus,lastFieldState:void 0})}},Eb=function(e,t,n){var s=e[0],r=e[1];return qd([s,0,r],t,n)},Cb=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})},wb={insert:qd,concat:pb,move:mb,pop:gb,push:xb,remove:Kd,removeBatch:bb,shift:Sb,swap:vb,unshift:Eb,update:Cb},Rb=function(e){return!!(e&&typeof e.focus=="function")},kb=function(){return typeof document>"u"?[]:Array.prototype.slice.call(document.forms).reduce(function(e,t){return e.concat(Array.prototype.slice.call(t).filter(Rb))},[])},Tb=function(e,t){return e.find(function(n){return n.name&&ge(t,n.name)})},Ab=function(){},jb=function(e,t){return function(n){var s=function(c){e||(e=kb),t||(t=Tb);var d=t(e(),c);d&&d.focus()},r=n.submit,o={},l=n.subscribe(function(u){o=u},{errors:!0,submitErrors:!0}),a=function(){var c=o,d=c.errors,f=c.submitErrors;d&&Object.keys(d).length?s(d):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,Ab):a(),u},function(){l(),n.submit=r}}};const Ob=M.styled("div",({$height:i})=>({height:`${i}px`,flexShrink:0})),Ib=M.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})),nc=M.styled("div",({$theme:i})=>({display:"flex",alignItems:"center",gap:i.sizing.scale200}));function Mb({leftContent:i,rightContent:e}){const t=A.useRef(null),[n,s]=A.useState(0);return A.useEffect(()=>{const r=t.current;if(!r)return;const o=new ResizeObserver(()=>{s(r.offsetHeight)});return o.observe(r),()=>o.disconnect()},[]),h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[h.jsxRuntimeExports.jsx(Ob,{$height:n}),h.jsxRuntimeExports.jsxs(Ib,{ref:t,children:[h.jsxRuntimeExports.jsx(nc,{children:i}),h.jsxRuntimeExports.jsx(nc,{children:e})]})]})}const Yd=A.createContext(null);function qa(){const i=A.useContext(Yd);if(!i)throw new Error("useFormContext must be used within a <Form>");return i}const Pb=jb(),yi=({onSubmit:i,initialValues:e,id:t,children:n,render:s,footer:r,focusOnError:o=!0})=>{const[l,a]=M.useStyletron(),u=A.useRef(new Map),c=A.useMemo(()=>({fieldRegistry:u.current}),[]);return h.jsxRuntimeExports.jsx(Yd.Provider,{value:c,children:h.jsxRuntimeExports.jsx(sb,{onSubmit:i,initialValues:e,mutators:{...wb},decorators:o?[Pb]:void 0,render:({handleSubmit:d})=>{const f=h.jsxRuntimeExports.jsxs("form",{className:l({display:"flex",flexDirection:"column",gap:a.sizing.scale600}),id:t,onSubmit:d,children:[n,Db(r)]});return s?s(f):f}})})};function Db(i){if(!i)return null;if(typeof i=="object"&&("left"in i||"right"in i)){const{left:e,right:t}=i;return h.jsxRuntimeExports.jsx(Mb,{leftContent:e,rightContent:t})}return i}const ho=(...i)=>e=>{for(const t of i){const n=t(e);if(n!==void 0)return n}},Ki=i=>i==null?!0:typeof i=="string"?i.trim()==="":Array.isArray(i)?i.length===0:h.isRecord(i)?Object.keys(i).length===0:!1,$i=(i="This field is required.")=>e=>{if(!(typeof e=="boolean"||typeof e=="number"))return Ki(e)?i:void 0},Lb=(i,e=`Must be at least ${i}.`)=>t=>{if(Ki(t))return;const n=Number(t);return isNaN(n)||n<i?e:void 0},Nb=(i,e=`Must be at most ${i}.`)=>t=>{if(Ki(t))return;const n=Number(t);return isNaN(n)||n>i?e:void 0},Fb=(i,e=`Must be at least ${i} characters.`)=>t=>Ki(t)?void 0:String(t).length<i?e:void 0,Ka=(i,e=`Must be at most ${i} characters.`)=>t=>Ki(t)?void 0:String(t).length>i?e:void 0,Ya=(i,e="Invalid format.")=>t=>Ki(t)||(typeof i=="string"?new RegExp(i):i).test(String(t))?void 0:e,Bb=(i="Must be a valid URL.")=>e=>{if(!Ki(e))return h.isAbsoluteUrl(String(e))?void 0:i};function Wt(i){if(!i)return;const e=[];if(i.min!==void 0&&e.push(Lb(i.min)),i.max!==void 0&&e.push(Nb(i.max)),i.minLength!==void 0&&e.push(Fb(i.minLength)),i.maxLength!==void 0&&e.push(Ka(i.maxLength)),i.regex&&e.push(Ya(i.regex.pattern,i.regex.errorMessage)),i.url){const t=typeof i.url=="object"?i.url.errorMessage:void 0;e.push(Bb(t))}if(i.validate&&e.push(i.validate),e.length!==0)return e.length===1?e[0]:ho(...e)}const Vb=({label:i,required:e,description:t})=>{const[n,s]=M.useStyletron();return h.jsxRuntimeExports.jsxs("span",{className:n({display:"flex",gap:s.sizing.scale200,minHeight:s.sizing.scale600,alignItems:"center"}),children:[i,e?h.jsxRuntimeExports.jsx("span",{className:n({color:s.colors.negative}),children:"*"}):null,t?h.jsxRuntimeExports.jsx(h.HelpTooltip,{text:t}):null]})},_b=({counter:i,labelEndEnhancer:e})=>{const[t,n]=M.useStyletron();return h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[i&&h.jsxRuntimeExports.jsxs("span",{className:t({...n.typography.font100,color:n.colors.contentPrimary}),children:[i.length,"/",i.maxLength]}),e]})},Qe=({label:i,required:e,description:t,labelEndEnhancer:n,caption:s,error:r,counter:o,children:l})=>{const[a,u]=M.useStyletron(),c=o||n?h.jsxRuntimeExports.jsx(_b,{counter:o,labelEndEnhancer:n}):void 0;return h.jsxRuntimeExports.jsx("div",{className:a({width:"100%"}),children:h.jsxRuntimeExports.jsx(hx.FormControl,{label:i&&h.jsxRuntimeExports.jsx(Vb,{label:i,required:e,description:t}),labelEndEnhancer:c,caption:s&&h.jsxRuntimeExports.jsx(h.TruncatedText,{children:h.jsxRuntimeExports.jsx(h.Markdown,{children:s})}),error:r,overrides:{ControlContainer:{style:{marginBottom:0}},LabelEndEnhancer:{style:{display:"flex",alignItems:"center",gap:u.sizing.scale300}},Caption:{style:({$error:d,$positive:f})=>({display:d||f?"flex":"block"})}},children:l})})};function zb(i,e){const{fieldRegistry:t}=qa();A.useEffect(()=>(e&&t.set(i,{label:e}),()=>{t.delete(i)}),[i,e,t])}function ke(i,e){zb(i,e==null?void 0:e.label);const t=e!=null&&e.required?ho($i(),...e.validate?[e.validate]:[]):e==null?void 0:e.validate,s=uo(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 fo=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:u,labelEndEnhancer:c,format:d,parse:f,checkboxLabel:p,toggle:m=!1})=>{const{input:g,meta:x}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:d,parse:f}),y=S=>{g.onChange(S.currentTarget.checked)},b=p??(g.value?"Enabled":"Disabled");return h.jsxRuntimeExports.jsx(Qe,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:x.touched&&x.error?x.error:void 0,children:h.jsxRuntimeExports.jsx(Li.Checkbox,{checked:g.value??!1,onChange:o?void 0:y,onBlur:g.onBlur,onFocus:g.onFocus,disabled:l,checkmarkType:m?Li.STYLE_TYPE.toggle_round:Li.STYLE_TYPE.default,labelPlacement:Li.LABEL_PLACEMENT.right,overrides:{Label:{style:({$theme:S})=>({fontSize:S.sizing.scale550})},Root:{style:o?{cursor:"default"}:{}}},children:b})})};function $b({name:i,config:e}){const t=e,n=Wt(t.validation);return h.jsxRuntimeExports.jsx(fo,{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 Xd=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,disabled:o,description:l,caption:a,labelEndEnhancer:u,format:c,parse:d,options:f})=>{const[p,m]=M.useStyletron(),{input:g,meta:x}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:c,parse:d}),{value:y=[],onChange:b}=g,S=A.useCallback(v=>{const C=y.includes(v)?y.filter(k=>k!==v):[...y,v];b(C)},[y,b]),E=f.some(v=>v.description);return h.jsxRuntimeExports.jsx(Qe,{label:e,required:s,description:l,labelEndEnhancer:u,caption:a,error:x.touched&&x.error?x.error:void 0,children:f.length===0?h.jsxRuntimeExports.jsx("span",{children:"No options available"}):h.jsxRuntimeExports.jsx("div",{className:p({display:"flex",flexDirection:E?"column":"row",flexWrap:E?void 0:"wrap",gap:m.sizing.scale600}),children:f.map(v=>h.jsxRuntimeExports.jsxs(Li.Checkbox,{checked:y.includes(v.id),onChange:()=>S(v.id),disabled:o,overrides:{Label:{style:({$theme:C})=>({fontSize:C.sizing.scale550})}},children:[v.label,v.description&&h.jsxRuntimeExports.jsx(h.DescriptionText,{children:v.description})]},v.id))})})};function Hb({name:i,config:e}){const t=e,n=Wt(t.validation);return h.jsxRuntimeExports.jsx(Xd,{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 bi=(i=>(i.EPOCH_SECONDS="epoch",i.ISO_DATE_STRING="iso",i))(bi||{});function Gb(i=bi.ISO_DATE_STRING){const e=i===bi.EPOCH_SECONDS?n=>n?h.getDateFromEpochSeconds(parseInt(n)):null:n=>n?new Date(n):null,t=i===bi.EPOCH_SECONDS?n=>n?String(h.getEpochSecondsFromDate(n)):"":n=>n?n.toISOString():"";return{format:n=>Ub(e(n)),parse:n=>t(Wb(n))}}function Ub(i){if(!i)return null;const e=i.getTimezoneOffset();return new Date(i.getTime()+e*60*1e3)}function Wb(i){if(!i)return i;const e=i.getTimezoneOffset();return new Date(i.getTime()-e*60*1e3)}const Tr=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,placeholder:l,disabled:a,description:u,caption:c,labelEndEnhancer:d,noFutureDate:f,dateFormat:p=bi.ISO_DATE_STRING})=>{const{format:m,parse:g}=Gb(p),{input:x,meta:y}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:m,parse:g});return h.jsxRuntimeExports.jsx(Qe,{label:e,required:s,description:u,labelEndEnhancer:d,caption:c,error:y.touched&&y.error?y.error:void 0,children:h.jsxRuntimeExports.jsx(dx.DatePicker,{id:x.name,value:x.value,onChange:({date:b})=>{h.lodashExports.isNil(b)&&qb(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 qb(i){return h.lodashExports.isNil(i)||i===""||h.lodashExports.isArray(i)&&!i.length}function Kb({name:i,config:e}){const t=e,n=Wt(t.validation);return h.jsxRuntimeExports.jsx(Tr,{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 po({label:i="Add more",shape:e,onClick:t}){const[,n]=M.useStyletron();return h.jsxRuntimeExports.jsx(U.Button,{type:"button",kind:U.KIND.secondary,size:U.SIZE.compact,shape:e,startEnhancer:h.jsxRuntimeExports.jsx(h.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 Yb({row:i,keyConfig:e,valueConfig:t,readOnly:n,disabled:s,deletable:r=!0,size:o,keyError:l,onChange:a,onDelete:u,onFocus:c,onBlur:d}){const[f,p]=M.useStyletron(),m=i.key&&i.value?d:void 0;return h.jsxRuntimeExports.jsxs("div",{className:f({display:"flex",alignItems:"flex-start",gap:p.sizing.scale300,width:"100%"}),children:[h.jsxRuntimeExports.jsx(it.Input,{value:i.key,onChange:g=>a({...i,key:g.currentTarget.value}),onFocus:c,onBlur:m,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}}}),h.jsxRuntimeExports.jsx(it.Input,{value:i.value,onChange:g=>a({...i,value:g.currentTarget.value}),onFocus:c,onBlur:m,placeholder:(t==null?void 0:t.placeholder)??"Value",readOnly:n,disabled:s,size:o,overrides:{Root:{style:{flex:3}}}}),!n&&r&&h.jsxRuntimeExports.jsx(U.Button,{type:"button","aria-label":"Delete",kind:U.KIND.tertiary,shape:U.SHAPE.circle,onClick:()=>u(i),overrides:{BaseButton:{style:{marginBottom:p.sizing.scale600}}},children:h.jsxRuntimeExports.jsx(h.Icon,{name:"trashCan",kind:h.IconKind.TERTIARY})})]})}const Xb={},Qb="cannot have duplicated values";function Jb({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:u,labelEndEnhancer:c,format:d,parse:f,keyConfig:p,valueConfig:m,singleValue:g,creatable:x=!0,deletable:y=!0,emptyMessage:b,size:S}){const[E,v]=M.useStyletron(),{input:C,meta:k}=ke(i,{required:s,validate:r,defaultValue:t??Xb,initialValue:n,label:e,format:d,parse:f}),j=A.useRef(0),[R,H]=A.useState(()=>{const L=Zb(C.value);return j.current=L.length,g&&L.length===0?(j.current=1,[{id:0,key:"",value:""}]):L}),N=A.useCallback(L=>{H(W=>{const ee=W.map(ae=>ae.id===L.id?L:ae);return C.onChange(sc(ee)),ee})},[C]),B=()=>{H(L=>[...L,{id:j.current++,key:"",value:""}])},$=A.useCallback(L=>{H(W=>{const ee=W.filter(ae=>ae.id!==L.id);return C.onChange(sc(ee)),ee})},[C]),P=new Set(R.map(L=>L.key).filter((L,W,ee)=>L&&ee.indexOf(L)!==W));return h.jsxRuntimeExports.jsx(Qe,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:k.touched&&k.error?k.error:void 0,children:h.jsxRuntimeExports.jsxs("div",{className:E({display:"flex",flexDirection:"column",gap:v.sizing.scale300}),children:[R.length===0&&b&&h.jsxRuntimeExports.jsx("div",{className:E({...v.typography.ParagraphSmall,marginBottom:v.sizing.scale200}),children:b}),R.map(L=>h.jsxRuntimeExports.jsx(Yb,{row:L,keyConfig:p,valueConfig:m,readOnly:o,disabled:l,deletable:y&&!g,size:S,keyError:P.has(L.key)?`${(p==null?void 0:p.placeholder)??"Keys"} ${Qb}`:void 0,onChange:N,onDelete:$,onFocus:C.onFocus,onBlur:C.onBlur},L.id)),!g&&!o&&x&&h.jsxRuntimeExports.jsx(po,{onClick:B,label:"Add more"})]})})}function Zb(i){return Object.entries(i??{}).map(([e,t],n)=>({id:n,key:e,value:t}))}function sc(i){return Object.fromEntries(i.map(e=>[e.key,e.value]))}function eS({name:i,config:e}){const t=e,n=Wt(t.validation);return h.jsxRuntimeExports.jsx(Jb,{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 Qd=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:u,caption:c,labelEndEnhancer:d,format:f,parse:p,rows:m,maxLength:g})=>{var v;const{input:x,meta:y}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p}),[b,S]=M.useStyletron(),E=((v=x.value)==null?void 0:v.length)??0;return h.jsxRuntimeExports.jsx(Qe,{label:e,required:s,description:u,labelEndEnhancer:d,caption:c,error:y.touched&&y.error?y.error:void 0,counter:g?{length:E,maxLength:g}:void 0,children:o?h.jsxRuntimeExports.jsx("div",{className:b({...S.typography.font300,minHeight:String(S.typography.font300.lineHeight),border:`${S.sizing.scale0} solid ${S.colors.borderOpaque}`,borderRadius:S.borders.radius300,paddingTop:S.sizing.scale400,paddingBottom:S.sizing.scale400,paddingLeft:S.sizing.scale550,paddingRight:S.sizing.scale550}),children:h.jsxRuntimeExports.jsx(h.Markdown,{children:x.value})}):h.jsxRuntimeExports.jsx(fd.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,disabled:l,rows:m,maxLength:g,overrides:{Input:{style:{resize:"vertical"}}}})})};function tS({name:i,config:e}){const t=e,n=Wt(t.validation);return h.jsxRuntimeExports.jsx(Qd,{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 Xa=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:u,caption:c,labelEndEnhancer:d,format:f,parse:p})=>{const{input:m,meta:g}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p});return h.jsxRuntimeExports.jsx(Qe,{label:e,required:s,description:u,labelEndEnhancer:d,caption:c,error:g.touched&&g.error?g.error:void 0,children:h.jsxRuntimeExports.jsx(it.Input,{id:m.name,type:"number",value:m.value==null?"":String(m.value),name:m.name,onChange:x=>m.onChange(iS(x.currentTarget.value)),onBlur:m.onBlur,onFocus:m.onFocus,placeholder:a,readOnly:o,disabled:l})})};function iS(i){if(i==="")return;const e=Number(i);return isNaN(e)?void 0:e}function nS({name:i,config:e}){const t=e,n=Wt(t.validation);return h.jsxRuntimeExports.jsx(Xa,{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 sS={RadioMarkOuter:{style:({$disabled:i,$theme:e})=>i?{backgroundColor:e.colors.tickFillSelected}:{}}},rS={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}}},oS=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:u,labelEndEnhancer:c,format:d,parse:f,options:p})=>{const[,m]=M.useStyletron(),{input:g,meta:x}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:d,parse:f}),y=A.useMemo(()=>p.findIndex(S=>S.value===g.value),[p,g]),b=A.useCallback((S,E)=>{S.preventDefault(),S.stopPropagation(),g.onChange(p[E].value)},[g,p]);return h.jsxRuntimeExports.jsx(Qe,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:x.touched&&x.error?x.error:void 0,children:h.jsxRuntimeExports.jsx(Oi.TileGroup,{kind:Oi.TILE_GROUP_KIND.singleSelect,onClick:b,selected:y,disabled:l||o,overrides:sS,children:p.map(S=>h.jsxRuntimeExports.jsx(Oi.Tile,{tileKind:Oi.TILE_KIND.selection,leadingContent:()=>h.jsxRuntimeExports.jsx(be.LabelMedium,{$style:{textAlign:"left"},children:S.label}),headerAlignment:Oi.ALIGNMENT.left,bodyAlignment:Oi.ALIGNMENT.left,overrides:rS,children:h.jsxRuntimeExports.jsx(Oi.StyledParagraph,{$style:{textAlign:"left",marginBottom:m.sizing.scale600},children:S.description})},String(S.value)))})})},Jd=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:u,labelEndEnhancer:c,format:d,parse:f,options:p,align:m=Io.ALIGN.horizontal})=>{var S;const{input:g,meta:x}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:d,parse:f}),y=p.every(({value:E})=>typeof E=="boolean"),b=A.useCallback(E=>{const v=E.currentTarget.value;g.onChange(y?v==="true":v)},[g,y]);return o?h.jsxRuntimeExports.jsx(Qe,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:x.touched&&x.error?x.error:void 0,children:h.jsxRuntimeExports.jsx(it.Input,{id:g.name,readOnly:!0,value:((S=p.find(E=>E.value===g.value))==null?void 0:S.label)??"",overrides:{InputContainer:{style:({$theme:E})=>({backgroundColor:E.colors.backgroundPrimary})}}})}):h.jsxRuntimeExports.jsx(Qe,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:x.touched&&x.error?x.error:void 0,children:h.jsxRuntimeExports.jsx(Io.RadioGroup,{name:g.name,value:typeof g.value=="boolean"?String(g.value):g.value,align:m,disabled:l,onChange:b,onBlur:g.onBlur,onFocus:g.onFocus,overrides:{RadioGroupRoot:{style:({$theme:E})=>({gap:E.sizing.scale600})}},children:p.map(E=>h.jsxRuntimeExports.jsx(Io.Radio,{value:typeof E.value=="boolean"?String(E.value):E.value,disabled:E.disabled,overrides:{RadioMarkOuter:{style:({$theme:v})=>({height:v.sizing.scale600,width:v.sizing.scale600})},RadioMarkInner:{style:({$checked:v,$theme:C})=>({height:v?C.sizing.scale100:C.sizing.scale400,width:v?C.sizing.scale100:C.sizing.scale400,transform:"none"})}},children:E.label},String(E.value)))})})},Qa=i=>i.options.some(t=>!!t.description)?h.jsxRuntimeExports.jsx(oS,{...i}):h.jsxRuntimeExports.jsx(Jd,{...i});function lS({name:i,config:e}){const t=e,n=Wt(t.validation);return h.jsxRuntimeExports.jsx(Qa,{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 aS(i,e,t){const n={Popover:{props:{ignoreBoundary:!0}},Input:{props:{name:i}}};return e?M.mergeOverrides(n,{Tag:{props:{closeable:!1,disabled:!1}}}):t?M.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 uS(i){return i?Array.isArray(i)?i:[i]:[]}function Wo(i){return JSON.stringify(i,(e,t)=>h.isRecord(t)?Object.fromEntries(Object.entries(t).sort(([n],[s])=>n.localeCompare(s))):t)}function wt({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:u,labelEndEnhancer:c,placeholder:d,format:f,parse:p,options:m,visibleOptionLimit:g,isLoading:x=!1,clearable:y=!0,searchable:b=!0,multi:S=!1,creatable:E=!1,getOptionContent:v}){const{input:C,meta:k}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p}),{baseUiOptions:j,findByValue:R,findByKey:H}=A.useMemo(()=>{const $=new Map;return{baseUiOptions:m.map(L=>{const W=Wo(L.id);return $.set(W,L),{id:W,label:L.label,disabled:L.disabled}}),findByValue:L=>$.get(Wo(L)),findByKey:L=>$.get(L)}},[m]);A.useEffect(()=>{if(x||E)return;const $=C.value;if(!(!$||Array.isArray($)&&$.length===0))if(S){const P=$,L=P.filter(W=>R(W));L.length!==P.length&&C.onChange(L)}else R($)||C.onChange("")},[R,x]);const N=$=>{var L;const P=$.value;S?C.onChange(P.map(W=>{var ee;return((ee=H(W.id))==null?void 0:ee.id)??W.id})):P.length>0?C.onChange(((L=H(P[0].id))==null?void 0:L.id)??P[0].id):C.onChange("")},B=A.useMemo(()=>{const $=[];for(const P of uS(C.value)){const L=Wo(P),W=H(L);W?$.push({id:L,label:W.label,disabled:W.disabled}):E&&$.push({id:L,label:String(P)})}return $},[C.value,H,E]);return h.jsxRuntimeExports.jsx(Qe,{label:e,required:s,description:a,labelEndEnhancer:c,caption:u,error:k.touched&&k.error?k.error:void 0,children:h.jsxRuntimeExports.jsx(hn.Select,{id:i,value:B,options:j,onChange:N,onBlur:C.onBlur,onFocus:C.onFocus,placeholder:!l&&!o?d:"",disabled:l,clearable:!l&&!o&&y,searchable:b,multi:S,overrides:aS(i,l,o),creatable:E,filterOptions:($,P,L,W)=>hn.filterOptions($,P,L,W).slice(0,g),isLoading:x,getOptionLabel:({option:$})=>{if(!v)return $.label;const P=H(String($.id));return P?v(P):$.label},getValueLabel:({option:$})=>$.label})})}function cS({name:i,config:e}){const t=e,n=Wt(t.validation);return h.jsxRuntimeExports.jsx(wt,{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 hS(i){const{closeable:e,index:t,onRemove:n,readOnly:s,updateValue:r,value:o}=i,[,l]=M.useStyletron(),[a,u]=A.useState(!1),[c,d]=A.useState(o),f={paddingTop:l.sizing.scale100,paddingRight:l.sizing.scale100,paddingBottom:l.sizing.scale100,paddingLeft:l.sizing.scale100},p=()=>{d(o),u(!1)},m=()=>{r(c,t),u(!1)},g=x=>{x.key==="Enter"&&m()};return a&&!s?h.jsxRuntimeExports.jsx(h.Tag,{contentMaxWidth:"100%",overrides:{ActionIcon:{component:h.Icon,props:{name:"check",onMouseDown:m,size:l.sizing.scale500}},Root:{style:f}},behavior:h.TAG_BEHAVIOR.selection,hierarchy:bn.HIERARCHY.secondary,children:h.jsxRuntimeExports.jsx(it.StyledInput,{$adjoined:it.ADJOINED.none,autoFocus:!0,onBlur:p,onChange:x=>d(x.target.value),onKeyDown:g,size:c.length+1,$size:it.SIZE.compact,style:{padding:0},value:c})}):h.jsxRuntimeExports.jsx(h.Tag,{closeable:e,onActionClick:n,onClick:()=>u(!0),overrides:{Root:{style:f}},hierarchy:bn.HIERARCHY.primary,children:o})}const dS=A.forwardRef(function(e,t){const{clear:n,readOnly:s,removeValue:r,updateValue:o,value:l,valueList:a,...u}=e,[,c]=M.useStyletron(),d=()=>{var p;n(),t&&typeof t!="function"&&((p=t.current)==null||p.focus())},f=p=>{var m;p.target===p.currentTarget&&t&&typeof t!="function"&&((m=t.current)==null||m.focus())};return h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[h.jsxRuntimeExports.jsxs(hn.StyledValueContainer,{$multi:!0,$style:{gap:c.sizing.scale100},onClick:f,children:[a.map((p,m)=>h.jsxRuntimeExports.jsx(hS,{value:p,index:m,closeable:!s,onRemove:()=>r(m),readOnly:s,updateValue:o},m)),h.jsxRuntimeExports.jsx(it.StyledInput,{...u,$adjoined:it.ADJOINED.none,readOnly:s,ref:t,size:String(l??"").length+1,$size:it.SIZE.compact,value:l})]}),a.length>0&&!s&&h.jsxRuntimeExports.jsx(hn.StyledIconsContainer,{children:h.jsxRuntimeExports.jsx(hn.StyledClearIcon,{onClick:d,children:h.jsxRuntimeExports.jsx(fx.DeleteAlt,{})})})]})});function fS({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:u,caption:c,labelEndEnhancer:d,format:f,parse:p}){const{input:m,meta:g}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p}),[x,y]=A.useState(""),b=Array.isArray(m.value)?m.value:[],S=R=>{m.onChange([...b,R]),y("")},E=R=>m.onChange(b.filter((H,N)=>N!==R)),v=(R,H)=>{const N=[...b];N[H]=R,m.onChange(N)},C=()=>{m.onChange([]),y("")},k=R=>{if(o)return;const H=R.key==="Enter"&&x,N=R.key==="Backspace"&&b.length>0&&!x;H?(R.preventDefault(),S(x)):N&&E(b.length-1)},j=()=>{m.onBlur(),x&&S(x)};return h.jsxRuntimeExports.jsx(Qe,{label:e,required:s,description:u,labelEndEnhancer:d,caption:c,error:g.touched&&g.error?g.error:void 0,children:h.jsxRuntimeExports.jsx(it.Input,{...m,id:i,value:x,onChange:R=>y(R.currentTarget.value),onBlur:j,placeholder:!l&&!o&&b.length===0?a:"",readOnly:o,disabled:l,overrides:{InputContainer:{style:({$theme:R})=>o&&!l?{backgroundColor:R.colors.backgroundPrimary}:{}},Input:{component:dS,props:{clear:C,onKeyDown:k,readOnly:o,removeValue:E,updateValue:v,valueList:b},style:{width:"auto",flexGrow:1,padding:0}}}})})}function pS({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:u,caption:c,labelEndEnhancer:d,format:f,parse:p,maxLength:m}){var b;const{input:g,meta:x}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p}),y=((b=g.value)==null?void 0:b.length)??0;return h.jsxRuntimeExports.jsx(Qe,{label:e,required:s,description:u,labelEndEnhancer:d,caption:c,error:x.touched&&x.error?x.error:void 0,counter:m?{length:y,maxLength:m}:void 0,children:h.jsxRuntimeExports.jsx(it.Input,{id:g.name,value:g.value??"",name:g.name,onChange:S=>g.onChange(S.currentTarget.value),onBlur:g.onBlur,onFocus:g.onFocus,placeholder:a,readOnly:o,disabled:l,maxLength:m})})}function He(i){return i.multi?h.jsxRuntimeExports.jsx(fS,{...i}):h.jsxRuntimeExports.jsx(pS,{...i})}function mS({name:i,config:e}){const t=e,n=Wt(t.validation);return h.jsxRuntimeExports.jsx(He,{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 mo=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:u,caption:c,labelEndEnhancer:d,format:f,parse:p,rows:m,maxLength:g})=>{var S;const{input:x,meta:y}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p}),b=((S=x.value)==null?void 0:S.length)??0;return h.jsxRuntimeExports.jsx(Qe,{label:e,required:s,description:u,labelEndEnhancer:d,caption:c,error:y.touched&&y.error?y.error:void 0,counter:g?{length:b,maxLength:g}:void 0,children:h.jsxRuntimeExports.jsx(fd.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,readOnly:o,disabled:l,rows:m,maxLength:g,overrides:{Input:{style:{resize:"vertical"}}}})})};function gS({name:i,config:e}){const t=e;return h.jsxRuntimeExports.jsx(mo,{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 Zd=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,description:o,caption:l,labelEndEnhancer:a,format:u,parse:c,placeholder:d,urlName:f})=>{const{input:p,meta:m}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:u,parse:c}),g=p.value;return h.jsxRuntimeExports.jsx(Qe,{label:e,required:s,description:o,labelEndEnhancer:a,caption:l,error:m.touched&&m.error?m.error:void 0,children:h.isNavigableUrl(g)?h.jsxRuntimeExports.jsx(h.Link,{href:g,children:h.jsxRuntimeExports.jsx(h.TruncatedText,{children:f??e??g})}):h.jsxRuntimeExports.jsx("span",{children:d})})};function xS({name:i,config:e}){const t=e,n=Wt(t.validation);return h.jsxRuntimeExports.jsx(Zd,{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 yS={string:mS,number:nS,boolean:$b,select:cS,checkbox:Hb,radio:lS,date:Kb,textarea:gS,url:xS,map:eS,markdown:tS},bS=A.createContext(null),SS=()=>A.useContext(bS);function vS(i){const e=SS();return(e==null?void 0:e.renderers[i])??yS[i]}function ES({fieldPath:i,config:e}){const t=vS((e==null?void 0:e.type)??"");return!t||!e?null:h.jsxRuntimeExports.jsx(t,{name:i,config:e})}function qo(i){return i==null||i===""||Array.isArray(i)&&!i.length}function ef(i,e){return"is"in i?e===i.is:"isNot"in i?!qo(e)&&e!==i.isNot:"isEmpty"in i?i.isEmpty?qo(e):!qo(e):"containsAny"in i?Array.isArray(e)?i.containsAny.some(t=>e.includes(t)):i.containsAny.some(t=>e===t):!0}function CS({layout:i,children:e}){const{input:t}=uo(i.when,{subscription:{value:!0}});return ef(i,t.value)?h.jsxRuntimeExports.jsx(h.jsxRuntimeExports.Fragment,{children:e}):null}const wS=({children:i})=>{const[e,t]=M.useStyletron();return h.jsxRuntimeExports.jsx("div",{className:e({display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gridColumnGap:t.sizing.scale800}),children:i})},Ja=({children:i,title:e,description:t,expanded:n,defaultExpanded:s=!1,onToggle:r,disabled:o=!1,overrides:l={}})=>{const[a,u]=A.useState(s),c=n!==void 0,d=c?n:a;A.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=!d;c||u(x),r==null||r(x)},[p,m]=M.getOverrides(l.HeaderTitle,h.StyledBoxTitle),g=e?h.jsxRuntimeExports.jsxs("div",{children:[h.jsxRuntimeExports.jsx(p,{...m,children:e}),t&&h.jsxRuntimeExports.jsx(h.DescriptionText,{children:t})]}):void 0;return h.jsxRuntimeExports.jsx(px.Panel,{expanded:d,onChange:f,title:g,overrides:M.mergeOverrides({PanelContainer:{component:h.StyledBoxContainer,style:({$expanded:x,$theme:y})=>({...!x&&{gap:0},transitionProperty:"gap",transitionDuration:y.animation.timing500})},Header:{style:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight: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})},Yi=({title:i,description:e,tooltip:t,collapsible:n=!1,expanded:s,onToggle:r,endEnhancer:o,overrides:l={},children:a})=>{const[u,c]=M.useStyletron(),d=i&&t?h.jsxRuntimeExports.jsxs("div",{className:u({display:"flex",alignItems:"center",gap:c.sizing.scale100}),children:[i,h.jsxRuntimeExports.jsx(h.HelpTooltip,{text:t})]}):i,f=d&&o?h.jsxRuntimeExports.jsxs("div",{className:u({display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"}),children:[d,o]}):d,p=e?h.jsxRuntimeExports.jsx(h.Markdown,{children:e}):void 0;return n?h.jsxRuntimeExports.jsx(Ja,{title:f,description:p,expanded:s,defaultExpanded:!1,onToggle:r,overrides:{Content:{style:{paddingTop:0}}},children:a}):h.jsxRuntimeExports.jsx(h.Box,{title:f,description:p,overrides:M.mergeOverrides({BoxContainer:{style:{marginBottom:c.sizing.scale600}}},l),children:a})},Za=({name:i,span:e,children:t})=>{const[n,s]=M.useStyletron(),r=A.Children.toArray(t),o=(e==null?void 0:e.reduce((l,a)=>l+a,0))??r.length;return h.jsxRuntimeExports.jsxs("div",{className:n({flexGrow:1,boxSizing:"border-box"}),children:[i&&h.jsxRuntimeExports.jsx("div",{className:n(s.typography.LabelMedium),children:i}),h.jsxRuntimeExports.jsx(vr.Grid,{gridColumns:o,gridMargins:[0],gridMaxWidth:0,children:r.map((l,a)=>h.jsxRuntimeExports.jsx(vr.Cell,{span:e==null?void 0:e[a],children:l},a))})]})};function RS({config:i,fields:e}){const t=h.jsxRuntimeExports.jsx(tf,{items:i.items,fields:e});switch(i.type){case"group":return h.jsxRuntimeExports.jsx(Yi,{title:i.title,description:i.description,tooltip:i.tooltip,collapsible:i.collapsible,children:t});case"row":return h.jsxRuntimeExports.jsx(Za,{name:i.name,span:i.span,children:t});case"grid":return h.jsxRuntimeExports.jsx(wS,{children:t});case"condition":return h.jsxRuntimeExports.jsx(CS,{layout:i,children:t})}}function tf({items:i,fields:e}){return h.jsxRuntimeExports.jsx(h.jsxRuntimeExports.Fragment,{children:i.map((t,n)=>typeof t=="string"?h.jsxRuntimeExports.jsx(ES,{fieldPath:t,config:e[t]},t):h.jsxRuntimeExports.jsx(RS,{config:t,fields:e},n))})}function kS(i,e){const t=h.lodashExports.cloneDeep(i);return TS(t,e),t}function TS(i,e){const t=h.lodashExports.toPath(e);if(t.length===0)return;do h.lodashExports.unset(i,t),t.pop();while(t.length>0&&h.lodashExports.isEmpty(h.lodashExports.get(i,t)));const n=h.lodashExports.get(i,t);Array.isArray(n)&&h.lodashExports.set(i,t,n.filter(s=>s!==void 0))}function AS(i,e){return nf(e.layout,i)}function nf(i,e){return i.reduce((t,n)=>typeof n=="string"?t:n.type==="condition"&&!ef(n,h.lodashExports.get(t,n.when))?sf(n.items,t):nf(n.items,t),e)}function sf(i,e){return i.reduce((t,n)=>typeof n=="string"?kS(t,n):sf(n.items,t),e)}const Ko={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 jS(){const[i,e]=A.useState();return h.jsxRuntimeExports.jsxs(en,{children:[h.jsxRuntimeExports.jsx(be.HeadingXXLarge,{children:"Component Sandbox"}),h.jsxRuntimeExports.jsx(Ms.Block,{marginBottom:"24px",children:"This is a sandbox for testing WIP components and features."}),h.jsxRuntimeExports.jsx(Ms.Block,{width:"400px",children:h.jsxRuntimeExports.jsxs(yi,{initialValues:{mode:"basic"},onSubmit:t=>{const n=AS(t,Ko);e(n)},children:[h.jsxRuntimeExports.jsx(tf,{items:Ko.layout,fields:Ko.fields}),h.jsxRuntimeExports.jsx(Wa,{children:"Submit"})]})}),i?h.jsxRuntimeExports.jsxs(Ms.Block,{marginTop:"24px",children:[h.jsxRuntimeExports.jsx(be.LabelMedium,{marginBottom:"scale300",children:"Last submitted values"}),h.jsxRuntimeExports.jsx(Ms.Block,{as:"pre",backgroundColor:"backgroundSecondary",padding:"12px",children:JSON.stringify(i,null,2)})]}):null]})}var Ct=(i=>(i.PRIMARY="primary",i.SECONDARY="secondary",i.TERTIARY="tertiary",i))(Ct||{});function OS(){var a;const{fieldRegistry:i}=qa(),{submitErrors:e,errors:t,touched:n}=co({submitErrors:!0,errors:!0,touched:!0}),s=e==null?void 0:e[is],r=s instanceof Error?s.message:s,o=r?[{fieldPath:is,errorMessage:r}]:[];if(!t)return o;const l=[];for(const[u,c]of Object.entries(n??{})){if(!c)continue;const d=h.lodashExports.get(t,u);typeof d=="string"&&l.push({fieldPath:u,fieldLabel:(a=i.get(u))==null?void 0:a.label,errorMessage:d,focus:()=>{var f;(f=document.querySelector(`[name="${u}"]`))==null||f.focus()}})}return[...o,...l]}function rf(){const[i,e]=M.useStyletron(),t=OS();return t.length===0?null:h.jsxRuntimeExports.jsx(h.Banner,{kind:"negative",children:t.map(n=>h.jsxRuntimeExports.jsxs("div",{className:i({...e.typography.ParagraphSmall,textAlign:"left"}),children:[n.fieldLabel&&h.jsxRuntimeExports.jsx(mx.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&&h.jsxRuntimeExports.jsx(h.jsxRuntimeExports.Fragment,{children:" "}),h.jsxRuntimeExports.jsx(h.Markdown,{children:n.errorMessage})]},n.fieldPath))})}const Es=({isOpen:i,onDismiss:e,heading:t,size:n=Er.SIZE.large,onSubmit:s,initialValues:r,submitLabel:o="Submit",children:l})=>{const a=A.useId(),u=async c=>{try{await s(c),e()}catch(d){return{[is]:d instanceof Error?d:new Error(String(d))}}};return h.jsxRuntimeExports.jsxs(yi,{id:a,initialValues:r,onSubmit:u,render:c=>h.jsxRuntimeExports.jsx(h.Dialog,{isOpen:i,onDismiss:e,heading:t,size:n,placement:Er.PLACEMENT.topCenter,buttonDock:{primaryAction:h.jsxRuntimeExports.jsx(Wa,{formId:a,children:o}),dismissiveAction:h.jsxRuntimeExports.jsx(U.Button,{kind:U.KIND.tertiary,onClick:e,overrides:{BaseButton:{style:{minWidth:"150px"}}},children:"Cancel"})},children:c}),children:[l,h.jsxRuntimeExports.jsx(rf,{})]})},IS=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,MS=i=>(Array.isArray(i)?i:[]).every(n=>typeof n=="string"&&IS.test(n))?void 0:"Must be a valid email.";var Fl=(i=>(i[i.EMAIL=1]="EMAIL",i[i.SLACK=2]="SLACK",i))(Fl||{}),tn=(i=>(i[i.PIPELINE_RUN_STATE_SUCCEEDED=1]="PIPELINE_RUN_STATE_SUCCEEDED",i[i.PIPELINE_RUN_STATE_KILLED=2]="PIPELINE_RUN_STATE_KILLED",i[i.PIPELINE_RUN_STATE_FAILED=3]="PIPELINE_RUN_STATE_FAILED",i[i.PIPELINE_RUN_STATE_SKIPPED=4]="PIPELINE_RUN_STATE_SKIPPED",i[i.PIPELINE_RUN_STATE_STARTED=11]="PIPELINE_RUN_STATE_STARTED",i))(tn||{}),Bl=(i=>(i[i.PIPELINE_RUN=1]="PIPELINE_RUN",i))(Bl||{}),Ar=(i=>(i[i.QUEUED=0]="QUEUED",i[i.PENDING=1]="PENDING",i[i.RUNNING=2]="RUNNING",i[i.SUCCEEDED=3]="SUCCEEDED",i[i.KILLED=4]="KILLED",i[i.FAILED=5]="FAILED",i[i.SKIPPED=6]="SKIPPED",i))(Ar||{});const of=new Set([3,4,5,6]),lf="michelangelo/environment",PS={development:"Development",production:"Production",testing:"Testing"};function af(i){const e=i==null?void 0:i[lf];return e?PS[e.toLowerCase()]??"":""}const rc="-",DS=8,eu=(i={withDate:!1})=>{const e=`${rc}${crypto.randomUUID().substring(0,DS)}`;if(i.withDate){const t=new Date().toISOString(),n=h.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`${rc}${o}-${l}${e}`}return e},uf={0:"Pending",1:"Pending",2:"Running",3:"Success",4:"Killed",5:"Failed",6:"Skipped"},cf={0:"gray",1:"blue",2:"blue",3:"green",4:"red",5:"red",6:"gray"},hf={0:"Queued",1:"Pending",2:"Running",3:"Succeeded",4:"Killed",5:"Failed",6:"Skipped"},LS={0:"gray",1:"blue",2:"blue",3:"green",4:"red",5:"red",6:"gray"},df={id:"metadata.creationTimestamp.seconds",label:"Created",type:h.CellType.DATE},ff={id:"spec.pipeline.name",label:"Pipeline",items:[{id:"spec.pipeline.name",type:h.CellType.TEXT},{id:"spec.revision.name",type:h.CellType.DESCRIPTION}]},pf={id:"spec.actor.name",label:"Started by",type:h.CellType.TEXT},mf={id:"status.state",label:"State",type:h.CellType.STATE,stateTextMap:hf,stateColorMap:LS},Vl="pipelinerun.michelangelo/triggered-by",tu={id:`metadata.labels['${Vl}']`,label:"Triggered by",type:h.CellType.LINK,url:vt(({studio:i,data:e})=>{var n,s;const t=(s=(n=e==null?void 0:e.metadata)==null?void 0:n.labels)==null?void 0:s[Vl];return t?`/${i.projectId}/${i.phase}/triggers/${t}`:""})},iu=[df,ff,pf,tu,mf],NS=({step:i})=>{var a,u,c,d;const[e,t]=M.useStyletron();if(!i)return null;const n=h.timestampToString((a=i.startTime)==null?void 0:a.seconds),s=h.timestampToString((u=i.endTime)==null?void 0:u.seconds),r=h.formatElapsedSeconds((c=i.startTime)==null?void 0:c.seconds,(d=i.endTime)==null?void 0:d.seconds),o=i.state??0,l=e({...t.typography.ParagraphXSmall});return h.jsxRuntimeExports.jsxs("div",{className:e({display:"grid",gridTemplateColumns:"1.5fr 1fr 1fr 0.5fr auto",alignItems:"center",gap:t.sizing.scale400,width:"100%"}),children:[h.jsxRuntimeExports.jsx("span",{children:i.displayName}),h.jsxRuntimeExports.jsx("span",{className:l,children:n??"—"}),h.jsxRuntimeExports.jsx("span",{className:l,children:s??"—"}),h.jsxRuntimeExports.jsx("span",{className:l,children:r??"—"}),h.jsxRuntimeExports.jsx(h.Tag,{size:h.TAG_SIZE.xSmall,hierarchy:bn.HIERARCHY.secondary,behavior:h.TAG_BEHAVIOR.display,closeable:!1,color:cf[o]??"gray",children:uf[o]??"Unknown"})]})},gf=1,xf="pipeline_run.pipeline_name",yf={id:"status.state",label:"State",type:h.CellType.STATE,stateTextMap:{0:"Invalid",1:"Created",2:"Building",3:"Ready",4:"Error"},stateColorMap:{0:"red",1:"green",2:"yellow",3:"green",4:"red"}},bf={id:"spec.type",label:"Type",type:h.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"}},oc="spec.resume.pipelineRun.name",FS="spec.resume.resumeFrom",BS="Execute Workflow",VS=25;function _S(i){return{listOptionsExt:{operation:{criterion:[{fieldName:xf,operator:gf,matchValue:i}]}}}}const zS=({pipelineName:i})=>{const[e,t]=A.useState(!1),n=x=>t(x),{input:s}=ke(oc),r=s.value,{data:o,isLoading:l}=h.useStudioQuery({queryName:"ListPipelineRun",serviceOptions:_S(i),clientOptions:{enabled:e}}),{data:a,isLoading:u}=h.useStudioQuery({queryName:"GetPipelineRun",serviceOptions:{name:r},clientOptions:{enabled:!!r}}),c=A.useMemo(()=>{var x;return $S((x=o==null?void 0:o.pipelineRunList)==null?void 0:x.items,i)},[o,i]),d=A.useMemo(()=>GS(a==null?void 0:a.pipelineRun),[a]),f=A.useMemo(()=>d.map(x=>({id:x.displayName??"",label:x.displayName??""})),[d]),p=A.useMemo(()=>{const x=new Map;for(const y of d)y.displayName&&x.set(y.displayName,y);return x},[d]),m=!!r,g=m&&!u&&d.length===0;return h.jsxRuntimeExports.jsxs(Yi,{collapsible:!0,title:"Select run to resume from",description:"Continue a previous run instead of starting over. Completed tasks are reused from the source run.",onToggle:n,children:[h.jsxRuntimeExports.jsx(wt,{name:oc,label:"Pipeline run",placeholder:"Search runs…",options:c,isLoading:l,caption:!l&&c.length===0?"This pipeline has no finished runs to resume from.":void 0}),h.jsxRuntimeExports.jsx(wt,{multi:!0,name:FS,label:"Steps",placeholder:m?"Search steps…":"Select a pipeline run first",options:f,isLoading:u,disabled:!m||g,creatable:!1,getOptionContent:x=>h.jsxRuntimeExports.jsx(NS,{step:p.get(x.id)}),caption:g?"This run has no recorded workflow tasks to resume from.":"Leave empty to continue from where the source run stopped, reusing all cached outputs."})]})};function $S(i,e){return i?i.filter(t=>{var n,s,r,o;return((s=(n=t.spec)==null?void 0:n.pipeline)==null?void 0:s.name)===e&&((r=t.status)==null?void 0:r.state)!==void 0&&of.has(t.status.state)&&!!((o=t.metadata)!=null&&o.name)}).sort((t,n)=>{var s,r,o,l;return Number(((r=(s=n.metadata)==null?void 0:s.creationTimestamp)==null?void 0:r.seconds)??0)-Number(((l=(o=t.metadata)==null?void 0:o.creationTimestamp)==null?void 0:l.seconds)??0)}).slice(0,VS).map(t=>{var n;return{id:((n=t.metadata)==null?void 0:n.name)??"",label:HS(t)}}):[]}function HS(i){var n,s,r,o;const e=hf[((n=i.status)==null?void 0:n.state)??0]??"Unknown",t=h.timestampToString((r=(s=i.metadata)==null?void 0:s.creationTimestamp)==null?void 0:r.seconds);return[(o=i.metadata)==null?void 0:o.name,e,t].filter(Boolean).join(" · ")}function GS(i){var t,n;const e=(n=(t=i==null?void 0:i.status)==null?void 0:t.steps)==null?void 0:n.find(s=>s.name===BS);return((e==null?void 0:e.subSteps)??[]).filter(s=>!!s.displayName)}const lc=[tn.PIPELINE_RUN_STATE_STARTED,tn.PIPELINE_RUN_STATE_SUCCEEDED,tn.PIPELINE_RUN_STATE_FAILED,tn.PIPELINE_RUN_STATE_KILLED,tn.PIPELINE_RUN_STATE_SKIPPED],US=({record:i,onClose:e})=>{var l;const{projectId:t}=h.useStudioParams("base"),n=((l=i==null?void 0:i.metadata)==null?void 0:l.name)??"",s=h.useStudioMutation({mutationName:"CreatePipelineRun"}),r=async a=>{if(s.isPending)return;const u=WS(a,t);await s.mutateAsync({metadata:u.metadata,spec:{...u.spec,notifications:a.notifyOnCompletion?qS(a):[]}})},o={metadata:{name:`run${eu({withDate:!0})}`,namespace:t},spec:{pipeline:{name:n,namespace:t}}};return h.jsxRuntimeExports.jsxs(Es,{isOpen:!0,onDismiss:e,heading:"Start new pipeline run",onSubmit:r,submitLabel:"Run",initialValues:o,children:[h.jsxRuntimeExports.jsx(He,{name:"spec.pipeline.name",label:"Pipeline to run",readOnly:!0}),h.jsxRuntimeExports.jsx(Jd,{name:`metadata.labels.${lf}`,label:"Which environment do you want to use?",required:!0,options:[{value:"development",label:"Development"},{value:"production",label:"Production"}]}),h.jsxRuntimeExports.jsx(mo,{name:"spec.description",label:"Description",placeholder:"Enter a description for this run…",description:"Optional. Helps identify this run in the pipeline run list."}),h.jsxRuntimeExports.jsx(zS,{pipelineName:n}),h.jsxRuntimeExports.jsxs(Yi,{title:"Set Up Notifications (Optional)",children:[h.jsxRuntimeExports.jsx(fo,{name:"notifyOnCompletion",checkboxLabel:"Do you want to receive notifications when pipeline run completed?",toggle:!0}),h.jsxRuntimeExports.jsx(fb,{name:"notifyOnCompletion",subscription:{value:!0},children:({input:a})=>a.value?h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[h.jsxRuntimeExports.jsx(He,{name:"notificationEmails",label:"Emails",multi:!0,validate:MS,placeholder:"e.g., name@example.com"}),h.jsxRuntimeExports.jsx(He,{name:"notificationSlackDestinations",label:"Slack Channels or Users",multi:!0,placeholder:"e.g., #channel or @user"})]}):null})]})]})};function WS(i,e){var o,l,a,u;const t=(a=(l=(o=i.spec)==null?void 0:o.resume)==null?void 0:l.pipelineRun)==null?void 0:a.name,{resume:n,...s}=i.spec;if(!t)return{...i,spec:s};const r=((u=i.spec.resume)==null?void 0:u.resumeFrom)??[];return{...i,spec:{...s,resume:{pipelineRun:{name:t,namespace:e},...r.length>0&&{resumeFrom:r}}}}}function qS(i){const e=r=>(r==null?void 0:r.filter(o=>o.trim()!==""))??[],t=e(i.notificationEmails),n=e(i.notificationSlackDestinations),s=[];return t.length>0&&s.push({notificationType:Fl.EMAIL,eventTypes:lc,resourceType:Bl.PIPELINE_RUN,emails:t,slackDestinations:[]}),n.length>0&&s.push({notificationType:Fl.SLACK,eventTypes:lc,resourceType:Bl.PIPELINE_RUN,emails:[],slackDestinations:n}),s}const nu={id:"status.state",label:"State",type:h.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:h.CellType.TEXT},{id:"spec.revision.name",type:h.CellType.DESCRIPTION}]},KS=[{unit:"day",seconds:86400},{unit:"hour",seconds:3600},{unit:"minute",seconds:60}],vf=i=>{var t;const e=i==null?void 0:i.triggerType;switch(e==null?void 0:e.case){case"cronSchedule":return e.value.cron?`cron ${e.value.cron}`:"";case"intervalSchedule":return YS((t=e.value.interval)==null?void 0:t.seconds);case"batchRerun":return"batch rerun";default:return""}};function YS(i){const e=Number(i??0);if(!Number.isFinite(e)||e<=0)return"";for(const{unit:t,seconds:n}of KS)if(e%n===0){const s=e/n;return s===1?`every ${t}`:`every ${s} ${t}s`}return`every ${e} seconds`}const XS={type:"detail",metadata:[{id:"metadata.creationTimestamp.seconds",label:"Created",type:h.CellType.DATE},{id:"spec.owner.name",label:"Owner",type:h.CellType.TEXT},bf,{id:"spec.commit.branch",label:"Branch",type:h.CellType.TEXT},yf],pages:[{id:"runs",label:"Runs",type:"table",queryConfig:{endpoint:"list",service:"pipelineRun",serviceOptions:{listOptionsExt:{operation:{criterion:[{fieldName:xf,operator:gf,matchValue:"${page.metadata.name}"}]}}}},tableConfig:{columns:[{id:"metadata.name",label:"Name",url:"/${studio.projectId}/${studio.phase}/runs/${row.metadata.name}"},...iu]}},{id:"triggers",label:"Triggers",type:"table",queryConfig:{endpoint:"list",service:"triggerRun",serviceOptions:{listOptions:{fieldSelector:"pipeline_name=${page.metadata.name}"}}},tableConfig:{columns:[{id:"metadata.name",label:"Name",url:"/${studio.projectId}/${studio.phase}/triggers/${row.metadata.name}"},{id:"metadata.creationTimestamp.seconds",label:"Created",type:h.CellType.DATE},{id:"spec.actor.name",label:"Started by",type:h.CellType.TEXT},{id:"schedule",label:"Schedule",type:h.CellType.TEXT,accessor:i=>{var e;return vf((e=i.spec)==null?void 0:e.trigger)}},nu]}}]},QS=[{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:h.CellType.DATE},bf,{id:"spec.commit.branch",label:"Branch",type:h.CellType.TEXT},yf],JS={type:"list",tableConfig:{columns:QS}};function ZS({triggerMap:i}){const{input:e}=ke("sourceTriggerName"),{input:t}=ke("isBackfill"),{input:n}=ke("startTimestamp"),{input:s}=ke("endTimestamp"),r=i[e.value],o=!!t.value,l=Object.keys((r==null?void 0:r.parametersMap)??{}).map(a=>({id:a,label:a}));return h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[h.jsxRuntimeExports.jsx(Qa,{name:"autoFlip",label:"Automatically switch to the latest revision once changes are applied? (Coming soon)",caption:"Coming soon — not yet available.",options:[{value:!0,label:"Yes"},{value:!1,label:"No"}],initialValue:!1,disabled:!0}),h.jsxRuntimeExports.jsx(fo,{name:"isBackfill",checkboxLabel:"Is this a backfill run?",toggle:!0}),o?h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[h.jsxRuntimeExports.jsx(Tr,{name:"startTimestamp",label:"Execution start date & time",dateFormat:bi.EPOCH_SECONDS,noFutureDate:!0,required:!0,validate:a=>s.value&&Number(a)>Number(s.value)?"Start date & time must be before end date & time.":void 0}),h.jsxRuntimeExports.jsx(Tr,{name:"endTimestamp",label:"Execution end date & time",dateFormat:bi.EPOCH_SECONDS,noFutureDate:!0,required:!0,validate:a=>n.value&&Number(a)<Number(n.value)?"End date & time must be after start date & time.":void 0}),h.jsxRuntimeExports.jsx(wt,{name:"selectedParams",label:"Parameter IDs",multi:!0,options:l,caption:"Selecting no parameters runs every parameter."}),h.jsxRuntimeExports.jsx(Xa,{name:"maxConcurrencyOverride",label:"Max concurrency",initialValue:r==null?void 0:r.maxConcurrency,description:"Overrides the trigger's default max concurrency for this run only."})]}):null]})}const ev=({record:i,onClose:e})=>{var c,d,f,p;const{projectId:t}=h.useStudioParams("base"),n=((c=i==null?void 0:i.metadata)==null?void 0:c.name)??"",{data:s,isLoading:r}=h.useStudioQuery({queryName:"GetPipeline",serviceOptions:{name:n},clientOptions:{enabled:!!n}}),o=((p=(f=(d=s==null?void 0:s.pipeline)==null?void 0:d.spec)==null?void 0:f.manifest)==null?void 0:p.triggerMap)??{},l=Object.keys(o).sort().map(m=>{const g=vf(o[m]);return{id:m,label:g?`${m} — ${g}`:m}}),a=h.useStudioMutation({mutationName:"CreateTriggerRun",successOperations:[{type:"invalidate",targets:["ListTriggerRun"]}]}),u=async m=>{if(a.isPending)return;const g=o[m.sourceTriggerName];if(!g)throw new Error(`Trigger "${m.sourceTriggerName}" is no longer defined on this pipeline. Close this dialog and try again.`);await a.mutateAsync({metadata:{name:tv(g,m.isBackfill),namespace:t},spec:{pipeline:{name:n,namespace:t},trigger:nv(g,m),sourceTriggerName:m.sourceTriggerName,autoFlip:!!m.autoFlip,...sv(m)}})};return h.jsxRuntimeExports.jsxs(Es,{isOpen:!0,onDismiss:e,heading:"Run trigger",onSubmit:u,submitLabel:"Run",children:[h.jsxRuntimeExports.jsx(He,{name:"pipelineName",label:"Pipeline",initialValue:n,readOnly:!0}),h.jsxRuntimeExports.jsx(wt,{name:"sourceTriggerName",label:"Trigger",placeholder:"Select a trigger…",options:l,isLoading:r,required:!0,caption:!r&&l.length===0?"This pipeline declares no triggers. Add one to its manifest to run it.":"The pipeline runs on the schedule this trigger defines."}),h.jsxRuntimeExports.jsx(ZS,{triggerMap:o})]})};function tv(i,e){return`${iv(i,e)}${eu({withDate:!0})}`}function iv(i,e){var t,n;return((t=i.triggerType)==null?void 0:t.case)==="batchRerun"?"batch-rerun":e?"backfill":((n=i.triggerType)==null?void 0:n.case)==="intervalSchedule"?"interval":"cron"}function nv(i,e){var n;if(!e.isBackfill)return i;const t={...i};return e.maxConcurrencyOverride!=null&&(t.maxConcurrency=e.maxConcurrencyOverride),(n=e.selectedParams)!=null&&n.length&&i.parametersMap&&(t.parametersMap=Object.fromEntries(Object.entries(i.parametersMap).filter(([s])=>{var r;return(r=e.selectedParams)==null?void 0:r.includes(s)}))),t}function sv(i){return!i.isBackfill||!i.startTimestamp||!i.endTimestamp?{}:{startTimestamp:{seconds:i.startTimestamp},endTimestamp:{seconds:i.endTimestamp}}}const rv=i=>{var t;const e=(t=i.spec)==null?void 0:t.manifest;return!!e&&Object.keys(e.triggerMap??{}).length===0},go={id:"pipelines",name:"Pipelines",service:"pipeline",state:"active",views:[JS,XS],actions:[{display:{label:"Run",icon:"playerPlay"},hierarchy:Ct.PRIMARY,modal:{type:"custom",component:US}},{display:{label:"Run trigger",icon:"calendarRepeat"},hierarchy:Ct.SECONDARY,disabled:[{condition:vt(({data:i})=>rv(i)),message:"No triggers defined for this pipeline"}],modal:{type:"custom",component:ev}},{display:{label:"Delete",icon:"trashCan"},hierarchy:Ct.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:vt(({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"},Ef={[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"}},ov={[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"}},Cf=1024;let lv=0,Yo=class{constructor(e,t){this.from=e,this.to=t}};class ie{constructor(e={}){this.id=lv++,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=nt.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}}ie.closedBy=new ie({deserialize:i=>i.split(" ")});ie.openedBy=new ie({deserialize:i=>i.split(" ")});ie.group=new ie({deserialize:i=>i.split(" ")});ie.isolate=new ie({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});ie.contextHash=new ie({perNode:!0});ie.lookAhead=new ie({perNode:!0});ie.mounted=new ie({perNode:!0});class jr{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[ie.mounted.id]}}const av=Object.create(null);class nt{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):av,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new nt(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(ie.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(ie.group),r=-1;r<(s?s.length:0);r++){let o=t[r<0?n.name:s[r]];if(o)return o}}}}nt.none=new nt("",Object.create(null),0,8);class su{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 nt(n.name,s,n.id,n.flags):n)}return new su(t)}}const Fs=new WeakMap,ac=new WeakMap;var Pe;(function(i){i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays"})(Pe||(Pe={}));class Te{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=jr.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 zl(this.topNode,e)}cursorAt(e,t=0,n=0){let s=Fs.get(this)||this.topNode,r=new zl(s);return r.moveTo(e,t),Fs.set(this,r._tree),r}get topNode(){return new pt(this,0,0,null)}resolve(e,t=0){let n=ns(Fs.get(this)||this.topNode,e,t,!1);return Fs.set(this,n),n}resolveInner(e,t=0){let n=ns(ac.get(this)||this.topNode,e,t,!0);return ac.set(this,n),n}resolveStack(e,t=0){return hv(this,e,t)}iterate(e){let{enter:t,leave:n,from:s=0,to:r=this.length}=e,o=e.mode||0,l=(o&Pe.IncludeAnonymous)>0;for(let a=this.cursor(o|Pe.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:lu(nt.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,s)=>new Te(this.type,t,n,s,this.propValues),e.makeTree||((t,n,s)=>new Te(nt.none,t,n,s)))}static build(e){return dv(e)}}Te.empty=new Te(nt.none,[],[],0);class ru{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 ru(this.buffer,this.index)}}class Ei{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return nt.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&&!(wf(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 Ei(r,o,this.set)}}function wf(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 ns(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 pt&&i.index<0?null:i.parent;if(!o)return i;i=o}let r=n?0:Pe.IgnoreOverlays;if(n)for(let o=i,l=o.parent;l;o=l,l=o.parent)o instanceof pt&&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 zl(this,e)}getChild(e,t=null,n=null){let s=uc(this,e,t,n);return s.length?s[0]:null}getChildren(e,t=null,n=null){return uc(this,e,t,n)}resolve(e,t=0){return ns(this,e,t,!1)}resolveInner(e,t=0){return ns(this,e,t,!0)}matchContext(e){return _l(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 pt 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],d=a[e]+o.from;if(wf(s,n,d,d+c.length)){if(c instanceof Ei){if(r&Pe.ExcludeBuffers)continue;let f=c.findChild(0,c.buffer.length,t,n-d,s);if(f>-1)return new mi(new uv(o,c,e,d),null,f)}else if(r&Pe.IncludeAnonymous||!c.type.isAnonymous||ou(c)){let f;if(!(r&Pe.IgnoreMounts)&&(f=jr.get(c))&&!f.overlay)return new pt(f.tree,d,e,o);let p=new pt(c,d,e,o);return r&Pe.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,n,s)}}}if(r&Pe.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&Pe.IgnoreOverlays)&&(s=jr.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 pt(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 uc(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 _l(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 uv{constructor(e,t,n,s){this.parent=e,this.buffer=t,this.index=n,this.start=s}}class mi 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 mi(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&Pe.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 mi(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 mi(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 mi(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 Te(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function kf(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 pt&&t.index<0?null:t.parent,s=i.slice();return n?s[e]=n:s.splice(e,1),new cv(s,t)}class cv{constructor(e,t){this.heads=e,this.node=t}get next(){return kf(this.heads)}}function hv(i,e,t){let n=i.resolveInner(e,t),s=null;for(let r=n instanceof pt?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=jr.get(r.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new pt(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[n])).push(ns(l,e,t,!1))}}return s?kf(s):n}class zl{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 pt)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 pt?(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&Pe.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pe.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pe.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&Pe.IncludeAnonymous||l instanceof Ei||!l.type.isAnonymous||ou(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 mi(this.buffer,t,this.stack[s]);return this.bufferNode=new mi(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 _l(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 _l(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 ou(i){return i.children.some(e=>e instanceof Ei||!e.type.isAnonymous||ou(e))}function dv(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:s=Cf,reused:r=[],minRepeatType:o=n.types.length}=i,l=Array.isArray(t)?new ru(t,t.length):t,a=n.types,u=0,c=0;function d(v,C,k,j,R,H){let{id:N,start:B,end:$,size:P}=l,L=c,W=u;if(P<0)if(l.next(),P==-1){let q=r[N];k.push(q),j.push(B-v);return}else if(P==-3){u=N;return}else if(P==-4){c=N;return}else throw new RangeError(`Unrecognized record size: ${P}`);let ee=a[N],ae,ne,te=B-v;if($-B<=s&&(ne=x(l.pos-C,R))){let q=new Uint16Array(ne.size-ne.skip),w=l.pos-ne.size,I=q.length;for(;l.pos>w;)I=y(ne.start,q,I);ae=new Ei(q,$-ne.start,n),te=ne.start-v}else{let q=l.pos-P;l.next();let w=[],I=[],D=N>=o?N:-1,F=0,Q=$;for(;l.pos>q;)D>=0&&l.id==D&&l.size>=0?(l.end<=Q-s&&(m(w,I,B,F,l.end,Q,D,L,W),F=w.length,Q=l.end),l.next()):H>2500?f(B,q,w,I):d(B,q,w,I,D,H+1);if(D>=0&&F>0&&F<w.length&&m(w,I,B,F,B,Q,D,L,W),w.reverse(),I.reverse(),D>-1&&F>0){let Z=p(ee,W);ae=lu(ee,w,I,0,w.length,0,$-B,Z,Z)}else ae=g(ee,w,I,$-B,L-$,W)}k.push(ae),j.push(te)}function f(v,C,k,j){let R=[],H=0,N=-1;for(;l.pos>C;){let{id:B,start:$,end:P,size:L}=l;if(L>4)l.next();else{if(N>-1&&$<N)break;N<0&&(N=P-s),R.push(B,$,P),H++,l.next()}}if(H){let B=new Uint16Array(H*4),$=R[R.length-2];for(let P=R.length-3,L=0;P>=0;P-=3)B[L++]=R[P],B[L++]=R[P+1]-$,B[L++]=R[P+2]-$,B[L++]=L;k.push(new Ei(B,R[2]-$,n)),j.push($-v)}}function p(v,C){return(k,j,R)=>{let H=0,N=k.length-1,B,$;if(N>=0&&(B=k[N])instanceof Te){if(!N&&B.type==v&&B.length==R)return B;($=B.prop(ie.lookAhead))&&(H=j[N]+B.length+$)}return g(v,k,j,R,H,C)}}function m(v,C,k,j,R,H,N,B,$){let P=[],L=[];for(;v.length>j;)P.push(v.pop()),L.push(C.pop()+k-R);v.push(g(n.types[N],P,L,H-R,B-H,$)),C.push(R-k)}function g(v,C,k,j,R,H,N){if(H){let B=[ie.contextHash,H];N=N?[B].concat(N):[B]}if(R>25){let B=[ie.lookAhead,R];N=N?[B].concat(N):[B]}return new Te(v,C,k,j,N)}function x(v,C){let k=l.fork(),j=0,R=0,H=0,N=k.end-s,B={size:0,start:0,skip:0};e:for(let $=k.pos-v;k.pos>$;){let P=k.size;if(k.id==C&&P>=0){B.size=j,B.start=R,B.skip=H,H+=4,j+=4,k.next();continue}let L=k.pos-P;if(P<0||L<$||k.start<N)break;let W=k.id>=o?4:0,ee=k.start;for(k.next();k.pos>L;){if(k.size<0)if(k.size==-3)W+=4;else break e;else k.id>=o&&(W+=4);k.next()}R=ee,j+=P,H+=W}return(C<0||j==v)&&(B.size=j,B.start=R,B.skip=H),B.size>4?B:void 0}function y(v,C,k){let{id:j,start:R,end:H,size:N}=l;if(l.next(),N>=0&&j<o){let B=k;if(N>4){let $=l.pos-(N-4);for(;l.pos>$;)k=y(v,C,k)}C[--k]=B,C[--k]=H-v,C[--k]=R-v,C[--k]=j}else N==-3?u=j:N==-4&&(c=j);return k}let b=[],S=[];for(;l.pos>0;)d(i.start||0,i.bufferStart||0,b,S,-1,0);let E=(e=i.length)!==null&&e!==void 0?e:b.length?S[0]+b[0].length:0;return new Te(a[i.topID],b.reverse(),S.reverse(),E)}const cc=new WeakMap;function ur(i,e){if(!i.isAnonymous||e instanceof Ei||e.type!=i)return 1;let t=cc.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof Te)){t=1;break}t+=ur(i,n)}cc.set(e,t)}return t}function lu(i,e,t,n,s,r,o,l,a){let u=0;for(let m=n;m<s;m++)u+=ur(i,e[m]);let c=Math.ceil(u*1.5/8),d=[],f=[];function p(m,g,x,y,b){for(let S=x;S<y;){let E=S,v=g[S],C=ur(i,m[S]);for(S++;S<y;S++){let k=ur(i,m[S]);if(C+k>=c)break;C+=k}if(S==E+1){if(C>c){let k=m[E];p(k.children,k.positions,0,k.children.length,g[E]+b);continue}d.push(m[E])}else{let k=g[S-1]+m[S-1].length-v;d.push(lu(i,m,g,E,S,v,k,null,a))}f.push(v+b-r)}}return p(e,t,n,s,0),(l||a)(d,f,o)}class _i{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 _i(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,d=c?c.fromA:1e9;if(d-a>=n)for(;o&&o.from<d;){let f=o;if(a>=f.from||d<=f.to||u){let p=Math.max(f.from,a)-u,m=Math.min(f.to,d)-u;f=p>=m?null:new _i(p,m,f.tree,f.offset+u,l>0,!!c)}if(f&&s.push(f),o.to>d)break;o=r<e.length?e[r++]:null}if(!c)break;a=c.toA,u=c.toA-c.toB}return s}}class Tf{startParse(e,t,n){return typeof e=="string"&&(e=new fv(e)),n=n?n.length?n.map(s=>new Yo(s.from,s.to)):[new Yo(0,0)]:[new Yo(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 fv{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 ie({perNode:!0});class Or{constructor(e,t,n,s,r,o,l,a,u,c=0,d){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=d}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 Or(e,[],t,n,n,0,[],0,s?new hc(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 d=a?this.stack[a-1]:0,f=this.bufferBase+this.buffer.length-d;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 Or(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 pv(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 hc(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 hc{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class pv{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 Ir{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 Ir(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 Ir(this.stack,this.pos,this.index)}}function Bs(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 cr{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const dc=new cr;class mv{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=dc,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=dc,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 fn{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;gv(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}fn.prototype.contextual=fn.prototype.fallback=fn.prototype.extend=!1;fn.prototype.fallback=fn.prototype.extend=!1;function gv(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 m=i[p];if(a.allows(m)&&(e.token.value==-1||e.token.value==m||xv(m,e.token.value,s,r))){e.acceptToken(m);break}}let c=e.next,d=0,f=i[o+2];if(e.next<0&&f>d&&i[u+f*3-3]==65535){o=i[u+f*3-1];continue e}for(;d<f;){let p=d+f>>1,m=u+p+(p<<1),g=i[m],x=i[m+1]||65536;if(c<g)f=p;else if(c>=x)d=p+1;else{o=i[m+2],e.advance();continue e}}break}}function fc(i,e,t){for(let n=e,s;(s=i[n])!=65535;n++)if(s==t)return n-e;return-1}function xv(i,e,t,n){let s=fc(t,n,e);return s<0||fc(t,n,i)<s}const st=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG);let Xo=null;function pc(i,e,t){let n=i.cursor(Pe.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 yv{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?pc(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?pc(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 Te){if(o==e){if(o<this.safeFrom)return null;let l=o+r.length;if(l<=this.safeTo){let a=r.prop(ie.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 bv{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new cr)}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],d=this.tokens[u];if(!(n&&!c.fallback)&&((c.contextual||d.start!=e.pos||d.mask!=o||d.context!=l)&&(this.updateCachedToken(d,c,e),d.mask=o,d.context=l),d.lookAhead>d.end+25&&(a=Math.max(d.lookAhead,a)),d.value!=0)){let f=t;if(d.extended>-1&&(t=this.addActions(e,d.extended,d.end,t)),t=this.addActions(e,d.value,d.end,t),!c.extend&&(n=d,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!n&&e.pos==this.stream.end&&(n=new cr,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 cr,{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=Jt(l,u+2);else{s==0&&l[u+1]==2&&(s=this.putAction(Jt(l,u+2),t,n,s));break}l[u]==t&&(s=this.putAction(Jt(l,u+1),t,n,s))}return s}}class Sv{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 mv(t,s),this.tokens=new bv(e,this.stream),this.topTerm=e.top[1];let{from:r}=s[0];this.stacks=[Or.start(this,e.top[0],r)],this.fragments=n.length&&this.stream.end-r>e.bufferLength*4?new yv(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&&Ev(s);if(o)return st&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw st&&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 st&&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=st?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 d=this.fragments.nodeAt(s);d;){let f=this.parser.nodeSet.types[d.type.id]==d.type?r.getGoto(e.state,d.type.id):-1;if(f>-1&&d.length&&(!u||(d.prop(ie.contextHash)||0)==c))return e.useNode(d,f),st&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(d.type.id)})`),!0;if(!(d instanceof Te)||d.children.length==0||d.positions[0]>0)break;let p=d.children[0];if(p instanceof Te&&d.positions[0]==0)d=p;else break}}let l=r.stateSlot(e.state,4);if(l>0)return e.reduce(l),st&&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++],d=a[u++],f=a[u++],p=u==a.length||!n,m=p?e:e.split(),g=this.tokens.mainToken;if(m.apply(c,d,g?g.start:m.pos,f),st&&console.log(o+this.stackID(m)+` (via ${(c&65536)==0?"shift":`reduce of ${r.getName(c&65535)}`} for ${r.getName(d)} @ ${s}${m==e?"":", split"})`),p)return!0;m.pos>s?t.push(m):n.push(m)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return mc(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=st?this.stackID(l)+" -> ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),st&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,n))))continue;let d=l.split(),f=c;for(let p=0;p<10&&d.forceReduce()&&(st&&console.log(f+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,n));p++)st&&(f=this.stackID(d)+" -> ");for(let p of l.recoverByInsert(a))st&&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),st&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),mc(l,n)):(!s||s.score<l.score)&&(s=l)}return s}stackToTree(e){return e.close(),Te.build({buffer:Ir.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=(Xo||(Xo=new WeakMap)).get(e);return t||Xo.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function mc(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 vv{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}}class Mr extends Tf{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=ie[a]);for(let u=1;u<l.length;){let c=l[u++];if(c>=0)r(c,a,l[u++]);else{let d=l[u+-c];for(let f=-c;f>0;f--)r(l[u++],a,d);u++}}}this.nodeSet=new su(t.map((l,a)=>nt.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=Cf;let o=Bs(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(gc),this.states=Bs(e.states,Uint32Array),this.data=Bs(e.stateData),this.goto=Bs(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new fn(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 Sv(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=Jt(n,r+2)];else{if(n[r+1]==2)return Jt(n,r+2);break}if(o==t||o==0)return Jt(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=Jt(this.data,r+2);else break;s=t(Jt(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=Jt(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(Mr.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]=gc(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 vv(e,n,s)}static deserialize(e){return new Mr(e)}}function Jt(i,e){return i[e]|i[e+1]<<16}function Ev(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 gc(i){if(i.external){let e=i.extend?1:0;return(t,n)=>i.external(t,n)<<1|e}return i.get}let Cv=0;class ht{constructor(e,t,n,s){this.name=e,this.set=t,this.base=n,this.modified=s,this.id=Cv++}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 ht&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let s=new ht(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 Pr(e);return n=>n.modified.indexOf(t)>-1?n:Pr.get(n.base||n,n.modified.concat(t).sort((s,r)=>s.id-r.id))}}let wv=0;class Pr{constructor(e){this.name=e,this.instances=[],this.id=wv++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(l=>l.base==e&&Rv(t,l.modified));if(n)return n;let s=[],r=new ht(e.name,s,e,t);for(let l of t)l.instances.push(r);let o=kv(t);for(let l of e.set)if(!l.modified.length)for(let a of o)s.push(Pr.get(l,a));return r}}function Rv(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function kv(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 d=0;;){if(l=="..."&&d>0&&d+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]),d+=f[0].length,d==s.length)break;let p=s[d++];if(d==s.length&&p=="!"){o=0;break}if(p!="/")throw new RangeError("Invalid path: "+s);l=s.slice(d)}let a=r.length-1,u=r[a];if(!u)throw new RangeError("Invalid path: "+s);let c=new ss(n,o,a>0?r.slice(0,a):null);e[u]=c.sort(e[u])}}return jf.add(e)}const jf=new ie({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 ss(s.tags,s.mode,s.context);t?t.next=r:n=r,t=r}return n}});class ss{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}}ss.empty=new ss([],2,null);function Of(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 Tv(i,e){let t=null;for(let n of i){let s=n.style(e);s&&(t=t?t+" "+s:s)}return t}function Av(i,e,t,n=0,s=i.length){let r=new jv(n,Array.isArray(e)?e:[e],t);r.highlightRange(i.cursor(),n,s,"",r.highlighters),r.flush(s)}class jv{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=Ov(e)||ss.empty,d=Tv(r,c.tags);if(d&&(u&&(u+=" "),u+=d,c.mode==1&&(s+=(s?" ":"")+d)),this.startSpan(Math.max(t,l),u),c.opaque)return;let f=e.tree&&e.tree.prop(ie.mounted);if(f&&f.overlay){let p=e.node.enter(f.overlay[0].from+l,1),m=this.highlighters.filter(x=>!x.scope||x.scope(f.tree.type)),g=e.firstChild();for(let x=0,y=l;;x++){let b=x<f.overlay.length?f.overlay[x]:null,S=b?b.from+l:a,E=Math.max(t,y),v=Math.min(n,S);if(E<v&&g)for(;e.from<v&&(this.highlightRange(e,E,v,s,r),this.startSpan(Math.min(v,e.to),u),!(e.to>=S||!e.nextSibling())););if(!b||S>n)break;y=b.to+l,y>t&&(this.highlightRange(p.cursor(),Math.max(t,b.from+l),Math.min(n,y),"",m),this.startSpan(Math.min(n,y),u))}g&&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 Ov(i){let e=i.type.prop(jf);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}const V=ht.define,Vs=V(),hi=V(),xc=V(hi),yc=V(hi),di=V(),_s=V(di),Qo=V(di),Dt=V(),Ii=V(Dt),Ot=V(),It=V(),$l=V(),Ln=V($l),zs=V(),T={comment:Vs,lineComment:V(Vs),blockComment:V(Vs),docComment:V(Vs),name:hi,variableName:V(hi),typeName:xc,tagName:V(xc),propertyName:yc,attributeName:V(yc),className:V(hi),labelName:V(hi),namespace:V(hi),macroName:V(hi),literal:di,string:_s,docString:V(_s),character:V(_s),attributeValue:V(_s),number:Qo,integer:V(Qo),float:V(Qo),bool:V(di),regexp:V(di),escape:V(di),color:V(di),url:V(di),keyword:Ot,self:V(Ot),null:V(Ot),atom:V(Ot),unit:V(Ot),modifier:V(Ot),operatorKeyword:V(Ot),controlKeyword:V(Ot),definitionKeyword:V(Ot),moduleKeyword:V(Ot),operator:It,derefOperator:V(It),arithmeticOperator:V(It),logicOperator:V(It),bitwiseOperator:V(It),compareOperator:V(It),updateOperator:V(It),definitionOperator:V(It),typeOperator:V(It),controlOperator:V(It),punctuation:$l,separator:V($l),bracket:Ln,angleBracket:V(Ln),squareBracket:V(Ln),paren:V(Ln),brace:V(Ln),content:Dt,heading:Ii,heading1:V(Ii),heading2:V(Ii),heading3:V(Ii),heading4:V(Ii),heading5:V(Ii),heading6:V(Ii),contentSeparator:V(Dt),list:V(Dt),quote:V(Dt),emphasis:V(Dt),strong:V(Dt),link:V(Dt),monospace:V(Dt),strikethrough:V(Dt),inserted:V(),deleted:V(),changed:V(),invalid:V(),meta:zs,documentMeta:V(zs),annotation:V(zs),processingInstruction:V(zs),definition:ht.defineModifier("definition"),constant:ht.defineModifier("constant"),function:ht.defineModifier("function"),standard:ht.defineModifier("standard"),local:ht.defineModifier("local"),special:ht.defineModifier("special")};for(let i in T){let e=T[i];e instanceof ht&&(e.name=i)}Of([{tag:T.link,class:"tok-link"},{tag:T.heading,class:"tok-heading"},{tag:T.emphasis,class:"tok-emphasis"},{tag:T.strong,class:"tok-strong"},{tag:T.keyword,class:"tok-keyword"},{tag:T.atom,class:"tok-atom"},{tag:T.bool,class:"tok-bool"},{tag:T.url,class:"tok-url"},{tag:T.labelName,class:"tok-labelName"},{tag:T.inserted,class:"tok-inserted"},{tag:T.deleted,class:"tok-deleted"},{tag:T.literal,class:"tok-literal"},{tag:T.string,class:"tok-string"},{tag:T.number,class:"tok-number"},{tag:[T.regexp,T.escape,T.special(T.string)],class:"tok-string2"},{tag:T.variableName,class:"tok-variableName"},{tag:T.local(T.variableName),class:"tok-variableName tok-local"},{tag:T.definition(T.variableName),class:"tok-variableName tok-definition"},{tag:T.special(T.variableName),class:"tok-variableName2"},{tag:T.definition(T.propertyName),class:"tok-propertyName tok-definition"},{tag:T.typeName,class:"tok-typeName"},{tag:T.namespace,class:"tok-namespace"},{tag:T.className,class:"tok-className"},{tag:T.macroName,class:"tok-macroName"},{tag:T.propertyName,class:"tok-propertyName"},{tag:T.operator,class:"tok-operator"},{tag:T.comment,class:"tok-comment"},{tag:T.meta,class:"tok-meta"},{tag:T.invalid,class:"tok-invalid"},{tag:T.punctuation,class:"tok-punctuation"}]);const Iv=Af({String:T.string,Number:T.number,"True False":T.bool,PropertyName:T.propertyName,Null:T.null,", :":T.separator,"[ ]":T.squareBracket,"{ }":T.brace}),Mv=Mr.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:[Iv],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=[],If=[];(()=>{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?If:Hl).push(t=t+i[e])})();function Pv(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>=If[n])e=n+1;else return!0;if(e==t)return!1}}function bc(i){return i>=127462&&i<=127487}const Sc=8205;function Dv(i,e,t=!0,n=!0){return(t?Mf:Lv)(i,e,n)}function Mf(i,e,t){if(e==i.length)return e;e&&Pf(i.charCodeAt(e))&&Df(i.charCodeAt(e-1))&&e--;let n=Jo(i,e);for(e+=vc(n);e<i.length;){let s=Jo(i,e);if(n==Sc||s==Sc||t&&Pv(s))e+=vc(s),n=s;else if(bc(s)){let r=0,o=e-2;for(;o>=0&&bc(Jo(i,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function Lv(i,e,t){for(;e>0;){let n=Mf(i,e-2,t);if(n<e)return n;e--}return 0}function Jo(i,e){let t=i.charCodeAt(e);if(!Df(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return Pf(n)?(t-55296<<10)+(n-56320)+65536:t}function Pf(i){return i>=56320&&i<57344}function Df(i){return i>=55296&&i<56320}function vc(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]=vn(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),Nt.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]=vn(this,e,t);let n=[];return this.decompose(e,t,n,0),Nt.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 qn(this),r=new qn(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 qn(this,e)}iterRange(e,t=this.length){return new Lf(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 Nf(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 Ee(e):Nt.from(Ee.split(e,[]))}}class Ee extends oe{constructor(e,t=Nv(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 Fv(s,l,n,o);s=l+1,n++}}decompose(e,t,n,s){let r=e<=0&&t>=this.length?this:new Ee(Ec(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=n.pop(),l=hr(r.text,o.text.slice(),0,r.length);if(l.length<=32)n.push(new Ee(l,o.length+r.length));else{let a=l.length>>1;n.push(new Ee(l.slice(0,a)),new Ee(l.slice(a)))}}else n.push(r)}replace(e,t,n){if(!(n instanceof Ee))return super.replace(e,t,n);[e,t]=vn(this,e,t);let s=hr(this.text,hr(n.text,Ec(this.text,0,e)),t),r=this.length+n.length-(t-e);return s.length<=32?new Ee(s,r):Nt.from(Ee.split(s,[]),r)}sliceString(e,t=this.length,n=`
|
|
24
|
-
`){[e,t]=
|
|
25
|
-
`){[e,t]=
|
|
26
|
-
`,this;e--}else if(s instanceof Ee){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 Ee?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 Lf{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new qn(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 Nf{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()},qn.prototype[Symbol.iterator]=Lf.prototype[Symbol.iterator]=Nf.prototype[Symbol.iterator]=function(){return this});class Fv{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 vn(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 Dv(i,e,t,n)}function Bv(i){return i>=56320&&i<57344}function Vv(i){return i>=55296&&i<56320}function Je(i,e){let t=i.charCodeAt(e);if(!Vv(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return Bv(n)?(t-55296<<10)+(n-56320)+65536:t}function au(i){return i<=65535?String.fromCharCode(i):(i-=65536,String.fromCharCode((i>>10)+55296,(i&1023)+56320))}function Ft(i){return i<65536?1:2}const Gl=/\r\n?|\n/;var Ke=(function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i})(Ke||(Ke={}));class $t{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){Ul(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 $t(e)}composeDesc(e){return this.empty?e:e.empty?this:Ff(this,e)}mapDesc(e,t=!1){return e.empty?this:Wl(this,e,t)}mapPos(e,t=-1,n=Ke.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!=Ke.Simple&&u>=e&&(n==Ke.TrackDel&&s<e&&u>e||n==Ke.TrackBefore&&s<e||n==Ke.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 $t(e)}static create(e){return new $t(e)}}class je extends $t{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 Ul(this,(t,n,s,r,o)=>e=e.replace(s,s+(n-t),o),!1),e}mapDesc(e,t=!1){return Wl(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 je(t,n)}compose(e){return this.empty?e:e.empty?this:Ff(this,e,!0)}map(e,t=!1){return e.empty?this:Wl(this,e,t,!0)}iterChanges(e,t=!1){Ul(this,e,t)}get desc(){return $t.create(this.sections)}filter(e){let t=[],n=[],s=[],r=new rs(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 d=r.ins==-1?-1:r.off==0?r.ins:0;ze(t,c,d),d>0&&gi(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 je(t,n),filtered:$t.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 d=new je(s,r);l=l?l.compose(d.map(l)):d,s=[],r=[],o=0}function u(c){if(Array.isArray(c))for(let d of c)u(d);else if(c instanceof je){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:d,to:f=d,insert:p}=c;if(d>f||d<0||f>t)throw new RangeError(`Invalid change range ${d} to ${f} (in doc of length ${t})`);let m=p?typeof p=="string"?oe.of(p.split(n||Gl)):p:oe.empty,g=m.length;if(d==f&&g==0)return;d<o&&a(),d>o&&ze(s,d-o,-1),ze(s,f-d,g),gi(r,s,m),o=f}}return u(e),a(!l),l}static empty(e){return new je(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 je(t,n)}static createSet(e,t){return new je(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 gi(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 Ul(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,d=oe.empty;for(;u+=l,c+=a,a&&n&&(d=d.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,d),s=u,r=c}}}function Wl(i,e,t,n=!1){let s=[],r=n?[]:null,o=new rs(i),l=new rs(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&&gi(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 d=Math.min(c,l.len);u+=d,c-=d,l.forward(d)}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&&gi(r,s,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?je.createSet(s,r):$t.create(s);throw new Error("Mismatched change set lengths")}}}function Ff(i,e,t=!1){let n=[],s=t?[]:null,r=new rs(i),o=new rs(e);for(let l=!1;;){if(r.done&&o.done)return s?je.createSet(n,s):$t.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&&gi(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&&gi(s,n,o.text)}else o.ins==-1?(ze(n,r.off?0:r.len,a,l),s&&gi(s,n,r.textBit(a))):(ze(n,r.off?0:r.len,o.off?0:o.ins,l),s&&!o.off&&gi(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 rs{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 Ni{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 Ni(n,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return O.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return O.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 O.range(e.anchor,e.head)}static create(e,t,n){return new Ni(e,t,n)}}class O{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:O.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 O([this.main],0)}addRange(e,t=!0){return O.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,O.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 O(e.ranges.map(t=>Ni.fromJSON(t)),e.main)}static single(e,t=e){return new O([O.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 O.normalized(e.slice(),t);n=r.to}return new O(e,t)}static cursor(e,t=0,n,s){return Ni.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?Ni.create(t,e,48|r):Ni.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?O.range(a,l):O.range(l,a))}}return new O(e,t)}}function Bf(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let uu=0;class G{constructor(e,t,n,s,r){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=s,this.id=uu++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new G(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:cu),!!e.static,e.enables)}of(e){return new dr([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new dr(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new dr(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}}function cu(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}class dr{constructor(e,t,n,s){this.dependencies=e,this.facet=t,this.type=n,this.value=s,this.id=uu++}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 d of this.dependencies)d=="doc"?a=!0:d=="selection"?u=!0:(((t=e[d.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[d.id]);return{create(d){return d.values[o]=n(d),1},update(d,f){if(a&&f.docChanged||u&&(f.docChanged||f.selection)||ql(d,c)){let p=n(d);if(l?!Cc(p,d.values[o],s):!s(p,d.values[o]))return d.values[o]=p,1}return 0},reconfigure:(d,f)=>{let p,m=f.config.address[r];if(m!=null){let g=Lr(f,m);if(this.dependencies.every(x=>x instanceof G?f.facet(x)===d.facet(x):x instanceof Be?f.field(x,!1)==d.field(x,!1):!0)||(l?Cc(p=n(d),g,s):s(p=n(d),g)))return d.values[o]=g,0}else p=n(d);return d.values[o]=p,1}}}}function Cc(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 ql(i,e){let t=!1;for(let n of e)Kn(i,n)&1&&(t=!0);return t}function _v(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 d=Lr(a,n[c]);if(s[c]==2)for(let f of d)u.push(f);else u.push(d)}return e.combine(u)}return{create(a){for(let u of n)Kn(a,u);return a.values[o]=l(a),1},update(a,u){if(!ql(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=ql(a,n),d=u.config.facets[e.id],f=u.facet(e);if(d&&!c&&cu(t,d))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 $s=G.define({static:!0});class Be{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 Be(uu++,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($s).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($s),o=s.facet($s),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,$s.of({field:this,create:e})]}get extension(){return this}}const Pi={lowest:4,low:3,default:2,high:1,highest:0};function Nn(i){return e=>new Vf(e,i)}const Xi={highest:Nn(Pi.highest),high:Nn(Pi.high),default:Nn(Pi.default),low:Nn(Pi.low),lowest:Nn(Pi.lowest)};class Vf{constructor(e,t){this.inner=e,this.prec=t}}class xo{of(e){return new Kl(this,e)}reconfigure(e){return xo.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Kl{constructor(e,t){this.compartment=e,this.inner=t}}class Dr{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 zv(e,t,o))f instanceof Be?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],m=p[0].facet,g=c&&c[f]||[];if(p.every(x=>x.type==0))if(l[m.id]=a.length<<1|1,cu(g,p))a.push(n.facet(m));else{let x=m.combine(p.map(y=>y.value));a.push(n&&m.compare(x,n.facet(m))?n.facet(m):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[m.id]=u.length<<1,u.push(x=>_v(x,m,p))}}let d=u.map(f=>f(l));return new Dr(e,o,d,l,a,r)}}function zv(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 Kl&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let u of o)r(u,l);else if(o instanceof Kl){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 Vf)r(o.inner,o.prec);else if(o instanceof Be)n[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof dr)n[l].push(o),o.facet.extensions&&r(o.facet.extensions,Pi.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,Pi.default),n.reduce((o,l)=>o.concat(l))}function Kn(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 Lr(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}const _f=G.define(),Yl=G.define({combine:i=>i.some(e=>e),static:!0}),zf=G.define({combine:i=>i.length?i[0]:void 0,static:!0}),$f=G.define(),Hf=G.define(),Gf=G.define(),Uf=G.define({combine:i=>i.length?i[0]:!1});class qt{constructor(e,t){this.type=e,this.value=t}static define(){return new $v}}class $v{of(e){return new qt(this,e)}}class Hv{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 Hv(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 Oe{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&&Bf(n,t.newLength),r.some(l=>l.type==Oe.time)||(this.annotations=r.concat(Oe.time.of(Date.now())))}static create(e,t,n,s,r,o){return new Oe(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(Oe.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Oe.time=qt.define();Oe.userEvent=qt.define();Oe.addToHistory=qt.define();Oe.remote=qt.define();function Gv(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 Wf(i,e,t){var n;let s,r,o;return t?(s=e.changes,r=je.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 Xl(i,e,t){let n=e.selection,s=pn(e.annotations);return e.userEvent&&(s=s.concat(Oe.userEvent.of(e.userEvent))),{changes:e.changes instanceof je?e.changes:je.of(e.changes||[],t,i.facet(zf)),selection:n&&(n instanceof O?n:O.single(n.anchor,n.head)),effects:pn(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function qf(i,e,t){let n=Xl(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=Wf(n,Xl(i,e[r],o?n.changes.newLength:i.doc.length),o)}let s=Oe.create(i,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return Wv(t?Uv(s):s)}function Uv(i){let e=i.startState,t=!0;for(let s of e.facet($f)){let r=s(i);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:Gv(t,r))}if(t!==!0){let s,r;if(t===!1)r=i.changes.invertedDesc,s=je.empty(e.doc.length);else{let o=i.changes.filter(t);s=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}i=Oe.create(e,s,i.selection&&i.selection.map(r),J.mapEffects(i.effects,r),i.annotations,i.scrollIntoView)}let n=e.facet(Hf);for(let s=n.length-1;s>=0;s--){let r=n[s](i);r instanceof Oe?i=r:Array.isArray(r)&&r.length==1&&r[0]instanceof Oe?i=r[0]:i=qf(e,pn(r),!1)}return i}function Wv(i){let e=i.startState,t=e.facet(Gf),n=i;for(let s=t.length-1;s>=0;s--){let r=t[s](i);r&&Object.keys(r).length&&(n=Wf(n,Xl(e,r,i.changes.newLength),!0))}return n==i?i:Oe.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}const qv=[];function pn(i){return i==null?qv:Array.isArray(i)?i:[i]}var Se=(function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i})(Se||(Se={}));const Kv=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Ql;try{Ql=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Yv(i){if(Ql)return Ql.test(i);for(let e=0;e<i.length;e++){let t=i[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||Kv.test(t)))return!0}return!1}function Xv(i){return e=>{if(!/\S/.test(e))return Se.Space;if(Yv(e))return Se.Word;for(let t=0;t<i.length;t++)if(e.indexOf(i[t])>-1)return Se.Word;return Se.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++)Kn(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 Kn(this,n),Lr(this,n)}update(...e){return qf(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:s}=t;for(let l of e.effects)l.is(xo.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=pn(n).concat(l.value));let r;t?r=e.startState.values.slice():(t=Dr.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(Yl)?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:O.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=pn(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 d=s.mapDesc(u,!0);r.push(a.range.map(d)),s=s.compose(c),o=J.mapEffects(o,c).concat(J.mapEffects(pn(a.effects),d))}return{changes:s,selection:O.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof je?e:je.of(e,this.doc.length,this.facet(se.lineSeparator))}toText(e){return oe.of(e.split(this.facet(se.lineSeparator)||Gl))}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:(Kn(this,t),Lr(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 Be&&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:O.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=Dr.resolve(e.extensions||[],new Map),n=e.doc instanceof oe?e.doc:oe.of((e.doc||"").split(t.staticFacet(se.lineSeparator)||Gl)),s=e.selection?e.selection instanceof O?e.selection:O.single(e.selection.anchor,e.selection.head):O.single(0);return Bf(s,n.length),t.staticFacet(Yl)||(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(Uf)}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(_f))for(let o of r(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){return Xv(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))!=Se.Word)break;o=a}for(;l<s;){let a=Fe(t,l);if(r(t.slice(l,a))!=Se.Word)break;l=a}return o==l?null:O.range(o+n,l+n)}}se.allowMultipleSelections=Yl;se.tabSize=G.define({combine:i=>i.length?i[0]:4});se.lineSeparator=zf;se.readOnly=Uf;se.phrases=G.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=_f;se.changeFilter=$f;se.transactionFilter=Hf;se.transactionExtender=Gf;xo.reconfigure=J.define();function Kt(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 Hi{eq(e){return this==e}range(e,t=e){return os.create(e,t,this)}}Hi.prototype.startSide=Hi.prototype.endSide=0;Hi.prototype.point=!1;Hi.prototype.mapMode=Ke.TrackDel;class os{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new os(e,t,n)}}function Jl(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}class hu{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,d=this.to[a]+e,f,p;if(c==d){let m=t.mapPos(c,u.startSide,u.mapMode);if(m==null||(f=p=m,u.startSide!=u.endSide&&(p=t.mapPos(c,u.endSide),p<f)))continue}else if(f=t.mapPos(c,u.startSide),p=t.mapPos(d,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 hu(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 Kf(this,null,-1).goto(0),a=0,u=[],c=new ni;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let d=t[a++];c.addInner(d.from,d.to,d.value)||u.push(d)}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(os.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:d}=a.map(l,e);c&&(s=Math.max(s,c.maxPoint),t.push(c),n.push(d))}}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 ls.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return ls.from(e).goto(t)}static compare(e,t,n,s,r=-1){let o=e.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=r),l=t.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=r),a=wc(o,l,n),u=new Fn(o,a,r),c=new Fn(l,a,r);n.iterGaps((d,f,p)=>Rc(u,d,c,f,p,s)),n.empty&&n.length==0&&Rc(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=wc(r,o),a=new Fn(r,l,0).goto(n),u=new Fn(o,l,0).goto(n);for(;;){if(a.to!=u.to||!Zl(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 Fn(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),d=o.pointFrom<t?c.length+1:o.point.startSide<0?c.length:Math.min(c.length,a);s.point(l,u,o.point,c,d,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 ni;for(let s of e instanceof os?[e]:t?Qv(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 Qv(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 ni{finishChunk(e){this.chunks.push(new hu(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 ni)).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 wc(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 Kf{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 ls{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 Kf(o,t,n,r));return s.length==1?s[0]:new ls(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--)Zo(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--)Zo(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(),Zo(this.heap,0)}}}function Zo(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 Fn{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=ls.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){Hs(this.active,e),Hs(this.activeTo,e),Hs(this.activeRank,e),this.minActive=kc(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++;Gs(this.active,t,n),Gs(this.activeTo,t,s),Gs(this.activeRank,t,r),e&&Gs(e,t,this.cursor.from),this.minActive=kc(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&&Hs(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 Rc(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,d=c<0?i.to+a:t.to,f=Math.min(d,o);if(i.point||t.point?i.point&&t.point&&(i.point==t.point||i.point.eq(t.point))&&Zl(i.activeForPoint(i.to),t.activeForPoint(t.to))||r.comparePoint(l,f,i.point,t.point):f>l&&!Zl(i.active,t.active)&&r.compareRange(l,f,i.active,t.active),d>o)break;(u||i.openEnd!=t.openEnd)&&r.boundChange&&r.boundChange(d),l=d,c<=0&&i.next(),c>=0&&t.next()}}function Zl(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 Hs(i,e){for(let t=e,n=i.length-1;t<n;t++)i[t]=i[t+1];i.pop()}function Gs(i,e,t){for(let n=i.length-1;n>=e;n--)i[n+1]=i[n];i[e]=t}function kc(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 jn(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 ea(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 ta="ͼ",Tc=typeof Symbol>"u"?"__"+ta:Symbol.for(ta),ia=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Ac=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Ci{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=[],d=/^@(\w+)\b/.exec(o[0]),f=d&&d[1]=="keyframes";if(d&&l==null)return a.push(o[0]+";");for(let p in l){let m=l[p];if(/&/.test(p))r(p.split(/,\s*/).map(g=>o.map(x=>g.replace(/&/,x))).reduce((g,x)=>g.concat(x)),m,a);else if(m&&typeof m=="object"){if(!d)throw new RangeError("The value of a property ("+p+") should be a primitive value.");r(s(p),m,c,f)}else m!=null&&c.push(p.replace(/_.*/,"").replace(/[A-Z]/g,g=>"-"+g.toLowerCase())+": "+m+";")}(c.length||f)&&a.push((n&&!d&&!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=
|
|
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 wi={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:"'"},as={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Zv=typeof navigator<"u"&&/Mac/.test(navigator.platform),eE=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ne=0;Ne<10;Ne++)wi[48+Ne]=wi[96+Ne]=String(Ne);for(var Ne=1;Ne<=24;Ne++)wi[Ne+111]="F"+Ne;for(var Ne=65;Ne<=90;Ne++)wi[Ne]=String.fromCharCode(Ne+32),as[Ne]=String.fromCharCode(Ne);for(var el in wi)as.hasOwnProperty(el)||(as[el]=wi[el]);function tE(i){var e=Zv&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||eE&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?as:wi)[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++)Yf(i,arguments[e]);return i}function Yf(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++)Yf(i,e[t]);else throw new RangeError("Unsupported child node: "+e)}let qe=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},na=typeof document<"u"?document:{documentElement:{style:{}}};const sa=/Edge\/(\d+)/.exec(qe.userAgent),Xf=/MSIE \d/.test(qe.userAgent),ra=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(qe.userAgent),yo=!!(Xf||ra||sa),Oc=!yo&&/gecko\/(\d+)/i.test(qe.userAgent),tl=!yo&&/Chrome\/(\d+)/.exec(qe.userAgent),iE="webkitFontSmoothing"in na.documentElement.style,oa=!yo&&/Apple Computer/.test(qe.vendor),Ic=oa&&(/Mobile\/\w+/.test(qe.userAgent)||qe.maxTouchPoints>2);var z={mac:Ic||/Mac/.test(qe.platform),windows:/Win/.test(qe.platform),linux:/Linux|X11/.test(qe.platform),ie:yo,ie_version:Xf?na.documentMode||6:ra?+ra[1]:sa?+sa[1]:0,gecko:Oc,gecko_version:Oc?+(/Firefox\/(\d+)/.exec(qe.userAgent)||[0,0])[1]:0,chrome:!!tl,chrome_version:tl?+tl[1]:0,ios:Ic,android:/Android\b/.test(qe.userAgent),webkit_version:iE?+(/\bAppleWebKit\/(\d+)/.exec(qe.userAgent)||[0,0])[1]:0,safari:oa,safari_version:oa?+(/\bVersion\/(\d+(\.\d+)?)/.exec(qe.userAgent)||[0,0])[1]:0,tabSize:na.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function us(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function la(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function fr(i,e){if(!e.anchorNode)return!1;try{return la(i,e.anchorNode)}catch{return!1}}function En(i){return i.nodeType==3?Ui(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function Yn(i,e,t,n){return t?Mc(i,e,t,n,-1)||Mc(i,e,t,n,1):!1}function Gi(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function Nr(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function Mc(i,e,t,n,s){for(;;){if(i==t&&e==n)return!0;if(e==(s<0?0:Gt(i))){if(i.nodeName=="DIV")return!1;let r=i.parentNode;if(!r||r.nodeType!=1)return!1;e=Gi(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?Gt(i):0}else return!1}}function Gt(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 nE(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 Qf(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 sE(i,e,t,n,s,r,o,l){let a=i.ownerDocument,u=a.defaultView||window;for(let c=i,d=!1;c&&!d;)if(c.nodeType==1){let f,p=c==a.body,m=1,g=1;if(p)f=nE(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(d=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let b=c.getBoundingClientRect();({scaleX:m,scaleY:g}=Qf(c,b)),f={left:b.left,right:b.left+c.clientWidth*m,top:b.top,bottom:b.top+c.clientHeight*g}}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,S=f.bottom-f.top;y=(s=="center"&&b<=S?e.top+b/2-S/2:s=="start"||s=="center"&&t<0?e.top-o:e.bottom-S+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,S=0;if(y){let E=c.scrollTop;c.scrollTop+=y/g,S=(c.scrollTop-E)*g}if(x){let E=c.scrollLeft;c.scrollLeft+=x/m,b=(c.scrollLeft-E)*m}e={left:e.left-b,top:e.top-S,right:e.right-b,bottom:e.bottom-S},b&&Math.abs(b-x)<1&&(n="nearest"),S&&Math.abs(S-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 rE(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 oE{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?Gt(t):0),n,Math.min(e.focusOffset,n?Gt(n):0))}set(e,t,n,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=s}}let Mi=null;z.safari&&z.safari_version>=26&&(Mi=!1);function Jf(i){if(i.setActive)return i.setActive();if(Mi)return i.focus(Mi);let e=[];for(let t=i;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(i.focus(Mi==null?{get preventScroll(){return Mi={preventScroll:!0},!0}}:void 0),!Mi){Mi=!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 Pc;function Ui(i,e,t=e){let n=Pc||(Pc=document.createRange());return n.setEnd(i,t),n.setStart(i,e),n}function mn(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 lE(i){for(;i;){if(i&&(i.nodeType==9||i.nodeType==11&&i.host))return i;i=i.assignedSlot||i.parentNode}return null}function Zf(i){for(;i.attributes.length;)i.removeAttributeNode(i.attributes[0])}function aE(i,e){let t=e.focusNode,n=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=n)return!1;for(n=Math.min(n,Gt(t));;)if(n){if(t.nodeType!=1)return!1;let s=t.childNodes[n-1];s.contentEditable=="false"?n--:(t=s,n=Gt(t))}else{if(t==i)return!0;n=Gi(t),t=t.parentNode}}function ep(i){return i.scrollTop>Math.max(1,i.scrollHeight-i.clientHeight-4)}function tp(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=Gt(t)}else if(t.parentNode&&!Nr(t))n=Gi(t),t=t.parentNode;else return null}}function ip(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&&!Nr(t))n=Gi(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,Gi(e),t)}static after(e,t){return new $e(e.parentNode,Gi(e)+1,t)}}const du=[];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=Dc(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=Dc(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=Gt(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 d=this.children[a],f=u+d.length;if(u<e&&f>t)return d.domBoundsAround(e,t,u);if(f>=e&&s==-1&&(s=a,r=u),u>t&&d.dom.parentNode==this.dom){o=a,l=c;break}c=f,u=f+d.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=du){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 np(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 Dc(i){let e=i.nextSibling;return i.parentNode.removeChild(i),e}class np{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 sp(i,e,t,n,s,r,o,l,a){let{children:u}=i,c=u.length?u[e]:null,d=r.length?r[r.length-1]:null,f=d?d.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(t,s,r.length?d:null,t==0,l,a))){if(n<u.length){let p=u[n];p&&(s<p.length||p.breakAfter&&(d!=null&&d.breakAfter))?(e==n&&(p=p.split(s),s=0),!f&&d&&p.merge(0,s,d,!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&&(d?d.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 rp(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),d=e-t;for(let f of n)d+=f.length;i.length+=d,sp(i,u,c,l,a,n,0,s,r)}const uE=256;class Rt 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 Rt)||this.length-(t-e)+n.length>uE||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 Rt(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 cE(this.dom,e,t)}}class si 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(Zf(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 si&&n.mark.eq(this.mark))||e&&r<=0||t<this.length&&o<=0)?!1:(rp(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 si(this.mark,t,o)}domAtPos(e){return op(this,e)}coordsAt(e,t){return ap(this,e,t)}}function cE(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=Ui(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 ei extends de{static create(e,t,n){return new ei(e,t,n)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}split(e){let t=ei.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 ei)||!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 ei&&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 Cn extends de{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof Cn&&e.side==this.side}split(){return new Cn(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}}Rt.prototype.children=ei.prototype.children=Cn.prototype.children=du;function op(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 lp(i,e,t){let n,{children:s}=i;t>0&&e instanceof si&&s.length&&(n=s[s.length-1])instanceof si&&n.mark.eq(e.mark)?lp(n,e.children[0],t-1):(s.push(e),e.setParent(i)),i.length+=e.length}function ap(i,e,t){let n=null,s=-1,r=null,o=-1;function l(u,c){for(let d=0,f=0;d<u.children.length&&f<=c;d++){let p=u.children[d],m=f+p.length;m>=c&&(p.children.length?l(p,c-f):(!r||r.isHidden&&(t>0||dE(r,p)))&&(m>c||f==m&&p.getSide()>0)?(r=p,o=c-f):(f<c||f==m&&p.getSide()<0&&!p.isHidden)&&(n=p,s=c-f)),f=m}}l(i,e);let a=(t<0?n:r)||n||r;return a?a.coordsAt(Math.max(0,a==n?s:o),t):hE(i)}function hE(i){let e=i.dom.lastChild;if(!e)return i.dom.getBoundingClientRect();let t=En(e);return t[t.length-1]||null}function dE(i,e){let t=i.coordsAt(0,1),n=e.coordsAt(0,1);return t&&n&&n.top<t.bottom}function aa(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 Fr(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 ua(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 fE(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 oi{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 Ye=(function(i){return i[i.Text=0]="Text",i[i.WidgetBefore=1]="WidgetBefore",i[i.WidgetAfter=2]="WidgetAfter",i[i.WidgetRange=3]="WidgetRange",i})(Ye||(Ye={}));class K extends Hi{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 ws(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 Ri(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}=up(e,t);n=(r?t?-3e8:-1:5e8)-1,s=(o?t?2e8:1:-6e8)+1}return new Ri(e,n,s,t,e.widget||null,!0)}static line(e){return new Rs(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 ws extends K{constructor(e){let{start:t,end:n}=up(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 ws&&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))&&Fr(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)}}ws.prototype.point=!1;class Rs extends K{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Rs&&this.spec.class==e.spec.class&&Fr(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)}}Rs.prototype.mapMode=Ke.TrackBefore;Rs.prototype.point=!0;class Ri 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?Ke.TrackBefore:Ke.TrackAfter:Ke.TrackDel}get type(){return this.startSide!=this.endSide?Ye.WidgetRange:this.startSide<=0?Ye.WidgetBefore:Ye.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Ri&&pE(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)}}Ri.prototype.point=!0;function up(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 pE(i,e){return i==e||!!(i&&e&&i.compare(e))}function pr(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 Re 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 Re))return!1;this.dom||n.transferDOM(this)}return s&&this.setDeco(n?n.attrs:null),rp(this,e,t,n?n.children.slice():[],r,o),!0}split(e){let t=new Re;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){Fr(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){lp(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=aa(t,this.attrs||{})),n&&(this.attrs=aa({class:n},this.attrs||{}))}domAtPos(e){return op(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(Zf(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&&(ua(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 si;)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 Rt))){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 Rt)||/[^ -~]/.test(n.text))return null;let s=En(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=ap(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 Re&&this.children.length==0&&e.children.length==0&&Fr(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 Re)return r;if(o>t)break}s=o+r.breakAfter}return null}}class ti 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 ti)||!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 ti(this.widget,t,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return du}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 ti&&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 ca?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 ca extends oi{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 Xn{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 ti&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Re),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Us(new Cn(-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 ti)&&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(Us(new Rt(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 Ri){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 Ri)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new ti(n.widget||wn.block,l,n));else{let a=ei.create(n.widget||wn.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),d=this.getLine();this.pendingBuffer==2&&!u&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(s),u&&(d.append(Us(new Cn(1),s),r),r=s.length+Math.max(0,r-s.length)),d.append(Us(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 Xn(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 Us(i,e){for(let t of e)i=new si(t,[i],i.length);return i}class wn extends oi{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}}wn.inline=new wn("span");wn.block=new wn("div");var ye=(function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i})(ye||(ye={}));const Wi=ye.LTR,fu=ye.RTL;function cp(i){let e=[];for(let t=0;t<i.length;t++)e.push(1<<+i[t]);return e}const mE=cp("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),gE=cp("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),ha=Object.create(null),Mt=[];for(let i of["()","[]","{}"]){let e=i.charCodeAt(0),t=i.charCodeAt(1);ha[e]=t,ha[t]=-e}function hp(i){return i<=247?mE[i]:1424<=i&&i<=1524?2:1536<=i&&i<=1785?gE[i-1536]:1774<=i&&i<=2220?4:8192<=i&&i<=8204?256:64336<=i&&i<=65023?4:1}const xE=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class xi{get dir(){return this.level%2?fu:Wi}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 dp(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||!dp(n.inner,s.inner))return!1}return!0}const pe=[];function yE(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,d=a;u<l;u++){let f=hp(i.charCodeAt(u));f==512?f=c:f==8&&d==4&&(f=16),pe[u]=f==4?2:f,f&7&&(d=f),c=f}for(let u=o,c=a,d=a;u<l;u++){let f=pe[u];if(f==128)u<l-1&&c==pe[u+1]&&c&24?f=pe[u]=c:pe[u]=256;else if(f==64){let p=u+1;for(;p<l&&pe[p]==64;)p++;let m=u&&c==8||p<t&&pe[p]==8?d==1?1:8:256;for(let g=u;g<p;g++)pe[g]=m;u=p-1}else f==8&&d==1&&(pe[u]=1);c=f,f&7&&(d=f)}}}function bE(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 d=u,f,p,m;d<c;d++)if(p=ha[f=i.charCodeAt(d)])if(p<0){for(let g=l-3;g>=0;g-=3)if(Mt[g+1]==-p){let x=Mt[g+2],y=x&2?s:x&4?x&1?r:s:0;y&&(pe[d]=pe[Mt[g]]=y),l=g;break}}else{if(Mt.length==189)break;Mt[l++]=d,Mt[l++]=f,Mt[l++]=a}else if((m=pe[d])==2||m==1){let g=m==s;a=g?0:1;for(let x=l-3;x>=0;x-=3){let y=Mt[x+2];if(y&2)break;if(g)Mt[x+2]|=2;else{if(y&4)break;Mt[x+2]|=4}}}}}function SE(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 d=r==1,f=(c<e?pe[c]:n)==1,p=d==f?d?1:2:n;for(let m=c,g=s,x=g?t[g-1].to:i;m>a;)m==x&&(m=t[--g].from,x=g?t[g-1].to:i),pe[--m]=p;a=c}else r=u,a++}}}function da(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,d=!1;if(u==r.length||a<r[u].from){let g=pe[a];g!=l&&(c=!1,d=g==16)}let f=!c&&l==1?[]:null,p=c?n:n+1,m=a;e:for(;;)if(u<r.length&&m==r[u].from){if(d)break e;let g=r[u];if(!c)for(let x=g.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++,f)f.push(g);else{g.from>a&&o.push(new xi(a,g.from,p));let x=g.direction==Wi!=!(p%2);fa(i,x?n+1:n,s,g.inner,g.from,g.to,o),a=g.to}m=g.to}else{if(m==t||(c?pe[m]!=l:pe[m]==l))break;m++}f?da(i,a,m,n+1,s,f,o):a<m&&o.push(new xi(a,m,p)),a=m}else for(let a=t,u=r.length;a>e;){let c=!0,d=!1;if(!u||a>r[u-1].to){let g=pe[a-1];g!=l&&(c=!1,d=g==16)}let f=!c&&l==1?[]:null,p=c?n:n+1,m=a;e:for(;;)if(u&&m==r[u-1].to){if(d)break e;let g=r[--u];if(!c)for(let x=g.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(f)f.push(g);else{g.to<a&&o.push(new xi(g.to,a,p));let x=g.direction==Wi!=!(p%2);fa(i,x?n+1:n,s,g.inner,g.from,g.to,o),a=g.from}m=g.from}else{if(m==e||(c?pe[m-1]!=l:pe[m-1]==l))break;m--}f?da(i,m,a,n+1,s,f,o):m<a&&o.push(new xi(m,a,p)),a=m}}function fa(i,e,t,n,s,r,o){let l=e%2?2:1;yE(i,s,r,n,l),bE(i,s,r,n,l),SE(s,r,n,l),da(i,s,r,e,t,n,o)}function vE(i,e,t){if(!i)return[new xi(0,0,e==fu?1:0)];if(e==Wi&&!t.length&&!xE.test(i))return fp(i.length);if(t.length)for(;i.length>pe.length;)pe[pe.length]=256;let n=[],s=e==Wi?0:1;return fa(i,s,s,t,0,i.length,n),n}function fp(i){return[new xi(0,i,0)]}let pp="";function EE(i,e,t,n,s){var r;let o=n.head-i.from,l=xi.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),pp=i.text.slice(Math.min(o,c),Math.max(o,c));let d=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return d&&c==u&&d.level+(s?0:1)<a.level?O.cursor(d.side(!s,t)+i.from,d.forward(s,t)?1:-1,d.level):O.cursor(c+i.from,a.forward(s,t)?-1:1,a.level)}function CE(i,e,t){for(let n=e;n<t;n++){let s=hp(i.charCodeAt(n));if(s==1)return Wi;if(s==2||s==4)return fu}return Wi}const mp=G.define(),gp=G.define(),xp=G.define(),yp=G.define(),pa=G.define(),bp=G.define(),Sp=G.define(),pu=G.define(),mu=G.define(),vp=G.define({combine:i=>i.some(e=>e)}),Ep=G.define({combine:i=>i.some(e=>e)}),Cp=G.define();class gn{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 gn(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 gn(O.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Ws=J.define({map:(i,e)=>i.map(e)}),wp=J.define();function et(i,e,t){let n=i.facet(yp);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 Zt=G.define({combine:i=>i.length?i[0]:!0});let wE=0;const ln=G.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(ln.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(ln.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:s,provide:r,decorations:o}=t||{};return new Ce(wE++,e,n,s,l=>{let a=[];return o&&a.push(cs.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 il{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(et(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){et(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){et(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Rp=G.define(),gu=G.define(),cs=G.define(),kp=G.define(),ks=G.define(),Tp=G.define();function Nc(i,e){let t=i.state.facet(Tp);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,d=s;for(let f=l.length-1;f>=0;f--,a--){let p=l[f].spec.bidiIsolate,m;if(p==null&&(p=CE(e.text,u,c)),a>0&&d.length&&(m=d[d.length-1]).to==u&&m.direction==p)m.to=c,d=m.inner;else{let g={from:u,to:c,direction:p,inner:[]};d.push(g),d=g.inner}}}}),s}const Ap=G.define();function xu(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 zn=G.define();class mt{constructor(e,t,n,s){this.fromA=e,this.toA=t,this.fromB=n,this.toB=s}join(e){return new mt(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 d=t[r],f=t[r+1],p=Math.max(l,d),m=Math.min(c,f);if(p<=m&&new mt(p+u,m+u,p,m).addToSet(n),f>c)break;r+=2}if(!a)return n;new mt(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),o=a.toA,l=a.toB}}}class Br{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=je.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 mt(r,o,l,a))),this.changedRanges=s}static create(e,t,n){return new Br(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 Fc 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 Re],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new mt(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:!IE(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let r=s>-1?kE(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:u,to:c}=this.hasComposition;n=new mt(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=jE(o,l,e.changes);return n=mt.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 ti&&o.widget instanceof ca&&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:d}=l,f,p,m,g;if(n&&n.range.fromB<d&&n.range.toB>c){let E=Xn.build(this.view.state.doc,c,n.range.fromB,this.decorations,this.dynamicDecorationMap),v=Xn.build(this.view.state.doc,n.range.toB,d,this.decorations,this.dynamicDecorationMap);p=E.breakAtStart,m=E.openStart,g=v.openEnd;let C=this.compositionView(n);v.breakAtStart?C.breakAfter=1:v.content.length&&C.merge(C.length,C.length,v.content[0],!1,v.openStart,0)&&(C.breakAfter=v.content[0].breakAfter,v.content.shift()),E.content.length&&C.merge(0,0,E.content[E.content.length-1],!0,0,E.openEnd)&&E.content.pop(),f=E.content.concat(C).concat(v.content)}else({content:f,breakAtStart:p,openStart:m,openEnd:g}=Xn.build(this.view.state.doc,c,d,this.decorations,this.dynamicDecorationMap));let{i:x,off:y}=r.findPos(u,1),{i:b,off:S}=r.findPos(a,-1);sp(this,b,S,x,y,f,p,m,g)}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(wp)&&(this.editContextFormatting=n.value)}compositionView(e){let t=new Rt(e.text.nodeValue);t.flags|=8;for(let{deco:s}of e.marks)t=new si(s,[t],t.length);let n=new Re;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(Zt)||this.dom.tabIndex>-1)&&fr(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&&RE(a)){let d=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(d,a.node.childNodes[a.offset]||null)),a=u=new $e(d,0),o=!0}let c=this.view.observer.selectionRange;(o||!c.focusNode||(!Yn(a.node,a.offset,c.anchorNode,c.anchorOffset)||!Yn(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)&&OE(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let d=us(this.view.root);if(d)if(l.empty){if(z.gecko){let f=TE(a.node,a.offset);if(f&&f!=3){let p=(f==1?tp:ip)(a.node,a.offset);p&&(a=new $e(p.node,p.offset))}}d.collapse(a.node,a.offset),l.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=l.bidiLevel)}else if(d.extend){d.collapse(a.node,a.offset);try{d.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),d.removeAllRanges(),d.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&&Yn(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=us(e.root),{anchorNode:s,anchorOffset:r}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let o=Re.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 d=e.observer.selectionRange;e.docView.posFromDOM(d.anchorNode,d.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 Re&&(n=r.domAtPos(0))}for(let s=e.offset-1;!n&&s>=0;s--){let r=de.get(t.childNodes[s]);r instanceof Re&&(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 Re)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 Re&&!(n instanceof Re&&t>=0)))n=l,s=u;else if(n&&u==e&&a==e&&l instanceof ti&&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 Re))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 Rt))return null;let r=Fe(s.text,n);if(r==n)return null;let o=Ui(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==ye.LTR;for(let u=0,c=0;c<this.children.length;c++){let d=this.children[c],f=u+d.length;if(f>s)break;if(u>=n){let p=d.dom.getBoundingClientRect();if(t.push(p.height),o){let m=d.dom.lastChild,g=m?En(m):[];if(g.length){let x=g[g.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+d.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?ye.RTL:ye.LTR}measureTextSize(){for(let r of this.children)if(r instanceof Re){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=En(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 np(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 ca(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(cs).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),n=!1,s=this.view.state.facet(kp).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(Cp))try{if(u(this.view,e.range,e))return!0}catch(c){et(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=xu(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;sE(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==ye.LTR)}lineHasWidget(e){let{i:t}=this.childCursor().findPos(e);if(t==this.children.length)return!1;let n=s=>s instanceof ei||s.children.some(n);return n(this.children[t])}}function RE(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 jp(i,e){let t=i.observer.selectionRange;if(!t.focusNode)return null;let n=tp(t.focusNode,t.focusOffset),s=ip(t.focusNode,t.focusOffset),r=n||s;if(s&&n&&s.node!=n.node){let l=de.get(s.node);if(!l||l instanceof Rt&&l.text!=s.node.nodeValue)r=s;else if(i.docView.lastCompositionAfterCursor){let a=de.get(n.node);!a||a instanceof Rt&&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 kE(i,e,t){let n=jp(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 mt(a.mapPos(r),a.mapPos(o),r,o),c=[];for(let d=s.parentNode;;d=d.parentNode){let f=de.get(d);if(f instanceof si)c.push({node:d,deco:f.mark});else{if(f instanceof Re||d.nodeName=="DIV"&&d.parentNode==i.contentDOM)return{range:u,text:s,marks:c,line:d};if(d!=i.contentDOM)c.push({node:d,deco:new ws({inclusive:!0,attributes:fE(d),tagName:d.tagName.toLowerCase()})});else return null}}}function TE(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 AE=class{constructor(){this.changes=[]}compareRange(e,t){pr(e,t,this.changes)}comparePoint(e,t){pr(e,t,this.changes)}boundChange(e){pr(e,e,this.changes)}};function jE(i,e,t){let n=new AE;return re.compare(i,e,t,n),n.changes}function OE(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 IE(i,e){let t=!1;return e&&i.iterChangedRanges((n,s)=>{n<e.to&&s>e.from&&(t=!0)}),t}function ME(i,e,t=1){let n=i.charCategorizer(e),s=i.doc.lineAt(e),r=e-s.from;if(s.length==0)return O.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 O.range(o+s.from,l+s.from)}function PE(i,e){return e.left>i?e.left-i:Math.max(0,i-e.right)}function DE(i,e){return e.top>i?e.top-i:Math.max(0,i-e.bottom)}function nl(i,e){return i.top<e.bottom-1&&i.bottom>e.top+1}function Bc(i,e){return e<i.top?{top:e,left:i.left,right:i.right,bottom:i.bottom}:i}function Vc(i,e){return e>i.bottom?{top:i.top,left:i.left,right:i.right,bottom:e}:i}function ma(i,e,t){let n,s,r,o,l=!1,a,u,c,d;for(let m=i.firstChild;m;m=m.nextSibling){let g=En(m);for(let x=0;x<g.length;x++){let y=g[x];s&&nl(s,y)&&(y=Bc(Vc(y,s.bottom),s.top));let b=PE(e,y),S=DE(t,y);if(b==0&&S==0)return m.nodeType==3?_c(m,e,t):ma(m,e,t);(!n||o>S||o==S&&r>b)&&(n=m,s=y,r=b,o=S,l=b?e<y.left?x>0:x<g.length-1:!0),b==0?t>y.bottom&&(!c||c.bottom<y.bottom)?(a=m,c=y):t<y.top&&(!d||d.top>y.top)&&(u=m,d=y):c&&nl(c,y)?c=Vc(c,y.bottom):d&&nl(d,y)&&(d=Bc(d,y.top))}}if(c&&c.bottom>=t?(n=a,s=c):d&&d.top<=t&&(n=u,s=d),!n)return{node:i,offset:0};let f=Math.max(s.left,Math.min(s.right,e));if(n.nodeType==3)return _c(n,f,t);if(l&&n.contentEditable!="false")return ma(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 _c(i,e,t){let n=i.nodeValue.length,s=-1,r=1e9,o=0;for(let l=0;l<n;l++){let a=Ui(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 d=(c.top>t?c.top-t:t-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&d<r){let f=e>=(c.left+c.right)/2,p=f;if((z.chrome||z.gecko)&&Ui(i,l).getBoundingClientRect().left==c.right&&(p=!f),d<=0)return{node:i,offset:l+(p?1:0)};s=l+(p?1:0),r=d}}}return{node:i,offset:s>-1?s:o>0?i.nodeValue.length:0}}function Op(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:d}=e,f=d-l;if(f<0)return 0;if(f>u)return i.state.doc.length;for(let E=i.viewState.heightOracle.textHeight/2,v=!1;a=i.elementAtHeight(f),a.type!=Ye.Text;)for(;f=n>0?a.bottom+E:a.top-E,!(f>=0&&f<=u);){if(v)return t?null:0;v=!0,n=-n}d=l+f;let p=a.from;if(p<i.viewport.from)return i.viewport.from==0?0:t?null:zc(i,o,a,c,d);if(p>i.viewport.to)return i.viewport.to==i.state.doc.length?i.state.doc.length:t?null:zc(i,o,a,c,d);let m=i.dom.ownerDocument,g=i.root.elementFromPoint?i.root:m,x=g.elementFromPoint(c,d);x&&!i.contentDOM.contains(x)&&(x=null),x||(c=Math.max(o.left+1,Math.min(o.right-1,c)),x=g.elementFromPoint(c,d),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(m.caretPositionFromPoint){let E=m.caretPositionFromPoint(c,d);E&&({offsetNode:y,offset:b}=E)}else if(m.caretRangeFromPoint){let E=m.caretRangeFromPoint(c,d);E&&({startContainer:y,startOffset:b}=E)}y&&(!i.contentDOM.contains(y)||z.safari&&LE(y,b,c)||z.chrome&&NE(y,b,c))&&(y=void 0),y&&(b=Math.min(Gt(y),b))}if(!y||!i.docView.dom.contains(y)){let E=Re.find(i.docView,p);if(!E)return f>a.top+a.height/2?a.to:a.from;({node:y,offset:b}=ma(E.dom,c,d))}let S=i.docView.nearest(y);if(!S)return null;if(S.isWidget&&((r=S.dom)===null||r===void 0?void 0:r.nodeType)==1){let E=S.dom.getBoundingClientRect();return e.y<E.top||e.y<=E.bottom&&e.x<=(E.left+E.right)/2?S.posAtStart:S.posAtEnd}else return S.localPosFromDOM(y,b)+S.posAtStart}function zc(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+ea(o,r,i.state.tabSize)}function Ip(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 Ui(i,n-1,n).getBoundingClientRect().right>t}function LE(i,e,t){return Ip(i,e,t)}function NE(i,e,t){if(e!=0)return Ip(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():Ui(i,0,Math.max(i.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function ga(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==Ye.Text&&(s.type!=r.type||(t<0?r.from<e:r.to>e)))&&(s=r)}}return s||n}return n}function FE(i,e,t,n){let s=ga(i,e.head,e.assoc||-1),r=!n||s.type!=Ye.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==ye.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return O.cursor(a,t?-1:1)}return O.cursor(t?s.to:s.from,t?-1:1)}function $c(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=EE(s,r,o,l,t),c=pp;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),
|
|
31
|
-
`&&i.lineWrapping&&(n&&(n=O.single(n.main.anchor-1,n.main.head-1)),t={from:s.from,to:s.to,insert:oe.of([" "])}),t)return yu(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=Mp(i.state.facet(ks).map(a=>a(i)),n))),i.dispatch({selection:n,scrollIntoView:o,userEvent:l}),!0}else return!1}function yu(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&&mn(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)&&mn(i.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&mn(i.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let o,l=()=>o||(o=GE(i,e,t));return i.state.facet(bp).some(a=>a(i,e.from,e.to,r,l))||i.dispatch(l()),!0}function GE(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=Qn(s.facet(ks).map(d=>d(i)),u,a);e.from==c&&(o=c)}if(o>-1)n={changes:e,selection:O.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),d,f=t&&jp(i,t.main.head);if(f){let g=e.insert.length-(e.to-e.from);d={from:f.from,to:f.to-g}}else d=i.state.doc.lineAt(r.head);let p=r.to-e.to,m=r.to-r.from;n=s.changeByRange(g=>{if(g.from==r.from&&g.to==r.to)return{changes:a,range:u||g.map(a)};let x=g.to-p,y=x-c.length;if(g.to-g.from!=m||i.state.sliceDoc(y,x)!=c||g.to>=d.from&&g.from<=d.to)return{range:g};let b=s.changes({from:y,to:x,insert:e.insert}),S=g.to-r.to;return{changes:b,range:u?O.range(Math.max(0,u.anchor+S),Math.max(0,u.head+S)):g.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 Dp(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 UE(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 Hc(t,n)),(s!=t||r!=n)&&e.push(new Hc(s,r))),e}function WE(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?O.single(t+e,n+e):null}class qE{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&&uC(e.contentDOM.ownerDocument)}handleEvent(e){!tC(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=KE(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&&Np.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=Lp.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||YE.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,mn(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 Gc(i,e){return(t,n)=>{try{return e.call(i,n,t)}catch(s){et(t.state,s)}}}function KE(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(Gc(n.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(Gc(n.value,a))}}for(let n in kt)t(n).handlers.push(kt[n]);for(let n in xt)t(n).observers.push(xt[n]);return e}const Lp=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],YE="dthko",Np=[16,17,18,20,91,92,224,225],qs=6;function Ks(i){return Math.max(0,i)*.7+8}function XE(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}class QE{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=rE(e.contentDOM),this.atoms=e.state.facet(ks).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)&&JE(e,t),this.dragging=eC(e,t)&&Vp(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&&XE(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=xu(this.view);e.clientX-a.left<=s+qs?t=-Ks(s-e.clientX):e.clientX+a.right>=o-qs&&(t=Ks(e.clientX-o)),e.clientY-a.top<=r+qs?n=-Ks(r-e.clientY):e.clientY+a.bottom>=l-qs&&(n=Ks(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=Mp(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 JE(i,e){let t=i.state.facet(mp);return t.length?t[0](e):z.mac?e.metaKey:e.ctrlKey}function ZE(i,e){let t=i.state.facet(gp);return t.length?t[0](e):z.mac?!e.altKey:!e.ctrlKey}function eC(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let n=us(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 tC(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 kt=Object.create(null),xt=Object.create(null),Fp=z.ie&&z.ie_version<15||z.ios&&z.webkit_version<604;function iC(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(),Bp(i,t.value)},50)}function bo(i,e,t){for(let n of i.facet(e))t=n(t,i);return t}function Bp(i,e){e=bo(i.state,pu,e);let{state:t}=i,n,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(xa!=null&&t.selection.ranges.every(a=>a.empty)&&xa==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 d=t.toText((o?r.line(s++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:d},range:O.cursor(u.from+d.length)}})}else o?n=t.changeByRange(a=>{let u=r.line(s++);return{changes:{from:a.from,to:a.to,insert:u.text},range:O.cursor(a.from+u.length)}}):n=t.replaceSelection(r);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}xt.scroll=i=>{i.inputState.lastScrollTop=i.scrollDOM.scrollTop,i.inputState.lastScrollLeft=i.scrollDOM.scrollLeft};kt.keydown=(i,e)=>(i.inputState.setSelectionOrigin("select"),e.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);xt.touchstart=(i,e)=>{i.inputState.lastTouchTime=Date.now(),i.inputState.setSelectionOrigin("select.pointer")};xt.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};kt.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(xp))if(t=n(i,e),t)break;if(!t&&e.button==0&&(t=rC(i,e)),t){let n=!i.hasFocus;i.inputState.startMouseSelection(new QE(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 Uc(i,e,t,n){if(n==1)return O.cursor(e,t);if(n==2)return ME(i.state,e,t);{let s=Re.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++,O.range(o,l)}}let Wc=(i,e,t)=>e>=t.top&&e<=t.bottom&&i>=t.left&&i<=t.right;function nC(i,e,t,n){let s=Re.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&&Wc(t,n,o))return-1;let l=s.coordsAt(r,1);return l&&Wc(t,n,l)?1:o&&o.bottom>=n?-1:1}function qc(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:nC(i,t,e.clientX,e.clientY)}}const sC=z.ie&&z.ie_version<=11;let Kc=null,Yc=0,Xc=0;function Vp(i){if(!sC)return i.detail;let e=Kc,t=Xc;return Kc=i,Xc=Date.now(),Yc=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(Yc+1)%3:1}function rC(i,e){let t=qc(i,e),n=Vp(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=qc(i,r),u,c=Uc(i,a.pos,a.bias,n);if(t.pos!=a.pos&&!o){let d=Uc(i,t.pos,t.bias,n),f=Math.min(d.from,c.from),p=Math.max(d.to,c.to);c=f<c.from?O.range(f,p):O.range(p,f)}return o?s.replaceRange(s.main.extend(c.from,c.to)):l&&n==1&&s.ranges.length>1&&(u=oC(s,a.pos))?u:l?s.addRange(c):O.create([c])}}}function oC(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 O.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}kt.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=O.range(r,o))}}let{inputState:n}=i;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",bo(i.state,mu,i.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};kt.dragend=i=>(i.inputState.draggedContent=null,!1);function Qc(i,e,t,n){if(t=bo(i.state,pu,t),!t)return;let s=i.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=i.inputState,o=n&&r&&ZE(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}kt.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&&Qc(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 Qc(i,e,n,!0),!0}return!1};kt.paste=(i,e)=>{if(i.state.readOnly)return!0;i.observer.flush();let t=Fp?null:e.clipboardData;return t?(Bp(i,t.getData("text/plain")||t.getData("text/uri-list")),!0):(iC(i),!1)};function lC(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 aC(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:bo(i,mu,e.join(i.lineBreak)),ranges:t,linewise:n}}let xa=null;kt.copy=kt.cut=(i,e)=>{let{text:t,ranges:n,linewise:s}=aC(i.state);if(!t&&!s)return!1;xa=s?t:null,e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=Fp?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(lC(i,t),!1)};const _p=qt.define();function zp(i,e){let t=[];for(let n of i.facet(Sp)){let s=n(i,e);s&&t.push(s)}return t.length?i.update({effects:t,annotations:_p.of(!0)}):null}function $p(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=zp(i.state,e);t?i.dispatch(t):i.update([])}},10)}xt.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),$p(i)};xt.blur=i=>{i.observer.clearSelectionRange(),$p(i)};xt.compositionstart=xt.compositionupdate=i=>{i.observer.editContext||(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0))};xt.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))};xt.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};kt.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 yu(i,{from:a,to:u,insert:i.state.toText(r)},null),!0}}let s;if(z.chrome&&z.android&&(s=Lp.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(()=>xt.compositionend(i,e),20),!1};const Jc=new Set;function uC(i){Jc.has(i)||(Jc.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}const Zc=["pre-wrap","normal","pre-line","break-spaces"];let Rn=!1;function eh(){Rn=!1}class cC{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 Zc.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=Zc.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 hC{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Bt{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"?Ye.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 Ri?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 Bt(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var xe=(function(i){return i[i.ByPos=0]="ByPos",i[i.ByHeight=1]="ByHeight",i[i.ByPosNoHeight=2]="ByPosNoHeight",i})(xe||(xe={}));const mr=.001;class Xe{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)>mr&&(Rn=!0),this.height=e)}replace(e,t,n){return Xe.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:d}=s[l],f=r.lineAt(a,xe.ByPosNoHeight,n.setDoc(t),0,0),p=f.to>=u?f:r.lineAt(u,xe.ByPosNoHeight,n,0,0);for(d+=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,xe.ByPosNoHeight,n,0,0));c+=f.from-a,a=f.from;let m=bu.build(n.setDoc(o),e,c,d);r=Vr(r,r.replace(a,u,m))}return r.updateHeight(n,0)}static empty(){return new lt(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 dC(Xe.of(e.slice(0,t)),o,Xe.of(e.slice(n)))}}function Vr(i,e){return i==e?i:(i.constructor!=e.constructor&&(Rn=!0),e)}Xe.prototype.size=1;class Hp extends Xe{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,s){return new Bt(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 lt extends Hp{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,s){return new Bt(s,this.length,n,this.height,this.breaks)}replace(e,t,n){let s=n[0];return n.length==1&&(s instanceof lt||s instanceof Le&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof Le?s=new lt(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):Xe.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 Le extends Xe{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),d=l+c.length*a,f=Math.max(n,e-d/2);return new Bt(c.from,c.length,f,d,0)}else{let u=Math.max(0,Math.min(o-r,Math.floor((e-n)/l))),{from:c,length:d}=t.doc.line(r+u);return new Bt(c,d,n+l*u,l,0)}}lineAt(e,t,n,s,r){if(t==xe.ByHeight)return this.blockAt(e,n,s,r);if(t==xe.ByPosNoHeight){let{from:p,to:m}=n.doc.lineAt(e);return new Bt(p,m-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,d=u.number-o,f=s+l*d+a*(u.from-r-d);return new Bt(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,d=s;c<=t;){let f=n.doc.lineAt(c);if(c==e){let m=f.number-l;d+=a*m+u*(e-r-m)}let p=a+u*f.length;o(new Bt(f.from,f.length,d,p,0)),d+=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 Le?n[n.length-1]=new Le(r.length+s):n.push(null,new Le(s-1))}if(e>0){let r=n[0];r instanceof Le?n[0]=new Le(e+r.length):n.unshift(new Le(e-1),null)}return Xe.of(n)}decomposeLeft(e,t){t.push(new Le(e-1),null)}decomposeRight(e,t){t.push(null,new Le(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 Le(s.from-t-1).updateHeight(e,t));l<=r&&s.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let d=s.heights[s.index++];a==-1?a=d:Math.abs(d-a)>=mr&&(a=-2);let f=new lt(c,d);f.outdated=!1,o.push(f),l+=c+1}l<=r&&o.push(null,new Le(r-l).updateHeight(e,l));let u=Xe.of(o);return(a<0||Math.abs(u.height-this.height)>=mr||Math.abs(a-this.heightMetrics(e,t).perLine)>=mr)&&(Rn=!0),Vr(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 dC extends Xe{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==xe.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==xe.ByPosNoHeight?xe.ByPosNoHeight:xe.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,xe.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&&th(r,o-1),t<this.length){let l=r.length;this.decomposeRight(t,r),th(r,l)}return Xe.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?Xe.of(this.break?[e,null,t]:[e,t]):(this.left=Vr(this.left,e),this.right=Vr(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 th(i,e){let t,n;i[e]==null&&(t=i[e-1])instanceof Le&&(n=i[e+1])instanceof Le&&i.splice(e-1,3,new Le(t.length+1+n.length))}const fC=5;class bu{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 lt?s.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new lt(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 Hp(o,s,n)):(o||r||s>=fC)&&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 lt(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new Le(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 lt)return e;let t=new lt(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 lt)&&!this.isCovered?this.nodes.push(new lt(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 lt&&s.updateHeight(this.oracle,n),n+=s?s.length:1;return this.nodes}static build(e,t,n,s){let r=new bu(n,e);return re.spans(t,n,s,r,0),r.finish(n)}}function pC(i,e,t){let n=new mC;return re.compare(i,e,t,n,0),n.changes}class mC{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,s){(e<t||n&&n.heightRelevant||s&&s.heightRelevant)&&pr(e,t,this.changes,5)}}function gC(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,d=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&d.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=d.position=="absolute"||d.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 xC(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 yC(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class rl{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 bC(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class bC extends oi{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 ih{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=nh,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ye.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(gu).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new cC(t),this.stateDeco=e.facet(cs).filter(n=>typeof n!="function"),this.heightMap=Xe.empty().applyChanges(this.stateDeco,oe.empty,this.heightOracle.setDoc(e.doc),[new mt(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 Ys(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?nh:new Su(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(Hn(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(cs).filter(c=>typeof c!="function");let s=e.changedRanges,r=mt.extendWithRanges(s,pC(n,this.stateDeco,e?e.changes:je.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);eh(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||Rn)&&(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(Ep)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),s=this.heightOracle,r=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?ye.RTL:ye.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:E,scaleY:v}=Qf(t,l);(E>.005&&Math.abs(this.scaleX-E)>.005||v>.005&&Math.abs(this.scaleY-v)>.005)&&(this.scaleX=E,this.scaleY=v,u|=16,o=a=!0)}let d=(parseInt(n.paddingTop)||0)*this.scaleY,f=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=d||this.paddingBottom!=f)&&(this.paddingTop=d,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=ep(e.scrollDOM);let m=(this.printing?yC:gC)(t,this.paddingTop),g=m.top-this.pixelViewport.top,x=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;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&&!xC(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 E=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(E)&&(o=!0),o||s.lineWrapping&&Math.abs(b-this.contentDOMWidth)>s.charWidth){let{lineHeight:v,charWidth:C,textHeight:k}=e.docView.measureTextSize();o=v>0&&s.refresh(r,v,C,k,Math.max(5,b/C),E),o&&(e.docView.minWidth=0,u|=16)}g>0&&x>0?c=Math.max(g,x):g<0&&x<0&&(c=Math.min(g,x)),eh();for(let v of this.viewports){let C=v.from==this.viewport.from?E:e.docView.measureVisibleLineHeights(v);this.heightMap=(o?Xe.empty().applyChanges(this.stateDeco,oe.empty,this.heightOracle,[new mt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new hC(v.from,C))}Rn&&(u|=2)}let S=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return S&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),u|=this.updateForViewport()),(u&2||S)&&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 Ys(s.lineAt(o-n*1e3,xe.ByHeight,r,0,0).from,s.lineAt(l+(1-n)*1e3,xe.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),d=s.lineAt(u,xe.ByPos,r,0,0),f;t.y=="center"?f=(d.top+d.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&u<a.from?f=d.top:f=d.bottom-c,a=new Ys(s.lineAt(f-1e3/2,xe.ByHeight,r,0,0).from,s.lineAt(f+c+1e3/2,xe.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 Ys(this.heightMap.lineAt(n,xe.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,xe.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,xe.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,xe.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 rl(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!=ye.LTR&&!n)return[];let l=[],a=(c,d,f,p)=>{if(d-c<r)return;let m=this.state.selection.main,g=[m.from];m.empty||g.push(m.to);for(let y of g)if(y>c&&y<d){a(c,y-10,f,p),a(y+10,d,f,p);return}let x=vC(e,y=>y.from>=f.from&&y.to<=f.to&&Math.abs(y.from-c)<r&&Math.abs(y.to-d)<r&&!g.some(b=>y.from<b&&y.to>b));if(!x){if(d<f.to&&t&&n&&t.visibleRanges.some(S=>S.from<=d&&S.to>=d)){let S=t.moveToLineBoundary(O.cursor(d),!1,!0).head;S>c&&(d=S)}let y=this.gapSize(f,c,d,p),b=n||y<2e6?y:2e6;x=new rl(c,d,y,b)}l.push(x)},u=c=>{if(c.length<o||c.type!=Ye.Text)return;let d=SC(c.from,c.to,this.stateDeco);if(d.total<o)return;let f=this.scrollTarget?this.scrollTarget.range.head:null,p,m;if(n){let g=s/this.heightOracle.lineLength*this.heightOracle.lineHeight,x,y;if(f!=null){let b=Qs(d,f),S=((this.visibleBottom-this.visibleTop)/2+g)/c.height;x=b-S,y=b+S}else x=(this.visibleTop-c.top-g)/c.height,y=(this.visibleBottom-c.top+g)/c.height;p=Xs(d,x),m=Xs(d,y)}else{let g=d.total*this.heightOracle.charWidth,x=s*this.heightOracle.charWidth,y=0;if(g>2e6)for(let C of e)C.from>=c.from&&C.from<c.to&&C.size!=C.displaySize&&C.from*this.heightOracle.charWidth+y<this.pixelViewport.left&&(y=C.size-C.displaySize);let b=this.pixelViewport.left+y,S=this.pixelViewport.right+y,E,v;if(f!=null){let C=Qs(d,f),k=((S-b)/2+x)/g;E=C-k,v=C+k}else E=(b-x)/g,v=(S+x)/g;p=Xs(d,E),m=Xs(d,v)}p>c.from&&a(c.from,p,c,d),m<c.to&&a(m,c.to,c,d)};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=Qs(s,n)-Qs(s,t);return this.heightOracle.lineWrapping?e.height*r:s.total*this.heightOracle.charWidth*r}updateLineGaps(e){rl.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)||Hn(this.heightMap.lineAt(e,xe.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)||Hn(this.heightMap.lineAt(this.scaler.fromDOM(e),xe.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 Hn(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 Ys{constructor(e,t){this.from=e,this.to=t}}function SC(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 Xs({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 Qs(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 vC(i,e){for(let t of i)if(e(t))return t}const nh={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}};class Su{constructor(e,t,n){let s=0,r=0,o=0;this.viewports=n.map(({from:l,to:a})=>{let u=t.lineAt(l,xe.ByPos,e,0,0).top,c=t.lineAt(a,xe.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 Su?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 Hn(i,e){if(e.scale==1)return i;let t=e.toDOM(i.top),n=e.toDOM(i.bottom);return new Bt(i.from,i.length,t,n-t,Array.isArray(i._content)?i._content.map(s=>Hn(s,e)):i._content)}const Js=G.define({combine:i=>i.join(" ")}),ya=G.define({combine:i=>i.indexOf(!0)>-1}),ba=Ci.newName(),Gp=Ci.newName(),Up=Ci.newName(),Wp={"&light":"."+Gp,"&dark":"."+Up};function Sa(i,e,t){return new Ci(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 EC=Sa("."+ba,{"&":{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"}},Wp),CC={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},ol=z.ie&&z.ie_version<=11;class wC{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new oE,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 kC(e),e.state.facet(Zt)&&(e.contentDOM.editContext=this.editContext.editContext)),ol&&(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(Zt)?n.root.activeElement!=this.dom:!fr(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&&Yn(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=us(e.root);if(!t)return!1;let n=z.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&RC(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let s=fr(this.dom,n);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&aE(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,CC),ol&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),ol&&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&&mn(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&&fr(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 HE(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=Pp(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=sh(t,e.previousSibling||e.target.previousSibling,-1),s=sh(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(Zt)!=e.state.facet(Zt)&&(e.view.contentDOM.editContext=e.state.facet(Zt)?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 sh(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 rh(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 Yn(o.node,o.offset,s,r)&&([t,n,s,r]=[s,r,t,n]),{anchorNode:t,anchorOffset:n,focusNode:s,focusOffset:r}}function RC(i,e){if(e.getComposedRanges){let s=e.getComposedRanges(i.root)[0];if(s)return rh(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?rh(i,t):null}class kC{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=Dp(e.state.sliceDoc(l,a),n.text,(u?s.from:s.to)-l,u?"end":null);if(!c){let f=O.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));f.main.eq(s)||e.dispatch({selection:f,userEvent:"select"});return}let d={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)&&d.from==o-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(d={from:l,to:a,insert:oe.of([n.text.replace("."," ")])}),this.pendingContextChange=d,!e.state.readOnly){let f=this.to-this.from+(d.to-d.from+d.insert.length);yu(e,d,O.single(this.toEditorPos(n.selectionStart,f),this.toEditorPos(n.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),d.from<d.to&&!d.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:wp.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=us(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||lE(e.parent)||document,this.viewState=new ih(e.state||se.create(e)),e.scrollTo&&e.scrollTo.is(Ws)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ln).map(s=>new il(s));for(let s of this.plugins)s.update(this);this.observer=new wC(this),this.inputState=new qE(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Fc(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 Oe?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(_p))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=zp(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=Br.create(this,r,e),s.flags|=l;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(d&&(d=d.map(f.changes)),f.scrollIntoView){let{main:p}=f.state.selection;d=new gn(p.empty?p:O.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of f.effects)p.is(Ws)&&(d=p.value.clip(this.state))}this.viewState.update(s,d),this.bidiCache=_r.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(zn)!=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(Js)!=s.state.facet(Js)&&(this.viewState.mustMeasureContent=!0),(t||n||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let f of this.state.facet(pa))try{f(s)}catch(p){et(this.state,p,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Pp(this,c)&&u.force&&mn(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 ih(e),this.plugins=e.facet(ln).map(n=>new il(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new Fc(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(ln),n=e.state.facet(ln);if(t!=n){let s=[];for(let r of n){let o=t.indexOf(r);if(o<0)s.push(new il(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){et(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(ep(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(m){return et(this.state,m),oh}}),d=Br.create(this,this.state,[]),f=!1;d.flags|=a,t?t.flags|=a:t=d,this.updateState=2,d.empty||(this.updatePlugins(d),this.inputState.update(d),this.updateAttrs(),f=this.docView.update(d),f&&this.docViewUpdate());for(let p=0;p<u.length;p++)if(c[p]!=oh)try{let m=u[p];m.write&&m.write(c[p],this)}catch(m){et(this.state,m)}if(f&&this.docView.updateSelection(!0),!d.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 m=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-o;if(m>1||m<-1){s=s+m,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(pa))l(t)}get themeClasses(){return ba+" "+(this.state.facet(ya)?Up:Gp)+" "+this.state.facet(Js)}updateAttrs(){let e=lh(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(Zt)?"true":"false",class:"cm-content",style:`${z.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),lh(this,gu,t);let n=this.observer.ignore(()=>{let s=ua(this.contentDOM,this.contentAttrs,t),r=ua(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(zn);let e=this.state.facet(_.cspNonce);Ci.mount(this.root,this.styleModules.concat(EC).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 sl(this,e,$c(this,e,t,n))}moveByGroup(e,t){return sl(this,e,$c(this,e,t,n=>BE(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 O.cursor(r.side(t,s)+e.from,r.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,n=!0){return FE(this,e,t,n)}moveVertically(e,t,n){return sl(this,e,VE(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(),Op(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[xi.find(r,e-s.from,-1,t)];return Cs(n,o.dir==ye.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(vp)||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>TC)return fp(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||dp(r.isolates,n=Nc(this,e))))return r.order;n||(n=Nc(this,e));let s=vE(e.text,t,n);return this.bidiCache.push(new _r(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 Ws.of(new gn(typeof e=="number"?O.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 Ws.of(new gn(O.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=Ci.newName(),s=[Js.of(n),zn.of(Sa(`.${n}`,e))];return t&&t.dark&&s.push(ya.of(!0)),s}static baseTheme(e){return Xi.lowest(zn.of(Sa("."+ba,e,Wp)))}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=zn;_.inputHandler=bp;_.clipboardInputFilter=pu;_.clipboardOutputFilter=mu;_.scrollHandler=Cp;_.focusChangeEffect=Sp;_.perLineTextDirection=vp;_.exceptionSink=yp;_.updateListener=pa;_.editable=Zt;_.mouseSelectionStyle=xp;_.dragMovesSelection=gp;_.clickAddsSelectionRange=mp;_.decorations=cs;_.outerDecorations=kp;_.atomicRanges=ks;_.bidiIsolatedRanges=Tp;_.scrollMargins=Ap;_.darkTheme=ya;_.cspNonce=G.define({combine:i=>i.length?i[0]:""});_.contentAttributes=gu;_.editorAttributes=Rp;_.lineWrapping=_.contentAttributes.of({class:"cm-lineWrapping"});_.announce=J.define();const TC=4096,oh={};class _r{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:ye.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 _r(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function lh(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&&aa(o,t)}return t}const AC=z.mac?"mac":z.windows?"win":z.linux?"linux":"key";function jC(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 OC=Xi.default(_.domEventHandlers({keydown(i,e){return Kp(qp(e.state),i,e,"editor")}})),So=G.define({enables:OC}),ah=new WeakMap;function qp(i){let e=i.facet(So),t=ah.get(e);return t||ah.set(e,t=PC(e.reduce((n,s)=>n.concat(s),[]))),t}function IC(i,e,t){return Kp(qp(i.state),e,i,t)}let fi=null;const MC=4e3;function PC(i,e=AC){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 d,f;let p=t[o]||(t[o]=Object.create(null)),m=l.split(/ (?!$)/).map(y=>jC(y,e));for(let y=1;y<m.length;y++){let b=m.slice(0,y).join(" ");s(b,!0),p[b]||(p[b]={preventDefault:!0,stopPropagation:!1,run:[S=>{let E=fi={view:S,prefix:b,scope:o};return setTimeout(()=>{fi==E&&(fi=null)},MC),!0}]})}let g=m.join(" ");s(g,!1);let x=p[g]||(p[g]={preventDefault:!1,stopPropagation:!1,run:((f=(d=p._any)===null||d===void 0?void 0:d.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:d}=o;for(let f in c)c[f].run.push(p=>d(p,va))}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 va=null;function Kp(i,e,t,n){va=e;let s=tE(e),r=Je(s,0),o=Ft(r)==s.length&&s!=" ",l="",a=!1,u=!1,c=!1;fi&&fi.view==t&&fi.scope==n&&(l=fi.prefix+" ",Np.indexOf(e.keyCode)<0&&(u=!0,fi=null));let d=new Set,f=x=>{if(x){for(let y of x.run)if(!d.has(y)&&(d.add(y),y(t)))return x.stopPropagation&&(c=!0),!0;x.preventDefault&&(x.stopPropagation&&(c=!0),u=!0)}return!1},p=i[n],m,g;return p&&(f(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))&&(m=wi[e.keyCode])&&m!=s?(f(p[l+Zs(m,e,!0)])||e.shiftKey&&(g=as[e.keyCode])!=s&&g!=m&&f(p[l+Zs(g,e,!1)]))&&(a=!0):o&&e.shiftKey&&f(p[l+Zs(s,e,!0)])&&(a=!0),!a&&f(p._any)&&(a=!0)),u&&(a=!0),a&&c&&e.stopPropagation(),va=null,a}class Ts{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=Yp(e);return[new Ts(t,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return DC(e,t,n)}}function Yp(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==ye.LTR?e.left:e.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:e.top-i.scrollDOM.scrollTop*i.scaleY}}function uh(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 DC(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==ye.LTR,o=i.contentDOM,l=o.getBoundingClientRect(),a=Yp(i),u=o.querySelector(".cm-line"),c=u&&window.getComputedStyle(u),d=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),f=l.right-(c?parseInt(c.paddingRight):0),p=ga(i,n,1),m=ga(i,s,-1),g=p.type==Ye.Text?p:null,x=m.type==Ye.Text?m:null;if(g&&(i.lineWrapping||p.widgetLineBreaks)&&(g=uh(i,n,1,g)),x&&(i.lineWrapping||m.widgetLineBreaks)&&(x=uh(i,s,-1,x)),g&&x&&g.from==x.from&&g.to==x.to)return b(S(t.from,t.to,g));{let v=g?S(t.from,null,g):E(p,!1),C=x?S(null,t.to,x):E(m,!0),k=[];return(g||p).to<(x||m).from-(g&&x?1:0)||p.widgetLineBreaks>1&&v.bottom+i.defaultLineHeight/2<C.top?k.push(y(d,v.bottom,f,C.top)):v.bottom<C.top&&i.elementAtHeight((v.bottom+C.top)/2).type==Ye.Text&&(v.bottom=C.top=(v.bottom+C.top)/2),b(v).concat(k).concat(b(C))}function y(v,C,k,j){return new Ts(e,v-a.left,C-a.top,k-v,j-C)}function b({top:v,bottom:C,horizontal:k}){let j=[];for(let R=0;R<k.length;R+=2)j.push(y(k[R],v,k[R+1],C));return j}function S(v,C,k){let j=1e9,R=-1e9,H=[];function N(P,L,W,ee,ae){let ne=i.coordsAtPos(P,P==k.to?-2:2),te=i.coordsAtPos(W,W==k.from?2:-2);!ne||!te||(j=Math.min(ne.top,te.top,j),R=Math.max(ne.bottom,te.bottom,R),ae==ye.LTR?H.push(r&&L?d:ne.left,r&&ee?f:te.right):H.push(!r&&ee?d:te.left,!r&&L?f:ne.right))}let B=v??k.from,$=C??k.to;for(let P of i.visibleRanges)if(P.to>B&&P.from<$)for(let L=Math.max(P.from,B),W=Math.min(P.to,$);;){let ee=i.state.doc.lineAt(L);for(let ae of i.bidiSpans(ee)){let ne=ae.from+ee.from,te=ae.to+ee.from;if(ne>=W)break;te>L&&N(Math.max(ne,L),v==null&&ne<=B,Math.min(te,W),C==null&&te>=$,ae.dir)}if(L=ee.to+1,L>=W)break}return H.length==0&&N(B,v==null,$,C==null,i.textDirection),{top:j,bottom:R,horizontal:H}}function E(v,C){let k=l.top+(C?v.top:v.bottom);return{top:k,bottom:k,horizontal:[]}}}function LC(i,e){return i.constructor==e.constructor&&i.eq(e)}class NC{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(gr)!=e.state.facet(gr)&&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(gr);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)=>!LC(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 gr=G.define();function Xp(i){return[Ce.define(e=>new NC(e,i)),gr.of(i)]}const hs=G.define({combine(i){return Kt(i,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function FC(i={}){return[hs.of(i),BC,VC,_C,Ep.of(!0)]}function Qp(i){return i.startState.facet(hs)!=i.state.facet(hs)}const BC=Xp({above:!0,markers(i){let{state:e}=i,t=e.facet(hs),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:O.cursor(s.head,s.head>s.anchor?-1:1);for(let a of Ts.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=Qp(i);return t&&ch(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){ch(e.state,i)},class:"cm-cursorLayer"});function ch(i,e){e.style.animationDuration=i.facet(hs).cursorBlinkRate+"ms"}const VC=Xp({above:!1,markers(i){return i.state.selection.ranges.map(e=>e.empty?[]:Ts.forRange(i,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||Qp(i)},class:"cm-selectionLayer"}),_C=Xi.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)}}),Gn=Be.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)}}),zC=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(Gn);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(Gn)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:i}=this,e=i.state.field(Gn),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(Gn)!=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 $C(){return[Gn,zC]}function hh(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 HC(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 GC{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 d=n(l,a,u);d&&c(u,u+l[0].length,d)};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 ni,n=t.add.bind(t);for(let{from:s,to:r}of HC(e,this.maxLength))hh(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),d=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])){d=l;break}}let f=[],p,m=(g,x,y)=>f.push(y.range(g,x));if(a==u)for(this.regexp.lastIndex=c-a.from;(p=this.regexp.exec(a.text))&&p.index<d-a.from;)this.addMatch(p,e,p.index+a.from,m);else hh(e.state.doc,this.regexp,c,d,(g,x)=>this.addMatch(x,e,g,m));t=t.update({filterFrom:c,filterTo:d,filter:(g,x)=>g<c||x>d,add:f})}}return t}}const Ea=/x/.unicode!=null?"gu":"g",UC=new RegExp(`[\0-\b
|
|
33
|
-
--\u2028\u2029\uFEFF-]`,Ea),WC={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 ll=null;function qC(){var i;if(ll==null&&typeof document<"u"&&document.body){let e=document.body.style;ll=((i=e.tabSize)!==null&&i!==void 0?i:e.MozTabSize)!=null}return ll||!1}const xr=G.define({combine(i){let e=Kt(i,{render:null,specialChars:UC,addSpecialChars:null});return(e.replaceTabs=!qC())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Ea)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Ea)),e}});function KC(i={}){return[xr.of(i),YC()]}let dh=null;function YC(){return dh||(dh=Ce.fromClass(class{constructor(i){this.view=i,this.decorations=K.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(i.state.facet(xr)),this.decorations=this.decorator.createDeco(i)}makeDecorator(i){return new GC({regexp:i.specialChars,decoration:(e,t,n)=>{let{doc:s}=t.state,r=Je(e[0],0);if(r==9){let o=s.lineAt(n),l=t.state.tabSize,a=jn(o.text,l,n-o.from);return K.replace({widget:new ZC((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=K.replace({widget:new JC(i,r)}))},boundary:i.replaceTabs?void 0:/[^]/})}update(i){let e=i.state.facet(xr);i.startState.facet(xr)!=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 XC="•";function QC(i){return i>=32?XC:i==10?"":String.fromCharCode(9216+i)}class JC extends oi{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=QC(this.code),n=e.state.phrase("Control character")+" "+(WC[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 ZC extends oi{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 e1(){return i1}const t1=K.line({class:"cm-activeLine"}),i1=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(t1.range(s.from)),e=s.from)}return K.set(t)}},{decorations:i=>i.decorations});class n1 extends oi{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?En(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 s1(i){let e=Ce.fromClass(class{constructor(t){this.view=t,this.placeholder=i?K.set([K.widget({widget:new n1(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 Ca=2e3;function r1(i,e,t){let n=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>Ca||t.off>Ca||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(O.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=ea(u.text,o,i.tabSize,!0);if(c<0)r.push(O.cursor(u.to));else{let d=ea(u.text,l,i.tabSize);r.push(O.range(u.from+c,u.from+d))}}}return r}function o1(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function fh(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>Ca?-1:s==n.length?o1(i,e.clientX):jn(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:r,off:s}}function l1(i,e){let t=fh(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=fh(i,s);if(!l)return n;let a=r1(i.state,t,l);return a.length?o?O.create(a.concat(n.ranges)):O.create(a):n}}:null}function a1(i){let e=(t=>t.altKey&&t.button==0);return _.mouseSelectionStyle.of((t,n)=>e(n)?l1(t,n):null)}const u1={Alt:[18,i=>!!i.altKey],Control:[17,i=>!!i.ctrlKey],Shift:[16,i=>!!i.shiftKey],Meta:[91,i=>!!i.metaKey]},c1={style:"cursor: crosshair"};function h1(i={}){let[e,t]=u1[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?c1:null})]}const er="-10000px";class Zp{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 d=0;d<this.tooltips.length;d++){let f=this.tooltips[d];f&&f.create==u.create&&(c=d)}if(c<0)o[a]=this.createTooltipView(u,a?o[a-1]:null),l&&(l[a]=!!u.above);else{let d=o[a]=this.tooltipViews[c];l&&(l[a]=t[c]),d.update&&d.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 d1(i){let e=i.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const al=G.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)||d1}}}),ph=new WeakMap,vu=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(al);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 Zp(i,Eu,(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(al);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=er,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=xu(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(al).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,d=i.pos[l],f=i.size[l];if(!d||a.clip!==!1&&(d.bottom<=Math.max(t.top,n.top)||d.top>=Math.min(t.bottom,n.bottom)||d.right<Math.max(t.left,n.left)-.1||d.left>Math.min(t.right,n.right)+.1)){c.style.top=er;continue}let p=a.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,m=p?7:0,g=f.right-f.left,x=(e=ph.get(u))!==null&&e!==void 0?e:f.bottom-f.top,y=u.offset||p1,b=this.view.textDirection==ye.LTR,S=f.width>n.right-n.left?b?n.left:n.right-f.width:b?Math.max(n.left,Math.min(d.left-(p?14:0)+y.x,n.right-g)):Math.min(Math.max(n.left,d.left-g+(p?14:0)-y.x),n.right-g),E=this.above[l];!a.strictSide&&(E?d.top-x-m-y.y<n.top:d.bottom+x+m+y.y>n.bottom)&&E==n.bottom-d.bottom>d.top-n.top&&(E=this.above[l]=!E);let v=(E?d.top-n.top:n.bottom-d.bottom)-m;if(v<x&&u.resize!==!1){if(v<this.view.defaultLineHeight){c.style.top=er;continue}ph.set(u,x),c.style.height=(x=v)/r+"px"}else c.style.height&&(c.style.height="");let C=E?d.top-x-m-y.y:d.bottom+m+y.y,k=S+g;if(u.overlap!==!0)for(let j of o)j.left<k&&j.right>S&&j.top<C+x&&j.bottom>C&&(C=E?j.top-x-2-m:j.bottom+m+2);if(this.position=="absolute"?(c.style.top=(C-i.parent.top)/r+"px",mh(c,(S-i.parent.left)/s)):(c.style.top=C/r+"px",mh(c,S/s)),p){let j=d.left+(b?y.x:-y.x)-(S+14-7);p.style.left=j/s+"px"}u.overlap!==!0&&o.push({left:S,top:C,right:k,bottom:C+x}),c.classList.toggle("cm-tooltip-above",E),c.classList.toggle("cm-tooltip-below",!E),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=er}},{eventObservers:{scroll(){this.maybeMeasure()}}});function mh(i,e){let t=parseInt(i.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(i.style.left=e+"px")}const f1=_.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"}}}),p1={x:0,y:0},Eu=G.define({enables:[vu,f1]}),zr=G.define({combine:i=>i.reduce((e,t)=>e.concat(t),[])});class vo{static create(e){return new vo(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Zp(e,zr,(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 m1=Eu.compute([zr],i=>{let e=i.facet(zr);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:vo.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class g1{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 ei)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==ye.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=>et(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(vu),t=e?e.manager.tooltips.findIndex(n=>n.create==vo.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&&!x1(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:!y1(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 tr=4;function x1(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-tr&&e.clientX<=n+tr&&e.clientY>=s-tr&&e.clientY<=r+tr}function y1(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 b1(i,e={}){let t=J.define(),n=Be.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,Ke.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(S1)&&(s=[]);return s},provide:s=>zr.from(s)});return{active:n,extension:[n,Ce.define(s=>new g1(s,i,n,t,e.hoverTime||300)),m1]}}function em(i,e){let t=i.plugin(vu);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}const S1=J.define(),gh=G.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 ds(i,e){let t=i.plugin(tm),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}const tm=Ce.fromClass(class{constructor(i){this.input=i.state.facet(fs),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(gh);this.top=new ir(i,!0,e.topContainer),this.bottom=new ir(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(gh);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new ir(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new ir(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(fs);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 ir{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=xh(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=xh(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 xh(i){let e=i.nextSibling;return i.remove(),e}const fs=G.define({enables:tm});class ri extends Hi{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}ri.prototype.elementClass="";ri.prototype.toDOM=void 0;ri.prototype.mapMode=Ke.TrackBefore;ri.prototype.startSide=ri.prototype.endSide=-1;ri.prototype.point=!0;const yr=G.define(),v1=G.define(),E1={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>re.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Jn=G.define();function C1(i){return[im(),Jn.of({...E1,...i})]}const yh=G.define({combine:i=>i.some(e=>e)});function im(i){return[w1]}const w1=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(Jn).map(e=>new Sh(i,e)),this.fixed=!i.state.facet(yh);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(yh)!=!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(yr),this.view.viewport.from),n=[],s=this.gutters.map(r=>new R1(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==Ye.Text&&o){wa(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==Ye.Text){wa(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(Jn),t=i.state.facet(Jn),n=i.docChanged||i.heightChanged||i.viewportChanged||!re.eq(i.startState.facet(yr),i.state.facet(yr),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 Sh(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==ye.LTR?{left:n,right:s}:{right:n,left:s}})});function bh(i){return Array.isArray(i)?i:[i]}function wa(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}class R1{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 nm(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=[];wa(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(v1)){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 Sh{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=bh(t.markers(e)),t.initialSpacer&&(this.spacer=new nm(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=bh(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 nm{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":""),k1(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 d=o;d<this.markers.length;d++)if(this.markers[d].compare(a)){l=d,u=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(s);let d=s.nextSibling;s.remove(),s=d}}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 k1(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 T1=G.define(),A1=G.define(),an=G.define({combine(i){return Kt(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 ul extends ri{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function cl(i,e){return i.state.facet(an).formatNumber(e,i.state)}const j1=Jn.compute([an],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(T1)},lineMarker(e,t,n){return n.some(s=>s.toDOM)?null:new ul(cl(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let s of e.state.facet(A1)){let r=s(e,t,n);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(an)!=e.state.facet(an),initialSpacer(e){return new ul(cl(e,vh(e.state.doc.lines)))},updateSpacer(e,t){let n=cl(t.view,vh(t.view.state.doc.lines));return n==e.number?e:new ul(n)},domEventHandlers:i.facet(an).domEventHandlers,side:"before"}));function O1(i={}){return[an.of(i),im(),j1]}function vh(i){let e=9;for(;e<i;)e=e*10+9;return e}const I1=new class extends ri{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},M1=yr.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(I1.range(s)))}return re.of(e)});function P1(){return M1}var hl;const un=new ie;function D1(i){return G.define({combine:i?e=>e.concat(i):void 0})}const L1=new ie;class St{constructor(e,t,n=[],s=""){this.data=e,this.name=s,se.prototype.hasOwnProperty("tree")||Object.defineProperty(se.prototype,"tree",{get(){return Ge(this)}}),this.parser=t,this.extension=[ki.of(this),se.languageData.of((r,o,l)=>{let a=Eh(r,o,l),u=a.type.prop(un);if(!u)return[];let c=r.facet(u),d=a.type.prop(L1);if(d){let f=a.resolve(o-a.from,l);for(let p of d)if(p.test(f,r)){let m=r.facet(p.facet);return p.type=="replace"?m:m.concat(c)}}return c})].concat(n)}isActiveAt(e,t,n=-1){return Eh(e,t,n).type.prop(un)==this.data}findRegions(e){let t=e.facet(ki);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(un)==this.data){n.push({from:o,to:o+r.length});return}let l=r.prop(ie.mounted);if(l){if(l.tree.prop(un)==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 Te&&s(u,r.positions[a]+o)}};return s(Ge(e),0),n}get allowsNesting(){return!0}}St.setState=J.define();function Eh(i,e,t){let n=i.facet(ki),s=Ge(i).topNode;if(!n||n.allowsNesting)for(let r=s;r;r=r.enter(e,t,Pe.ExcludeBuffers))r.type.isTop&&(s=r);return s}class $r extends St{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=D1(e.languageData);return new $r(t,e.parser.configure({props:[un.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new $r(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Ge(i){let e=i.field(St.state,!1);return e?e.tree:Te.empty}class N1{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 Bn=null;class Hr{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 Hr(e,t,[],Te.empty,0,n,[],null)}startParse(){return this.parser.startParse(new N1(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Te.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(_i.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(_i.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Bn;Bn=this;try{return e()}finally{Bn=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Ch(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,d,f)=>a.push({fromA:u,toA:c,fromB:d,toB:f})),n=_i.applyChanges(n,a),s=Te.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),d=e.mapPos(u.to,-1);c<d&&l.push({from:c,to:d})}}}return new Hr(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=Ch(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 Tf{createParse(t,n,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=Bn;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 Te(nt.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 Bn}}function Ch(i,e,t){return _i.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}class kn{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 kn(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Hr.create(e.facet(ki).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new kn(n)}}St.state=Be.define({create:kn.init,update(i,e){for(let t of e.effects)if(t.is(St.setState))return t.value;return e.startState.facet(ki)!=e.state.facet(ki)?kn.init(e.state):i.apply(e)}});let sm=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(sm=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const dl=typeof navigator<"u"&&(!((hl=navigator.scheduling)===null||hl===void 0)&&hl.isInputPending)?()=>navigator.scheduling.isInputPending():null,F1=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(St.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(St.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=sm(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(St.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!dl?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<s&&n.doc.length>s+1e3,a=r.context.work(()=>dl&&dl()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:St.setState.of(new kn(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=>et(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()}}}),ki=G.define({combine(i){return i.length?i[0]:null},enables:i=>[St.state,F1,_.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});class B1{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const V1=G.define(),Eo=G.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 Gr(i){let e=i.facet(Eo);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function ps(i,e){let t="",n=i.tabSize,s=i.facet(Eo)[0];if(s==" "){for(;e>=n;)t+=" ",e-=n;s=" "}for(let r=0;r<e;r++)t+=s;return t}function Cu(i,e){i instanceof se&&(i=new Co(i));for(let n of i.state.facet(V1)){let s=n(i,e);if(s!==void 0)return s}let t=Ge(i.state);return t.length>=e?_1(i,t,e):null}class Co{constructor(e,t={}){this.state=e,this.options=t,this.unit=Gr(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 jn(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 rm=new ie;function _1(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 om(n,i,t)}function om(i,e,t){for(let n=i;n;n=n.next){let s=$1(n.node);if(s)return s(wu.create(e,t,n))}return 0}function z1(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function $1(i){let e=i.type.prop(rm);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(ie.closedBy))){let s=i.lastChild,r=s&&n.indexOf(s.name)>-1;return o=>W1(o,!0,1,void 0,r&&!z1(o)?s.from:void 0)}return i.parent==null?H1:null}function H1(){return 0}class wu extends Co{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 wu(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(G1(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return om(this.context.next,this.base,this.pos)}}function G1(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function U1(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 W1(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=U1(i);return a?l?i.column(a.from):i.column(a.to):i.baseIndent+(l?0:i.unit*t)}function wh({except:i,units:e=1}={}){return t=>{let n=i&&i.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}const q1=200;function K1(){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+q1)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 d=Cu(o,c.from);if(d==null)continue;let f=/^\s*/.exec(c.text)[0],p=ps(o,d);f!=p&&a.push({from:c.from,to:c.from+f.length,insert:p})}return a.length?[i,{changes:a,sequential:!0}]:i})}const Y1=G.define(),lm=new ie;function X1(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 Q1(i,e,t){let n=Ge(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(lm);if(a&&(l.to<n.length-50||n.length==i.doc.length||!J1(l))){let u=a(l,i);u&&u.from<=t&&u.from>=e&&u.to>t&&(r=u)}}return r}function J1(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function Ur(i,e,t){for(let n of i.facet(Y1)){let s=n(i,e,t);if(s)return s}return Q1(i,e,t)}function am(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 wo=J.define({map:am}),As=J.define({map:am});function um(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 qi=Be.define({create(){return K.none},update(i,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((t,n)=>i=Rh(i,t,n)),i=i.map(e.changes);for(let t of e.effects)if(t.is(wo)&&!Z1(i,t.value.from,t.value.to)){let{preparePlaceholder:n}=e.state.facet(dm),s=n?K.replace({widget:new ow(n(e.state,t.value))}):kh;i=i.update({add:[s.range(t.value.from,t.value.to)]})}else t.is(As)&&(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=Rh(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(kh.range(n,s))}return K.set(e,!0)}});function Rh(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 Wr(i,e,t){var n;let s=null;return(n=i.field(qi,!1))===null||n===void 0||n.between(e,t,(r,o)=>{(!s||s.from>r)&&(s={from:r,to:o})}),s}function Z1(i,e,t){let n=!1;return i.between(e,e,(s,r)=>{s==e&&r==t&&(n=!0)}),n}function cm(i,e){return i.field(qi,!1)?e:e.concat(J.appendConfig.of(fm()))}const ew=i=>{for(let e of um(i)){let t=Ur(i.state,e.from,e.to);if(t)return i.dispatch({effects:cm(i.state,[wo.of(t),hm(i,t)])}),!0}return!1},tw=i=>{if(!i.state.field(qi,!1))return!1;let e=[];for(let t of um(i)){let n=Wr(i.state,t.from,t.to);n&&e.push(As.of(n),hm(i,n,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function hm(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 iw=i=>{let{state:e}=i,t=[];for(let n=0;n<e.doc.length;){let s=i.lineBlockAt(n),r=Ur(e,s.from,s.to);r&&t.push(wo.of(r)),n=(r?i.lineBlockAt(r.to):s).to+1}return t.length&&i.dispatch({effects:cm(i.state,t)}),!!t.length},nw=i=>{let e=i.state.field(qi,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,i.state.doc.length,(n,s)=>{t.push(As.of({from:n,to:s}))}),i.dispatch({effects:t}),!0},sw=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:ew},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:tw},{key:"Ctrl-Alt-[",run:iw},{key:"Ctrl-Alt-]",run:nw}],rw={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},dm=G.define({combine(i){return Kt(i,rw)}});function fm(i){return[qi,uw]}function pm(i,e){let{state:t}=i,n=t.facet(dm),s=o=>{let l=i.lineBlockAt(i.posAtDOM(o.target)),a=Wr(i.state,l.from,l.to);a&&i.dispatch({effects:As.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 kh=K.replace({widget:new class extends oi{toDOM(i){return pm(i,null)}}});class ow extends oi{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return pm(e,this.value)}}const lw={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class fl extends ri{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 aw(i={}){let e={...lw,...i},t=new fl(e,!0),n=new fl(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(ki)!=o.state.facet(ki)||o.startState.field(qi,!1)!=o.state.field(qi,!1)||Ge(o.startState)!=Ge(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new ni;for(let a of o.viewportLineBlocks){let u=Wr(o.state,a.from,a.to)?n:Ur(o.state,a.from,a.to)?t:null;u&&l.add(a.from,a.from,u)}return l.finish()}}),{domEventHandlers:r}=e;return[s,C1({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 fl(e,!1)},domEventHandlers:{...r,click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let u=Wr(o.state,l.from,l.to);if(u)return o.dispatch({effects:As.of(u)}),!0;let c=Ur(o.state,l.from,l.to);return c?(o.dispatch({effects:wo.of(c)}),!0):!1}}}),fm()]}const uw=_.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 js{constructor(e,t){this.specs=e;let n;function s(l){let a=Ci.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 St?l=>l.prop(un)==o.data:o?l=>l==o:void 0,this.style=Of(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=n?new Ci(n):null,this.themeType=t.themeType}static define(e,t){return new js(e,t||{})}}const Ra=G.define(),mm=G.define({combine(i){return i.length?[i[0]]:null}});function pl(i){let e=i.facet(Ra);return e.length?e:i.facet(mm)}function gm(i,e){let t=[hw],n;return i instanceof js&&(i.module&&t.push(_.styleModule.of(i.module)),n=i.themeType),e!=null&&e.fallback?t.push(mm.of(i)):n?t.push(Ra.computeN([_.darkTheme],s=>s.facet(_.darkTheme)==(n=="dark")?[i]:[])):t.push(Ra.of(i)),t}class cw{constructor(e){this.markCache=Object.create(null),this.tree=Ge(e.state),this.decorations=this.buildDeco(e,pl(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Ge(e.state),n=pl(e.state),s=n!=pl(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 ni;for(let{from:s,to:r}of e.visibleRanges)Av(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 hw=Xi.high(Ce.fromClass(cw,{decorations:i=>i.decorations})),dw=js.define([{tag:T.meta,color:"#404740"},{tag:T.link,textDecoration:"underline"},{tag:T.heading,textDecoration:"underline",fontWeight:"bold"},{tag:T.emphasis,fontStyle:"italic"},{tag:T.strong,fontWeight:"bold"},{tag:T.strikethrough,textDecoration:"line-through"},{tag:T.keyword,color:"#708"},{tag:[T.atom,T.bool,T.url,T.contentSeparator,T.labelName],color:"#219"},{tag:[T.literal,T.inserted],color:"#164"},{tag:[T.string,T.deleted],color:"#a11"},{tag:[T.regexp,T.escape,T.special(T.string)],color:"#e40"},{tag:T.definition(T.variableName),color:"#00f"},{tag:T.local(T.variableName),color:"#30a"},{tag:[T.typeName,T.namespace],color:"#085"},{tag:T.className,color:"#167"},{tag:[T.special(T.variableName),T.macroName],color:"#256"},{tag:T.definition(T.propertyName),color:"#00c"},{tag:T.comment,color:"#940"},{tag:T.invalid,color:"#f00"}]),fw=_.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),xm=1e4,ym="()[]{}",bm=G.define({combine(i){return Kt(i,{afterCursor:!0,brackets:ym,maxScanDistance:xm,renderMatch:gw})}}),pw=K.mark({class:"cm-matchingBracket"}),mw=K.mark({class:"cm-nonmatchingBracket"});function gw(i){let e=[],t=i.matched?pw:mw;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 xw=Be.define({create(){return K.none},update(i,e){if(!e.docChanged&&!e.selection)return i;let t=[],n=e.state.facet(bm);for(let s of e.state.selection.ranges){if(!s.empty)continue;let r=Vt(e.state,s.head,-1,n)||s.head>0&&Vt(e.state,s.head-1,1,n)||n.afterCursor&&(Vt(e.state,s.head,1,n)||s.head<e.state.doc.length&&Vt(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)}),yw=[xw,fw];function bw(i={}){return[bm.of(i),yw]}const Sw=new ie;function ka(i,e,t){let n=i.prop(e<0?ie.openedBy:ie.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 Ta(i){let e=i.type.prop(Sw);return e?e(i.node):i}function Vt(i,e,t,n={}){let s=n.maxScanDistance||xm,r=n.brackets||ym,o=Ge(i),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let u=ka(a.type,t,r);if(u&&a.from<a.to){let c=Ta(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return vw(i,e,t,a,c,u,r)}}return Ew(i,e,t,o,l.type,s,r)}function vw(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 d=Ta(c);return{start:a,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if(ka(c.type,t,o))u++;else if(ka(c.type,-t,o)){if(u==0){let d=Ta(c);return{start:a,end:d&&d.from<d.to?{from:d.from,to:d.to}:void 0,matched:!1}}u--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function Ew(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),d=0;for(let f=0;!c.next().done&&f<=r;){let p=c.value;t<0&&(f+=p.length);let m=e+f*t;for(let g=t>0?0:p.length-1,x=t>0?p.length:-1;g!=x;g+=t){let y=o.indexOf(p[g]);if(!(y<0||n.resolveInner(m+g,1).type!=s))if(y%2==0==t>0)d++;else{if(d==1)return{start:u,end:{from:m+g,to:m+g+1},matched:y>>1==a>>1};d--}}t>0&&(f+=p.length)}return c.done?{start:u,matched:!1}:null}const Cw=Object.create(null),Th=[nt.none],Ah=[],jh=Object.create(null),ww=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"]])ww[i]=Rw(Cw,e);function ml(i,e){Ah.indexOf(i)>-1||(Ah.push(i),console.warn(e))}function Rw(i,e){let t=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let c=i[u]||T[u];c?typeof c=="function"?a.length?a=a.map(c):ml(u,`Modifier ${u} used at start of tag`):a.length?ml(u,`Tag ${u} used as modifier`):a=Array.isArray(c)?c:[c]:ml(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=jh[s];if(r)return r.id;let o=jh[s]=nt.define({id:Th.length,name:n,props:[Af({[n]:t})]});return Th.push(o),o.id}ye.RTL,ye.LTR;const kw=$r.define({name:"json",parser:Mv.configure({props:[rm.add({Object:wh({except:/^\s*\}/}),Array:wh({except:/^\s*\]/})}),lm.add({"Object Array":X1})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function Tw(){return new B1(kw)}const Aw=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=ku(i.state,t.from);return n.line?jw(i):n.block?Iw(i):!1};function Ru(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 jw=Ru(Dw,0),Ow=Ru(Sm,0),Iw=Ru((i,e)=>Sm(i,e,Pw(e)),0);function ku(i,e){let t=i.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const Vn=50;function Mw(i,{open:e,close:t},n,s){let r=i.sliceDoc(n-Vn,n),o=i.sliceDoc(s,s+Vn),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,d;s-n<=2*Vn?c=d=i.sliceDoc(n,s):(c=i.sliceDoc(n,n+Vn),d=i.sliceDoc(s-Vn,s));let f=/^\s*/.exec(c)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-t.length;return c.slice(f,f+e.length)==e&&d.slice(m,m+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(d.charAt(m-1))?1:0}}:null}function Pw(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 Sm(i,e,t=e.selection.ranges){let n=t.map(r=>ku(e,r.from).block);if(!n.every(r=>r))return null;let s=t.map((r,o)=>Mw(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 Dw(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=ku(e,r).line;if(u){for(let c=r;c<=o;){let d=e.doc.lineAt(c);if(d.from>s&&(r==o||o>d.from)){s=d.from;let f=/^\s*/.exec(d.text)[0].length,p=f==d.length,m=d.text.slice(f,f+u.length)==u?f:-1;f<d.text.length&&f<a&&(a=f),n.push({line:d,comment:m,token:u,indent:f,empty:p,single:!1})}c=d.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:d}of n)(d||!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=qt.define(),Lw=qt.define(),Nw=G.define(),vm=G.define({combine(i){return Kt(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)})}}),Em=Be.define({create(){return _t.empty},update(i,e){let t=e.state.facet(vm),n=e.annotation(Aa);if(n){let a=tt.fromTransaction(e,n.selection),u=n.side,c=u==0?i.undone:i.done;return a?c=qr(c,c.length,t.minDepth,a):c=Rm(c,e.startState.selection),new _t(u==0?n.rest:c,u==0?c:n.rest)}let s=e.annotation(Lw);if((s=="full"||s=="before")&&(i=i.isolate()),e.annotation(Oe.addToHistory)===!1)return e.changes.empty?i:i.addMapping(e.changes.desc);let r=tt.fromTransaction(e),o=e.annotation(Oe.time),l=e.annotation(Oe.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 _t(i.done.map(tt.fromJSON),i.undone.map(tt.fromJSON))}});function Fw(i={}){return[Em,vm.of(i),_.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?Cm:e.inputType=="historyRedo"?ja:null;return n?(e.preventDefault(),n(t)):!1}})]}function Ro(i,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let s=t.field(Em,!1);if(!s)return!1;let r=s.pop(i,t,e);return r?(n(r),!0):!1}}const Cm=Ro(0,!1),ja=Ro(1,!1),Bw=Ro(0,!0),Vw=Ro(1,!0);class tt{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 tt(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 tt(e.changes&&je.fromJSON(e.changes),[],e.mapped&&$t.fromJSON(e.mapped),e.startSelection&&O.fromJSON(e.startSelection),e.selectionsAfter.map(O.fromJSON))}static fromTransaction(e,t){let n=dt;for(let s of e.startState.facet(Nw)){let r=s(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new tt(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,dt)}static selection(e){return new tt(void 0,dt,void 0,void 0,e)}}function qr(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 _w(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 zw(i,e){return i.ranges.length==e.ranges.length&&i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function wm(i,e){return i.length?e.length?i.concat(e):i:e}const dt=[],$w=200;function Rm(i,e){if(i.length){let t=i[i.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-$w));return n.length&&n[n.length-1].eq(e)?i:(n.push(e),qr(i,i.length-1,1e9,t.setSelAfter(n)))}else return[tt.selection([e])]}function Hw(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 gl(i,e){if(!i.length)return i;let t=i.length,n=dt;for(;t;){let s=Gw(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?[tt.selection(n)]:dt}function Gw(i,e,t){let n=wm(i.selectionsAfter.length?i.selectionsAfter.map(l=>l.map(e)):dt,t);if(!i.changes)return tt.selection(n);let s=i.changes.map(e),r=e.mapDesc(i.changes,!0),o=i.mapped?i.mapped.composeDesc(r):r;return new tt(s,J.mapEffects(i.effects,e),o,i.startSelection.map(r),n)}const Uw=/^(input\.type|delete)($|\.)/;class _t{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 _t(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||Uw.test(n))&&(!l.selectionsAfter.length&&t-this.prevTime<s.newGroupDelay&&s.joinToEvent(r,_w(l.changes,e.changes))||n=="input.type.compose")?o=qr(o,o.length-1,s.minDepth,new tt(e.changes.compose(l.changes),wm(J.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,dt)):o=qr(o,o.length,s.minDepth,e),new _t(o,dt,t,n)}addSelection(e,t,n,s){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:dt;return r.length>0&&t-this.prevTime<s&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&zw(r[r.length-1],e)?this:new _t(Rm(this.done,e),this.undone,t,n)}addMapping(e){return new _t(gl(this.done,e),gl(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:Hw(s),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=s.length==1?dt:s.slice(0,s.length-1);return r.mapped&&(l=gl(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}}_t.empty=new _t(dt,dt);const Ww=[{key:"Mod-z",run:Cm,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:ja,preventDefault:!0},{linux:"Ctrl-Shift-z",run:ja,preventDefault:!0},{key:"Mod-u",run:Bw,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Vw,preventDefault:!0}];function On(i,e){return O.create(i.ranges.map(e),i.mainIndex)}function Tt(i,e){return i.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function At({state:i,dispatch:e},t){let n=On(i.selection,t);return n.eq(i.selection,!0)?!1:(e(Tt(i,n)),!0)}function ko(i,e){return O.cursor(e?i.to:i.from)}function km(i,e){return At(i,t=>t.empty?i.moveByChar(t,e):ko(t,e))}function Ue(i){return i.textDirectionAt(i.state.selection.main.head)==ye.LTR}const Tm=i=>km(i,!Ue(i)),Am=i=>km(i,Ue(i));function jm(i,e){return At(i,t=>t.empty?i.moveByGroup(t,e):ko(t,e))}const qw=i=>jm(i,!Ue(i)),Kw=i=>jm(i,Ue(i));function Yw(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 To(i,e,t){let n=Ge(i).resolveInner(e.head),s=t?ie.closedBy:ie.openedBy;for(let a=e.head;;){let u=t?n.childAfter(a):n.childBefore(a);if(!u)break;Yw(i,u,s)?n=u:a=t?u.to:u.from}let r=n.type.prop(s),o,l;return r&&(o=t?Vt(i,n.from,1):Vt(i,n.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?n.to:n.from,O.cursor(l,t?-1:1)}const Xw=i=>At(i,e=>To(i.state,e,!Ue(i))),Qw=i=>At(i,e=>To(i.state,e,Ue(i)));function Om(i,e){return At(i,t=>{if(!t.empty)return ko(t,e);let n=i.moveVertically(t,e);return n.head!=t.head?n:i.moveToLineBoundary(t,e)})}const Im=i=>Om(i,!1),Mm=i=>Om(i,!0);function Pm(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 Dm(i,e){let t=Pm(i),{state:n}=i,s=On(n.selection,o=>o.empty?i.moveVertically(o,e,t.height):ko(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(Tt(n,s),{effects:r}),!0}const Oh=i=>Dm(i,!1),Oa=i=>Dm(i,!0);function Ti(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=O.cursor(n.from+r))}return s}const Jw=i=>At(i,e=>Ti(i,e,!0)),Zw=i=>At(i,e=>Ti(i,e,!1)),eR=i=>At(i,e=>Ti(i,e,!Ue(i))),tR=i=>At(i,e=>Ti(i,e,Ue(i))),iR=i=>At(i,e=>O.cursor(i.lineBlockAt(e.head).from,1)),nR=i=>At(i,e=>O.cursor(i.lineBlockAt(e.head).to,-1));function sR(i,e,t){let n=!1,s=On(i.selection,r=>{let o=Vt(i,r.head,-1)||Vt(i,r.head,1)||r.head>0&&Vt(i,r.head-1,1)||r.head<i.doc.length&&Vt(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 O.cursor(l)});return n?(e(Tt(i,s)),!0):!1}const rR=({state:i,dispatch:e})=>sR(i,e);function yt(i,e){let t=On(i.state.selection,n=>{let s=e(n);return O.range(n.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return t.eq(i.state.selection)?!1:(i.dispatch(Tt(i.state,t)),!0)}function Lm(i,e){return yt(i,t=>i.moveByChar(t,e))}const Nm=i=>Lm(i,!Ue(i)),Fm=i=>Lm(i,Ue(i));function Bm(i,e){return yt(i,t=>i.moveByGroup(t,e))}const oR=i=>Bm(i,!Ue(i)),lR=i=>Bm(i,Ue(i)),aR=i=>yt(i,e=>To(i.state,e,!Ue(i))),uR=i=>yt(i,e=>To(i.state,e,Ue(i)));function Vm(i,e){return yt(i,t=>i.moveVertically(t,e))}const _m=i=>Vm(i,!1),zm=i=>Vm(i,!0);function $m(i,e){return yt(i,t=>i.moveVertically(t,e,Pm(i).height))}const Ih=i=>$m(i,!1),Mh=i=>$m(i,!0),cR=i=>yt(i,e=>Ti(i,e,!0)),hR=i=>yt(i,e=>Ti(i,e,!1)),dR=i=>yt(i,e=>Ti(i,e,!Ue(i))),fR=i=>yt(i,e=>Ti(i,e,Ue(i))),pR=i=>yt(i,e=>O.cursor(i.lineBlockAt(e.head).from)),mR=i=>yt(i,e=>O.cursor(i.lineBlockAt(e.head).to)),Ph=({state:i,dispatch:e})=>(e(Tt(i,{anchor:0})),!0),Dh=({state:i,dispatch:e})=>(e(Tt(i,{anchor:i.doc.length})),!0),Lh=({state:i,dispatch:e})=>(e(Tt(i,{anchor:i.selection.main.anchor,head:0})),!0),Nh=({state:i,dispatch:e})=>(e(Tt(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),gR=({state:i,dispatch:e})=>(e(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),xR=({state:i,dispatch:e})=>{let t=Ao(i).map(({from:n,to:s})=>O.range(n,Math.min(s+1,i.doc.length)));return e(i.update({selection:O.create(t),userEvent:"select"})),!0},yR=({state:i,dispatch:e})=>{let t=On(i.selection,n=>{let s=Ge(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 O.range(l.to,l.from)}return n});return t.eq(i.selection)?!1:(e(Tt(i,t)),!0)};function Hm(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(Tt(t,O.create(s,s.length-1))),!0)}const bR=i=>Hm(i,!1),SR=i=>Hm(i,!0),vR=({state:i,dispatch:e})=>{let t=i.selection,n=null;return t.ranges.length>1?n=O.create([t.main]):t.main.empty||(n=O.create([O.cursor(t.main.head)])),n?(e(Tt(i,n)),!0):!1};function Os(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=nr(i,a,!1)):a>o&&(t="delete.forward",a=nr(i,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=nr(i,o,!1),l=nr(i,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:O.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 nr(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 Gm=(i,e,t)=>Os(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=jn(l,r.tabSize),c=u%Gr(r)||Gr(r);for(let d=0;d<c&&l[l.length-1-d]==" ";d++)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}),Ia=i=>Gm(i,!1,!0),Um=i=>Gm(i,!0,!1),Wm=(i,e)=>Os(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}),qm=i=>Wm(i,!1),ER=i=>Wm(i,!0),CR=i=>Os(i,e=>{let t=i.lineBlockAt(e.head).to;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)}),wR=i=>Os(i,e=>{let t=i.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),RR=i=>Os(i,e=>{let t=i.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)}),kR=({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:O.cursor(n.from)}));return e(i.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},TR=({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:O.cursor(l)}});return t.changes.empty?!1:(e(i.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Ao(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 Km(i,e,t){if(i.readOnly)return!1;let n=[],s=[];for(let r of Ao(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(O.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(O.range(a.anchor-l,a.head-l))}}return n.length?(e(i.update({changes:n,scrollIntoView:!0,selection:O.create(s,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}const AR=({state:i,dispatch:e})=>Km(i,e,!1),jR=({state:i,dispatch:e})=>Km(i,e,!0);function Ym(i,e,t){if(i.readOnly)return!1;let n=[];for(let s of Ao(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 OR=({state:i,dispatch:e})=>Ym(i,e,!1),IR=({state:i,dispatch:e})=>Ym(i,e,!0),MR=i=>{if(i.state.readOnly)return!1;let{state:e}=i,t=e.changes(Ao(e).map(({from:s,to:r})=>(s>0?s--:r<e.doc.length&&r++,{from:s,to:r}))),n=On(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 PR(i,e){if(/\(\)|\[\]|\{\}/.test(i.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Ge(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(ie.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 Fh=Xm(!1),DR=Xm(!0);function Xm(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&&PR(e,r);i&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new Co(e,{simulateBreak:r,simulateDoubleBreak:!!a}),c=Cu(u,r);for(c==null&&(c=jn(/^\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 d=["",ps(e,c)];return a&&d.push(ps(e,u.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:oe.of(d)},range:O.cursor(r+1+d[1].length)}});return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function Tu(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:O.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 Co(i,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=Tu(i,(r,o,l)=>{let a=Cu(n,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let u=/^\s*/.exec(r.text)[0],c=ps(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},Qm=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(Tu(i,(t,n)=>{n.push({from:t.from,insert:i.facet(Eo)})}),{userEvent:"input.indent"})),!0),Jm=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(Tu(i,(t,n)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=jn(s,i.tabSize),o=0,l=ps(i,Math.max(0,r-Gr(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),NR=i=>(i.setTabFocusMode(),!0),FR=[{key:"Ctrl-b",run:Tm,shift:Nm,preventDefault:!0},{key:"Ctrl-f",run:Am,shift:Fm},{key:"Ctrl-p",run:Im,shift:_m},{key:"Ctrl-n",run:Mm,shift:zm},{key:"Ctrl-a",run:iR,shift:pR},{key:"Ctrl-e",run:nR,shift:mR},{key:"Ctrl-d",run:Um},{key:"Ctrl-h",run:Ia},{key:"Ctrl-k",run:CR},{key:"Ctrl-Alt-h",run:qm},{key:"Ctrl-o",run:kR},{key:"Ctrl-t",run:TR},{key:"Ctrl-v",run:Oa}],BR=[{key:"ArrowLeft",run:Tm,shift:Nm,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:qw,shift:oR,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:eR,shift:dR,preventDefault:!0},{key:"ArrowRight",run:Am,shift:Fm,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Kw,shift:lR,preventDefault:!0},{mac:"Cmd-ArrowRight",run:tR,shift:fR,preventDefault:!0},{key:"ArrowUp",run:Im,shift:_m,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Ph,shift:Lh},{mac:"Ctrl-ArrowUp",run:Oh,shift:Ih},{key:"ArrowDown",run:Mm,shift:zm,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Dh,shift:Nh},{mac:"Ctrl-ArrowDown",run:Oa,shift:Mh},{key:"PageUp",run:Oh,shift:Ih},{key:"PageDown",run:Oa,shift:Mh},{key:"Home",run:Zw,shift:hR,preventDefault:!0},{key:"Mod-Home",run:Ph,shift:Lh},{key:"End",run:Jw,shift:cR,preventDefault:!0},{key:"Mod-End",run:Dh,shift:Nh},{key:"Enter",run:Fh,shift:Fh},{key:"Mod-a",run:gR},{key:"Backspace",run:Ia,shift:Ia,preventDefault:!0},{key:"Delete",run:Um,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:qm,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:ER,preventDefault:!0},{mac:"Mod-Backspace",run:wR,preventDefault:!0},{mac:"Mod-Delete",run:RR,preventDefault:!0}].concat(FR.map(i=>({mac:i.key,run:i.run,shift:i.shift}))),VR=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Xw,shift:aR},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Qw,shift:uR},{key:"Alt-ArrowUp",run:AR},{key:"Shift-Alt-ArrowUp",run:OR},{key:"Alt-ArrowDown",run:jR},{key:"Shift-Alt-ArrowDown",run:IR},{key:"Mod-Alt-ArrowUp",run:bR},{key:"Mod-Alt-ArrowDown",run:SR},{key:"Escape",run:vR},{key:"Mod-Enter",run:DR},{key:"Alt-l",mac:"Ctrl-l",run:xR},{key:"Mod-i",run:yR,preventDefault:!0},{key:"Mod-[",run:Jm},{key:"Mod-]",run:Qm},{key:"Mod-Alt-\\",run:LR},{key:"Shift-Mod-k",run:MR},{key:"Shift-Mod-\\",run:rR},{key:"Mod-/",run:Aw},{key:"Alt-A",run:Ow},{key:"Ctrl-m",mac:"Shift-Alt-m",run:NR}].concat(BR),_R={key:"Tab",run:Qm,shift:Jm},Bh=typeof String.prototype.normalize=="function"?i=>i.normalize("NFKD"):i=>i;class Tn{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(Bh(l)):Bh,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 Je(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=au(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Ft(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"&&(Tn.prototype[Symbol.iterator]=function(){return this});const Zm={from:-1,to:-1,match:/.*/.exec("")},Au="gm"+(/x/.unicode==null?"":"u");class eg{constructor(e,t,n,s=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=Zm,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new tg(e,t,n,s,r);this.re=new RegExp(t,Au+(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=Kr(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=Kr(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 xl=new WeakMap;class xn{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let s=xl.get(e);if(!s||s.from>=n||s.to<=t){let l=new xn(t,e.sliceString(t,n));return xl.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)),xl.set(e,new xn(o,r)),new xn(t,r.slice(t-o,n-o))}}class tg{constructor(e,t,n,s,r){this.text=e,this.to=r,this.done=!1,this.value=Zm,this.matchPos=Kr(e,s),this.re=new RegExp(t,Au+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.flat=xn.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=Kr(this.text,s+(n==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=xn.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(eg.prototype[Symbol.iterator]=tg.prototype[Symbol.iterator]=function(){return this});function zR(i){try{return new RegExp(i,Au),!0}catch{return!1}}function Kr(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 Ma(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:Zn.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:Zn.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,d]=r,f=c?+c.slice(1):0,p=u?+u:l.number;if(u&&d){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 m=o.doc.line(Math.max(1,Math.min(o.doc.lines,p))),g=O.cursor(m.from+Math.max(0,Math.min(f,m.length)));i.dispatch({effects:[Zn.of(!1),_.scrollIntoView(g.from,{y:"center"})],selection:g}),i.focus()}return{dom:n}}const Zn=J.define(),Vh=Be.define({create(){return!0},update(i,e){for(let t of e.effects)t.is(Zn)&&(i=t.value);return i},provide:i=>fs.from(i,e=>e?Ma:null)}),$R=i=>{let e=ds(i,Ma);if(!e){let t=[Zn.of(!0)];i.state.field(Vh,!1)==null&&t.push(J.appendConfig.of([Vh,HR])),i.dispatch({effects:t}),e=ds(i,Ma)}return e&&e.dom.querySelector("input").select(),!0},HR=_.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"}}}),GR={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},UR=G.define({combine(i){return Kt(i,GR,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function WR(i){return[QR,XR]}const qR=K.mark({class:"cm-selectionMatch"}),KR=K.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function _h(i,e,t,n){return(t==0||i(e.sliceDoc(t-1,t))!=Se.Word)&&(n==e.doc.length||i(e.sliceDoc(n,n+1))!=Se.Word)}function YR(i,e,t,n){return i(e.sliceDoc(t,t+1))==Se.Word&&i(e.sliceDoc(n-1,n))==Se.Word}const XR=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(UR),{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),!(_h(o,t,s.from,s.to)&&YR(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 Tn(t.doc,r,a.from,a.to);for(;!u.next().done;){let{from:c,to:d}=u.value;if((!o||_h(o,t,c,d))&&(s.empty&&c<=s.from&&d>=s.to?l.push(KR.range(c,d)):(c>=s.to||d<=s.from)&&l.push(qR.range(c,d)),l.length>e.maxMatches))return K.none}}return K.set(l)}},{decorations:i=>i.decorations}),QR=_.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),JR=({state:i,dispatch:e})=>{let{selection:t}=i,n=O.create(t.ranges.map(s=>i.wordAt(s.head)||O.cursor(s.head)),t.mainIndex);return n.eq(t)?!1:(e(i.update({selection:n})),!0)};function ZR(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 Tn(i.doc,e,n[n.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new Tn(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 ek=({state:i,dispatch:e})=>{let{ranges:t}=i.selection;if(t.some(r=>r.from===r.to))return JR({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=ZR(i,n);return s?(e(i.update({selection:i.selection.addRange(O.range(s.from,s.to),!1),effects:_.scrollIntoView(s.to)})),!0):!1},In=G.define({combine(i){return Kt(i,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new dk(e),scrollToMatch:e=>_.scrollIntoView(e)})}});class ig{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||zR(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 sk(this):new ik(this)}getCursor(e,t=0,n){let s=e.doc?e:se.create({doc:e});return n==null&&(n=s.doc.length),this.regexp?sn(this,s,t,n):nn(this,s,t,n)}}class ng{constructor(e){this.spec=e}}function nn(i,e,t,n){return new Tn(e.doc,i.unquoted,t,n,i.caseSensitive?void 0:s=>s.toLowerCase(),i.wholeWord?tk(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function tk(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(Yr(s,t-r))!=Se.Word||e(Xr(s,t-r))!=Se.Word)&&(e(Xr(s,n-r))!=Se.Word||e(Yr(s,n-r))!=Se.Word))}class ik extends ng{constructor(e){super(e)}nextMatch(e,t,n){let s=nn(this.spec,e,n,e.doc.length).nextOverlapping();if(s.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);s=nn(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=nn(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=nn(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=nn(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 sn(i,e,t,n){return new eg(e.doc,i.search,{ignoreCase:!i.caseSensitive,test:i.wholeWord?nk(e.charCategorizer(e.selection.main.head)):void 0},t,n)}function Yr(i,e){return i.slice(Fe(i,e,!1),e)}function Xr(i,e){return i.slice(e,Fe(i,e))}function nk(i){return(e,t,n)=>!n[0].length||(i(Yr(n.input,n.index))!=Se.Word||i(Xr(n.input,n.index))!=Se.Word)&&(i(Xr(n.input,n.index+n[0].length))!=Se.Word||i(Yr(n.input,n.index+n[0].length))!=Se.Word)}class sk extends ng{nextMatch(e,t,n){let s=sn(this.spec,e,n,e.doc.length).next();return s.done&&(s=sn(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=sn(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=sn(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=sn(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 ms=J.define(),ju=J.define(),Si=Be.define({create(i){return new yl(Pa(i).create(),null)},update(i,e){for(let t of e.effects)t.is(ms)?i=new yl(t.value.create(),i.panel):t.is(ju)&&(i=new yl(i.query,t.value?Ou:null));return i},provide:i=>fs.from(i,e=>e.panel)});class yl{constructor(e,t){this.query=e,this.panel=t}}const rk=K.mark({class:"cm-searchMatch"}),ok=K.mark({class:"cm-searchMatch cm-searchMatch-selected"}),lk=Ce.fromClass(class{constructor(i){this.view=i,this.decorations=this.highlight(i.state.field(Si))}update(i){let e=i.state.field(Si);(e!=i.startState.field(Si)||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 ni;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 d=t.state.selection.ranges.some(f=>f.from==u&&f.to==c);n.add(u,c,d?ok:rk)})}return n.finish()}},{decorations:i=>i.decorations});function Is(i){return e=>{let t=e.state.field(Si,!1);return t&&t.query.spec.valid?i(e,t):og(e)}}const Qr=Is((i,{query:e})=>{let{to:t}=i.state.selection.main,n=e.nextMatch(i.state,t,t);if(!n)return!1;let s=O.single(n.from,n.to),r=i.state.facet(In);return i.dispatch({selection:s,effects:[Iu(i,n),r.scrollToMatch(s.main,i)],userEvent:"select.search"}),rg(i),!0}),Jr=Is((i,{query:e})=>{let{state:t}=i,{from:n}=t.selection.main,s=e.prevMatch(t,n,n);if(!s)return!1;let r=O.single(s.from,s.to),o=i.state.facet(In);return i.dispatch({selection:r,effects:[Iu(i,s),o.scrollToMatch(r.main,i)],userEvent:"select.search"}),rg(i),!0}),ak=Is((i,{query:e})=>{let t=e.matchAll(i.state,1e3);return!t||!t.length?!1:(i.dispatch({selection:O.create(t.map(n=>O.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),uk=({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 Tn(i.doc,i.sliceDoc(n,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==n&&(o=r.length),r.push(O.range(l.value.from,l.value.to))}return e(i.update({selection:O.create(r,o),userEvent:"select.search.matches"})),!0},zh=Is((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 d=i.state.changes(l);return o&&(a=O.single(o.from,o.to).map(d),c.push(Iu(i,o)),c.push(t.facet(In).scrollToMatch(a.main,i))),i.dispatch({changes:d,selection:a,effects:c,userEvent:"input.replace"}),!0}),ck=Is((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 Ou(i){return i.state.facet(In).createPanel(i)}function Pa(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(In);return new ig({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 sg(i){let e=ds(i,Ou);return e&&e.dom.querySelector("[main-field]")}function rg(i){let e=sg(i);e&&e==i.root.activeElement&&e.select()}const og=i=>{let e=i.state.field(Si,!1);if(e&&e.panel){let t=sg(i);if(t&&t!=i.root.activeElement){let n=Pa(i.state,e.query.spec);n.valid&&i.dispatch({effects:ms.of(n)}),t.focus(),t.select()}}else i.dispatch({effects:[ju.of(!0),e?ms.of(Pa(i.state,e.query.spec)):J.appendConfig.of(pk)]});return!0},lg=i=>{let e=i.state.field(Si,!1);if(!e||!e.panel)return!1;let t=ds(i,Ou);return t&&t.dom.contains(i.root.activeElement)&&i.focus(),i.dispatch({effects:ju.of(!1)}),!0},hk=[{key:"Mod-f",run:og,scope:"editor search-panel"},{key:"F3",run:Qr,shift:Jr,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Qr,shift:Jr,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:lg,scope:"editor search-panel"},{key:"Mod-Shift-l",run:uk},{key:"Mod-Alt-g",run:$R},{key:"Mod-d",run:ek,preventDefault:!0}];class dk{constructor(e){this.view=e;let t=this.query=e.state.field(Si).query.spec;this.commit=this.commit.bind(this),this.searchField=fe("input",{value:t.search,placeholder:rt(e,"Find"),"aria-label":rt(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:rt(e,"Replace"),"aria-label":rt(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",()=>Qr(e),[rt(e,"next")]),n("prev",()=>Jr(e),[rt(e,"previous")]),n("select",()=>ak(e),[rt(e,"all")]),fe("label",null,[this.caseField,rt(e,"match case")]),fe("label",null,[this.reField,rt(e,"regexp")]),fe("label",null,[this.wordField,rt(e,"by word")]),...e.state.readOnly?[]:[fe("br"),this.replaceField,n("replace",()=>zh(e),[rt(e,"replace")]),n("replaceAll",()=>ck(e),[rt(e,"replace all")])],fe("button",{name:"close",onclick:()=>lg(e),"aria-label":rt(e,"close"),type:"button"},["×"])])}commit(){let e=new ig({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:ms.of(e)}))}keydown(e){IC(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Jr:Qr)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),zh(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(ms)&&!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(In).top}}function rt(i,e){return i.state.phrase(e)}const sr=30,rr=/[\s\.,:;?!]/;function Iu(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-sr),o=Math.min(s,t+sr),l=i.state.sliceDoc(r,o);if(r!=n.from){for(let a=0;a<sr;a++)if(!rr.test(l[a+1])&&rr.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-sr;a--)if(!rr.test(l[a-1])&&rr.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 fk=_.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"}}),pk=[Si,Xi.low(lk),fk];class ag{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=Ge(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(ug(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 $h(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 mk(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=$h(e)+$h(t)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function gk(i){let e=i.map(s=>typeof s=="string"?{label:s}:s),[t,n]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:mk(e);return s=>{let r=s.matchBefore(n);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}class Hh{constructor(e,t,n,s){this.completion=e,this.source=t,this.match=n,this.score=s}}function zi(i){return i.selection.main.from}function ug(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 cg=qt.define();function xk(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:O.cursor(l.from+r+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Gh=new WeakMap;function yk(i){if(!Array.isArray(i))return i;let e=Gh.get(i);return e||Gh.set(i,e=gk(i)),e}const Zr=J.define(),gs=J.define();class bk{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=Je(e,t),s=Ft(n);this.chars.push(n);let r=e.slice(t,t+s),o=r.toUpperCase();this.folded.push(Je(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=Je(e,0),S=Ft(b),E=S==e.length?0:-100;if(b!=t[0])if(b==n[0])E+=-200;else return null;return this.ret(E,[0,S])}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,S=Math.min(e.length,200);b<S&&u<a;){let E=Je(e,b);(E==t[u]||E==n[u])&&(s[u++]=b),b+=Ft(E)}if(u<a)return null}let c=0,d=0,f=!1,p=0,m=-1,g=-1,x=/[a-z]/.test(e),y=!0;for(let b=0,S=Math.min(e.length,200),E=0;b<S&&d<a;){let v=Je(e,b);l<0&&(c<a&&v==t[c]&&(r[c++]=b),p<a&&(v==t[p]||v==n[p]?(p==0&&(m=b),g=b+1,p++):p=0));let C,k=v<255?v>=48&&v<=57||v>=97&&v<=122?2:v>=65&&v<=90?1:0:(C=au(v))!=C.toLowerCase()?1:C!=C.toUpperCase()?2:0;(!b||k==1&&x||E==0&&k!=0)&&(t[d]==v||n[d]==v&&(f=!0)?o[d++]=b:o.length&&(y=!1)),E=k,b+=Ft(v)}return d==a&&o[0]==0&&y?this.result(-100+(f?-200:0),o,e):p==a&&m==0?this.ret(-200-e.length+(g==e.length?0:-100),[0,g]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):p==a?this.ret(-900-e.length,[m,g]):d==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?Ft(Je(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 Sk{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 De=G.define({combine(i){return Kt(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:vk,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=>Uh(e(n),t(n)),optionClass:(e,t)=>n=>Uh(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Uh(i,e){return i?e?i+" "+e:i:e}function vk(i,e,t,n,s,r){let o=i.textDirection==ye.RTL,l=o,a=!1,u="top",c,d,f=e.left-s.left,p=s.right-e.right,m=n.right-n.left,g=n.bottom-n.top;if(l&&f<Math.min(m,p)?l=!1:!l&&p<Math.min(m,f)&&(l=!0),m<=(l?f:p))c=Math.max(s.top,Math.min(t.top,s.bottom-g))-e.top,d=Math.min(400,l?f:p);else{a=!0,d=Math.min(400,(o?e.right:s.right-e.left)-30);let b=s.bottom-e.bottom;b>=g||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: ${d/y}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function Ek(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++],d=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,d))),f.className="cm-completionMatchedText",a=d}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 bl(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 Ck{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(De);this.optionContent=Ek(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=bl(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,d;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(d=/-(\d+)$/.exec(c.id))&&+d[1]<u.length){this.applyCompletion(e,u[+d[1]]),a.preventDefault();return}}),this.dom.addEventListener("focusout",a=>{let u=e.state.field(this.stateField,!1);u&&u.tooltip&&e.state.facet(De).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:gs.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=bl(r.length,o,e.state.facet(De).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=bl(t.options.length,t.selected,this.view.state.facet(De).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=>et(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&&Rk(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(De).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 d=this.optionClass(l);d&&(c.className=d);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 wk(i,e){return t=>new Ck(t,i,e)}function Rk(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 Wh(i){return(i.boost||0)*100+(i.apply?10:0)+(i.info?5:0)+(i.type?1:0)}function kk(i,e){let t=[],n=null,s=null,r=c=>{t.push(c);let{section:d}=c.completion;if(d){n||(n=[]);let f=typeof d=="string"?d:d.name;n.some(p=>p.name==f)||n.push(typeof d=="string"?{name:f}:d)}},o=e.facet(De);for(let c of i)if(c.hasResult()){let d=c.result.getMatch;if(c.result.filter===!1)for(let f of c.result.options)r(new Hh(f,c.source,d?d(f):[],1e9-t.length));else{let f=e.sliceDoc(c.from,c.to),p,m=o.filterStrict?new Sk(f):new bk(f);for(let g of c.result.options)if(p=m.match(g.label)){let x=g.displayLabel?d?d(g,p.matched):[]:p.matched,y=p.score+(g.boost||0);if(r(new Hh(g,c.source,x,y)),typeof g.section=="object"&&g.section.rank==="dynamic"){let{name:b}=g.section;s||(s=Object.create(null)),s[b]=Math.max(y,s[b]||-1e9)}}}}if(n){let c=Object.create(null),d=0,f=(p,m)=>(p.rank==="dynamic"&&m.rank==="dynamic"?s[m.name]-s[p.name]:0)||(typeof p.rank=="number"?p.rank:1e9)-(typeof m.rank=="number"?m.rank:1e9)||(p.name<m.name?-1:1);for(let p of n.sort(f))d-=1e5,c[p.name]=d;for(let p of t){let{section:m}=p.completion;m&&(p.score+=c[typeof m=="string"?m:m.name])}}let l=[],a=null,u=o.compareCompletions;for(let c of t.sort((d,f)=>f.score-d.score||u(d.completion,f.completion))){let d=c.completion;!a||a.label!=d.label||a.detail!=d.detail||a.type!=null&&d.type!=null&&a.type!=d.type||a.apply!=d.apply||a.boost!=d.boost?l.push(c):Wh(c.completion)>Wh(a)&&(l[l.length-1]=c),a=c.completion}return l}class cn{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 cn(this.options,qh(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=kk(e,t);if(!l.length)return s&&e.some(u=>u.isPending)?s.setDisabled():null;let a=t.facet(De).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 cn(l,qh(n,a),{pos:e.reduce((u,c)=>c.hasResult()?Math.min(u,c.from):u,1e8),create:Mk,above:r.aboveCursor},s?s.timestamp:Date.now(),a,!1)}map(e){return new cn(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new cn(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class eo{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new eo(Ok,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(De),r=(n.override||t.languageDataAt("autocomplete",zi(t)).map(yk)).map(a=>(this.active.find(c=>c.source==a)||new ft(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(Mu));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!Tk(r,this.active)||l?o=cn.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 ft(a.source,0):a));for(let a of e.effects)a.is(dg)&&(o=o&&o.setSelected(a.value,this.id));return r==this.active&&o==this.open?this:new eo(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Ak:jk}}function Tk(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 Ak={"aria-autocomplete":"list"},jk={};function qh(i,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":i};return e>-1&&(t["aria-activedescendant"]=i+"-"+e),t}const Ok=[];function hg(i,e){if(i.isUserEvent("input.complete")){let n=i.annotation(cg);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 ft{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=hg(e,t),s=this;(n&8||n&16&&this.touches(e))&&(s=new ft(s.source,0)),n&4&&s.state==0&&(s=new ft(this.source,1)),s=s.updateFor(e,n);for(let r of e.effects)if(r.is(Zr))s=new ft(s.source,1,r.value);else if(r.is(gs))s=new ft(s.source,0);else if(r.is(Mu))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(zi(e.state))}}class yn extends ft{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=zi(e.state);if(l>o||!s||t&2&&(zi(e.startState)==this.from||l<this.limit))return new ft(this.source,t&4?1:0);let a=e.changes.mapPos(this.limit);return Ik(s.validFor,e.state,r,o)?new yn(this.source,this.explicit,a,s,r,o):s.update&&(s=s.update(s,r,o,new ag(e.state,l,!1)))?new yn(this.source,this.explicit,a,s,s.from,(n=s.to)!==null&&n!==void 0?n:zi(e.state)):new ft(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new yn(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new ft(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function Ik(i,e,t,n){if(!i)return!1;let s=e.sliceDoc(t,n);return typeof i=="function"?i(s,t,n,e):ug(i,!0).test(s)}const Mu=J.define({map(i,e){return i.map(t=>t.map(e))}}),dg=J.define(),Ze=Be.define({create(){return eo.start()},update(i,e){return i.update(e)},provide:i=>[Eu.from(i,e=>e.tooltip),_.contentAttributes.from(i,e=>e.attrs)]});function Pu(i,e){const t=e.completion.apply||e.completion.label;let n=i.state.field(Ze).active.find(s=>s.source==e.source);return n instanceof yn?(typeof t=="string"?i.dispatch({...xk(i.state,t,n.from,n.to),annotations:cg.of(e.completion)}):t(i,e.completion,n.from,n.to),!0):!1}const Mk=wk(Ze,Pu);function or(i,e="option"){return t=>{let n=t.state.field(Ze,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<t.state.facet(De).interactionDelay)return!1;let s=1,r;e=="page"&&(r=em(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:dg.of(l)}),!0}}const Pk=i=>{let e=i.state.field(Ze,!1);return i.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<i.state.facet(De).interactionDelay?!1:Pu(i,e.open.options[e.open.selected])},Sl=i=>i.state.field(Ze,!1)?(i.dispatch({effects:Zr.of(!0)}),!0):!1,Dk=i=>{let e=i.state.field(Ze,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(i.dispatch({effects:gs.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 Nk=50,Fk=1e3,Bk=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(Ze).active)e.isPending&&this.startQuery(e)}update(i){let e=i.state.field(Ze),t=i.state.facet(De);if(!i.selectionSet&&!i.docChanged&&i.startState.field(Ze)==e)return;let n=i.transactions.some(r=>{let o=hg(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>Nk&&Date.now()-o.time>Fk){for(let l of o.context.abortListeners)try{l()}catch(a){et(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(Zr)))&&(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(Ze);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(De).updateSyncTime))}startQuery(i){let{state:e}=this.view,t=zi(e),n=new ag(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:gs.of(null)}),et(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(De).updateSyncTime))}accept(){var i;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(De),n=this.view.state.field(Ze);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=zi(r.updates.length?r.updates[0].startState:this.view.state),a=Math.min(l,r.done.from+(r.active.explicit?0:1)),u=new yn(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 ft(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:Mu.of(e)})}},{eventHandlers:{blur(i){let e=this.view.state.field(Ze,!1);if(e&&e.tooltip&&this.view.state.facet(De).closeOnBlur){let t=e.open&&em(this.view,e.open.tooltip);(!t||!t.dom.contains(i.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:gs.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Zr.of(!1)}),20),this.composing=0}}}),Vk=typeof navigator=="object"&&/Win/.test(navigator.platform),_k=Xi.highest(_.domEventHandlers({keydown(i,e){let t=e.state.field(Ze,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||i.key.length>1||i.ctrlKey&&!(Vk&&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&&Pu(e,n),!1}})),zk=_.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"}}}),xs={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Fi=J.define({map(i,e){let t=e.mapPos(i,-1,Ke.TrackAfter);return t??void 0}}),Du=new class extends Hi{};Du.startSide=1;Du.endSide=-1;const fg=Be.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(Fi)&&(i=i.update({add:[Du.range(t.value,t.value+1)]}));return i}});function $k(){return[Gk,fg]}const vl="()[]{}<>«»»«[]{}";function pg(i){for(let e=0;e<vl.length;e+=2)if(vl.charCodeAt(e)==i)return vl.charAt(e+1);return au(i<128?i:i+1)}function mg(i,e){return i.languageDataAt("closeBrackets",e)[0]||xs}const Hk=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Gk=_.inputHandler.of((i,e,t,n)=>{if((Hk?i.composing:i.compositionStarted)||i.state.readOnly)return!1;let s=i.state.selection.main;if(n.length>2||n.length==2&&Ft(Je(n,0))==1||e!=s.from||t!=s.to)return!1;let r=qk(i.state,n);return r?(i.dispatch(r),!0):!1}),Uk=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let n=mg(i,i.selection.main.head).brackets||xs.brackets,s=null,r=i.changeByRange(o=>{if(o.empty){let l=Kk(i.doc,o.head);for(let a of n)if(a==l&&jo(i.doc,o.head)==pg(Je(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:O.cursor(o.head-a.length)}}return{range:s=o}});return s||e(i.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},Wk=[{key:"Backspace",run:Uk}];function qk(i,e){let t=mg(i,i.selection.main.head),n=t.brackets||xs.brackets;for(let s of n){let r=pg(Je(s,0));if(e==s)return r==s?Qk(i,s,n.indexOf(s+s+s)>-1,t):Yk(i,s,r,t.before||xs.before);if(e==r&&gg(i,i.selection.main.from))return Xk(i,s,r)}return null}function gg(i,e){let t=!1;return i.field(fg).between(0,i.doc.length,n=>{n==e&&(t=!0)}),t}function jo(i,e){let t=i.sliceString(e,e+2);return t.slice(0,Ft(Je(t,0)))}function Kk(i,e){let t=i.sliceString(e-2,e);return Ft(Je(t,0))==t.length?t:t.slice(1)}function Yk(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:Fi.of(o.to+e.length),range:O.range(o.anchor+e.length,o.head+e.length)};let l=jo(i.doc,o.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:Fi.of(o.head+e.length),range:O.cursor(o.head+e.length)}:{range:s=o}});return s?null:i.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Xk(i,e,t){let n=null,s=i.changeByRange(r=>r.empty&&jo(i.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:O.cursor(r.head+t.length)}:n={range:r});return n?null:i.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Qk(i,e,t,n){let s=n.stringPrefixes||xs.stringPrefixes,r=null,o=i.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:Fi.of(l.to+e.length),range:O.range(l.anchor+e.length,l.head+e.length)};let a=l.head,u=jo(i.doc,a),c;if(u==e){if(Kh(i,a))return{changes:{insert:e+e,from:a},effects:Fi.of(a+e.length),range:O.cursor(a+e.length)};if(gg(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:O.cursor(a+f.length)}}}else{if(t&&i.sliceDoc(a-2*e.length,a)==e+e&&(c=Yh(i,a-2*e.length,s))>-1&&Kh(i,c))return{changes:{insert:e+e+e+e,from:a},effects:Fi.of(a+e.length),range:O.cursor(a+e.length)};if(i.charCategorizer(a)(u)!=Se.Word&&Yh(i,a,s)>-1&&!Jk(i,a,e,s))return{changes:{insert:e+e,from:a},effects:Fi.of(a+e.length),range:O.cursor(a+e.length)}}return{range:r=l}});return r?null:i.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Kh(i,e){let t=Ge(i).resolveInner(e+1);return t.parent&&t.from==e}function Jk(i,e,t,n){let s=Ge(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 Yh(i,e,t){let n=i.charCategorizer(e);if(n(i.sliceDoc(e-1,e))!=Se.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))!=Se.Word)return r}return-1}function Zk(i={}){return[_k,Ze,De.of(i),Bk,eT,zk]}const xg=[{key:"Ctrl-Space",run:Sl},{mac:"Alt-`",run:Sl},{mac:"Alt-i",run:Sl},{key:"Escape",run:Dk},{key:"ArrowDown",run:or(!0)},{key:"ArrowUp",run:or(!1)},{key:"PageDown",run:or(!0,"page")},{key:"PageUp",run:or(!1,"page")},{key:"Enter",run:Pk}],eT=Xi.highest(So.computeN([De],i=>i.facet(De).defaultKeymap?[xg]:[]));class Xh{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class Di{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let s=n.facet(ys).markerFilter;s&&(e=s(e,n));let r=e.slice().sort((p,m)=>p.from-m.from||p.to-m.to),o=new ni,l=[],a=0,u=n.doc.iter(),c=0,d=n.doc.length;for(let p=0;;){let m=p==r.length?null:r[p];if(!m&&!l.length)break;let g,x;if(l.length)g=a,x=l.reduce((S,E)=>Math.min(S,E.to),m&&m.from>g?m.from:1e8);else{if(g=m.from,g>d)break;x=m.to,l.push(m),p++}for(;p<r.length;){let S=r[p];if(S.from==g&&(S.to>S.from||S.to==g))l.push(S),p++,x=Math.min(S.to,x);else{x=Math.min(S.from,x);break}}x=Math.min(x,d);let y=!1;if(l.some(S=>S.from==g&&(S.to==x||x==d))&&(y=g==x,!y&&x-g<10)){let S=g-(c+u.value.length);S>0&&(u.next(S),c=g);for(let E=g;;){if(E>=x){y=!0;break}if(!u.lineBreak&&c+u.value.length>E)break;E=c+u.value.length,c+=u.value.length,u.next()}}let b=fT(l);if(y)o.add(g,g,K.widget({widget:new uT(b),diagnostics:l.slice()}));else{let S=l.reduce((E,v)=>v.markClass?E+" "+v.markClass:E,"");o.add(g,x,K.mark({class:"cm-lintRange cm-lintRange-"+b+S,diagnostics:l.slice(),inclusiveEnd:l.some(E=>E.to>x)}))}if(a=x,a==d)break;for(let S=0;S<l.length;S++)l[S].to<=a&&l.splice(S--,1)}let f=o.finish();return new Di(f,t,An(f))}}function An(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 Xh(s,r,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new Xh(n.from,r,n.diagnostic)}}),n}function tT(i,e){let t=e.pos,n=e.end||t,s=i.state.facet(ys).hideOn(i,t,n);if(s!=null)return s;let r=i.startState.doc.lineAt(e.pos);return!!(i.effects.some(o=>o.is(yg))||i.changes.touchesRange(r.from,Math.max(r.to,n)))}function iT(i,e){return i.field(at,!1)?e:e.concat(J.appendConfig.of(pT))}const yg=J.define(),Lu=J.define(),bg=J.define(),at=Be.define({create(){return new Di(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=An(t,i.selected.diagnostic,r)||An(t,null,r)}!t.size&&s&&e.state.facet(ys).autoPanel&&(s=null),i=new Di(t,s,n)}for(let t of e.effects)if(t.is(yg)){let n=e.state.facet(ys).autoPanel?t.value.length?bs.open:null:i.panel;i=Di.init(t.value,n,e.state)}else t.is(Lu)?i=new Di(i.diagnostics,t.value?bs.open:null,i.selected):t.is(bg)&&(i=new Di(i.diagnostics,i.panel,t.value));return i},provide:i=>[fs.from(i,e=>e.panel),_.decorations.from(i,e=>e.diagnostics)]}),nT=K.mark({class:"cm-lintRange cm-lintRange-active"});function sT(i,e,t){let{diagnostics:n}=i.state.field(at),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(ys).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:rT(i,s)}}}:null}function rT(i,e){return fe("ul",{class:"cm-tooltip-lint"},e.map(t=>vg(i,t,!1)))}const oT=i=>{let e=i.state.field(at,!1);(!e||!e.panel)&&i.dispatch({effects:iT(i.state,[Lu.of(!0)])});let t=ds(i,bs.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},Qh=i=>{let e=i.state.field(at,!1);return!e||!e.panel?!1:(i.dispatch({effects:Lu.of(!1)}),!0)},lT=i=>{let e=i.state.field(at,!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)},aT=[{key:"Mod-Shift-m",run:oT,preventDefault:!0},{key:"F8",run:lT}],ys=G.define({combine(i){return{sources:i.map(e=>e.source).filter(e=>e!=null),...Kt(i.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Jh,tooltipFilter:Jh,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 Jh(i,e){return i?e?(t,n)=>e(i(t,n),n):i:e}function Sg(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 vg(i,e,t){var n;let s=t?Sg(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 m=An(i.state.field(at).diagnostics,e);m&&r.apply(i,m.from,m.to)},{name:u}=r,c=s[o]?u.indexOf(s[o]):-1,d=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]})"`}.`},d)}),e.source&&fe("div",{class:"cm-diagnosticSource"},e.source))}class uT extends oi{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 Zh{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=vg(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class bs{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)Qh(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=Sg(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=An(this.view.state.field(at).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:()=>Qh(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(at).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(at),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 d=-1,f;for(let p=n;p<this.items.length;p++)if(this.items[p].diagnostic==c){d=p;break}d<0?(f=new Zh(this.view,c),this.items.splice(n,0,f),s=!0):(f=this.items[d],d>n&&(this.items.splice(n,d-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 Zh(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(at),n=An(t.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:bg.of(n)})}static open(e){return new bs(e)}}function cT(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 lr(i){return cT(`<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 hT=_.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:lr("#d11")},".cm-lintRange-warning":{backgroundImage:lr("orange")},".cm-lintRange-info":{backgroundImage:lr("#999")},".cm-lintRange-hint":{backgroundImage:lr("#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 dT(i){return i=="error"?4:i=="warning"?3:i=="info"?2:1}function fT(i){let e="hint",t=1;for(let n of i){let s=dT(n.severity);s>t&&(t=s,e=n.severity)}return e}const pT=[at,_.decorations.compute([at],i=>{let{selected:e,panel:t}=i.field(at);return!e||!t||e.from==e.to?K.none:K.set([nT.range(e.from,e.to)])}),b1(sT,{hideOn:tT}),hT];var ed=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(Wk)),e.defaultKeymap!==!1&&(n=n.concat(VR)),e.searchKeymap!==!1&&(n=n.concat(hk)),e.historyKeymap!==!1&&(n=n.concat(Ww)),e.foldKeymap!==!1&&(n=n.concat(sw)),e.completionKeymap!==!1&&(n=n.concat(xg)),e.lintKeymap!==!1&&(n=n.concat(aT));var s=[];return e.lineNumbers!==!1&&s.push(O1()),e.highlightActiveLineGutter!==!1&&s.push(P1()),e.highlightSpecialChars!==!1&&s.push(KC()),e.history!==!1&&s.push(Fw()),e.foldGutter!==!1&&s.push(aw()),e.drawSelection!==!1&&s.push(FC()),e.dropCursor!==!1&&s.push($C()),e.allowMultipleSelections!==!1&&s.push(se.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&s.push(K1()),e.syntaxHighlighting!==!1&&s.push(gm(dw,{fallback:!0})),e.bracketMatching!==!1&&s.push(bw()),e.closeBrackets!==!1&&s.push($k()),e.autocompletion!==!1&&s.push(Zk()),e.rectangularSelection!==!1&&s.push(a1()),t!==!1&&s.push(h1()),e.highlightActiveLine!==!1&&s.push(e1()),e.highlightSelectionMatches!==!1&&s.push(WR()),e.tabSize&&typeof e.tabSize=="number"&&s.push(Eo.of(" ".repeat(e.tabSize))),s.concat([So.of(n.flat())]).filter(Boolean)};const mT="#e5c07b",td="#e06c75",gT="#56b6c2",xT="#ffffff",br="#abb2bf",Da="#7d8799",yT="#61afef",bT="#98c379",id="#d19a66",ST="#c678dd",vT="#21252b",nd="#2c313a",sd="#282c34",El="#353a42",ET="#3E4451",rd="#528bff",CT=_.theme({"&":{color:br,backgroundColor:sd},".cm-content":{caretColor:rd},".cm-cursor, .cm-dropCursor":{borderLeftColor:rd},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:ET},".cm-panels":{backgroundColor:vT,color:br},".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:sd,color:Da,border:"none"},".cm-activeLineGutter":{backgroundColor:nd},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:El},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:El,borderBottomColor:El},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:nd,color:br}}},{dark:!0}),wT=js.define([{tag:T.keyword,color:ST},{tag:[T.name,T.deleted,T.character,T.propertyName,T.macroName],color:td},{tag:[T.function(T.variableName),T.labelName],color:yT},{tag:[T.color,T.constant(T.name),T.standard(T.name)],color:id},{tag:[T.definition(T.name),T.separator],color:br},{tag:[T.typeName,T.className,T.number,T.changed,T.annotation,T.modifier,T.self,T.namespace],color:mT},{tag:[T.operator,T.operatorKeyword,T.url,T.escape,T.regexp,T.link,T.special(T.string)],color:gT},{tag:[T.meta,T.comment],color:Da},{tag:T.strong,fontWeight:"bold"},{tag:T.emphasis,fontStyle:"italic"},{tag:T.strikethrough,textDecoration:"line-through"},{tag:T.link,color:Da,textDecoration:"underline"},{tag:T.heading,fontWeight:"bold",color:td},{tag:[T.atom,T.bool,T.special(T.variableName)],color:id},{tag:[T.processingInstruction,T.string,T.inserted],color:bT},{tag:T.invalid,color:xT}]),RT=[CT,gm(wT)];var kT=_.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),TT=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(So.of([_R])),l&&(typeof l=="boolean"?a.unshift(ed()):a.unshift(ed(l))),o&&a.unshift(s1(o)),r){case"light":a.push(kT);break;case"dark":a.push(RT);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]},AT=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 jT{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 od{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 Cl=null,OT=()=>typeof window>"u"?new od:(Cl||(Cl=new od),Cl),ld=qt.define(),IT=200,MT=[];function PT(i){var{value:e,selection:t,onChange:n,onStatistics:s,onCreateEditor:r,onUpdate:o,extensions:l=MT,autoFocus:a,theme:u="light",height:c=null,minHeight:d=null,maxHeight:f=null,width:p=null,minWidth:m=null,maxWidth:g=null,placeholder:x="",editable:y=!0,readOnly:b=!1,indentWithTab:S=!0,basicSetup:E=!0,root:v,initialState:C}=i,[k,j]=A.useState(),[R,H]=A.useState(),[N,B]=A.useState(),$=A.useState(()=>({current:null}))[0],P=A.useState(()=>({current:null}))[0],L=_.theme({"&":{height:c,minHeight:d,maxHeight:f,width:p,minWidth:m,maxWidth:g},"& .cm-scroller":{height:"100% !important"}}),W=_.updateListener.of(ne=>{if(ne.docChanged&&typeof n=="function"&&!ne.transactions.some(w=>w.annotation(ld))){$.current?$.current.reset():($.current=new jT(()=>{if(P.current){var w=P.current;P.current=null,w()}$.current=null},IT),OT().add($.current));var te=ne.state.doc,q=te.toString();n(q,ne)}s&&s(AT(ne))}),ee=TT({theme:u,editable:y,readOnly:b,placeholder:x,indentWithTab:S,basicSetup:E}),ae=[W,L,...ee];return o&&typeof o=="function"&&ae.push(_.updateListener.of(o)),ae=ae.concat(l),A.useLayoutEffect(()=>{if(k&&!N){var ne={doc:e,selection:t,extensions:ae},te=C?se.fromJSON(C.json,ne,C.fields):se.create(ne);if(B(te),!R){var q=new _({state:te,parent:k,root:v});H(q),r&&r(q,te)}}return()=>{R&&(B(void 0),H(void 0))}},[k,N]),A.useEffect(()=>{i.container&&j(i.container)},[i.container]),A.useEffect(()=>()=>{R&&(R.destroy(),H(void 0)),$.current&&($.current.cancel(),$.current=null)},[R]),A.useEffect(()=>{a&&R&&R.focus()},[a,R]),A.useEffect(()=>{R&&R.dispatch({effects:J.reconfigure.of(ae)})},[u,l,c,d,f,p,m,g,x,y,b,S,E,n,o]),A.useEffect(()=>{if(e!==void 0){var ne=R?R.state.doc.toString():"";if(R&&e!==ne){var te=$.current&&!$.current.isDone,q=()=>{R&&e!==R.state.doc.toString()&&R.dispatch({changes:{from:0,to:R.state.doc.toString().length,insert:e||""},annotations:[ld.of(!0)]})};te?P.current=q:q()}}},[e,R]),{state:N,setState:B,view:R,setView:H,container:k,setContainer:j}}var DT=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Eg=A.forwardRef((i,e)=>{var{className:t,value:n="",selection:s,extensions:r=[],onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:u,autoFocus:c,theme:d="light",height:f,minHeight:p,maxHeight:m,width:g,minWidth:x,maxWidth:y,basicSetup:b,placeholder:S,indentWithTab:E,editable:v,readOnly:C,root:k,initialState:j}=i,R=Ss(i,DT),H=A.useRef(null),{state:N,view:B,container:$,setContainer:P}=PT({root:k,value:n,autoFocus:c,theme:d,height:f,minHeight:p,maxHeight:m,width:g,minWidth:x,maxWidth:y,basicSetup:b,placeholder:S,indentWithTab:E,editable:v,readOnly:C,selection:s,onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:u,extensions:r,initialState:j});A.useImperativeHandle(e,()=>({editor:H.current,state:N,view:B}),[H,$,N,B]);var L=A.useCallback(ee=>{H.current=ee,P(ee)},[P]);if(typeof n!="string")throw new Error("value must be typeof string but got "+typeof n);var W=typeof d=="string"?"cm-theme-"+d:"cm-theme";return h.jsxRuntimeExports.jsx("div",me({ref:L,className:""+W+(t?" "+t:"")},R))});Eg.displayName="CodeMirror";function Cg({value:i,language:e,readOnly:t=!1,height:n="300px",foldable:s=!1,onChange:r}){const[o]=M.useStyletron(),l=e==="json"?[Tw()]:[],a=_.theme({"&":{fontSize:"14px",fontFamily:"monospace"},".cm-content":{padding:"12px"},".cm-editor":{backgroundColor:t?"#F8F8F8":"#FFFFFF"},".cm-editor.cm-focused":{outline:"none"}});return h.jsxRuntimeExports.jsx("div",{className:o({border:"1px solid #E0E0E0",borderRadius:"4px",overflow:"hidden",height:n}),children:h.jsxRuntimeExports.jsx(Eg,{value:i,height:n,extensions:[...l,a],onChange:r,editable:!t,basicSetup:{lineNumbers:!0,foldGutter:s,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!1,bracketMatching:!0,closeBrackets:!1,autocompletion:!1,highlightSelectionMatches:!1,searchKeymap:!1}})})}function LT({data:i,isLoading:e}){var l,a,u,c,d,f,p,m;const[,t]=M.useStyletron(),n=i,s=(l=n==null?void 0:n.status)==null?void 0:l.sourcePipeline,r=((u=(a=s==null?void 0:s.pipeline)==null?void 0:a.spec)==null?void 0:u.manifest)??((d=(c=s==null?void 0:s.draftPipeline)==null?void 0:c.spec)==null?void 0:d.manifest)??((p=(f=n==null?void 0:n.spec)==null?void 0:f.pipelineSpec)==null?void 0:p.manifest),o=(m=r==null?void 0:r.content)==null?void 0:m.value;return e?h.jsxRuntimeExports.jsx(Vi.Skeleton,{animation:!0,height:"400px",width:"100%"}):o?h.jsxRuntimeExports.jsxs("section",{children:[h.jsxRuntimeExports.jsx(be.HeadingSmall,{marginTop:"0",marginBottom:t.sizing.scale600,children:"General"}),h.jsxRuntimeExports.jsx(h.Box,{title:"Manifest content",children:h.jsxRuntimeExports.jsx(Cg,{value:JSON.stringify(o,null,2),language:"json",readOnly:!0,foldable:!0,height:"auto"})})]}):h.jsxRuntimeExports.jsx(Ht,{illustration:h.jsxRuntimeExports.jsx(ii,{height:t.sizing.scale1600,width:t.sizing.scale1600,kind:gt.PRIMARY}),title:"No configuration available",description:"This pipeline run has no configuration attached to its manifest"})}function NT(i){return i.filter(e=>!!e.name&&!!e.url).map(e=>({id:e.name,accessor:()=>e.name,url:e.url,tooltip:e.tooltip}))}function Nu(i){const{links:e,title:t,isLoading:n=!1}=i;return h.jsxRuntimeExports.jsx(h.Box,{title:t,children:h.jsxRuntimeExports.jsx(h.Row,{items:NT(e),loading:n})})}const FT="Execute Workflow",BT="michelangelo/environment";function VT({data:i,isLoading:e}){var p,m,g,x,y,b,S,E,v;const[t,n]=M.useStyletron(),{projectId:s,phase:r}=h.useStudioParams("detail"),o=i,l=(g=(m=(p=o==null?void 0:o.spec)==null?void 0:p.resume)==null?void 0:m.pipelineRun)==null?void 0:g.name,a=[{name:"Michelangelo pipeline run logs",url:(y=_T((x=o==null?void 0:o.status)==null?void 0:x.steps,FT))==null?void 0:y.logUrl},{name:l?`Resumed from ${l}`:void 0,url:l?`/${s}/${r}/runs/${l}`:void 0}],u=[{id:"duration",label:"Duration",value:zT(o)??""},{id:"execution-timestamp",label:"Execution Timestamp",value:h.timestampToString((S=(b=o==null?void 0:o.metadata)==null?void 0:b.creationTimestamp)==null?void 0:S.seconds,h.TimeZone.Local)??""}],c=[{id:"environment",label:"Environment",value:((v=(E=o==null?void 0:o.metadata)==null?void 0:E.labels)==null?void 0:v[BT])??""}],d=t({display:"flex",flexDirection:"column",gap:n.sizing.scale600}),f=C=>h.jsxRuntimeExports.jsx(yi,{onSubmit:()=>{},initialValues:Object.fromEntries(C.map(k=>[k.id,k.value])),children:h.jsxRuntimeExports.jsx("div",{className:d,children:C.map(k=>e?h.jsxRuntimeExports.jsx(Vi.Skeleton,{animation:!0,height:"48px",width:"100%"},k.id):h.jsxRuntimeExports.jsx(He,{name:k.id,label:k.label,readOnly:!0},k.id))})});return h.jsxRuntimeExports.jsxs("div",{className:t({display:"flex",flexDirection:"column",gap:n.sizing.scale600}),children:[h.jsxRuntimeExports.jsx(Nu,{title:"Useful links",links:a,isLoading:e}),h.jsxRuntimeExports.jsxs("section",{children:[h.jsxRuntimeExports.jsx(be.HeadingSmall,{marginTop:"0",marginBottom:n.sizing.scale600,children:"Key status indicators"}),h.jsxRuntimeExports.jsx(h.Box,{children:f(u)})]}),h.jsxRuntimeExports.jsxs("section",{children:[h.jsxRuntimeExports.jsx(be.HeadingSmall,{marginTop:"0",marginBottom:n.sizing.scale600,children:"Configuration"}),h.jsxRuntimeExports.jsx(h.Box,{children:f(c)})]})]})}function _T(i,e){return i==null?void 0:i.find(t=>t.name===e)}function zT(i){var n,s,r,o;const e=Number((s=(n=i==null?void 0:i.metadata)==null?void 0:n.creationTimestamp)==null?void 0:s.seconds),t=(r=i==null?void 0:i.status)==null?void 0:r.state;if(isNaN(e)||t===void 0)return null;if(of.has(t)){const l=(((o=i==null?void 0:i.status)==null?void 0:o.steps)??[]).map(a=>{var u;return Number((u=a.endTime)==null?void 0:u.seconds)}).filter(a=>!isNaN(a));return l.length===0?null:ad(Math.max(...l)-e)}return t===Ar.RUNNING?ad(Math.floor(Date.now()/1e3)-e):null}function ad(i){const e=Math.max(0,Math.round(i)),t=[],n=Math.floor(e/3600),s=Math.floor(e%3600/60),r=e%60;return n>0&&t.push(`${n} ${n===1?"hour":"hours"}`),s>0&&t.push(`${s} ${s===1?"minute":"minutes"}`),(r>0||t.length===0)&&t.push(`${r} ${r===1?"second":"seconds"}`),t.join(" ")}const $T={type:"detail",metadata:iu,pages:[{id:"information",label:"Information",type:"custom",component:VT},{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:h.CellType.DATE},{id:"endTime.seconds",label:"End time",type:h.CellType.DATE},{id:"duration",label:"Duration",type:h.CellType.TEXT,accessor:i=>{var e,t;return h.formatElapsedSeconds((e=i.startTime)==null?void 0:e.seconds,(t=i.endTime)==null?void 0:t.seconds)}},{id:"logUrl",label:"Logs"},{id:"state",label:"Status",type:h.CellType.STATE,stateTextMap:uf,stateColorMap:cf},{id:"retry",label:"Actions",type:h.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}}}},{id:"configuration",label:"Pipeline Configuration",type:"custom",component:LT}]},HT="michelangelo/SpecUpdateTimestamp",GT="michelangelo/UpdateTimestamp",wg=1e6,to=63,Rg=/^[a-z0-9]([-a-z0-9]*[a-z0-9])?$/,io="Must only contain lowercase alphanumeric characters, '-', and must start and end with an alphanumeric character";function kg(i){var t,n,s,r;const e=(n=(t=i.metadata)==null?void 0:t.labels)==null?void 0:n[HT];return e?Number(e)/wg:(r=(s=i.metadata)==null?void 0:s.creationTimestamp)==null?void 0:r.seconds}function UT(i){var t,n,s,r;const e=(n=(t=i.metadata)==null?void 0:t.labels)==null?void 0:n[GT];return e?Number(e)/wg:(r=(s=i.metadata)==null?void 0:s.creationTimestamp)==null?void 0:r.seconds}const WT=[{id:"metadata.name",label:"Pipeline run name",items:[{id:"metadata.name",url:"/${studio.projectId}/${studio.phase}/runs/${data.metadata.name}"},{id:"spec.description",type:h.CellType.DESCRIPTION}]},ff,{id:"metadata",label:"Last Updated",type:h.CellType.DATE,accessor:i=>UT(i)},df,{id:"metadata.labels",label:"Environment",type:h.CellType.TEXT,accessor:i=>{var t;const e=(t=i==null?void 0:i.metadata)==null?void 0:t.labels;return af(e)||null}},pf,tu,mf],qT={type:"list",tableConfig:{columns:WT}},KT=new Set([Ar.FAILED,Ar.KILLED]),YT=i=>{var t;const e=(t=i.status)==null?void 0:t.state;return e!==void 0&&KT.has(e)},XT=[{source:"metadata.name",destination:"spec.resume.pipelineRun.name",transformation:i=>i},{source:"metadata.namespace",destination:"spec.resume.pipelineRun.namespace",transformation:i=>i},{destination:"spec.resume.resumeFrom",transformation:"unset"},{destination:"spec.retryInfo",transformation:"unset"},{destination:"spec.actor",transformation:"unset"},{destination:"spec.kill",transformation:"unset"},{destination:"status",transformation:"unset"},{destination:"typeMeta",transformation:"unset"},{source:"metadata",destination:"metadata",transformation:i=>({name:`run${eu({withDate:!0})}`,namespace:i.namespace})}],Oo={id:"runs",name:"Runs",service:"pipelineRun",state:"active",views:[qT,$T],actions:[{display:{label:"Retry",icon:"arrowCircular"},hierarchy:Ct.PRIMARY,disabled:[{condition:vt(({data:i})=>!YT(i)),message:"Only failed or killed runs can be retried"}],operation:{type:"mutation",mutation:{mutationName:"CreatePipelineRun",middleware:{operations:XT},successOperations:[{type:"invalidate",targets:["ListPipelineRun"]},{type:"toast",message:"A new pipeline run has been created from the failed step of this run.",action:{label:"See new run",route:vt("/${studio.projectId}/${studio.phase}/runs/${response.pipelineRun.metadata.name}")}}]}},modal:{type:"confirm",header:{title:"Retry Pipeline Run"},body:vt(({data:i})=>{var e;return`Retry run **${(e=i.metadata)==null?void 0:e.name}**? This starts a new run that reuses the cached results of every step that already succeeded.`}),button:{label:"Retry"}}}]},Tg={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:[{...go,state:"disabled"},{...Oo,state:"disabled"},{id:"datasources",name:"Data Sources",state:"disabled",service:"datasource",views:[]}]},QT=1,JT=i=>({operation:{criterion:[{fieldName:"model.model_family_name",operator:QT,matchValue:i}]}}),ZT=()=>{const i=vs(),{input:e}=ke("spec.modelFamilyName"),t=e.value??"",{data:n,isLoading:s}=h.useStudioQuery({queryName:"ListModelFamily",serviceOptions:{}}),{data:r,isLoading:o}=h.useStudioQuery({queryName:"ListModel",serviceOptions:{listOptionsExt:JT(t)}}),l=((n==null?void 0:n.modelFamilyList.items)??[]).map(u=>({id:u.metadata.name,label:u.spec.name||u.metadata.name})),a=((r==null?void 0:r.modelList.items)??[]).map(u=>({id:u.metadata.name,label:u.metadata.name}));return A.useEffect(()=>{i.change("spec.desiredRevision.name","")},[i,t]),h.jsxRuntimeExports.jsxs(Yi,{title:"Model",description:"The selected model will be deployed",children:[h.jsxRuntimeExports.jsx(wt,{name:"spec.modelFamilyName",label:"Model family",caption:"Model family the deployed model belongs to",options:l,isLoading:s,clearable:!1}),h.jsxRuntimeExports.jsx(wt,{name:"spec.desiredRevision.name",label:"Model",required:!0,caption:"Search and select the model to deploy",options:a,isLoading:o,disabled:!t,clearable:!1,placeholder:"Search model to deploy"})]})},wl={UNKNOWN:0,TRUE:1,FALSE:2},ot={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},Pt={INVALID:0,INITIALIZING:1,HEALTHY:2,UNHEALTHY:3,EMPTY:4},Un={INFERENCE_SERVER:1,OFFLINE:2,MOBILE:3,SELF_HOSTED:4},eA={[Un.INFERENCE_SERVER]:"Online",[Un.OFFLINE]:"Offline",[Un.MOBILE]:"Mobile",[Un.SELF_HOSTED]:"Self-hosted"},Ag={id:"status.stage",label:"Stage",type:h.CellType.TYPE,typeTextMap:{[ot.INVALID]:"Invalid",[ot.VALIDATION]:"Validation",[ot.PLACEMENT]:"Placement",[ot.RESOURCE_ACQUISITION]:"Resource acquisition",[ot.ROLLOUT_COMPLETE]:"Rollout complete",[ot.ROLLOUT_FAILED]:"Rollout failed",[ot.ROLLBACK_IN_PROGRESS]:"Rollback in progress",[ot.ROLLBACK_COMPLETE]:"Rollback complete",[ot.ROLLBACK_FAILED]:"Rollback failed",[ot.CLEAN_UP_IN_PROGRESS]:"Clean up in progress",[ot.CLEAN_UP_COMPLETE]:"Clean up complete",[ot.CLEAN_UP_FAILED]:"Clean up failed"}},jg={id:"status.state",label:"State",type:h.CellType.STATE,stateTextMap:{[Pt.INVALID]:"Invalid",[Pt.INITIALIZING]:"Initializing",[Pt.HEALTHY]:"Healthy",[Pt.UNHEALTHY]:"Unhealthy",[Pt.EMPTY]:"Empty"},stateColorMap:{[Pt.INVALID]:"gray",[Pt.INITIALIZING]:"blue",[Pt.HEALTHY]:"green",[Pt.UNHEALTHY]:"red",[Pt.EMPTY]:"gray"}},tA=({onClose:i})=>{const{projectId:e}=h.useStudioParams("base"),{data:t,isLoading:n}=h.useStudioQuery({queryName:"ListInferenceServer",serviceOptions:{}}),s=((t==null?void 0:t.inferenceServerList.items)??[]).map(a=>({id:a.metadata.name,label:a.metadata.name})),r=h.useStudioMutation({mutationName:"CreateDeployment",successOperations:[{type:"toast",message:"Deployment created"},{type:"invalidate",targets:["ListDeployment"]}]}),o=async a=>{if(r.isPending)return;const{modelFamilyName:u,...c}=a.spec;await r.mutateAsync({...a,spec:{...c,desiredRevision:{...a.spec.desiredRevision,namespace:e},target:{case:"inferenceServer",value:{...a.spec.target.value,namespace:e}}}})},l={metadata:{name:"",namespace:e},spec:{desiredRevision:{name:"",namespace:e},target:{case:"inferenceServer",value:{name:"",namespace:e}},strategy:{rolloutStrategy:{case:"rolling",value:{incrementPercentage:0}}},definition:{type:Un.INFERENCE_SERVER}}};return h.jsxRuntimeExports.jsxs(Es,{isOpen:!0,onDismiss:i,heading:"Create deployment",onSubmit:o,submitLabel:"Create",initialValues:l,children:[h.jsxRuntimeExports.jsx(He,{name:"metadata.name",label:"Name",required:!0,maxLength:to,validate:ho($i(),Ka(to),Ya(Rg,io)),caption:io,placeholder:"my-deployment"}),h.jsxRuntimeExports.jsx(wt,{name:"spec.target.value.name",label:"Inference server",required:!0,validate:$i(),options:s,isLoading:n,clearable:!1,caption:"The target inference server this deployment will serve traffic to"}),h.jsxRuntimeExports.jsx(ZT,{})]})},Xt={INVALID:0,CUSTOM:1,REGRESSION:2,BINARY_CLASSIFICATION:3,MULTICLASS_CLASSIFICATION:4,CLUSTERING:5,LLM_COMPLETION:6,LLM_CHAT_COMPLETION:7,LLM_EMBEDDING:8},Fu={[Xt.INVALID]:"Unknown",[Xt.CUSTOM]:"Custom",[Xt.REGRESSION]:"Regression",[Xt.BINARY_CLASSIFICATION]:"Binary Classification",[Xt.MULTICLASS_CLASSIFICATION]:"Multi-class Classification",[Xt.CLUSTERING]:"Clustering",[Xt.LLM_COMPLETION]:"LLM Completion",[Xt.LLM_CHAT_COMPLETION]:"LLM Chat",[Xt.LLM_EMBEDDING]:"LLM Embedding"};function _n({label:i,children:e}){const[,t]=M.useStyletron();return h.jsxRuntimeExports.jsxs("div",{children:[h.jsxRuntimeExports.jsx(be.LabelSmall,{color:t.colors.contentSecondary,marginBottom:t.sizing.scale200,children:i}),e]})}const Rl={BoxContainer:{style:{flexBasis:"320px",flexGrow:1}}};function kl({title:i,revision:e,emptyText:t,isLoading:n}){var m,g,x,y,b,S,E;const[s,r]=M.useStyletron(),{data:o,isLoading:l}=h.useStudioQuery({queryName:"GetModel",serviceOptions:{name:e==null?void 0:e.name,...(e==null?void 0:e.namespace)!=null&&{namespace:e.namespace}},clientOptions:{enabled:!!(e!=null&&e.name)}});if(n||e!=null&&e.name&&l)return h.jsxRuntimeExports.jsx(h.Box,{title:i,overrides:Rl,children:h.jsxRuntimeExports.jsx("div",{className:s({display:"flex",justifyContent:"center"}),children:h.jsxRuntimeExports.jsx(gx.Spinner,{})})});if(!(e!=null&&e.name))return h.jsxRuntimeExports.jsx(h.Box,{title:i,overrides:Rl,children:h.jsxRuntimeExports.jsx(h.Banner,{kind:"info",artwork:{type:ts.ARTWORK_TYPE.icon,icon:()=>h.jsxRuntimeExports.jsx(h.Icon,{name:"circleI",size:r.sizing.scale800})},children:t})});const a=o==null?void 0:o.model,u=(g=(m=a==null?void 0:a.spec)==null?void 0:m.owner)==null?void 0:g.name,c=(x=a==null?void 0:a.spec)==null?void 0:x.kind,d=c!=null?Fu[c]:void 0,f=(b=(y=a==null?void 0:a.metadata)==null?void 0:y.creationTimestamp)==null?void 0:b.seconds,p=(E=(S=a==null?void 0:a.spec)==null?void 0:S.sourcePipelineRun)==null?void 0:E.name;return h.jsxRuntimeExports.jsx(h.Box,{title:i,overrides:Rl,children:h.jsxRuntimeExports.jsxs("div",{className:s({display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:r.sizing.scale1200,rowGap:r.sizing.scale900}),children:[h.jsxRuntimeExports.jsx(_n,{label:"Model",children:h.jsxRuntimeExports.jsx(be.ParagraphMedium,{marginTop:"0",marginBottom:"0",children:e.name})}),h.jsxRuntimeExports.jsx(_n,{label:"Owner",children:h.jsxRuntimeExports.jsx(be.ParagraphMedium,{marginTop:"0",marginBottom:"0",children:u!=null&&u!==""?u:"—"})}),h.jsxRuntimeExports.jsx(_n,{label:"Creation time",children:h.jsxRuntimeExports.jsx(be.ParagraphMedium,{marginTop:"0",marginBottom:"0",children:f!=null?h.jsxRuntimeExports.jsx(h.DateTime,{timestamp:f}):"—"})}),h.jsxRuntimeExports.jsx(_n,{label:"Type",children:d!=null?h.jsxRuntimeExports.jsx(h.Tag,{size:h.TAG_SIZE.xSmall,behavior:h.TAG_BEHAVIOR.selection,hierarchy:bn.HIERARCHY.secondary,color:h.TAG_COLOR.gray,closeable:!1,children:d}):h.jsxRuntimeExports.jsx(be.ParagraphMedium,{marginTop:"0",marginBottom:"0",children:"—"})}),h.jsxRuntimeExports.jsx(_n,{label:"Source pipeline run",children:h.jsxRuntimeExports.jsx(be.ParagraphMedium,{marginTop:"0",marginBottom:"0",children:p!=null&&p!==""?p:"—"})})]})})}function iA({data:i,isLoading:e}){var p,m,g,x,y,b,S;const[t,n]=M.useStyletron(),{projectId:s,phase:r}=h.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"?(m=l.value)==null?void 0:m.name:void 0,u=[{name:a,url:`/${s}/${r}/targets/${a}`}],c=(x=(g=o==null?void 0:o.spec)==null?void 0:g.definition)==null?void 0:x.type,d=[{id:"type-of-deployment",label:"Type of deployment",value:c!=null?eA[c]??"":""}],f=Object.fromEntries(d.map(E=>[E.id,E.value]));return h.jsxRuntimeExports.jsxs("div",{className:t({display:"flex",flexDirection:"column",gap:n.sizing.scale600}),children:[h.jsxRuntimeExports.jsx(Nu,{title:"Useful links",links:u,isLoading:e}),h.jsxRuntimeExports.jsxs("section",{children:[h.jsxRuntimeExports.jsx(be.HeadingSmall,{marginTop:"0",marginBottom:n.sizing.scale600,children:"Key status indicators"}),h.jsxRuntimeExports.jsxs("div",{className:t({display:"flex",gap:n.sizing.scale600,flexWrap:"wrap"}),children:[h.jsxRuntimeExports.jsx(kl,{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}),h.jsxRuntimeExports.jsx(kl,{title:"Candidate model",revision:(b=o==null?void 0:o.status)==null?void 0:b.candidateRevision,emptyText:"No model currently being deployed",isLoading:e}),h.jsxRuntimeExports.jsx(kl,{title:"Desired model to be deployed",revision:(S=o==null?void 0:o.spec)==null?void 0:S.desiredRevision,emptyText:"No model configured to be deployed",isLoading:e})]})]}),h.jsxRuntimeExports.jsxs("section",{children:[h.jsxRuntimeExports.jsx(be.HeadingSmall,{marginTop:"0",marginBottom:n.sizing.scale600,children:"Configuration"}),h.jsxRuntimeExports.jsx(h.Box,{children:h.jsxRuntimeExports.jsx(yi,{onSubmit:()=>{},initialValues:f,children:h.jsxRuntimeExports.jsx("div",{className:t({display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:n.sizing.scale1200,rowGap:n.sizing.scale600}),children:d.map(E=>e?h.jsxRuntimeExports.jsx(Vi.Skeleton,{animation:!0,height:"48px",width:"100%"},E.id):h.jsxRuntimeExports.jsx(He,{name:E.id,label:E.label,readOnly:!0},E.id))})})})]})]})}const nA={type:"detail",metadata:[{id:"metadata.creationTimestamp.seconds",label:"Created",type:h.CellType.DATE},{id:"spec.owner.name",label:"Owner",type:h.CellType.TEXT},Ag,jg],pages:[{id:"info",label:"Information",type:"custom",component:iA},{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)===ot.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:h.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 wl.TRUE:return le.SUCCESS;case wl.FALSE:return le.ERROR;case wl.UNKNOWN:default:return le.RUNNING}}}}]},sA=[{id:"metadata.name",label:"Name",type:h.CellType.TEXT,url:"/${studio.projectId}/${studio.phase}/deployments/${row.metadata.name}"},{id:"status.currentRevision.name",label:"Model",type:h.CellType.TEXT},{id:"spec.definition.type",label:"Type",type:h.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}},Ag,{id:"spec.inferenceServer.name",label:"Target",type:h.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:h.CellType.TEXT},jg],rA={type:"list",tableConfig:{columns:sA}},oA={id:"deployments",name:"Deployments",service:"deployment",state:"active",views:[rA,nA],createAction:{display:{label:"Create deployment",icon:"plus"},component:tA}},Me={INVALID:0,INITIALIZED:1,CREATE_PENDING:2,SERVING:3,FAILED:4,DELETE_PENDING:5,CREATING:6,DELETING:7,DELETED:8},Tl={UNKNOWN:0,TRUE:1,FALSE:2},Og={DEDICATED:1,MULTI_TENANT:2},lA={TRITON:1},Sr={DEFAULT_TRITON:"default_triton",DEFAULT_TRITON_GPU:"default_triton_gpu",DEFAULT_TRITON_PYTHON:"default_triton_python"},Ig={id:"status.state",label:"State",type:h.CellType.STATE,stateTextMap:{[Me.INVALID]:"Invalid",[Me.INITIALIZED]:"Initialized",[Me.CREATE_PENDING]:"Create pending",[Me.SERVING]:"Serving",[Me.FAILED]:"Failed",[Me.DELETE_PENDING]:"Delete pending",[Me.CREATING]:"Initializing",[Me.DELETING]:"Deleting",[Me.DELETED]:"Deleted"},stateColorMap:{[Me.INVALID]:"gray",[Me.INITIALIZED]:"blue",[Me.CREATE_PENDING]:"blue",[Me.SERVING]:"green",[Me.FAILED]:"red",[Me.DELETE_PENDING]:"blue",[Me.CREATING]:"blue",[Me.DELETING]:"blue",[Me.DELETED]:"gray"}},aA=[1,2,3,4].map(i=>({id:i,label:`Tier ${i}`}));function uA(){var e;const{values:i}=co({values:!0});return((e=i==null?void 0:i.spec)==null?void 0:e.tenancyType)!==Og.MULTI_TENANT?null:h.jsxRuntimeExports.jsxs(Yi,{title:"Owner information",children:[h.jsxRuntimeExports.jsx(He,{name:"spec.ownerSpec.ownerInfo.owningTeam",label:"Owning team",required:!0,validate:$i(),description:"UUID for the team that owns this inference server."}),h.jsxRuntimeExports.jsx(He,{name:"spec.ownerSpec.ownerInfo.owners",label:"Owners",multi:!0}),h.jsxRuntimeExports.jsx(He,{name:"spec.ownerSpec.ownerInfo.ownerGroups",label:"Owner groups",multi:!0}),h.jsxRuntimeExports.jsx(wt,{name:"spec.ownerSpec.tier",label:"Tier",required:!0,validate:$i(),options:aA,clearable:!1})]})}const cA=[{id:Sr.DEFAULT_TRITON,label:"Triton"},{id:Sr.DEFAULT_TRITON_GPU,label:"Triton GPU"},{id:Sr.DEFAULT_TRITON_PYTHON,label:"Triton Python"}],hA=({onClose:i})=>{const{projectId:e}=h.useStudioParams("base"),t=h.useStudioMutation({mutationName:"CreateInferenceServer",successOperations:[{type:"toast",message:"Inference server created"},{type:"invalidate",targets:["ListInferenceServer"],delayMs:2e3}]}),n=async r=>{t.isPending||await t.mutateAsync(r)},s={metadata:{name:"",namespace:e},spec:{tenancyType:Og.DEDICATED,backendType:lA.TRITON,initSpec:{resourceSpec:{cpu:1,memory:"",diskSize:"",gpu:0},servingSpec:{version:"",containerBuildTemplate:Sr.DEFAULT_TRITON},numInstances:1}}};return h.jsxRuntimeExports.jsxs(Es,{isOpen:!0,onDismiss:i,heading:"Create target",onSubmit:n,submitLabel:"Create",initialValues:s,children:[h.jsxRuntimeExports.jsx(He,{name:"metadata.name",label:"Name",required:!0,maxLength:to,validate:ho($i(),Ka(to),Ya(Rg,io)),caption:io,placeholder:"e.g., my-inference-server"}),h.jsxRuntimeExports.jsx(He,{name:"targetTypeDisplay",label:"Target type",defaultValue:"Inference Server",readOnly:!0}),h.jsxRuntimeExports.jsx(wt,{name:"spec.initSpec.servingSpec.containerBuildTemplate",label:"Service Type",required:!0,validate:$i(),options:cA,clearable:!1,caption:'Set the type of image to use for the new inference server. Keep this value as "Triton" if you are unsure which one to use'}),h.jsxRuntimeExports.jsx(uA,{})]})},dA={type:"detail",metadata:[{id:"status.createTime",label:"Created",type:h.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:h.CellType.TEXT},Ig],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:h.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 Tl.TRUE:return le.SUCCESS;case Tl.FALSE:return le.ERROR;case Tl.UNKNOWN:default:return le.RUNNING}}}}]},fA=[{id:"metadata.name",label:"Target name",type:h.CellType.TEXT,url:"/${studio.projectId}/${studio.phase}/targets/${row.metadata.name}"},{id:"status.updateTime",label:"Last updated",type:h.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:h.CellType.TAG,accessor:()=>"Inference Server"},Ig],pA={type:"list",tableConfig:{columns:fA}},mA={id:"targets",name:"Targets",service:"inferenceServer",state:"active",views:[pA,dA],createAction:{display:{label:"Create target",icon:"plus"},component:hA}},gA=iu.filter(i=>i!==tu),xA={type:"detail",metadata:[{id:"metadata.creationTimestamp.seconds",label:"Created",type:h.CellType.DATE},{id:"spec.actor.name",label:"Started by",type:h.CellType.TEXT},Sf,nu],pages:[{id:"runs",label:"Recent Runs",type:"table",queryConfig:{endpoint:"list",service:"pipelineRun",serviceOptions:{listOptions:{labelSelector:`${Vl}=\${page.metadata.name}`}}},tableConfig:{columns:[{id:"metadata.name",label:"Name",url:"/${studio.projectId}/${studio.phase}/runs/${row.metadata.name}"},...gA]}}]},yA={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:h.CellType.DATE},{id:"spec.actor.name",label:"Started by",type:h.CellType.TEXT},Sf,nu]}};var Mg=(i=>(i[i.NO_ACTION=0]="NO_ACTION",i[i.KILL=1]="KILL",i[i.PAUSE=2]="PAUSE",i[i.RESUME=3]="RESUME",i))(Mg||{}),La=(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))(La||{});const ud=i=>{var t;const e=(t=i.status)==null?void 0:t.state;return e===La.RUNNING||e===La.PAUSED},Bu={id:"triggers",name:"Triggers",service:"triggerRun",state:"active",views:[yA,xA],actions:[{display:{label:"Kill",icon:"stopCircle"},hierarchy:vt(({data:i})=>ud(i)?Ct.SECONDARY:Ct.TERTIARY),disabled:[{condition:vt(({data:i})=>!ud(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:Mg.KILL}]}}},modal:{type:"confirm",header:{title:"Kill Trigger Run"},body:vt(({data:i})=>`Kill run **${i.metadata.name}** in pipeline **${i.spec.pipeline.name}**? This action cannot be undone.`),button:{label:"Kill"}}}]},Pg={id:"deploy",icon:"deploy",name:"Deploy & Predict",description:"Deploy your models and predict new data",state:"active",pipelineTypes:["PIPELINE_TYPE_PREDICTION","PIPELINE_TYPE_SCORER"],entities:[go,Bu,Oo,mA,oA]},Dg={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:[]},Lg={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:[go,Bu,Oo]};function bA({data:i,isLoading:e}){var p,m,g,x,y,b,S,E,v,C,k;const[t,n]=M.useStyletron(),{projectId:s,phase:r}=h.useStudioParams("detail"),o=i,l=(m=(p=o==null?void 0:o.spec)==null?void 0:p.sourcePipelineRun)==null?void 0:m.name,a=[{name:l,url:l?`/${s}/${r}/runs/${l}`:void 0}],u=[{id:"model-family",label:"Model family",value:((x=(g=o==null?void 0:o.spec)==null?void 0:g.modelFamily)==null?void 0:x.name)??""},{id:"training-framework",label:"Training framework",value:((y=o==null?void 0:o.spec)==null?void 0:y.trainingFramework)??""},{id:"source-platform",label:"Source platform",value:((b=o==null?void 0:o.spec)==null?void 0:b.source)??""}],c=Object.fromEntries(u.map(j=>[j.id,j.value])),d=[{id:"train-evaluation-hive-table",label:"Train evaluation Hive table",value:((E=(S=o==null?void 0:o.spec)==null?void 0:S.predictionResult)==null?void 0:E.trainTableName)??""},{id:"validation-evaluation-hive-table",label:"Validation evaluation Hive table",value:((C=(v=o==null?void 0:o.spec)==null?void 0:v.predictionResult)==null?void 0:C.testTableName)??""}],f=Object.fromEntries(d.map(j=>[j.id,j.value]));return h.jsxRuntimeExports.jsxs("div",{className:t({display:"flex",flexDirection:"column",gap:n.sizing.scale600}),children:[h.jsxRuntimeExports.jsx(Nu,{title:"Useful links",links:a,isLoading:e}),h.jsxRuntimeExports.jsx(h.Box,{title:"Description",children:e?h.jsxRuntimeExports.jsx(Vi.Skeleton,{animation:!0,height:"96px",width:"100%"}):h.jsxRuntimeExports.jsx(yi,{onSubmit:()=>{},initialValues:{description:((k=o==null?void 0:o.spec)==null?void 0:k.description)??""},children:h.jsxRuntimeExports.jsx(mo,{name:"description",readOnly:!0,rows:4})})}),h.jsxRuntimeExports.jsxs("section",{children:[h.jsxRuntimeExports.jsx(be.HeadingSmall,{marginTop:"0",marginBottom:n.sizing.scale600,children:"Configuration"}),h.jsxRuntimeExports.jsx(h.Box,{title:"Model context",children:h.jsxRuntimeExports.jsx(yi,{onSubmit:()=>{},initialValues:c,children:h.jsxRuntimeExports.jsx("div",{className:t({display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:n.sizing.scale1200,rowGap:n.sizing.scale600}),children:u.map(j=>e?h.jsxRuntimeExports.jsx(Vi.Skeleton,{animation:!0,height:"48px",width:"100%"},j.id):h.jsxRuntimeExports.jsx(He,{name:j.id,label:j.label,readOnly:!0},j.id))})})}),h.jsxRuntimeExports.jsx(h.Box,{title:"Training setup",overrides:{BoxContainer:{style:{marginTop:n.sizing.scale600}}},children:h.jsxRuntimeExports.jsx(yi,{onSubmit:()=>{},initialValues:f,children:h.jsxRuntimeExports.jsx("div",{className:t({display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:n.sizing.scale1200,rowGap:n.sizing.scale600}),children:d.map(j=>e?h.jsxRuntimeExports.jsx(Vi.Skeleton,{animation:!0,height:"48px",width:"100%"},j.id):h.jsxRuntimeExports.jsx(He,{name:j.id,label:j.label,readOnly:!0},j.id))})})})]})]})}const SA={type:"detail",metadata:[{id:"spec.sourcePipelineRun.name",label:"Source pipeline run",type:h.CellType.LINK,url:"/${studio.projectId}/${studio.phase}/runs/${page.spec.sourcePipelineRun.name}"},{id:"spec.owner.name",label:"Trained by",type:h.CellType.TEXT},{id:"metadata.creationTimestamp.seconds",label:"Creation time",type:h.CellType.DATE},{id:"lastUpdated",label:"Last updated",type:h.CellType.DATE,accessor:i=>kg(i)},{id:"spec.kind",label:"Type",type:h.CellType.TYPE,typeTextMap:Fu}],pages:[{id:"information",label:"Information",type:"custom",component:bA}]},vA=[{id:"metadata.name",label:"Model",items:[{id:"metadata.name",url:"/${studio.projectId}/${studio.phase}/models/${data.metadata.name}"},{id:"spec.description",type:h.CellType.DESCRIPTION}]},{id:"metadata.labels",label:"Environment",type:h.CellType.TEXT,accessor:i=>{var t;const e=(t=i==null?void 0:i.metadata)==null?void 0:t.labels;return af(e)||null}},{id:"spec.modelFamily.name",label:"Model Family",type:h.CellType.TEXT},{id:"spec.kind",label:"Type",type:h.CellType.TYPE,typeTextMap:Fu},{id:"metadata",label:"Last Updated",type:h.CellType.DATE,accessor:i=>kg(i)}],EA={type:"list",tableConfig:{columns:vA}},CA={id:"models",name:"Trained Models",service:"model",state:"active",views:[EA,SA]},Ng={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:[go,Bu,Oo,CA,{id:"evaluations",name:"Evaluations",state:"disabled",service:"evaluationReport",views:[]},{id:"notebooks",name:"Notebooks",state:"disabled",service:"notebook",views:[]}]},Vu={data:Tg,train:Ng,deploy:Pg,retrain:Lg,monitor:Dg},wA=[{id:"core-ml",name:"Core ML",phases:Object.values(Vu)}],RA=M.styled("hr",({$theme:i})=>({border:"none",borderBottom:`2px dashed ${i.colors.contentInverseTertiary}`,margin:`${i.sizing.scale200} 0`})),es=M.styled("div",({$theme:i})=>({display:"flex",flexDirection:"column",gap:i.sizing.scale800}));function Fg(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[Ef[n].borderColorName]})}},Content:{style:({$theme:l})=>({paddingTop:l.sizing.scale300})},...s};return h.jsxRuntimeExports.jsx(Ja,{...r,defaultExpanded:t??!1,overrides:o})}function Bg(i){return`task-${i.name}`}function Vg(i){const e=document.getElementById(Bg(i));if(!e)return;const t=e.getBoundingClientRect();window.scrollTo({top:window.scrollY+t.top-16,behavior:"smooth"})}function _u(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},..._u(t.subTasks,t)]}const kA=M.styled("div",({$theme:i})=>({display:"flex",flex:"auto",gap:i.sizing.scale300,flexWrap:"wrap",alignItems:"center"})),_g=M.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 zu(i){const{state:e}=i,[,{colors:t,sizing:n}]=M.useStyletron(),s=ov[e];return h.jsxRuntimeExports.jsx(h.Icon,{name:s.name,color:t[s.colorName],size:n.scale700})}const zg={overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},TA=M.styled("div",({$theme:{colors:i,sizing:e},$state:t,role:n})=>{const{colorName:s="contentPrimary",backgroundColorName:r="backgroundPrimary",borderColorName:o}=Ef[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"}}),AA=M.styled("div",({$theme:{typography:i}})=>({...i.LabelSmall,...zg}));function $g(i){const{task:e,onClick:t}=i,{focused:n,name:s,state:r,subTasks:o}=e,l=!!(o!=null&&o.length),[a]=M.useStyletron();return h.jsxRuntimeExports.jsxs(TA,{$state:r,tabIndex:0,...t?{role:"button",onClick:t}:{},children:[h.jsxRuntimeExports.jsx(zu,{state:r}),h.jsxRuntimeExports.jsx(AA,{children:s}),l&&n?h.jsxRuntimeExports.jsx("div",{className:a({position:"absolute",bottom:"-25px",left:"50%",transform:"translate(-50%, 0)"}),children:h.jsxRuntimeExports.jsx(_g,{$color:"contentInverseTertiary",$direction:"up"})}):null]})}function Na({taskList:i,onTaskClick:e}){return h.jsxRuntimeExports.jsx(h.jsxRuntimeExports.Fragment,{children:i.map((t,n)=>h.jsxRuntimeExports.jsxs(A.Fragment,{children:[n>0&&h.jsxRuntimeExports.jsx(_g,{$color:"contentInverseSecondary",$direction:"right"}),h.jsxRuntimeExports.jsx($g,{task:t,...e?{onClick:()=>e(t)}:{}})]},n))})}function Hg({matrix:i,onTaskClick:e,overrides:t}){const[n,s]=M.getOverrides(t==null?void 0:t.TaskListRenderer,Na),[r,o]=M.getOverrides((t==null?void 0:t.SubTaskListRenderer)??(t==null?void 0:t.TaskListRenderer),Na);return h.jsxRuntimeExports.jsx(h.jsxRuntimeExports.Fragment,{children:i.map((l,a)=>{const u=l.parent?r:n,c=l.parent?o:s;return h.jsxRuntimeExports.jsxs(A.Fragment,{children:[a>0&&h.jsxRuntimeExports.jsx(RA,{}),h.jsxRuntimeExports.jsx(kA,{children:h.jsxRuntimeExports.jsx(u,{taskList:l.taskList,onTaskClick:e,parent:l.parent,...c})})]},a)})})}function jA(i){const{label:e,cells:t,value:n}=i;return h.jsxRuntimeExports.jsx(Fg,{title:h.jsxRuntimeExports.jsx(be.LabelSmall,{children:e}),children:h.jsxRuntimeExports.jsx(h.Row,{items:t,record:n??void 0})})}const Ji={boolValue:"boolValue",listValue:"listValue",nullValue:"nullValue",numberValue:"numberValue",stringValue:"stringValue",structValue:"structValue"};function Gg(i){return!!i&&typeof i=="object"&&"fields"in i&&typeof i.fields=="object"&&!Array.isArray(i.fields)}function OA(i){const e=Object.entries(i),[t,n]=e[0]||[];return{kind:t,kindValue:n}}function IA(i){const e={};for(const[t,n]of Object.entries(i))e[t]=no(n);return e}function no(i){if(i==null)return i;if(Gg(i))return IA(i.fields);if(typeof i=="object"&&i!==null){const e=i,{kind:t,kindValue:n}=OA(e);switch(t){case Ji.listValue:return n&&typeof n=="object"&&"values"in n?n.values.map(r=>no(r)):[];case Ji.nullValue:return null;case Ji.structValue:return n?no(n):{};case Ji.boolValue:case Ji.numberValue:case Ji.stringValue:return n;default:return i}}return i}function MA(i){const{label:e,value:t}=i,n=Gg(t)?no(t):t,s=JSON.stringify(n,null,2);return h.jsxRuntimeExports.jsx(Ja,{title:h.jsxRuntimeExports.jsx(be.LabelSmall,{children:e}),children:h.jsxRuntimeExports.jsx(Cg,{readOnly:!0,language:"json",value:s,onChange:()=>null})})}function PA(i){const[e,t]=M.useStyletron(),{label:n,value:s,markdown:r=!0,error:o=!1}=i;if(!s)return null;const l=s.substring(0,1e4);return h.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:[h.jsxRuntimeExports.jsx(be.LabelSmall,{id:"textarea-title",children:n}),h.jsxRuntimeExports.jsx(be.ParagraphSmall,{"aria-labelledby":"textarea-title",className:e({marginBottom:0,marginTop:t.sizing.scale100}),children:r?h.jsxRuntimeExports.jsx(h.Markdown,{children:l}):l})]})}function DA(i){const[e,t]=M.useStyletron(),{task:n,bodySchema:s,overrides:r,metadata:o}=i,{subTasks:l}=n,a=h.useInterpolationResolver();if(l!=null&&l.length){const u=_u(l,n);return h.jsxRuntimeExports.jsxs(es,{children:[h.jsxRuntimeExports.jsx(h.Box,{children:h.jsxRuntimeExports.jsx(Hg,{matrix:u,onTaskClick:Vg,overrides:{TaskListRenderer:r==null?void 0:r.TaskListRenderer,SubTaskListRenderer:r==null?void 0:r.SubTaskListRenderer}})}),l.map((c,d)=>h.jsxRuntimeExports.jsx(Ug,{task:c,bodySchema:s,overrides:r,metadata:o},d))]})}if(s!=null&&s.length){const u=a(s,{row:n});return h.jsxRuntimeExports.jsx("div",{className:e({display:"flex",flexDirection:"column",gap:t.sizing.scale600}),children:u.map((c,d)=>{const{label:f}=c;if(c.type==="struct"){const p=h.getObjectValue(n.record,c.accessor);return h.jsxRuntimeExports.jsx(MA,{label:f,value:p},d)}if(c.type==="textarea"){const p=h.getObjectValue(n.record,c.accessor),{error:m,markdown:g}=c;return h.jsxRuntimeExports.jsx(PA,{label:f,value:p,error:m,markdown:g},d)}if(c.type==="metadata"){const{cells:p}=c;return h.jsxRuntimeExports.jsx(jA,{label:f,value:n.record,cells:p},d)}return null})})}return h.jsxRuntimeExports.jsxs("div",{children:["No subtasks, no body schema for ",n.name]})}function cd(i){const[e,t]=M.useStyletron(),{task:n,id:s,metadata:r}=i,{name:o,state:l}=n;return h.jsxRuntimeExports.jsxs(es,{id:s,children:[h.jsxRuntimeExports.jsxs("div",{className:e({display:"flex",gap:t.sizing.scale500}),children:[h.jsxRuntimeExports.jsx("div",{className:e({marginTop:"2px"}),children:h.jsxRuntimeExports.jsx(zu,{state:l})}),h.jsxRuntimeExports.jsx("div",{className:e({...t.typography.LabelLarge,marginBottom:t.sizing.scale100}),children:o})]}),r&&h.jsxRuntimeExports.jsx(h.Row,{items:r,record:n.record})]})}function Ug(i){var o;const{task:e,metadata:t,bodySchema:n,overrides:s}=i,r=Bg(e);return(o=e.subTasks)!=null&&o.length||n!=null&&n.length?h.jsxRuntimeExports.jsx(Fg,{id:r,title:h.jsxRuntimeExports.jsx(cd,{task:e,metadata:t}),defaultExpanded:e.focused,state:e.state,children:h.jsxRuntimeExports.jsx(DA,{task:e,bodySchema:n,metadata:t,overrides:s})}):h.jsxRuntimeExports.jsx(cd,{id:r,task:e,metadata:t})}function LA(i,e){const{tasks:t}=i,{accessor:n,subTasksAccessor:s}=t;function r(l,a,u){const c=u.findIndex((p,m)=>{const g=i.tasks.stateBuilder(p,m,u,e);return g!==le.SUCCESS&&g!==le.SKIPPED}),d=h.getObjectValue(l,t.header.heading),f=h.getObjectValue(l,"name");return{name:d!=null&&d.trim()?d:f,state:i.tasks.stateBuilder(l,a,u,e),subTasks:s?h.getObjectValue(l,s,[]).map(r):[],record:l,focused:c===a||c===-1&&a===u.length-1}}return h.getObjectValue(e,n,[]).map(r)}function NA(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 Wg(i){const{schema:e,data:t,overrides:n}=i,[s,r]=M.useStyletron(),o=(n==null?void 0:n.taskList)??LA(e,t);if(!o.length)return h.jsxRuntimeExports.jsx(Ht,{illustration:h.jsxRuntimeExports.jsx(ii,{height:"64px",width:"64px",kind:gt.PRIMARY}),title:e.emptyState.title,description:e.emptyState.description});const l=_u(o);return h.jsxRuntimeExports.jsxs(es,{children:[h.jsxRuntimeExports.jsx(h.Box,{title:h.jsxRuntimeExports.jsxs("div",{className:s({display:"flex",alignItems:"center",gap:r.sizing.scale500}),children:[h.jsxRuntimeExports.jsx(zu,{state:NA(o)}),"Overview"]}),children:h.jsxRuntimeExports.jsx(es,{children:h.jsxRuntimeExports.jsx(Hg,{matrix:l,onTaskClick:a=>{Vg(a)},overrides:{TaskListRenderer:n==null?void 0:n.TaskListRenderer,SubTaskListRenderer:n==null?void 0:n.SubTaskListRenderer}})})}),h.jsxRuntimeExports.jsx(es,{children:o.map((a,u)=>h.jsxRuntimeExports.jsx(Ug,{task:a,metadata:e.tasks.header.metadata,bodySchema:e.tasks.body,overrides:n},u))})]})}function FA(i,e){try{localStorage.setItem(i,JSON.stringify(e))}catch{}}function BA(i,e){try{const t=localStorage.getItem(i);return t===null?e:JSON.parse(t)??e}catch{return e}}const VA={};function qg(){return BA(Td,VA)}function _A(i,e){const t=qg();return h.lodashExports.isEqual(h.lodashExports.get(t,i),e)?!1:(FA(Td,h.lodashExports.set(h.lodashExports.cloneDeep(t),i,e)),!0)}function Zi(i,e){const t=qg(),[n,s]=A.useState(h.getObjectValue(t,i,e)??e);return[n,o=>{const l=o instanceof Function?o(n):o;_A(i,l),s(l)}]}function $u({tableSettingsId:i,filterSettingsId:e,initialState:t}){var j;const n=e??i,[s,r]=Zi(`${n}.globalFilter`,(t==null?void 0:t.globalFilter)??ci.globalFilter),[o,l]=Zi(`${n}.columnFilters`,(t==null?void 0:t.columnFilters)??ci.columnFilters),[a,u]=Zi(`${i}.pageSize`,((j=t==null?void 0:t.pagination)==null?void 0:j.pageSize)??ci.pagination.pageSize),[c,d]=Zi(`${i}.sorting`,(t==null?void 0:t.sorting)??ci.sorting),[f,p]=Zi(`${i}.columnOrder`,(t==null?void 0:t.columnOrder)??ci.columnOrder),[m,g]=Zi(`${i}.columnVisibility`,(t==null?void 0:t.columnVisibility)??ci.columnVisibility),[x,y]=A.useState(0),[b,S]=A.useState({}),[E,v]=A.useState((t==null?void 0:t.rowSelectionEnabled)??ci.rowSelectionEnabled),[C,k]=A.useState((t==null?void 0:t.grouping)??ci.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:d,columnOrder:f,setColumnOrder:p,columnVisibility:m,setColumnVisibility:g,rowSelection:b,setRowSelection:S,rowSelectionEnabled:E,setRowSelectionEnabled:v,grouping:C,setGrouping:k}}const zA=({isOpen:i,onDismiss:e,heading:t,onConfirm:n,confirmLabel:s="Confirm",destructive:r=!1,children:o,size:l=Er.SIZE.small})=>{const[a,u]=A.useState(!1),[c,d]=A.useState(null);A.useEffect(()=>{i||(u(!1),d(null))},[i]);const f=async()=>{u(!0);try{await n(),e()}catch(p){d(p instanceof Error?p.message:"An unexpected error occurred."),u(!1)}};return h.jsxRuntimeExports.jsxs(h.Dialog,{isOpen:i,onDismiss:e,heading:t,size:l,placement:Er.PLACEMENT.topCenter,buttonDock:{primaryAction:h.jsxRuntimeExports.jsx(U.Button,{isLoading:a,onClick:f,overrides:r?{BaseButton:{style:({$theme:p})=>({backgroundColor:p.colors.backgroundNegative})}}:void 0,children:s}),dismissiveAction:h.jsxRuntimeExports.jsx(U.Button,{kind:U.KIND.tertiary,onClick:e,disabled:a,children:"Cancel"})},children:[o,c&&h.jsxRuntimeExports.jsx(ts.Banner,{kind:ts.KIND.negative,children:c})]})};function $A({action:i,record:e,onClose:t}){const n=We.useNavigate(),s=h.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 h.jsxRuntimeExports.jsxs(zA,{isOpen:!0,onDismiss:t,onConfirm:r,heading:o.header.title,confirmLabel:o.button.label,destructive:o.destructive,size:o.size,children:[o.banner&&h.jsxRuntimeExports.jsx(h.Banner,{kind:o.banner.kind,artwork:o.banner.icon?{type:ts.ARTWORK_TYPE.icon,icon:()=>h.jsxRuntimeExports.jsx(h.Icon,{name:o.banner.icon})}:void 0,children:o.banner.content}),o.body&&h.jsxRuntimeExports.jsx(h.Markdown,{children:o.body})]})}function Kg({action:i,record:e,onClose:t}){var n;if(((n=i.modal)==null?void 0:n.type)==="custom"){const s=i.modal.component;return h.jsxRuntimeExports.jsx(s,{record:e,onClose:t})}return HA(i)?h.jsxRuntimeExports.jsx($A,{action:i,record:e,onClose:t}):null}function HA(i){var e;return((e=i.modal)==null?void 0:e.type)==="confirm"}const Yg=A.forwardRef((i,e)=>{const{item:t,onSelectAction:n,onClose:s,hoveredItem:r,setHoveredItem:o,keyboardActive:l,setKeyboardActive:a,...u}=i,c=r===t,d=t.disabled?void 0:()=>n(t),f=h.jsxRuntimeExports.jsx(Mo.MenuAdapter,{...u,ref:e,role:"option",artwork:t.display.icon?({size:p})=>h.jsxRuntimeExports.jsx(h.Icon,{name:t.display.icon,size:`${p}px`}):void 0,artworkSize:Mo.ARTWORK_SIZES.MEDIUM,overrides:{Root:{style:{height:"44px",opacity:t.disabled?.4:1}}},$disabled:t.disabled,onClick:d,children:h.jsxRuntimeExports.jsx(Mo.ListItemLabel,{children:t.display.label})});return!t.disabled||!t.disabledMessage?f:h.jsxRuntimeExports.jsx(Bi.Tooltip,{content:t.disabledMessage,autoFocus:!1,accessibilityType:Bi.ACCESSIBILITY_TYPE.tooltip,showArrow:!0,placement:Bi.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})});Yg.displayName="ActionMenuItem";function GA({actions:i,onSelectAction:e,onClose:t}){const[n,s]=A.useState(null),[r,o]=A.useState(!1);return h.jsxRuntimeExports.jsx("div",{onKeyDown:()=>{s(null),o(!0)},children:h.jsxRuntimeExports.jsx(xx.StatefulMenu,{items:i,onItemSelect:({item:l})=>{l.disabled||e(l)},overrides:{Option:{component:Yg,props:{onSelectAction:e,onClose:t,hoveredItem:n,setHoveredItem:s,keyboardActive:r,setKeyboardActive:o}},List:{style:({$theme:l})=>({padding:l.sizing.scale600})}}})})}function UA(i,e){return A.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 Xg({actions:i,buttonProps:e,record:t,popoverProps:n}){const s=A.useRef(!1),[r,o]=A.useState(null),l=We.useNavigate(),[,a]=M.useStyletron(),u=UA(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},d=()=>{document.body.style.overflow="",s.current=!1};return A.useEffect(()=>()=>{s.current&&(document.body.style.overflow="")},[]),h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[h.jsxRuntimeExports.jsx(zt.StatefulPopover,{focusLock:!0,placement:zt.PLACEMENT.bottomLeft,popperOptions:{modifiers:{preventOverflow:{enabled:!0,boundariesElement:"window",padding:8}}},...n,content:({close:f})=>h.jsxRuntimeExports.jsx(GA,{actions:u,onSelectAction:p=>{p.onClick(),f()},onClose:f}),onClose:d,onOpen:c,children:h.jsxRuntimeExports.jsx(U.Button,{kind:U.KIND.tertiary,shape:U.SHAPE.pill,overrides:{BaseButton:{style:{paddingLeft:a.sizing.scale100,paddingRight:a.sizing.scale100}}},...e,size:U.SIZE.compact,title:"Actions","data-tracking-name":"actions-popover-button",children:h.jsxRuntimeExports.jsx(h.Icon,{name:"overflowMenu"})})}),r&&h.jsxRuntimeExports.jsx(Kg,{action:r,record:t,onClose:()=>o(null)})]})}function WA({actions:i,record:e,...t}){const n=h.useInterpolationResolver(),s=A.useMemo(()=>n(i,{row:e}),[n,i,e]);return h.jsxRuntimeExports.jsx(Xg,{actions:s,record:e,...t})}function Qg(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})=>h.jsxRuntimeExports.jsx(WA,{actions:i.actions,record:n.record}):void 0,actionBarConfig:t,disablePagination:i.disablePagination,disableSorting:i.disableSorting,pageSizes:i.pageSizes,enableStickySides:i.enableStickySides}}function qA({isDetailViewLoading:i=!1,queryConfig:e,tableConfig:t,pageId:n}){var f,p;const{projectId:s,phase:r,entity:o}=h.useStudioParams("detail"),{data:l,isLoading:a,error:u}=h.useStudioQuery({queryName:`List${h.capitalizeFirstLetter(e.service)}`,serviceOptions:{namespace:s,...e.serviceOptions},clientOptions:{...e.clientOptions,enabled:!i&&((f=e.clientOptions)==null?void 0:f.enabled)}}),c=$u({tableSettingsId:`${r}/${o}/${n}`,filterSettingsId:`${s}/${r}/${o}/${n}`}),d=Qg(t,{data:((p=l==null?void 0:l[`${e.service}List`])==null?void 0:p.items)??[],loading:a||i,error:u??void 0});return h.jsxRuntimeExports.jsx(ao,{...d,state:c})}function KA({page:i,data:e,isLoading:t}){switch(i.type){case"custom":return A.createElement(i.component,{data:e,isLoading:t});case"execution":return h.jsxRuntimeExports.jsx(Wg,{schema:i,data:e??{}});case"table":{const n=i;return h.jsxRuntimeExports.jsx(qA,{isDetailViewLoading:t,queryConfig:n.queryConfig,tableConfig:n.tableConfig,pageId:n.id})}default:return h.jsxRuntimeExports.jsxs("div",{children:["Page type '",i.type,"' not yet supported"]})}}function YA(i){const e=M.mergeOverrides(i.overrides,{Root:{style:{transform:"unset"}},TabBorder:{style:{zIndex:-1}},TabHighlight:{style:{zIndex:0}}});return h.jsxRuntimeExports.jsx(Cr.Tabs,{...i,overrides:e})}function XA(i){const e=M.mergeOverrides(i.overrides,{TabPanel:{style:({$theme:t})=>({paddingTop:t.sizing.scale950,paddingLeft:0,paddingRight:0})}});return h.jsxRuntimeExports.jsx(Cr.Tab,{...i,overrides:e})}function Jg({tabs:i,activeTabId:e,onTabSelect:t}){var s;const n=e??((s=i[0])==null?void 0:s.id);return!i||i.length===0?h.jsxRuntimeExports.jsx("div",{children:"No tabs available"}):h.jsxRuntimeExports.jsx(YA,{activeKey:n,onChange:({activeKey:r})=>t==null?void 0:t(r),children:i.map(r=>h.jsxRuntimeExports.jsx(XA,{title:r.label,children:r.content},r.id))})}function hd({action:i,onClick:e,loading:t,kind:n,shape:s,overrides:r}){var c;const[o,l]=M.useStyletron(),a=(c=i.disabled)==null?void 0:c.find(d=>d.condition),u=h.jsxRuntimeExports.jsx(U.Button,{kind:n,shape:s,size:U.SIZE.compact,isLoading:t,disabled:!!a,overrides:r,startEnhancer:i.display.icon?()=>h.jsxRuntimeExports.jsx(h.Icon,{name:i.display.icon,size:l.sizing.scale550,color:"inherit"}):void 0,onClick:e,children:i.display.label});return a!=null&&a.message?h.jsxRuntimeExports.jsx(Bi.StatefulTooltip,{content:a.message,accessibilityType:Bi.ACCESSIBILITY_TYPE.tooltip,placement:Bi.PLACEMENT.bottom,showArrow:!0,children:h.jsxRuntimeExports.jsx("span",{className:o({display:"inline-flex"}),children:u})}):u}function QA(i){return{primary:i.find(e=>e.hierarchy===Ct.PRIMARY),secondary:i.filter(e=>e.hierarchy===Ct.SECONDARY),tertiary:i.filter(e=>!e.hierarchy||e.hierarchy===Ct.TERTIARY)}}function JA({actions:i,record:e,loading:t}){const[n,s]=M.useStyletron(),[r,o]=A.useState(null),l=We.useNavigate();if(i.length===0)return null;const{primary:a,secondary:u,tertiary:c}=QA(i),d=f=>{var p;f.modal?o(f):((p=f.operation)==null?void 0:p.type)==="route"&&l(f.operation.route)};return h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[h.jsxRuntimeExports.jsxs("div",{className:n({display:"flex",gap:s.sizing.scale300}),children:[a&&h.jsxRuntimeExports.jsx(hd,{action:a,onClick:()=>d(a),loading:t,kind:U.KIND.primary,overrides:{Root:{style:{width:"200px"}}}}),u.map(f=>h.jsxRuntimeExports.jsx(hd,{action:f,onClick:()=>d(f),loading:t,kind:U.KIND.secondary,shape:U.SHAPE.pill},f.display.label)),c.length>0&&h.jsxRuntimeExports.jsx(Xg,{actions:c,record:e,popoverProps:{placement:zt.PLACEMENT.bottomRight}})]}),r&&h.jsxRuntimeExports.jsx(Kg,{action:r,record:e,onClose:()=>o(null)})]})}const ZA=M.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 ej({subtitle:i,title:e,titleEnhancer:t,onGoBack:n,children:s,actions:r,record:o,loading:l}){const[a,u]=M.useStyletron(),c=h.useInterpolationResolver(),d=A.useMemo(()=>r?c(r,{page:o}):void 0,[c,r,o]);return h.jsxRuntimeExports.jsxs(ZA,{children:[h.jsxRuntimeExports.jsxs("div",{className:a({display:"flex",gap:u.sizing.scale800,justifyContent:"flex-start",alignItems:"flex-end"}),children:[h.jsxRuntimeExports.jsxs("h5",{className:a({margin:0,maxWidth:"50%"}),children:[i&&h.jsxRuntimeExports.jsx("div",{className:a({...u.typography.LabelSmall,color:u.colors.contentTertiary,marginBottom:u.sizing.scale300}),children:i}),h.jsxRuntimeExports.jsxs("div",{className:a({display:"flex",alignItems:"center",gap:u.sizing.scale300}),children:[n&&h.jsxRuntimeExports.jsx(U.Button,{"aria-label":"Go back",onClick:n,kind:U.KIND.tertiary,shape:U.SHAPE.circle,size:U.SIZE.compact,overrides:{BaseButton:{style:({$theme:f})=>({flexShrink:0,":hover":{backgroundColor:f.colors.contentInverseSecondary}})}},children:h.jsxRuntimeExports.jsx(h.Icon,{name:"arrowLeft",size:u.sizing.scale700})}),h.jsxRuntimeExports.jsx("div",{className:a({...u.typography.HeadingSmall,...zg}),children:e})]})]}),t,d&&h.jsxRuntimeExports.jsx("div",{className:a({marginLeft:"auto",flexShrink:0}),children:h.jsxRuntimeExports.jsx(JA,{actions:d,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]=M.useStyletron();return h.jsxRuntimeExports.jsxs("div",{className:u({display:"flex",flexDirection:"column",gap:c.sizing.scale800}),children:[h.jsxRuntimeExports.jsx(ej,{title:i,subtitle:e,titleEnhancer:a,onGoBack:t,actions:r,record:o,loading:l,children:n}),s]})}function tj({phases:i=Vu}){const[,e]=M.useStyletron(),{phase:t,entity:n,entityId:s,projectId:r,entityTab:o}=h.useStudioParams("detail"),l=We.useNavigate(),a=i[t].entities.find(b=>b.id===n),u=h.useInterpolationResolver(),{data:c,isLoading:d,error:f}=h.useStudioQuery({queryName:`Get${h.capitalizeFirstLetter((a==null?void 0:a.service)??"")}`,serviceOptions:{namespace:r,name:s},clientOptions:{enabled:!!(a!=null&&a.service)&&!!s}}),p=A.useCallback((b,S)=>{l(`/${r}/${t}/${n}/${s}/${b}`,S)},[l,r,t,n,s]),m=()=>{l(`/${r}/${t}/${n}`)},g=((a==null?void 0:a.views)??[]).find(b=>b.type==="detail")??void 0;if(A.useEffect(()=>{var E;if(f||d||!s||!((E=g==null?void 0:g.pages)!=null&&E.length))return;const b=g.pages.map(v=>v.id),S=b[0];o?b.includes(o)||p(S,{replace:!0}):p(S,{replace:!0})},[o,g,d,f,p]),f)return h.jsxRuntimeExports.jsx(Ht,{title:"Entity not found",description:`Could not load ${n} "${s}". ${f.message}`,illustration:h.jsxRuntimeExports.jsx(ii,{kind:gt.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(g,{page:x});return h.jsxRuntimeExports.jsx(Zg,{subtitle:a.name,title:s,onGoBack:m,actions:a.actions,record:x,loading:d,headerContent:h.jsxRuntimeExports.jsx(h.Row,{items:y.metadata,record:x,loading:d}),children:h.jsxRuntimeExports.jsx(Jg,{tabs:y.pages.map(b=>({id:b.id,label:b.label,content:h.jsxRuntimeExports.jsx(KA,{page:b,data:x,isLoading:d})})),activeTabId:o,onTabSelect:p})})}const ij="michelangelo/SourcePipelineType";function nj(i,e){if(e!=null&&e.length){if(i==="pipeline")return{fieldSelector:`pipeline_type in (${e.join(",")})`};if(i==="pipelineRun"||i==="triggerRun")return{labelSelector:`${ij} in (${e.join(",")})`}}}function sj({service:i,tableConfig:e,tableSettingsId:t,pipelineTypes:n,trailingActions:s}){var f;const{projectId:r}=h.useStudioParams("base"),o=nj(i,n),{data:l,isLoading:a,error:u}=h.useStudioQuery({queryName:`List${h.capitalizeFirstLetter(i)}`,serviceOptions:{namespace:r,...o&&{listOptions:o}}}),c=$u({filterSettingsId:`${r}/${t}`,tableSettingsId:t}),d=Qg(e,{data:((f=l==null?void 0:l[`${i}List`])==null?void 0:f.items)??[],loading:a,error:u??void 0});return h.jsxRuntimeExports.jsx(ao,{...d,actionBarConfig:{...d.actionBarConfig,trailing:s},state:c})}function rj({phaseConfig:i,entities:e}){const[t,n]=M.useStyletron(),s=We.useNavigate(),{projectId:r,entity:o}=h.useStudioParams("list"),[l,a]=A.useState(!1);A.useEffect(()=>{o||s(`/${r}/${i.id}/${e[0].id}`)},[o,s,r,i.id,e]);const u=e.findIndex(g=>g.id===o),c=u>=0?u.toString():"0",d=({activeKey:g})=>{const x=e[Number(g)];x&&s(`/${r}/${i.id}/${x.id}`)},f=e.find(g=>g.id===o);if(!f)return o?h.jsxRuntimeExports.jsx(Ht,{buttonConfig:{onClick:()=>s(`/${r}`),content:"Go home"},description:`Entity "${o}" not found`,illustration:h.jsxRuntimeExports.jsx(ii,{kind:gt.ERROR,width:n.sizing.scale1600,height:n.sizing.scale1600}),title:"Entity not found"}):null;const{createAction:p}=f,m=p&&h.jsxRuntimeExports.jsx(U.Button,{kind:U.KIND.primary,onClick:()=>a(!0),startEnhancer:p.display.icon&&h.jsxRuntimeExports.jsx(h.Icon,{name:p.display.icon,size:n.sizing.scale600,color:n.colors.buttonPrimaryText}),children:p.display.label});return h.jsxRuntimeExports.jsxs("div",{className:t({marginTop:n.sizing.scale800}),children:[h.jsxRuntimeExports.jsx(md,{icon:i.icon,label:i.name,description:i.description,docUrl:i.docUrl}),p&&l&&h.jsxRuntimeExports.jsx(p.component,{onClose:()=>a(!1)}),h.jsxRuntimeExports.jsx(Cr.Tabs,{activeKey:c,onChange:d,overrides:{Root:{style:({$theme:g})=>({marginTop:g.sizing.scale600})}},children:e.map((g,x)=>h.jsxRuntimeExports.jsx(Cr.Tab,{title:g.name,children:String(x)===c&&h.jsxRuntimeExports.jsx(sj,{service:g.service,tableConfig:{...f.views[0].tableConfig,actions:g.actions},tableSettingsId:`${i.id}/${g.id}`,pipelineTypes:i.pipelineTypes,trailingActions:m})},String(x)))})]})}function oj(i){return i.state==="active"&&i.views.some(e=>e.type==="list")}function lj({phases:i=Vu}={}){const[,e]=M.useStyletron(),{phase:t,projectId:n}=h.useStudioParams("list"),s=We.useNavigate();if(!(t in i))return h.jsxRuntimeExports.jsx(Ht,{title:"Phase not found",description:`Phase "${t}" configuration not found. Available phases: ${Object.keys(i).join(", ")}`,illustration:h.jsxRuntimeExports.jsx(ii,{kind:gt.ERROR,width:e.sizing.scale1600,height:e.sizing.scale1600}),buttonConfig:{onClick:()=>s(`/${n}`),content:"Go home"}});const r=i[t].entities.filter(oj);return r.length===0?h.jsxRuntimeExports.jsx(Ht,{title:"Phase has no active entities",description:`Phase "${t}" has no active entities with list views configured.`,illustration:h.jsxRuntimeExports.jsx(ii,{kind:gt.ERROR,width:e.sizing.scale1600,height:e.sizing.scale1600}),buttonConfig:{onClick:()=>s(`/${n}`),content:"Go home"}}):h.jsxRuntimeExports.jsx(rj,{phaseConfig:i[t],entities:r})}function aj({categories:i,topLevelLinks:e}){return h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[h.jsxRuntimeExports.jsx(h.BreadcrumbBar,{categories:i,topLevelLinks:e}),h.jsxRuntimeExports.jsx(We.Outlet,{})]})}const uj=[Tg,Ng,Pg,Lg,Dg];function cj(){return h.jsxRuntimeExports.jsxs(We.Routes,{children:[h.jsxRuntimeExports.jsx(We.Route,{index:!0,element:h.jsxRuntimeExports.jsx(en,{children:h.jsxRuntimeExports.jsx(Ly,{})})}),h.jsxRuntimeExports.jsx(We.Route,{path:"sandbox",element:h.jsxRuntimeExports.jsx(en,{children:h.jsxRuntimeExports.jsx(jS,{})})}),h.jsxRuntimeExports.jsxs(We.Route,{element:h.jsxRuntimeExports.jsx(aj,{categories:wA}),children:[h.jsxRuntimeExports.jsx(We.Route,{path:":projectId",element:h.jsxRuntimeExports.jsx(en,{children:h.jsxRuntimeExports.jsx(Cx,{phases:uj})})}),h.jsxRuntimeExports.jsx(We.Route,{path:":projectId/:phase/:entity/:entityId/:entityTab?",element:h.jsxRuntimeExports.jsx(en,{children:h.jsxRuntimeExports.jsx(tj,{})})}),h.jsxRuntimeExports.jsx(We.Route,{path:":projectId/:phase/:entity?",element:h.jsxRuntimeExports.jsx(en,{children:h.jsxRuntimeExports.jsx(lj,{})})})]})]})}function Hu(i){return i instanceof h.Interpolation||h.StringInterpolation.isInterpolation(i)}function Fa(i){return Hu(i)?!0:h.lodashExports.isArray(i)?i.some(Fa):h.isRecord(i)?h.lodashExports.values(i).some(Fa):!1}function ex(i){return h.lodashExports.mapValues(i,e=>{if(h.lodashExports.isNil(e)||Array.isArray(e))return e;if(!Hu(e))return h.isRecord(e)?ex(e):e})}function hj({children:i,value:e}){return h.jsxRuntimeExports.jsx(h.InterpolationContext.Provider,{value:e,children:i})}function Gu({children:i,...e}){return h.jsxRuntimeExports.jsx(h.RepeatedLayoutContext.Provider,{value:e,children:i})}function dj(){const{fieldRegistry:i}=qa(),e=vs();return{fieldRegistry:i,change:e.change,submit:e.submit}}const fj=({children:i})=>{const[e]=M.useStyletron();return h.jsxRuntimeExports.jsx("div",{className:e({boxSizing:"border-box"}),children:i})},pj=({title:i,kind:e="info",dismissible:t=!1,content:n})=>{const[s,r]=A.useState(!1),[o,l]=M.useStyletron();return s?null:h.jsxRuntimeExports.jsx(h.Banner,{title:i,artwork:{type:ts.ARTWORK_TYPE.icon,icon:()=>h.jsxRuntimeExports.jsx(h.Icon,{name:e==="info"?"circleI":"circleExclamation",size:l.sizing.scale800})},kind:e,action:t?{label:"Dismiss",icon:()=>h.jsxRuntimeExports.jsx(h.Icon,{name:"x-filled"}),onClick:()=>r(!0)}:void 0,children:typeof n=="string"?h.jsxRuntimeExports.jsx(h.Markdown,{children:n}):n})},mj=({name:i,description:e,children:t})=>{const[n,s]=M.useStyletron();return h.jsxRuntimeExports.jsxs("section",{children:[h.jsxRuntimeExports.jsxs("div",{className:n({display:"flex",alignItems:"flex-start",flexDirection:"column",gap:s.sizing.scale300,marginBottom:s.sizing.scale600}),children:[h.jsxRuntimeExports.jsx(be.HeadingSmall,{margin:0,children:i}),e&&h.jsxRuntimeExports.jsx(be.ParagraphSmall,{margin:0,children:h.jsxRuntimeExports.jsx(h.Markdown,{children:e})})]}),t]})};function so(){return so=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},so.apply(null,arguments)}function dd(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 gj=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 xj(i){var e=A.useRef();return e.current||(e.current=i()),e.current}var yj=["length"],bj=["meta","input"],Sj=Ua.reduce(function(i,e){return i[e]=!0,i},{}),vj=function(e,t){var n={},s=n.subscription,r=s===void 0?Sj:s,o=n.defaultValue,l=n.initialValue,a=n.isEqual,u=a===void 0?gj:a,c=n.validate,d=vs("useFieldArray"),f=d.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 m=A.useMemo(function(){return Object.keys(f).reduce(function(j,R){return j[R]=function(){for(var H=arguments.length,N=new Array(H),B=0;B<H;B++)N[B]=arguments[B];return f[R].apply(f,[e].concat(N))},j},{})},[e,f]),g=xj(function(){return function(j,R,H){if(c){var N=c(j,R,H);if(!N||Array.isArray(N))return N;var B=[];return B[dn]=N,B}}}),x=uo(e,{subscription:so({},r,{length:!0}),defaultValue:o,initialValue:l,isEqual:u,validate:g,format:function(R){return R}}),y=x.meta,b=y.length,S=dd(y,yj),E=x.input,v=dd(x,bj),C=function(R){for(var H=b||0,N=0;N<H;N++)R(e+"["+N+"]",N)},k=function(R){for(var H=b||0,N=[],B=0;B<H;B++)N.push(R(e+"["+B+"]",B));return N};return{fields:so({name:e,forEach:C,length:b||0,map:k},m,v,{value:E.value}),meta:S}};function tx(i,{minItems:e=0,readOnly:t=!1}={}){const{fields:n}=vj(i),s=A.useRef(Array.from({length:n.length??0},()=>crypto.randomUUID()));A.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 Ej({rootFieldPath:i,minItems:e=0,readOnly:t=!1,children:n,name:s,span:r,addLabel:o="Add more"}){const[l,a]=M.useStyletron(),{entries:u,handleItemAdd:c,remove:d,isRemovable:f}=tx(i,{minItems:e,readOnly:t});return h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[u.map(({id:p,indexedFieldPath:m},g)=>{const x=n(m,g),y=A.isValidElement(x)&&x.type===A.Fragment?x.props.children:x;return h.jsxRuntimeExports.jsx(Gu,{index:g,rootFieldPath:i,children:h.jsxRuntimeExports.jsxs("div",{className:l({display:"flex",alignItems:"end",gap:a.sizing.scale300}),children:[h.jsxRuntimeExports.jsx(Za,{name:s,span:r,children:y}),f&&h.jsxRuntimeExports.jsx(U.Button,{type:"button",kind:U.KIND.tertiary,shape:U.SHAPE.circle,size:U.SIZE.default,"aria-label":"Remove",onClick:()=>d(g),children:h.jsxRuntimeExports.jsx(h.Icon,{name:"deleteAlt",kind:h.IconKind.SECONDARY})})]})},p)}),!t&&h.jsxRuntimeExports.jsx(po,{label:o,onClick:c})]})}function Cj({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:d,isRemovable:f}=tx(i,{minItems:n,readOnly:s}),p=t??(e?`Add ${e.toLowerCase()}`:"Add more"),[m,g]=M.useStyletron();return h.jsxRuntimeExports.jsxs("div",{className:m({display:"flex",flexDirection:"column",gap:g.sizing.scale800}),children:[u.map(({id:x,indexedFieldPath:y},b)=>h.jsxRuntimeExports.jsx(Gu,{index:b,rootFieldPath:i,children:h.jsxRuntimeExports.jsx(Yi,{title:e?`${e} ${b+1}`:void 0,description:o,tooltip:l,collapsible:a,endEnhancer:f&&h.jsxRuntimeExports.jsx(U.Button,{type:"button",kind:U.KIND.secondary,shape:U.SHAPE.pill,size:U.SIZE.compact,startEnhancer:h.jsxRuntimeExports.jsx(h.Icon,{name:"trashCan",kind:h.IconKind.PRIMARY}),"aria-label":"Remove",onClick:()=>d(b),children:"Remove"}),overrides:{BoxContainer:{style:{marginBottom:0}}},children:r(y,b)})},x)),!s&&h.jsxRuntimeExports.jsx(po,{label:p,shape:U.SHAPE.pill,onClick:c})]})}var ix=(i=>(i.Admin="admin",i.Viewer="viewer",i))(ix||{});function wj({dependencies:i}){var e,t;return h.jsxRuntimeExports.jsx(h.ThemeProvider,{icons:i.theme.icons,children:h.jsxRuntimeExports.jsx(ox.LayersManager,{zIndex:200,children:h.jsxRuntimeExports.jsx(lx.SnackbarProvider,{children:h.jsxRuntimeExports.jsx(h.ServiceProvider,{...i.service,children:h.jsxRuntimeExports.jsx(h.ErrorProvider,{...i.error,children:h.jsxRuntimeExports.jsx(h.IconProvider,{icons:i.theme.icons,children:h.jsxRuntimeExports.jsxs(h.UserProvider,{...i.user??{timeZone:h.TimeZone.Local},children:[h.jsxRuntimeExports.jsx(vx,{links:(e=i.navigationBar)==null?void 0:e.links,onSignOut:(t=i.navigationBar)==null?void 0:t.onSignOut}),h.jsxRuntimeExports.jsx(cj,{})]})})})})})})})}exports.ApplicationError=h.ApplicationError;exports.BooleanCell=h.BooleanCell;exports.CellType=h.CellType;exports.DateCell=h.DateCell;exports.DefaultCellRenderer=h.DefaultCellRenderer;exports.DescriptionCell=h.DescriptionCell;exports.DescriptionHierarchy=h.DescriptionHierarchy;exports.GrpcStatusCode=h.GrpcStatusCode;exports.Interpolation=h.Interpolation;exports.LinkCell=h.LinkCell;exports.MultiCell=h.MultiCell;exports.Phase=h.Phase;exports.StateCell=h.StateCell;exports.StringInterpolation=h.StringInterpolation;exports.TagCell=h.TagCell;exports.TextCell=h.TextCell;exports.TimeZone=h.TimeZone;exports.TypeCell=h.TypeCell;exports.capitalizeFirstLetter=h.capitalizeFirstLetter;exports.cellTooltipHoc=h.cellTooltipHoc;exports.formatElapsedSeconds=h.formatElapsedSeconds;exports.getDateFromEpochSeconds=h.getDateFromEpochSeconds;exports.getEpochSecondsFromDate=h.getEpochSecondsFromDate;exports.getObjectSymbols=h.getObjectSymbols;exports.getObjectValue=h.getObjectValue;exports.isAbsoluteUrl=h.isAbsoluteUrl;exports.isNavigableUrl=h.isNavigableUrl;exports.isRecord=h.isRecord;exports.parseIsoString=h.parseIsoString;exports.safeStringify=h.safeStringify;exports.sentenceCaseEnumValue=h.sentenceCaseEnumValue;exports.timestampToString=h.timestampToString;exports.toFlatDotPathMap=h.toFlatDotPathMap;exports.useCellStyles=h.useCellStyles;exports.useCellToString=h.useCellToString;exports.useErrorNormalizer=h.useErrorNormalizer;exports.useGetCellRenderer=h.useGetCellRenderer;exports.useInterpolationResolver=h.useInterpolationResolver;exports.useRepeatedLayoutContext=h.useRepeatedLayoutContext;exports.useStudioMutation=h.useStudioMutation;exports.useStudioParams=h.useStudioParams;exports.useStudioQuery=h.useStudioQuery;exports.useSuccessOperations=h.useSuccessOperations;exports.useUrlQueryString=h.useUrlQueryString;exports.ActionHierarchy=Ct;exports.AddButton=po;exports.ArrayFormGroup=Cj;exports.ArrayFormRow=Ej;exports.BooleanField=fo;exports.CheckboxField=Xd;exports.CoreApp=wj;exports.DateField=Tr;exports.DateFormat=bi;exports.DetailView=Zg;exports.DetailViewPages=Jg;exports.Execution=Wg;exports.FilterMode=lo;exports.Form=yi;exports.FormBanner=pj;exports.FormColumn=fj;exports.FormControl=Qe;exports.FormDialog=Es;exports.FormErrorBanner=rf;exports.FormGroup=Yi;exports.FormRow=Za;exports.FormStep=mj;exports.FunctionInterpolation=pd;exports.InterpolationProvider=hj;exports.MarkdownField=Qd;exports.NumberField=Xa;exports.RadioField=Qa;exports.RepeatedLayoutProvider=Gu;exports.SelectField=wt;exports.StringField=He;exports.SubmitButton=Wa;exports.TASK_STATE=le;exports.Table=ao;exports.TaskListRenderer=Na;exports.TaskStepCard=$g;exports.TextareaField=mo;exports.UrlField=Zd;exports.UserRole=ix;exports.clearUnresolvedInterpolations=ex;exports.hasInterpolationProperty=Fa;exports.interpolate=vt;exports.isInterpolation=Hu;exports.useField=ke;exports.useForm=dj;exports.useFormState=co;exports.useLocalStorageTableState=$u;exports.useTableSelectionContext=ay;
|
|
22
|
+
*/function Uo(i,e){return i?R0(i)?ve.createElement(i,e):i:null}function R0(i){return w0(i)||typeof i=="function"||k0(i)}function w0(i){return typeof i=="function"&&(()=>{const e=Object.getPrototypeOf(i);return e.prototype&&e.prototype.isReactComponent})()}function k0(i){return typeof i=="object"&&typeof i.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(i.$$typeof.description)}function T0(i){const e={state:{},onStateChange:()=>{},renderFallbackValue:null,...i},[t]=ve.useState(()=>({current:p0(e)})),[n,s]=ve.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 A0(i){const[e,t]=A.useState(-1),n=A.useRef(null),s=()=>{const r=n.current;if(!r)return;const{scrollWidth:o,clientWidth:l,scrollLeft:a}=r,c=o-l;t(c===0?-1:Math.round(a)/c)};return A.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 po=(i=>(i.NONE="none",i.CLIENT="client",i.SERVER="server",i))(po||{});const j0=15,ou=15,I0=[{id:ou,label:String(ou)},{id:25,label:String(25)},{id:50,label:String(50)}],Bl="__JOIN__",di={globalFilter:"",columnFilters:[],pagination:{pageSize:j0},sorting:[],grouping:[],columnOrder:[],columnVisibility:{},rowSelectionEnabled:!1},Nd="ma-studio-table-settings";function Wa(i,e){var n;const t=((n=e==null?void 0:e.typeMeta)==null?void 0:n.kind)??"";return t in i?{...h.lodashExports.omit(i,t),...i[t]}:i}function qa(i,e,t){const n="original"in e?e.original:e.record,s=Wa(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),h.safeStringify(o).split(Bl).at(0)??""):o.split(Bl).at(0)??"":o}function O0({preFilteredRows:i,column:e}){const t=h.useCellToString();return A.useMemo(()=>{const n={},s={};return i.forEach(r=>{const o=qa(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 c=h.safeStringify(o);n[a]=o,s[c]=a}),[s,n]},[i,t,e])}function M0({column:i,close:e,getFilterValue:t,setFilterValue:n,preFilteredRows:s}){const r=za.CategoricalColumn({title:"",mapDataToValue:()=>""}).renderFilter,[o,l]=O0({preFilteredRows:s,column:i}),a=Object.keys(l),c=(t()??[]).map(f=>o[h.safeStringify(f)]).filter(Boolean),u=a.sort((f,p)=>{const m=c.includes(f),g=c.includes(p);return m===g?f.localeCompare(p):m?-1:1}),d=({selection:f,exclude:p})=>{const g=(p?a.filter(x=>!f.has(x)):Array.from(f)).map(x=>l[x]);n(g.length>0?g:void 0),e()};return h.jsxRuntimeExports.jsx(r,{data:u,setFilter:d,close:e,filterParams:{description:"",selection:new Set(c),exclude:!1}})}const P0=new Date("2022-01-01T00:00:00"),D0=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 L0({close:i,getFilterValue:e,setFilterValue:t}){const n=za.DatetimeColumn({title:"",mapDataToValue:()=>new Date}).renderFilter,s=[P0,new Date],r=D0(e());return h.jsxRuntimeExports.jsx(n,{data:s,setFilter:t,close:i,filterParams:r})}function Fd(i){switch(i){case h.CellType.DATE:return L0;default:return M0}}function N0(){const i=h.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,c)=>t(c)?!0:c.includes(qa(e,l,a));return o.autoRemove=t,o}}}}function F0(){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,c)=>{if(t(c)||c.range.length===1)return!0;const u=c.range.some(p=>typeof p=="string")?e(c):c,d=qa(i,l,a),f=h.getDateFromEpochSeconds(typeof d=="number"?d:parseFloat(String(d)));return za.DatetimeColumn({title:"",mapDataToValue:()=>new Date}).buildFilter(u)(f)};return o.autoRemove=t,o}}}}function Bd(){const i=N0(),e=F0();return t=>t.type===h.CellType.DATE?e(t):i(t)}function B0(i){const{column:e,preFilteredRows:t}=i,[n,s]=M.useStyletron(),[r,o]=A.useState(!1),[l,a]=A.useState(!1),[c,u]=A.useState(null),f=Bd()({id:e.id,type:e.type,label:e.label}),p=()=>{u(setTimeout(()=>a(!0),1e3))},m=()=>{c&&clearTimeout(c),a(!1)},g=Fd(e.type);return h.jsxRuntimeExports.jsx(zt.StatefulPopover,{placement:zt.PLACEMENT.bottomLeft,content:({close:x})=>h.jsxRuntimeExports.jsx(g,{column:e,close:x,getFilterValue:e.getFilterValue,setFilterValue:e.setFilterValue,preFilteredRows:t}),onOpen:()=>o(!0),onClose:()=>o(!1),children:h.jsxRuntimeExports.jsx(vn.Tag,{kind:vn.KIND.blue,overrides:r?{Root:{style:({$theme:x})=>({borderColor:x.colors.accent,borderWidth:"2px"})}}:{},onActionClick:()=>e.setFilterValue(void 0),children:h.jsxRuntimeExports.jsx(zi.Tooltip,{content:()=>h.jsxRuntimeExports.jsx("div",{className:n({maxWidth:s.sizing.scale4800,overflowWrap:"break-word"}),children:f.getActiveFilter(e.getFilterValue())}),placement:zt.PLACEMENT.top,isOpen:l,onMouseEnter:p,onMouseLeave:m,showArrow:!0,children:h.jsxRuntimeExports.jsx(h.TruncatedText,{children:f.getFilterSummary(e.getFilterValue())})})})})}function V0(i){const{filterableColumns:e,preFilteredRows:t}=i,[n,s]=M.useStyletron(),r=e.filter(o=>{const l=o.getFilterValue();return l!=null});return r.length===0?null:h.jsxRuntimeExports.jsx("div",{className:n({display:"flex",flexWrap:"wrap",gap:s.sizing.scale300}),children:r.map(o=>h.jsxRuntimeExports.jsx(B0,{column:o,preFilteredRows:t},o.id))})}const _0=M.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":$0(i.colors.borderOpaque)}));function $0(i){return{position:"absolute",width:"85%",content:'""',borderTop:"1px solid",borderColor:i,top:0,left:"7.5%"}}function z0({label:i,onClick:e}){return h.jsxRuntimeExports.jsxs(_0,{onClick:e,role:"option","aria-label":i,"data-testid":`filter-option-${i}`,children:[i,h.jsxRuntimeExports.jsx(h.Icon,{name:"chevronRight"})]})}const H0=M.styled("ul",{margin:0,padding:0,listStyle:"none",maxHeight:"340px",overflowY:"auto"});function G0({filterableColumns:i,setSelectedColumn:e}){const[t,n]=M.useStyletron();return h.jsxRuntimeExports.jsxs("div",{className:t({backgroundColor:n.colors.backgroundPrimary,borderRadius:n.borders.radius300,width:"214px",display:"flex",flexDirection:"column"}),children:[h.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"}),h.jsxRuntimeExports.jsx(H0,{role:"listbox",children:i.map(s=>h.jsxRuntimeExports.jsx(z0,{label:s.label,onClick:()=>e(s)},s.id))})]})}function U0(i){const{columnFilters:e,filterableColumns:t,onClose:n,preFilteredRows:s,selectedColumn:r,setColumnFilters:o,setSelectedColumn:l}=i,[a,c]=M.useStyletron();if(r){const u=Fd(r.type);return h.jsxRuntimeExports.jsxs("div",{className:a({backgroundColor:c.colors.backgroundPrimary}),children:[h.jsxRuntimeExports.jsx(U.Button,{onClick:()=>l(void 0),kind:U.KIND.tertiary,size:U.SIZE.compact,children:h.jsxRuntimeExports.jsx(h.Icon,{name:"arrowLeft",size:c.sizing.scale650})}),h.jsxRuntimeExports.jsx(u,{column:r,close:n,getFilterValue:()=>{const d=e.find(f=>f.id===r.id);return d==null?void 0:d.value},setFilterValue:d=>{const f=e.filter(p=>p.id!==r.id);d!==void 0&&f.push({id:r.id,value:d}),o(f)},preFilteredRows:s})]})}return h.jsxRuntimeExports.jsx(G0,{filterableColumns:t,setSelectedColumn:l})}function W0(i){const{filterableColumns:e,columnFilters:t,setColumnFilters:n,preFilteredRows:s}=i,[r,o]=A.useState(),[l,a]=A.useState(!1),c=A.useCallback(()=>{o(void 0),a(!1)},[]);return h.jsxRuntimeExports.jsx(zt.StatefulPopover,{placement:zt.PLACEMENT.rightTop,onClose:c,onOpen:()=>a(!0),overrides:{Body:{style:{overflow:"hidden"}}},content:({close:u})=>h.jsxRuntimeExports.jsx(U0,{columnFilters:t,filterableColumns:e,onClose:()=>{c(),u()},preFilteredRows:s,selectedColumn:r,setColumnFilters:n,setSelectedColumn:o}),children:h.jsxRuntimeExports.jsx(U.Button,{shape:U.SHAPE.pill,size:U.SIZE.compact,kind:l||t.length>0?U.KIND.primary:U.KIND.secondary,startEnhancer:h.jsxRuntimeExports.jsx(h.Icon,{name:"plus"}),overrides:{BaseButton:{style:{textWrap:"nowrap"}}},children:"Add filter"})})}function q0({value:i,onChange:e}){const[t,n]=A.useState(i);A.useEffect(()=>{n(o=>o===i?o:i)},[i]);const s=A.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 h.jsxRuntimeExports.jsx(Qe.Input,{clearable:!0,type:"search",value:t,onChange:r,size:Qe.SIZE.compact,overrides:{Root:{style:{width:"250px"}}},"aria-label":"Search",startEnhancer:h.jsxRuntimeExports.jsx(h.Icon,{name:"search"})})}const K0=M.styled("div",({$theme:i})=>({display:"flex",flexDirection:"column",gap:i.sizing.scale300})),Y0=M.styled("div",({$theme:i})=>({alignItems:"center",display:"flex",gap:i.sizing.scale300})),X0=M.styled("div",({$theme:i})=>({display:"flex",alignItems:"center",gap:i.sizing.scale300,marginLeft:"auto"}));function Q0({globalFilter:i,setGlobalFilter:e,columnFilters:t,setColumnFilters:n,preFilteredRows:s,configuration:r,filterableColumns:o=[]}){return h.jsxRuntimeExports.jsxs(K0,{children:[h.jsxRuntimeExports.jsxs(Y0,{children:[r.enableSearch&&h.jsxRuntimeExports.jsx(q0,{value:i,onChange:e}),r.enableFilters&&o.length>0&&h.jsxRuntimeExports.jsx(W0,{filterableColumns:o,columnFilters:t,setColumnFilters:n,preFilteredRows:s}),r.middle,r.trailing&&h.jsxRuntimeExports.jsx(X0,{children:r.trailing})]}),r.enableFilters&&o.length>0&&h.jsxRuntimeExports.jsx(V0,{filterableColumns:o,preFilteredRows:s})]})}function J0({expanded:i}){const[,e]=M.useStyletron(),t=i?"chevronDown":"chevronRight",n=i?"Collapse":"Expand";return h.jsxRuntimeExports.jsx(h.Icon,{name:t,title:n,size:e.sizing.scale600})}function Z0({cell:i,row:e,columnIndex:t}){const[n,s]=M.useStyletron();return i.getIsGrouped()||e.getCanExpand()&&t===0?h.jsxRuntimeExports.jsxs("div",{className:n({display:"flex",alignItems:"center",cursor:"pointer",gap:s.sizing.scale600}),onClick:e.getToggleExpandedHandler(),children:[h.jsxRuntimeExports.jsx(J0,{expanded:e.getIsExpanded()}),Uo(i.column.columnDef.cell,i.getContext())]}):i.getIsAggregated()?Uo(i.column.columnDef.aggregatedCell??i.column.columnDef.cell,i.getContext()):i.getIsPlaceholder()?null:Uo(i.column.columnDef.cell,i.getContext())}function Ir(i){return i.map(e=>({id:e.id,cells:e.getAllCells().map((t,n)=>({id:t.id,content:A.createElement(Z0,{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 ey=M.styled("div",({$theme:i})=>({textAlign:"center",margin:"90px auto",maxWidth:"450px",display:"flex",flexDirection:"column",alignItems:"center",gap:i.sizing.scale600}));function Gt(i){const[e]=M.useStyletron(),{illustration:t,title:n,description:s,buttonConfig:r}=i;return h.jsxRuntimeExports.jsxs(ey,{children:[t,h.jsxRuntimeExports.jsx(ge.HeadingXSmall,{className:e({margin:0}),children:n}),s&&h.jsxRuntimeExports.jsx(ge.ParagraphMedium,{className:e({margin:0}),children:s}),r&&h.jsxRuntimeExports.jsx(U.Button,{...h.lodashExports.omit(r,"content"),kind:U.KIND.secondary,shape:U.SHAPE.pill,children:r.content})]})}const ty=Wt.StyledTable,Ka=M.withStyle(Wt.StyledTableBody,({$theme:i})=>({backgroundColor:i.colors.tableHeadBackgroundColor})),Vd=Wt.StyledTableBodyRow,on=M.withStyle(Wt.StyledTableBodyCell,({$columnNumber:i,$enableRowSelection:e})=>({fontWeight:i===(e?1:0)?500:"normal",verticalAlign:"middle"})),_d=M.styled("div",{display:"flex",justifyContent:"center"});function Or({children:i}){const[e,t]=M.useStyletron();return h.jsxRuntimeExports.jsx(Ka,{children:h.jsxRuntimeExports.jsx(Vd,{children:h.jsxRuntimeExports.jsx(on,{colSpan:100,children:h.jsxRuntimeExports.jsx("div",{className:e({padding:t.sizing.scale600}),children:i})})})})}function iy({emptyState:i}){return h.jsxRuntimeExports.jsx(Or,{children:h.jsxRuntimeExports.jsx(Gt,{illustration:i.icon,title:i.title,description:i.content})})}var St=(i=>(i[i.ERROR=0]="ERROR",i[i.PRIMARY=1]="PRIMARY",i))(St||{});function si({width:i="64",height:e="64",kind:t=St.ERROR}){const[,n]=M.useStyletron(),s=t===St.ERROR?n.colors.contentNegative:n.colors.contentStateDisabled;return h.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:[h.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}),h.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"}),h.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 ny({error:i}){switch(i.code){case h.GrpcStatusCode.DEADLINE_EXCEEDED:return h.jsxRuntimeExports.jsx(Or,{children:h.jsxRuntimeExports.jsx(Gt,{illustration:h.jsxRuntimeExports.jsx(si,{kind:St.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 h.GrpcStatusCode.INVALID_ARGUMENT:default:return h.jsxRuntimeExports.jsx(Or,{children:h.jsxRuntimeExports.jsx(Gt,{illustration:h.jsxRuntimeExports.jsx(si,{kind:St.ERROR,height:"64px",width:"64px"}),title:"Unable to fetch data for the table",description:"Try reloading the table and retrying the request."})})}}var Mr=(i=>(i[i.DEFAULT=0]="DEFAULT",i[i.GREY=1]="GREY",i))(Mr||{});const sy={[Mr.DEFAULT]:{outlineColor:"safety",questionMarkColor:"white",backgroundColor:"black"},[Mr.GREY]:{outlineColor:"tableFilter",questionMarkColor:"white",backgroundColor:"black"}};function ry(i){const[,e]=M.useStyletron(),{kind:t=Mr.DEFAULT,height:n="64",width:s="64"}=i,{outlineColor:r,questionMarkColor:o,backgroundColor:l}=sy[t];return h.jsxRuntimeExports.jsxs("svg",{width:s,height:n,viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[h.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]}),h.jsxRuntimeExports.jsx("path",{d:"M11.2 29.875L4.43863 18L11.2 6.125H24.8L31.5614 18L24.8 29.875H11.2Z",fill:e.colors[l]}),h.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 oy({clearFilters:i}){return h.jsxRuntimeExports.jsx(Or,{children:h.jsxRuntimeExports.jsx(Gt,{illustration:h.jsxRuntimeExports.jsx(ry,{}),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 ly(i){if(typeof i.column.tooltip.content=="function"){const e=i.column.tooltip.content;return h.jsxRuntimeExports.jsx(e,{...i})}return h.jsxRuntimeExports.jsx(h.Markdown,{children:i.column.tooltip.content})}function ay(i,e){return i?Array.isArray(i)?i.length===1&&i[0]===e:i===e:!1}function cy(i,e,t,n){return function(r){const{column:o,value:l}=r,{action:a}=o.tooltip;if(a==="filter"&&ay(t,l))return h.jsxRuntimeExports.jsx(i,{...r});const c=()=>{a==="filter"&&n&&n([l])};return h.jsxRuntimeExports.jsx(h.CellTooltipWrapper,{actionHandler:c,content:h.jsxRuntimeExports.jsx(ly,{...r,row:e}),children:h.jsxRuntimeExports.jsx(i,{...r})})}}const uy=150;function hy(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:`${uy*(n+1)}px`}}return e}const Vl=i=>{const[e,t]=M.useStyletron(),{row:n,record:s,value:r,columnFilterValue:o,setColumnFilterValue:l}=i,c=h.useInterpolationResolver()(Wa(i.column,s),{row:s}),u=h.useCellStyles({record:s,style:c.style}),f=h.useGetCellRenderer()({column:c,record:s,value:r}),p=c.tooltip?cy(f,n,o,l):f;return h.jsxRuntimeExports.jsxs(h.CellContainer,{children:[h.jsxRuntimeExports.jsx("div",{className:e({...hy(t),...u}),children:h.jsxRuntimeExports.jsx(p,{column:c,record:s,value:r,CellComponent:Vl})}),h.jsxRuntimeExports.jsx(h.CellEnhancer,{endEnhancer:c.endEnhancer})]})};function dy(i){return e=>{const t=Wa(i,e);return"items"in t?t.items.map(n=>h.getObjectValue(e,n.accessor??n.id)).join(Bl):h.getObjectValue(e,t.accessor??t.id)}}function fy(i){const e=Bd();return A.useMemo(()=>i.map(t=>{const n=e(t);return{id:t.id,meta:t,accessorFn:dy(t),header:t.label,cell:s=>h.jsxRuntimeExports.jsx(Vl,{column:s.column.columnDef.meta,row:Ir([s.row])[0],record:s.row.original,value:s.getValue(),columnFilterValue:s.column.getFilterValue(),setColumnFilterValue:s.column.setFilterValue}),aggregatedCell:s=>t.aggregatedCell?h.jsxRuntimeExports.jsx(t.aggregatedCell,{column:s.column.columnDef.meta,record:s.row.original,value:s.getValue()}):h.jsxRuntimeExports.jsx(Vl,{column:s.column.columnDef.meta,row:Ir([s.row])[0],record:s.row.original,value:s.getValue(),columnFilterValue:s.column.getFilterValue(),setColumnFilterValue:s.column.setFilterValue}),filterFn:n.buildTableFilterFn(),enableColumnFilters:t.filterMode!==po.NONE,enableSorting:t.enableSorting??!0,enableGrouping:t.enableGrouping??!1,aggregationFn:t.aggregationFn,sortingFn:t.sortingFn??"auto",sortUndefined:"last"}}),[i,e])}function py(i){const{paginationState:e,pageCount:t,gotoPage:n}=i,{pageIndex:s}=e,[r,o]=A.useState(!1);A.useEffect(()=>{const a=s+1>t;s!==0&&a&&(o(!0),n(0))},[s,t,n]),A.useEffect(()=>{r&&s===0&&o(!1)},[r,s]);const l=s+1>t&&s!==0;return{isResetting:r||l}}const $d=ve.createContext({selectedRows:[],selectionEnabled:!1,setSelectionEnabled:()=>null,toggleAllRowsSelected:()=>null,getIsAllRowsSelected:()=>!1,getIsSomeRowsSelected:()=>!1}),my=()=>ve.useContext($d);function gy({children:i,value:e}){return h.jsxRuntimeExports.jsx($d.Provider,{value:e,children:i})}function xy({state:i,initialState:e}){const[t,n]=A.useState(e.rowSelectionEnabled);return{enableRowSelection:(i.setRowSelectionEnabled?i.rowSelectionEnabled:t)??!1,setRowSelectionEnabled:i.setRowSelectionEnabled??n}}const zd=i=>({width:i.sizing.scale900,minWidth:i.sizing.scale900,maxWidth:i.sizing.scale900});function Hd({canSelect:i,isSelected:e,onToggleSelection:t}){if(!i)return null;const n=s=>{s.stopPropagation(),t(s.target.checked)};return h.jsxRuntimeExports.jsx(Bi.Checkbox,{checked:e,onChange:n,overrides:{Root:{style:{alignItems:"center"}}}})}function yy(i){const[e,t]=A.useState(!1);return A.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 by={left:{right:"auto",left:"-7px",getOpacity:i=>i===-1?0:1-i},right:{right:"-7px",left:"auto",getOpacity:i=>i===-1?0:i}};function Sy(i,e){if(i==="none")return{};const{getOpacity:t,...n}=by[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 vy=56;function Ey(i,e){const t={};return i?(t[0]={stickySide:"left",position:0,shadowSide:"none"},t[1]={stickySide:"left",position:vy,shadowSide:"right"}):t[1]={stickySide:"left",position:0,shadowSide:"right"},t[e]={stickySide:"right",position:0,shadowSide:"left"},t}function Gd(i){return function(t){const{enableStickySides:n,enableRowSelection:s,lastColumnIndex:r,scrollRatio:o=-1,role:l,children:a,...c}=t,[u,d]=M.useStyletron(),f=A.useRef(null),p=yy(f);if(!n)return h.jsxRuntimeExports.jsx(i,{...c,children:a});const g={position:"sticky !important",backgroundColor:`${p&&l==="row"?d.colors.tableStripedBackground:d.colors.tableHeadBackgroundColor} !important`},x=Ey(s,r);return h.jsxRuntimeExports.jsx(i,{...c,ref:f,children:A.Children.map(a,(y,b)=>{const S=x[b];if(!S||!A.isValidElement(y))return y;const E={...g,[S.stickySide]:`${S.position}px !important`};return A.cloneElement(y,{className:`${u(E)} ${u(Sy(S.shadowSide,o))}`,"data-testid":`sticky-cell-${S.stickySide}-sticky`})})})}}const Cy=Gd(Wt.StyledTableBodyRow),Ry=({rows:i,enableRowSelection:e,enableStickySides:t,scrollRatio:n,subRow:s,actions:r})=>{const[o,l]=M.useStyletron(),a=i[0].cells.filter(c=>c.isVisible).length+1;return h.jsxRuntimeExports.jsx(Ka,{children:i.map(c=>h.jsxRuntimeExports.jsxs(A.Fragment,{children:[h.jsxRuntimeExports.jsxs(Cy,{enableStickySides:t,enableRowSelection:e,lastColumnIndex:a,scrollRatio:n,role:"row",children:[e&&h.jsxRuntimeExports.jsx(on,{className:o(zd(l)),children:h.jsxRuntimeExports.jsx(Hd,{canSelect:c.canSelect??!1,isSelected:c.isSelected??!1,onToggleSelection:c.onToggleSelection??(()=>{})})}),c.cells.filter(u=>u.isVisible).map((u,d)=>h.jsxRuntimeExports.jsx(on,{$columnNumber:d,$enableRowSelection:e,children:u.content},u.id)),h.jsxRuntimeExports.jsx(on,{children:h.jsxRuntimeExports.jsx(_d,{children:r&&A.createElement(r,{row:c})})})]}),s&&c.isExpanded&&h.jsxRuntimeExports.jsx(Wt.StyledTableBodyRow,{children:h.jsxRuntimeExports.jsx(on,{colSpan:c.cells.filter(u=>u.isVisible).length+(e?2:1),children:A.createElement(s,{row:c})})})]},c.id))})};function wy(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(pr.arrayMove(i.map(l=>l.id),r,o))}}function ky({columns:i,setColumnOrder:e,setColumnVisibility:t}){const[n,s]=M.useStyletron(),r=wy(i,e,t);return h.jsxRuntimeExports.jsx(zt.StatefulPopover,{placement:zt.PLACEMENT.bottomRight,content:()=>h.jsxRuntimeExports.jsx("div",{className:n({backgroundColor:s.colors.backgroundPrimary,borderRadius:s.borders.radius300,width:"214px",display:"flex",flexDirection:"column"}),children:h.jsxRuntimeExports.jsx(pr.List,{removable:!0,overrides:{Item:{style:{height:s.sizing.scale800}},Label:{component:o=>h.jsxRuntimeExports.jsx(pr.StyledLabel,{...o,children:o.$value.label})},CloseHandle:{component:o=>h.jsxRuntimeExports.jsx(pr.StyledCloseHandle,{...o,children:h.jsxRuntimeExports.jsx(Bi.Checkbox,{checked:o.$value.isVisible,disabled:!o.$value.canHide,title:`Toggle ${o.$value.label}`})})}},onChange:r,items:i.slice(1)})}),children:h.jsxRuntimeExports.jsx(U.Button,{title:"Configure columns",size:U.SIZE.mini,kind:U.KIND.tertiary,children:h.jsxRuntimeExports.jsx(h.Icon,{name:"settings"})})})}function Ty(i){const{column:e}=i,t=e.getIsSorted(),n=t==="desc"?"sortDescending":"sortAscending",s=t?h.IconKind.ACCENT:h.IconKind.TERTIARY;return h.jsxRuntimeExports.jsx(h.Icon,{name:n,kind:s,title:"Toggle Sort"})}const _l=M.withStyle(Wt.StyledTableHeadCell,({$theme:i})=>({zIndex:"unset",position:"inherit",...i.typography.LabelSmall})),Ay=M.withStyle(Wt.StyledTableHeadCellSortable,({$theme:i})=>({zIndex:"unset",position:"inherit",...i.typography.LabelSmall})),jy=M.withStyle(_l,{padding:0}),Iy=Gd(Wt.StyledTableHeadRow),Oy=({columns:i,setColumnOrder:e,setColumnVisibility:t,enableRowSelection:n,isSelected:s,onToggleSelection:r,enableStickySides:o,scrollRatio:l,stickyHeader:a=!1})=>{const[c,u]=M.useStyletron();return h.jsxRuntimeExports.jsx(Wt.StyledTableHead,{className:a?c({position:"sticky",top:0,zIndex:2,backgroundColor:u.colors.tableHeadBackgroundColor}):void 0,children:h.jsxRuntimeExports.jsxs(Iy,{enableStickySides:o,enableRowSelection:n,lastColumnIndex:i.filter(d=>d.isVisible).length+1,scrollRatio:l,role:"header",children:[n&&h.jsxRuntimeExports.jsx(_l,{role:"columnheader",className:c(zd(u)),children:h.jsxRuntimeExports.jsx(Hd,{canSelect:n,isSelected:s,onToggleSelection:r})}),i.filter(d=>d.isVisible).map(d=>d.canSort?h.jsxRuntimeExports.jsx(Ay,{$isFocusVisible:!1,onClick:d.onToggleSort,role:"columnheader",children:h.jsxRuntimeExports.jsxs("div",{className:c({display:"flex",alignItems:"center",gap:u.sizing.scale300}),children:[h.jsxRuntimeExports.jsx("div",{children:d.label}),h.jsxRuntimeExports.jsx(Ty,{column:{getIsSorted:()=>d.sortDirection??!1}})]})},d.id):h.jsxRuntimeExports.jsx(_l,{role:"columnheader",children:d.label},d.id)),e&&t&&h.jsxRuntimeExports.jsx(jy,{role:"columnheader",children:h.jsxRuntimeExports.jsx(_d,{children:h.jsxRuntimeExports.jsx(ky,{columns:i,setColumnOrder:e,setColumnVisibility:t})})})]})})};function My(){return h.jsxRuntimeExports.jsx(Ka,{"aria-label":"Loading",children:[1,2,3].map(i=>h.jsxRuntimeExports.jsx(Vd,{children:h.jsxRuntimeExports.jsx(on,{colSpan:100,children:h.jsxRuntimeExports.jsx(Si.Skeleton,{animation:!0,width:"100%",height:"22px"})})},i))})}function Py(i){const{pageSizes:e,state:t,setPageSize:n}=i,{pageSize:s}=t,[r,o]=M.useStyletron(),l=e.find(a=>a.id===s);return h.jsxRuntimeExports.jsxs("div",{className:r({...o.typography.LabelMedium,display:"flex",gap:o.sizing.scale600,alignItems:"center"}),children:[h.jsxRuntimeExports.jsx("div",{className:r({minWidth:"fit-content",paddingLeft:o.sizing.scale600}),children:"Rows per page"}),h.jsxRuntimeExports.jsx(dn.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 Dy(i){const{state:e,pageCount:t,gotoPage:n,fetchPlugin:s}=i,{pageIndex:r}=e,[o]=M.useStyletron(),l=Math.min(r+1,t);return h.jsxRuntimeExports.jsxs("div",{className:o({display:"flex",justifyContent:"space-between",width:"100%",alignItems:"center"}),children:[h.jsxRuntimeExports.jsx(Py,{pageSizes:i.pageSizes,state:i.state,setPageSize:i.setPageSize}),h.jsxRuntimeExports.jsx(gx.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:Ly}:{}}})]})}function Ly(){return h.jsxRuntimeExports.jsx(U.Button,{isLoading:!0,kind:U.KIND.tertiary,children:"Next"})}function Ny(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 Fy(i){const e=i.disablePagination??!1,t=i.disableSorting??!1,n=i.pageSizes??I0;return{...i,emptyState:i.emptyState??{icon:h.jsxRuntimeExports.jsx(si,{kind:St.PRIMARY,height:"64px",width:"64px"}),title:"No data",content:"No data is present."},loading:i.loading??!1,loadingView:i.loadingView??My,error:i.error??void 0,actionBarConfig:{enableSearch:!0,enableFilters:!0,...i.actionBarConfig},disablePagination:e,disableSorting:t,pageSizes:n,state:By(i.state,e,n),pagination:i.pagination??Dy,enableStickySides:i.enableStickySides??!0,body:i.body??Ry,header:i.header??Oy,unFilteredData:i.unFilteredData??i.data}}function By(i,e,t){var o;const n={...i,rowSelectionEnabled:(i==null?void 0:i.rowSelectionEnabled)??!1};if(e){const{pagination:l,setPagination:a,...c}=n;return c}const s=(o=n==null?void 0:n.pagination)==null?void 0:o.pageSize,r=Ny(s,t);return{...n,pagination:{pageIndex:0,...n==null?void 0:n.pagination,pageSize:r}}}const lu={globalFilter:"setGlobalFilter",columnFilters:"setColumnFilters",pagination:"setPagination",sorting:"setSorting",columnOrder:"setColumnOrder",columnVisibility:"setColumnVisibility",rowSelection:"setRowSelection",rowSelectionEnabled:"setRowSelectionEnabled",grouping:"setGrouping"};function Vy(i){const e={},t={},n=Object.keys(lu);for(const s of n){const r=lu[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 _y(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 Ud(i,e,t){return i.getValue(e)?h.safeStringify(i.getValue(e)).toLowerCase().includes(t.toLowerCase()):!1}Ud.autoRemove=i=>i==null;function $y(i){return i.map(e=>{const t=e.columnDef.meta,n=t.label??e.id;return{...t,label:n,type:t.type??h.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 Rs(i){var y,b,S,E;const e=Fy(i),t=fy(e.columns),[n,s]=M.useStyletron(),{state:r,initialState:o}=Vy(e.state??{}),{enableRowSelection:l,setRowSelectionEnabled:a}=xy({state:r,initialState:o}),{scrollRatio:c,tableRef:u,handleScrollRatioUpdate:d}=A0(t),f=T0({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:m0(),getFilteredRowModel:b0(),...e.disableSorting?{enableSorting:!1}:{getSortedRowModel:C0()},...e.disablePagination?{}:{getPaginationRowModel:E0()},...(y=o.grouping)!=null&&y.length||(b=r.grouping)!=null&&b.length?{getGroupedRowModel:S0(),getExpandedRowModel:ru()}:{},...e.subRow?{getExpandedRowModel:ru(),getRowCanExpand:()=>!0}:{},enableRowSelection:l,getColumnCanGlobalFilter:()=>!0,globalFilterFn:Ud,autoResetPageIndex:!1}),p=$y(f.getAllLeafColumns()),{isResetting:m}=py({gotoPage:f.setPageIndex,pageCount:f.getPageCount(),paginationState:f.getState().pagination}),g=_y({dataLength:e.data.length,error:e.error,loading:e.loading||m,hasFiltersApplied:((S=f.getState().globalFilter)==null?void 0:S.length)>0||(((E=f.getState().columnFilters)==null?void 0:E.length)??0)>0,filteredLength:f.getRowModel().rows.length,columnsLength:t.length}),x=e.unFilteredData.map(v=>({getValue:C=>{const k=t.find(O=>O.id===C);if(k)return k.accessorFn(v)},record:v}));return h.jsxRuntimeExports.jsx("div",{className:n({display:"flex",flexDirection:"column",gap:s.sizing.scale400}),children:h.jsxRuntimeExports.jsxs(gy,{value:{selectedRows:Ir(f.getSelectedRowModel().flatRows),selectionEnabled:l,setSelectionEnabled:a,toggleAllRowsSelected:v=>f.toggleAllRowsSelected(v),getIsAllRowsSelected:()=>f.getIsAllRowsSelected(),getIsSomeRowsSelected:()=>f.getIsSomeRowsSelected()},children:[h.jsxRuntimeExports.jsx(Q0,{globalFilter:f.getState().globalFilter,setGlobalFilter:f.setGlobalFilter,columnFilters:f.getState().columnFilters,setColumnFilters:f.setColumnFilters,preFilteredRows:x,configuration:e.actionBarConfig,filterableColumns:p.filter(v=>v.canFilter&&v.filterMode!==po.NONE)}),h.jsxRuntimeExports.jsx("div",{className:n({overflow:"auto",position:"relative",maxHeight:e.maxHeight}),ref:u,onScroll:d,children:h.jsxRuntimeExports.jsxs(ty,{children:[g==="loading"&&h.jsxRuntimeExports.jsx(e.loadingView,{}),g==="error"&&h.jsxRuntimeExports.jsx(ny,{error:e.error}),(g==="empty"||g==="no-columns")&&h.jsxRuntimeExports.jsx(iy,{emptyState:e.emptyState}),g==="filtered-empty"&&h.jsxRuntimeExports.jsx(oy,{clearFilters:()=>{f.setGlobalFilter(""),f.setColumnFilters([])}}),g!=="error"&&g!=="no-columns"&&h.jsxRuntimeExports.jsx(e.header,{columns:p,setColumnOrder:f.setColumnOrder,setColumnVisibility:f.setColumnVisibility,enableRowSelection:l,isSelected:f.getIsAllRowsSelected(),onToggleSelection:v=>f.toggleAllRowsSelected(v),enableStickySides:e.enableStickySides,scrollRatio:c,stickyHeader:!!e.maxHeight}),g==="ready"&&h.jsxRuntimeExports.jsx(e.body,{rows:Ir(f.getRowModel().rows),enableRowSelection:l,enableStickySides:e.enableStickySides,scrollRatio:c,subRow:e.subRow,actions:e.actions})]})}),!e.disablePagination&&g==="ready"&&f.getPreFilteredRowModel().rows.length>Math.min(...e.pageSizes.map(v=>v.id))&&h.jsxRuntimeExports.jsx(e.pagination,{gotoPage:f.setPageIndex,pageCount:f.getPageCount(),setPageSize:f.setPageSize,state:f.getState().pagination,pageSizes:e.pageSizes,fetchPlugin:e.fetchPlugin})]})})}function zy(){const[i,e]=M.useStyletron(),{data:t,isLoading:n}=h.useStudioQuery({queryName:"ListProject",serviceOptions:{namespace:""}});return h.jsxRuntimeExports.jsxs("div",{className:i({marginTop:e.sizing.scale400}),children:[h.jsxRuntimeExports.jsx("div",{className:i({paddingTop:e.sizing.scale400,paddingBottom:e.sizing.scale400}),children:h.jsxRuntimeExports.jsx(Rd,{label:"All Projects"})}),h.jsxRuntimeExports.jsx(Rs,{data:(t==null?void 0:t.projectList.items)??[],columns:Ml,loading:n})]})}function me(){return me=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},me.apply(null,arguments)}function ws(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 Hy=46,Gy=/\\(\\)?/g,Uy=RegExp(`[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,"g"),Wy=function(e){var t=[];return e.charCodeAt(0)===Hy&&t.push(""),e.replace(Uy,function(n,s,r,o){var l=n;r?l=o.replace(Gy,"$1"):s&&(l=s.trim()),t.push(l)}),t},zs={},qy=/[.[\]]+/,Wd=function(e){if(e==null||!e.length)return[];if(typeof e!="string")throw new Error("toPath() expects a string");return zs[e]==null&&(e.endsWith("[]")?zs[e]=e.split(qy).filter(Boolean):zs[e]=Wy(e)),zs[e]},xe=function(e,t){for(var n=Wd(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 Ky(i){var e=Yy(i,"string");return typeof e=="symbol"?e:String(e)}function Yy(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 Xy=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,c=i(void 0,t+1,n,s,r);return c===void 0?void 0:(a={},a[o]=c,a)}if(Array.isArray(e))throw new Error("Cannot set a non-numeric property on an array");var u=i(e[o],t+1,n,s,r);if(u===void 0){var d=Object.keys(e).length;if(e[o]===void 0&&d===0)return;if(e[o]!==void 0&&d<=1)return!isNaN(n[t-1])&&!r?{}:void 0;e[o];var f=ws(e,[o].map(Ky));return f}return me({},e,(l={},l[o]=u,l))}var p=Number(o);if(e==null){var m=i(void 0,t+1,n,s,r);if(m===void 0)return;var g=[];return g[p]=m,g}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},ft=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 Xy(e,0,Wd(t),n,s)},ss="FINAL_FORM/form-error",fn="FINAL_FORM/array-error";function au(i,e){var t=i.errors,n=i.initialValues,s=i.lastSubmittedValues,r=i.submitErrors,o=i.submitFailed,l=i.submitSucceeded,a=i.submitting,c=i.values,u=e.active,d=e.blur,f=e.change,p=e.data,m=e.focus,g=e.modified,x=e.modifiedSinceLastSubmit,y=e.name,b=e.touched,S=e.validating,E=e.visited,v=xe(c,y),C=xe(t,y);C&&C[fn]&&(C=C[fn]);var k=r&&xe(r,y),O=n&&xe(n,y),w=e.isEqual(O,v),D=!!(s&&!e.isEqual(xe(s,y),v)),N=!C&&!k;return{active:u,blur:d,change:f,data:p,dirty:!w,dirtySinceLastSubmit:D,error:C,focus:m,initial:O,invalid:!N,length:Array.isArray(v)?v.length:void 0,modified:g,modifiedSinceLastSubmit:x,name:y,pristine:w,submitError:k,submitFailed:o,submitSucceeded:l,submitting:a,touched:b,valid:N,value:v,visited:E,validating:S}}var Ya=["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","modified","modifiedSinceLastSubmit","pristine","submitError","submitFailed","submitSucceeded","submitting","touched","valid","value","visited","validating"],Nt=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 qd(i,e,t,n,s,r){var o=!1;return s.forEach(function(l){n[l]&&(i[l]=e[l],(!t||(~r.indexOf(l)?!Nt(e[l],t[l]):e[l]!==t[l]))&&(o=!0))}),o}var Qy=["data"],Jy=function(e,t,n,s){var r={blur:e.blur,change:e.change,focus:e.focus,name:e.name},o=qd(r,e,t,n,Ya,Qy)||!t;return o||s?r:void 0},Kd=["active","dirty","dirtyFields","dirtyFieldsSinceLastSubmit","dirtySinceLastSubmit","error","errors","hasSubmitErrors","hasValidationErrors","initialValues","invalid","modified","modifiedSinceLastSubmit","pristine","submitting","submitError","submitErrors","submitFailed","submitSucceeded","touched","valid","validating","values","visited"],Zy=["touched","visited"];function cu(i,e,t,n){var s={},r=qd(s,i,e,t,Kd,Zy)||!e;return r||n?s:void 0}var uu=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!Nt(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"}),eb="4.20.10",tb=function(e,t){return e===t},ln=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 ib(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,c=i.submitFailed,u=i.submitSucceeded,d=i.submitError,f=i.submitErrors,p=i.valid,m=i.validating,g=i.values;return{active:e,dirty:!l,dirtySinceLastSubmit:t,modifiedSinceLastSubmit:n,error:s,errors:r,hasSubmitErrors:!!(d||f&&ln(f)),hasValidationErrors:!!(s||ln(r)),invalid:!p,initialValues:o,pristine:l,submitting:a,submitFailed:c,submitSucceeded:u,submitError:d,submitErrors:f,valid:p,validating:m>0,values:g}}function Yd(i,e,t,n,s,r){var o=s(t,n,e,r);return o?(i(o),!0):!1}function hu(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,c=l.subscriber,u=l.notified;Yd(c,a,e,t,n,s||!u)&&(l.notified=!0)}})}function nb(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 c={subscribers:{index:0,entries:{}},fieldSubscribers:{},fields:{},formState:{asyncErrors:{},dirtySinceLastSubmit:!1,modifiedSinceLastSubmit:!1,errors:{},initialValues:s&&me({},s),invalid:!1,pristine:!0,submitting:!1,submitFailed:!1,submitSucceeded:!1,resetWhileSubmitting:!1,valid:!0,validating:0,values:s?me({},s):{}},lastFormState:void 0},u=0,d=!1,f=!1,p=!1,m=0,g={},x=function(R){return function(I){return delete g[R],I}},y=function(R,I,L){var V=xe(R.formState.values,I),Q=L(V);R.formState.values=ft(R.formState.values,I,Q)||{}},b=function(R,I,L){if(R.fields[I]){var V,Q;R.fields=me({},R.fields,(V={},V[L]=me({},R.fields[I],{name:L,blur:function(){return te.blur(L)},change:function(he){return te.change(L,he)},focus:function(){return te.focus(L)},lastFieldState:void 0}),V)),delete R.fields[I],R.fieldSubscribers=me({},R.fieldSubscribers,(Q={},Q[L]=R.fieldSubscribers[I],Q)),delete R.fieldSubscribers[I];var Z=xe(R.formState.values,I);R.formState.values=ft(R.formState.values,I,void 0)||{},R.formState.values=ft(R.formState.values,L,Z),delete R.lastFormState}},S=function(R){return function(){if(r){for(var I={formState:c.formState,fields:c.fields,fieldSubscribers:c.fieldSubscribers,lastFormState:c.lastFormState},L=arguments.length,V=new Array(L),Q=0;Q<L;Q++)V[Q]=arguments[Q];var Z=r[R](V,I,{changeValue:y,getIn:xe,renameField:b,resetFieldState:te.resetFieldState,setIn:ft,shallowEqual:Nt});return c.formState=I.formState,c.fields=I.fields,c.fieldSubscribers=I.fieldSubscribers,c.lastFormState=I.lastFormState,O(void 0,function(){w(),W()}),Z}}},E=r?Object.keys(r).reduce(function(q,R){return q[R]=S(R),q},{}):{},v=function(R){var I=[];if(l){var L=l(me({},c.formState.values));Wo(L)?I.push(L.then(function(V){return R(V,!0)})):R(L,!1)}return I},C=function(R){return Object.keys(R.validators).reduce(function(I,L){var V=R.validators[Number(L)]();return V&&I.push(V),I},[])},k=function(R,I){var L=[],V=C(R);if(V.length){var Q;V.forEach(function(Z){var ue=Z(xe(c.formState.values,R.name),c.formState.values,Z.length===0||Z.length===3?au(c.formState,c.fields[R.name]):void 0);if(ue&&Wo(ue)){R.validating=!0;var he=ue.then(function(ce){c.fields[R.name]&&(c.fields[R.name].validating=!1,I(ce))});L.push(he)}else Q||(Q=ue)}),I(Q)}return L},O=function(R,I){if(d){f=!0,I();return}var L=c.fields,V=c.formState,Q=me({},L),Z=Object.keys(Q);if(!l&&!Z.some(function(ui){return C(Q[ui]).length})){I();return}var ue=!1;if(R){var he=Q[R];if(he){var ce=he.validateFields;ce&&(ue=!0,Z=ce.length?ce.concat(R):[R])}}var Ae={},_e={},Ct={},ci=[].concat(v(function(ui,Oi){Oi?_e=ui||{}:Ae=ui||{}}),Z.reduce(function(ui,Oi){return ui.concat(k(L[Oi],function(It){Ct[Oi]=It}))},[])),Oe=ci.length>0,Re=++m,Ji=Promise.all(ci).then(x(Re));Oe&&(g[Re]=Ji);var Zc=function(Oi){var It=me({},ue?V.errors:{},Ae,Oi?_e:V.asyncErrors),tu=function(Mi){Z.forEach(function(hi){if(L[hi]){var Ln=xe(Ae,hi),ux=xe(It,hi),hx=C(Q[hi]).length,dx=Ct[hi];Mi(hi,hx&&dx||l&&Ln||(!Ln&&!ue?ux:void 0))}})};tu(function(Dn,Mi){It=ft(It,Dn,Mi)||{}}),tu(function(Dn,Mi){if(Mi&&Mi[fn]){var hi=xe(It,Dn),Ln=[].concat(hi);Ln[fn]=Mi[fn],It=ft(It,Dn,Ln)}}),Nt(V.errors,It)||(V.errors=It),Oi&&(V.asyncErrors=_e),V.error=Ae[ss]};if(Oe&&(c.formState.validating++,I()),Zc(!1),I(),Oe){var eu=function(){c.formState.validating--,I(),c.formState.validating===0&&c.lastFormState.validating&&W()};Ji.then(function(){m>Re||Zc(!0)}).then(eu,eu)}},w=function(R){if(!u){var I=c.fields,L=c.fieldSubscribers,V=c.formState,Q=me({},I),Z=function(he){var ce=Q[he],Ae=au(V,ce),_e=ce.lastFieldState;ce.lastFieldState=Ae;var Ct=L[he];Ct&&hu(Ct,Ae,_e,Jy,_e===void 0)};R?Z(R):Object.keys(Q).forEach(Z)}},D=function(){Object.keys(c.fields).forEach(function(R){c.fields[R].touched=!0})},N=function(){return!!(c.formState.error||ln(c.formState.errors))},F=function(){var R=c.fields,I=c.formState,L=c.lastFormState,V=me({},R),Q=Object.keys(V),Z=!1,ue=Q.reduce(function(Oe,Re){var Ji=!V[Re].isEqual(xe(I.values,Re),xe(I.initialValues||{},Re));return Ji&&(Z=!0,Oe[Re]=!0),Oe},{}),he=Q.reduce(function(Oe,Re){var Ji=I.lastSubmittedValues||{};return V[Re].isEqual(xe(I.values,Re),xe(Ji,Re))||(Oe[Re]=!0),Oe},{});I.pristine=!Z,I.dirtySinceLastSubmit=!!(I.lastSubmittedValues&&Object.values(he).some(function(Oe){return Oe})),I.modifiedSinceLastSubmit=!!(I.lastSubmittedValues&&Object.keys(V).some(function(Oe){return V[Oe].modifiedSinceLastSubmit})),I.valid=!I.error&&!I.submitError&&!ln(I.errors)&&!(I.submitErrors&&ln(I.submitErrors));var ce=ib(I),Ae=Q.reduce(function(Oe,Re){return Oe.modified[Re]=V[Re].modified,Oe.touched[Re]=V[Re].touched,Oe.visited[Re]=V[Re].visited,Oe},{modified:{},touched:{},visited:{}}),_e=Ae.modified,Ct=Ae.touched,ci=Ae.visited;return ce.dirtyFields=L&&Nt(L.dirtyFields,ue)?L.dirtyFields:ue,ce.dirtyFieldsSinceLastSubmit=L&&Nt(L.dirtyFieldsSinceLastSubmit,he)?L.dirtyFieldsSinceLastSubmit:he,ce.modified=L&&Nt(L.modified,_e)?L.modified:_e,ce.touched=L&&Nt(L.touched,Ct)?L.touched:Ct,ce.visited=L&&Nt(L.visited,ci)?L.visited:ci,L&&Nt(L,ce)?L:ce},_=function(){return e&&!0&&e(F(),Object.keys(c.fields).reduce(function(R,I){return R[I]=c.fields[I],R},{}))},P=!1,B=!1,W=function q(){if(P)B=!0;else{if(P=!0,_(),!u&&!(d&&p)){var R=c.lastFormState,I=F();I!==R&&(c.lastFormState=I,hu(c.subscribers,I,R,cu))}P=!1,B&&(B=!1,q())}},ee=function(){return Object.keys(c.fields).some(function(R){return c.fields[R].beforeSubmit&&c.fields[R].beforeSubmit()===!1})},ae=function(){return Object.keys(c.fields).forEach(function(R){return c.fields[R].afterSubmit&&c.fields[R].afterSubmit()})},ne=function(){return Object.keys(c.fields).forEach(function(R){return c.fields[R].modifiedSinceLastSubmit=!1})};O(void 0,function(){W()});var te={batch:function(R){u++,R(),u--,w(),W()},blur:function(R){var I=c.fields,L=c.formState,V=I[R];V&&(delete L.active,I[R]=me({},V,{active:!1,touched:!0}),a?O(R,function(){w(),W()}):(w(),W()))},change:function(R,I){var L=c.fields,V=c.formState;if(xe(V.values,R)!==I){y(c,R,function(){return I});var Q=L[R];Q&&(L[R]=me({},Q,{modified:!0,modifiedSinceLastSubmit:!!V.lastSubmittedValues})),a?(w(),W()):O(R,function(){w(),W()})}},get destroyOnUnregister(){return!!t},set destroyOnUnregister(q){t=q},focus:function(R){var I=c.fields[R];I&&!I.active&&(c.formState.active=R,I.active=!0,I.visited=!0,w(),W())},mutators:E,getFieldState:function(R){var I=c.fields[R];return I&&I.lastFieldState},getRegisteredFields:function(){return Object.keys(c.fields)},getState:function(){return F()},initialize:function(R){var I=c.fields,L=c.formState,V=me({},I),Q=typeof R=="function"?R(L.values):R;n||(L.values=Q);var Z=n?Object.keys(V).reduce(function(ue,he){var ce=V[he],Ae=ce.isEqual(xe(L.values,he),xe(L.initialValues||{},he));return Ae||(ue[he]=xe(L.values,he)),ue},{}):{};L.initialValues=Q,L.values=Q,Object.keys(Z).forEach(function(ue){L.values=ft(L.values,ue,Z[ue])||{}}),O(void 0,function(){w(),W()})},isValidationPaused:function(){return d},pauseValidation:function(R){R===void 0&&(R=!0),d=!0,p=R},registerField:function(R,I,L,V){L===void 0&&(L={}),c.fieldSubscribers[R]||(c.fieldSubscribers[R]={index:0,entries:{}});var Q=c.fieldSubscribers[R].index++;c.fieldSubscribers[R].entries[Q]={subscriber:uu(I),subscription:L,notified:!1};var Z=c.fields[R]||{active:!1,afterSubmit:V&&V.afterSubmit,beforeSubmit:V&&V.beforeSubmit,data:V&&V.data||{},isEqual:V&&V.isEqual||tb,lastFieldState:void 0,modified:!1,modifiedSinceLastSubmit:!1,name:R,touched:!1,valid:!0,validateFields:V&&V.validateFields,validators:{},validating:!1,visited:!1};Z.blur=Z.blur||function(){return te.blur(R)},Z.change=Z.change||function(_e){return te.change(R,_e)},Z.focus=Z.focus||function(){return te.focus(R)},c.fields[R]=Z;var ue=!1,he=V&&V.silent,ce=function(){he&&c.fields[R]?w(R):(W(),w())};if(V){ue=!!(V.getValidator&&V.getValidator()),V.getValidator&&(c.fields[R].validators[Q]=V.getValidator);var Ae=xe(c.formState.values,R)===void 0;V.initialValue!==void 0&&(Ae||xe(c.formState.values,R)===xe(c.formState.initialValues,R))&&(c.formState.initialValues=ft(c.formState.initialValues||{},R,V.initialValue),c.formState.values=ft(c.formState.values,R,V.initialValue),O(void 0,ce)),V.defaultValue!==void 0&&V.initialValue===void 0&&xe(c.formState.initialValues,R)===void 0&&Ae&&(c.formState.values=ft(c.formState.values,R,V.defaultValue))}return ue?O(void 0,ce):ce(),function(){var _e=!1;c.fields[R]&&(_e=!!(c.fields[R].validators[Q]&&c.fields[R].validators[Q]()),delete c.fields[R].validators[Q]);var Ct=!!c.fieldSubscribers[R];Ct&&delete c.fieldSubscribers[R].entries[Q];var ci=Ct&&!Object.keys(c.fieldSubscribers[R].entries).length;ci&&(delete c.fieldSubscribers[R],delete c.fields[R],_e&&(c.formState.errors=ft(c.formState.errors,R,void 0)||{}),t&&(c.formState.values=ft(c.formState.values,R,void 0,!0)||{})),he||(_e?O(void 0,function(){W(),w()}):ci&&W())}},reset:function(R){R===void 0&&(R=c.formState.initialValues),c.formState.submitting&&(c.formState.resetWhileSubmitting=!0),c.formState.submitFailed=!1,c.formState.submitSucceeded=!1,delete c.formState.submitError,delete c.formState.submitErrors,delete c.formState.lastSubmittedValues,te.initialize(R||{})},resetFieldState:function(R){c.fields[R]=me({},c.fields[R],{active:!1,lastFieldState:void 0,modified:!1,touched:!1,valid:!0,validating:!1,visited:!1}),O(void 0,function(){w(),W()})},restart:function(R){R===void 0&&(R=c.formState.initialValues),te.batch(function(){for(var I in c.fields)te.resetFieldState(I),c.fields[I]=me({},c.fields[I],{active:!1,lastFieldState:void 0,modified:!1,modifiedSinceLastSubmit:!1,touched:!1,valid:!0,validating:!1,visited:!1});te.reset(R)})},resumeValidation:function(){d=!1,p=!1,f&&O(void 0,function(){w(),W()}),f=!1},setConfig:function(R,I){switch(R){case"debug":e=I;break;case"destroyOnUnregister":t=I;break;case"initialValues":te.initialize(I);break;case"keepDirtyOnReinitialize":n=I;break;case"mutators":r=I,I?(Object.keys(E).forEach(function(L){L in I||delete E[L]}),Object.keys(I).forEach(function(L){E[L]=S(L)})):Object.keys(E).forEach(function(L){delete E[L]});break;case"onSubmit":o=I;break;case"validate":l=I,O(void 0,function(){w(),W()});break;case"validateOnBlur":a=I;break;default:throw new Error("Unrecognised option "+R)}},submit:function(){var R=c.formState;if(!R.submitting){if(delete R.submitErrors,delete R.submitError,R.lastSubmittedValues=me({},R.values),N()){D(),ne(),c.formState.submitFailed=!0,W(),w();return}var I=Object.keys(g);if(I.length){Promise.all(I.map(function(he){return g[Number(he)]})).then(te.submit,console.error);return}var L=ee();if(!L){var V,Q=!1,Z=function(ce){R.submitting=!1;var Ae=R.resetWhileSubmitting;return Ae&&(R.resetWhileSubmitting=!1),ce&&ln(ce)?(R.submitFailed=!0,R.submitSucceeded=!1,R.submitErrors=ce,R.submitError=ce[ss],D()):(Ae||(R.submitFailed=!1,R.submitSucceeded=!0),ae()),W(),w(),Q=!0,V&&V(ce),ce};R.submitting=!0,R.submitFailed=!1,R.submitSucceeded=!1,R.lastSubmittedValues=me({},R.values),ne();var ue=o(R.values,te,Z);if(!Q){if(ue&&Wo(ue))return W(),w(),ue.then(Z,function(he){throw Z(),he});if(o.length>=3)return W(),w(),new Promise(function(he){V=he});Z(ue)}}}},subscribe:function(R,I){if(!R)throw new Error("No callback given.");if(!I)throw new Error("No subscription provided. What values do you want to listen to?");var L=uu(R),V=c.subscribers,Q=V.index++;V.entries[Q]={subscriber:L,subscription:I,notified:!1};var Z=F();return Yd(L,I,Z,Z,cu,!0),function(){delete V.entries[Q]}}};return te}var sb=["render","children","component"];function Xd(i,e,t){var n=i.render,s=i.children,r=i.component,o=ws(i,sb);if(r)return ve.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 Xt(i,e,t){t===void 0&&(t=function(r,o){return r===o});var n=A.useRef(i);A.useEffect(function(){t(i,n.current)||(e(),n.current=i)})}function rb(i){var e=A.useRef();return e.current||(e.current=i()),e.current}var qo=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},ob=function(e){return!!(e&&typeof e.stopPropagation=="function")},Qd=ve.createContext();function Jd(i){var e=A.useRef(i);return A.useEffect(function(){e.current=i}),e}var lb="6.5.8",Zd=function(e,t,n){n.forEach(function(s){Object.defineProperty(e,s,{get:function(){return t[s]},enumerable:!0})})},ef=function(e,t){return Zd(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"])},ab=function(e,t){return Zd(e,t,["active","data","dirty","dirtySinceLastSubmit","error","initial","invalid","length","modified","modifiedSinceLastSubmit","pristine","submitError","submitFailed","submitSucceeded","submitting","touched","valid","validating","visited"])},cb=["debug","decorators","destroyOnUnregister","form","initialValues","initialValuesEqual","keepDirtyOnReinitialize","mutators","onSubmit","subscription","validate","validateOnBlur"],ub={"final-form":eb,"react-final-form":lb},tf=Kd.reduce(function(i,e){return i[e]=!0,i},{});function hb(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,c=i.mutators,u=i.onSubmit,d=i.subscription,f=d===void 0?tf:d,p=i.validate,m=i.validateOnBlur,g=ws(i,cb),x={debug:e,destroyOnUnregister:s,initialValues:o,keepDirtyOnReinitialize:a,mutators:c,onSubmit:u,validate:p,validateOnBlur:m},y=rb(function(){var O=r||nb(x);return O.pauseValidation(),O}),b=ve.useState(function(){var O={};return y.subscribe(function(w){O=w},f)(),O}),S=b[0],E=b[1],v=Jd(S);ve.useEffect(function(){y.isValidationPaused()&&y.resumeValidation();var O=[y.subscribe(function(w){qo(w,v.current)||E(w)},f)].concat(n?n.map(function(w){return w(y)}):[]);return function(){y.pauseValidation(),O.reverse().forEach(function(w){return w()})}},n),process.env.NODE_ENV!=="production"&&Xt(n,function(){console.error("Form decorators should not change from one render to the next as new values will be ignored")},qo),Xt(e,function(){y.setConfig("debug",e)}),Xt(s,function(){y.destroyOnUnregister=!!s}),Xt(a,function(){y.setConfig("keepDirtyOnReinitialize",a)}),Xt(o,function(){y.setConfig("initialValues",o)},l||qo),Xt(c,function(){y.setConfig("mutators",c)}),Xt(u,function(){y.setConfig("onSubmit",u)}),Xt(p,function(){y.setConfig("validate",p)}),Xt(m,function(){y.setConfig("validateOnBlur",m)});var C=function(w){return w&&(typeof w.preventDefault=="function"&&w.preventDefault(),typeof w.stopPropagation=="function"&&w.stopPropagation()),y.submit()},k={form:me({},y,{reset:function(w){ob(w)?y.reset():y.reset(w)}}),handleSubmit:C};return ef(k,S),ve.createElement(Qd.Provider,{value:y},Xd(me({},g,{__versions:ub}),k,"ReactFinalForm"))}function ks(i){var e=ve.useContext(Qd);if(!e)throw new Error((i||"useForm")+" must be used inside of a <Form> component");return e}function db(i){var e=i===void 0?{}:i,t=e.onChange,n=e.subscription,s=n===void 0?tf:n,r=ks("useFormState"),o=ve.useRef(!0),l=ve.useRef(t);l.current=t;var a=ve.useState(function(){var f={};return r.subscribe(function(p){f=p},s)(),t&&t(f),f}),c=a[0],u=a[1];ve.useEffect(function(){return r.subscribe(function(f){o.current?o.current=!1:(u(f),l.current&&l.current(f))},s)},[]);var d={};return ef(d,c),d}var fb=typeof window<"u"&&window.navigator&&window.navigator.product&&window.navigator.product==="ReactNative",pb=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},mb=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,c=o.checked;switch(l){case"checkbox":if(n!==void 0){if(c)return Array.isArray(t)?t.concat(n):[n];if(!Array.isArray(t))return t;var u=t.indexOf(n);return u<0?t:t.slice(0,u).concat(t.slice(u+1))}else return!!c;case"select-multiple":return pb(e.target.options);default:return a}};function Ko(i){var e=ve.useRef(i);return ve.useEffect(function(){e.current=i}),ve.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 gb=Ya.reduce(function(i,e){return i[e]=!0,i},{}),Yo=function(e,t){return e===void 0?"":e},xb=function(e,t){return e===""?void 0:e},yb=function(e,t){return e===t};function mo(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,c=a===void 0?Yo:a,u=t.formatOnBlur,d=t.initialValue,f=t.multiple,p=t.parse,m=p===void 0?xb:p,g=t.subscription,x=g===void 0?gb:g,y=t.type,b=t.validateFields,S=t.value,E=ks("useField"),v=Jd(e),C=function(B,W){return E.registerField(i,B,x,{afterSubmit:n,beforeSubmit:function(){var ae=v.current,ne=ae.beforeSubmit,te=ae.formatOnBlur,q=ae.format,R=q===void 0?Yo:q;if(te){var I=E.getFieldState(i),L=I.value,V=R(L,i);V!==L&&E.change(i,V)}return ne&&ne()},data:o,defaultValue:l,getValidator:function(){return v.current.validate},initialValue:d,isEqual:function(ae,ne){return(v.current.isEqual||yb)(ae,ne)},silent:W,validateFields:b})},k=ve.useRef(!0),O=ve.useState(function(){var P={},B=E.destroyOnUnregister;return E.destroyOnUnregister=!1,C(function(W){P=W},!0)(),E.destroyOnUnregister=B,P}),w=O[0],D=O[1];ve.useEffect(function(){return C(function(P){k.current?k.current=!1:D(P)},!1)},[i,o,l,d]);var N={};ab(N,w);var F={name:i,get value(){var P=w.value;return u?r==="input"&&(P=Yo(P)):P=c(P,i),P===null&&!s&&(P=""),y==="checkbox"||y==="radio"?S:r==="select"&&f?P||[]:P},get checked(){var P=w.value;if(y==="checkbox")return P=c(P,i),S===void 0?!!P:!!(Array.isArray(P)&&~P.indexOf(S));if(y==="radio")return c(P,i)===S},onBlur:Ko(function(P){if(w.blur(),u){var B=E.getFieldState(w.name);w.change(c(B.value,w.name))}}),onChange:Ko(function(P){if(process.env.NODE_ENV!=="production"&&P&&P.target){var B=P.target.type,W=~["checkbox","radio","select-multiple"].indexOf(B)&&!y&&r!=="select",ee=B==="select-multiple"?w.value:S;W&&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(ee)?"["+ee+"]":'"'+ee+'"')+"."))}var ae=P&&P.target?mb(P,w.value,S,fb):P;w.change(m(ae,i))}),onFocus:Ko(function(P){return w.focus()})};f&&(F.multiple=f),y!==void 0&&(F.type=y);var _={input:F,meta:N};return _}var bb=["afterSubmit","allowNull","beforeSubmit","children","component","data","defaultValue","format","formatOnBlur","initialValue","isEqual","multiple","name","parse","subscription","type","validate","validateFields","value"],Sb=ve.forwardRef(function(e,t){var n=e.afterSubmit,s=e.allowNull,r=e.beforeSubmit,o=e.children,l=e.component,a=e.data,c=e.defaultValue,u=e.format,d=e.formatOnBlur,f=e.initialValue,p=e.isEqual,m=e.multiple,g=e.name,x=e.parse,y=e.subscription,b=e.type,S=e.validate,E=e.validateFields,v=e.value,C=ws(e,bb),k=mo(g,{afterSubmit:n,allowNull:s,beforeSubmit:r,children:o,component:l,data:a,defaultValue:c,format:u,formatOnBlur:d,initialValue:f,isEqual:p,multiple:m,parse:x,subscription:y,type:b,validate:S,validateFields:E,value:v});if(typeof o=="function")return o(me({},k,C));if(typeof l=="string")return ve.createElement(l,me({},k.input,{children:o,ref:t},C));if(!g)throw new Error("prop name cannot be undefined in <Field> component");return Xd(me({children:o,component:l,ref:t},C),k,"Field("+g+")")});function go(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=db({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 Xa=({children:i,formId:e,kind:t=U.KIND.primary,disabled:n,overrides:s,...r})=>{const{submitting:o}=go({submitting:!0});return h.jsxRuntimeExports.jsx(U.Button,{type:"submit",kind:t,form:e,disabled:n,isLoading:o,overrides:xx.mergeOverrides({BaseButton:{style:{minWidth:"200px"}}},s),...r,children:i})};function En(){return En=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},En.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(u){var d=[].concat(u||[]);return d.splice(r,0,o),d});var a=new RegExp("^"+s+"\\[(\\d+)\\](.*)"),c={};Object.keys(t.fields).forEach(function(u){var d=a.exec(u);if(d){var f=Number(d[1]);if(f>=r){var p=s+"["+(f+1)+"]"+d[2];c[p]=t.fields[u],c[p].name=p}f===r&&delete t.fields[u]}}),t.fields=En({},t.fields,c)},vb=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})},Eb=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(u){var d=[].concat(u||[]),f=d[r];return d.splice(r,1),d.splice(o,0,f),d});var a=s+"["+r+"]";Object.keys(t.fields).forEach(function(u){if(u.substring(0,a.length)===a){var d=u.substring(a.length),f=a+d,p=t.fields[f];if(r<o)for(var m=r;m<o;m++){var g=s+"["+m+"]"+d;c({destKey:g,source:t.fields[s+"["+(m+1)+"]"+d]})}else for(var x=r;x>o;x--){var y=s+"["+x+"]"+d;c({destKey:y,source:t.fields[s+"["+(x-1)+"]"+d]})}var b=s+"["+o+"]"+d;c({destKey:b,source:p})}});function c(u){var d=u.destKey,f=u.source;t.fields[d]=En({},f,{name:d,change:t.fields[d]&&t.fields[d].change,blur:t.fields[d]&&t.fields[d].blur,focus:t.fields[d]&&t.fields[d].focus,lastFieldState:void 0})}},Cb=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},Rb=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(u){var d=[].concat(u||[]);return l=d[r],d.splice(r,1),d});var a=new RegExp("^"+s+"\\[(\\d+)\\](.*)"),c=En({},t.fields);return Object.keys(t.fields).forEach(function(u){var d=a.exec(u);if(d){var f=Number(d[1]);if(f===r)delete t.fields[u];else if(f>r){delete t.fields[u];var p=s+"["+(f-1)+"]"+d[2];t.fields[p]=c[u],t.fields[p].name=p}}}),l},wb=function(e,t){return e.reduce(function(n,s){return s<t?n+1:n},0)},kb=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 c=[];o(t,s,function(f){if(c=r.map(function(g){return f&&f[g]}),!f||!l.length)return f;var p=[].concat(f),m=[];return l.forEach(function(g){p.splice(g-m.length,1),m.push(f&&f[g])}),p});var u=new RegExp("^"+s+"\\[(\\d+)\\](.*)"),d={};return Object.keys(t.fields).forEach(function(f){var p=u.exec(f);if(p){var m=Number(p[1]);if(!~l.indexOf(m)){var g=s+"["+(m-wb(l,m))+"]"+p[2];d[g]=t.fields[f],d[g].name=g}}else d[f]=t.fields[f]}),t.fields=d,c},Tb=function(e,t,n){var s=e[0];return sf([s,0],t,n)},Ab=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(d){var f=[].concat(d||[]),p=f[r];return f[r]=f[o],f[o]=p,f});var a=s+"["+r+"]",c=s+"["+o+"]";Object.keys(t.fields).forEach(function(d){if(d.substring(0,a.length)===a){var f=d.substring(a.length),p=a+f,m=c+f,g=t.fields[p];u({destKey:p,source:t.fields[m]}),u({destKey:m,source:g})}});function u(d){var f=d.destKey,p=d.source;t.fields[f]=En({},p,{name:f,change:t.fields[f].change,blur:t.fields[f].blur,focus:t.fields[f].focus,lastFieldState:void 0})}},jb=function(e,t,n){var s=e[0],r=e[1];return nf([s,0,r],t,n)},Ib=function(e,t,n){var s=e[0],r=e[1],o=e[2],l=n.changeValue;l(t,s,function(a){var c=[].concat(a||[]);return c.splice(r,1,o),c})},Ob={insert:nf,concat:vb,move:Eb,pop:Cb,push:Rb,remove:sf,removeBatch:kb,shift:Tb,swap:Ab,unshift:jb,update:Ib},Mb=function(e){return!!(e&&typeof e.focus=="function")},Pb=function(){return typeof document>"u"?[]:Array.prototype.slice.call(document.forms).reduce(function(e,t){return e.concat(Array.prototype.slice.call(t).filter(Mb))},[])},Db=function(e,t){return e.find(function(n){return n.name&&xe(t,n.name)})},Lb=function(){},Nb=function(e,t){return function(n){var s=function(u){e||(e=Pb),t||(t=Db);var d=t(e(),u);d&&d.focus()},r=n.submit,o={},l=n.subscribe(function(c){o=c},{errors:!0,submitErrors:!0}),a=function(){var u=o,d=u.errors,f=u.submitErrors;d&&Object.keys(d).length?s(d):f&&Object.keys(f).length&&s(f)};return n.submit=function(){var c=r.call(n);return c&&typeof c.then=="function"?c.then(a,Lb):a(),c},function(){l(),n.submit=r}}};const Fb=M.styled("div",({$height:i})=>({height:`${i}px`,flexShrink:0})),Bb=M.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})),du=M.styled("div",({$theme:i})=>({display:"flex",alignItems:"center",gap:i.sizing.scale200}));function Vb({leftContent:i,rightContent:e}){const t=A.useRef(null),[n,s]=A.useState(0);return A.useEffect(()=>{const r=t.current;if(!r)return;const o=new ResizeObserver(()=>{s(r.offsetHeight)});return o.observe(r),()=>o.disconnect()},[]),h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[h.jsxRuntimeExports.jsx(Fb,{$height:n}),h.jsxRuntimeExports.jsxs(Bb,{ref:t,children:[h.jsxRuntimeExports.jsx(du,{children:i}),h.jsxRuntimeExports.jsx(du,{children:e})]})]})}const rf=A.createContext(null);function Qa(){const i=A.useContext(rf);if(!i)throw new Error("useFormContext must be used within a <Form>");return i}const _b=Nb(),ii=({onSubmit:i,initialValues:e,id:t,children:n,render:s,footer:r,focusOnError:o=!0})=>{const[l,a]=M.useStyletron(),c=A.useRef(new Map),u=A.useMemo(()=>({fieldRegistry:c.current}),[]);return h.jsxRuntimeExports.jsx(rf.Provider,{value:u,children:h.jsxRuntimeExports.jsx(hb,{onSubmit:i,initialValues:e,mutators:{...Ob},decorators:o?[_b]:void 0,render:({handleSubmit:d})=>{const f=h.jsxRuntimeExports.jsxs("form",{className:l({display:"flex",flexDirection:"column",gap:a.sizing.scale600}),id:t,onSubmit:d,children:[n,$b(r)]});return s?s(f):f}})})};function $b(i){if(!i)return null;if(typeof i=="object"&&("left"in i||"right"in i)){const{left:e,right:t}=i;return h.jsxRuntimeExports.jsx(Vb,{leftContent:e,rightContent:t})}return i}const Vi=(...i)=>e=>{for(const t of i){const n=t(e);if(n!==void 0)return n}},Xi=i=>i==null?!0:typeof i=="string"?i.trim()==="":Array.isArray(i)?i.length===0:h.isRecord(i)?Object.keys(i).length===0:!1,pt=(i="This field is required.")=>e=>{if(!(typeof e=="boolean"||typeof e=="number"))return Xi(e)?i:void 0},mr=(i,e=`Must be at least ${i}.`)=>t=>{if(Xi(t))return;const n=Number(t);return isNaN(n)||n<i?e:void 0},zb=(i,e=`Must be at most ${i}.`)=>t=>{if(Xi(t))return;const n=Number(t);return isNaN(n)||n>i?e:void 0},Hb=(i,e=`Must be at least ${i} characters.`)=>t=>Xi(t)?void 0:String(t).length<i?e:void 0,Ja=(i,e=`Must be at most ${i} characters.`)=>t=>Xi(t)?void 0:String(t).length>i?e:void 0,Pr=(i,e="Invalid format.")=>t=>Xi(t)||(typeof i=="string"?new RegExp(i):i).test(String(t))?void 0:e,Gb=(i="Must be a valid URL.")=>e=>{if(!Xi(e))return h.isAbsoluteUrl(String(e))?void 0:i};function qt(i){if(!i)return;const e=[];if(i.min!==void 0&&e.push(mr(i.min)),i.max!==void 0&&e.push(zb(i.max)),i.minLength!==void 0&&e.push(Hb(i.minLength)),i.maxLength!==void 0&&e.push(Ja(i.maxLength)),i.regex&&e.push(Pr(i.regex.pattern,i.regex.errorMessage)),i.url){const t=typeof i.url=="object"?i.url.errorMessage:void 0;e.push(Gb(t))}if(i.validate&&e.push(i.validate),e.length!==0)return e.length===1?e[0]:Vi(...e)}const Ub=({label:i,required:e,description:t})=>{const[n,s]=M.useStyletron();return h.jsxRuntimeExports.jsxs("span",{className:n({display:"flex",gap:s.sizing.scale200,minHeight:s.sizing.scale600,alignItems:"center"}),children:[i,e?h.jsxRuntimeExports.jsx("span",{className:n({color:s.colors.negative}),children:"*"}):null,t?h.jsxRuntimeExports.jsx(h.HelpTooltip,{text:t}):null]})},Wb=({counter:i,labelEndEnhancer:e})=>{const[t,n]=M.useStyletron();return h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[i&&h.jsxRuntimeExports.jsxs("span",{className:t({...n.typography.font100,color:n.colors.contentPrimary}),children:[i.length,"/",i.maxLength]}),e]})},Ue=({label:i,required:e,description:t,labelEndEnhancer:n,caption:s,error:r,counter:o,children:l})=>{const[a,c]=M.useStyletron(),u=o||n?h.jsxRuntimeExports.jsx(Wb,{counter:o,labelEndEnhancer:n}):void 0;return h.jsxRuntimeExports.jsx("div",{className:a({width:"100%"}),children:h.jsxRuntimeExports.jsx(yx.FormControl,{label:i&&h.jsxRuntimeExports.jsx(Ub,{label:i,required:e,description:t}),labelEndEnhancer:u,caption:s&&h.jsxRuntimeExports.jsx(h.TruncatedText,{children:h.jsxRuntimeExports.jsx(h.Markdown,{children:s})}),error:r,overrides:{ControlContainer:{style:{marginBottom:0}},LabelEndEnhancer:{style:{display:"flex",alignItems:"center",gap:c.sizing.scale300}},Caption:{style:({$error:d,$positive:f})=>({display:d||f?"flex":"block"})}},children:l})})};function qb(i,e){const{fieldRegistry:t}=Qa();A.useEffect(()=>(e&&t.set(i,{label:e}),()=>{t.delete(i)}),[i,e,t])}function ke(i,e){qb(i,e==null?void 0:e.label);const t=e!=null&&e.required?Vi(pt(),...e.validate?[e.validate]:[]):e==null?void 0:e.validate,s=mo(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 xo=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:c,labelEndEnhancer:u,format:d,parse:f,checkboxLabel:p,toggle:m=!1})=>{const{input:g,meta:x}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:d,parse:f}),y=S=>{g.onChange(S.currentTarget.checked)},b=p??(g.value?"Enabled":"Disabled");return h.jsxRuntimeExports.jsx(Ue,{label:e,required:s,description:a,labelEndEnhancer:u,caption:c,error:x.touched&&x.error?x.error:void 0,children:h.jsxRuntimeExports.jsx(Bi.Checkbox,{checked:g.value??!1,onChange:o?void 0:y,onBlur:g.onBlur,onFocus:g.onFocus,disabled:l,checkmarkType:m?Bi.STYLE_TYPE.toggle_round:Bi.STYLE_TYPE.default,labelPlacement:Bi.LABEL_PLACEMENT.right,overrides:{Label:{style:({$theme:S})=>({fontSize:S.sizing.scale550})},Root:{style:o?{cursor:"default"}:{}}},children:b})})};function Kb({name:i,config:e}){const t=e,n=qt(t.validation);return h.jsxRuntimeExports.jsx(xo,{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 of=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,disabled:o,description:l,caption:a,labelEndEnhancer:c,format:u,parse:d,options:f})=>{const[p,m]=M.useStyletron(),{input:g,meta:x}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:u,parse:d}),{value:y=[],onChange:b}=g,S=A.useCallback(v=>{const C=y.includes(v)?y.filter(k=>k!==v):[...y,v];b(C)},[y,b]),E=f.some(v=>v.description);return h.jsxRuntimeExports.jsx(Ue,{label:e,required:s,description:l,labelEndEnhancer:c,caption:a,error:x.touched&&x.error?x.error:void 0,children:f.length===0?h.jsxRuntimeExports.jsx("span",{children:"No options available"}):h.jsxRuntimeExports.jsx("div",{className:p({display:"flex",flexDirection:E?"column":"row",flexWrap:E?void 0:"wrap",gap:m.sizing.scale600}),children:f.map(v=>h.jsxRuntimeExports.jsxs(Bi.Checkbox,{checked:y.includes(v.id),onChange:()=>S(v.id),disabled:o,overrides:{Label:{style:({$theme:C})=>({fontSize:C.sizing.scale550})}},children:[v.label,v.description&&h.jsxRuntimeExports.jsx(h.DescriptionText,{children:v.description})]},v.id))})})};function Yb({name:i,config:e}){const t=e,n=qt(t.validation);return h.jsxRuntimeExports.jsx(of,{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 vi=(i=>(i.EPOCH_SECONDS="epoch",i.ISO_DATE_STRING="iso",i))(vi||{});function Xb(i=vi.ISO_DATE_STRING){const e=i===vi.EPOCH_SECONDS?n=>n?h.getDateFromEpochSeconds(parseInt(n)):null:n=>n?new Date(n):null,t=i===vi.EPOCH_SECONDS?n=>n?String(h.getEpochSecondsFromDate(n)):"":n=>n?n.toISOString():"";return{format:n=>Qb(e(n)),parse:n=>t(Jb(n))}}function Qb(i){if(!i)return null;const e=i.getTimezoneOffset();return new Date(i.getTime()+e*60*1e3)}function Jb(i){if(!i)return i;const e=i.getTimezoneOffset();return new Date(i.getTime()-e*60*1e3)}const Dr=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,placeholder:l,disabled:a,description:c,caption:u,labelEndEnhancer:d,noFutureDate:f,dateFormat:p=vi.ISO_DATE_STRING})=>{const{format:m,parse:g}=Xb(p),{input:x,meta:y}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:m,parse:g});return h.jsxRuntimeExports.jsx(Ue,{label:e,required:s,description:c,labelEndEnhancer:d,caption:u,error:y.touched&&y.error?y.error:void 0,children:h.jsxRuntimeExports.jsx(bx.DatePicker,{id:x.name,value:x.value,onChange:({date:b})=>{h.lodashExports.isNil(b)&&Zb(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 Zb(i){return h.lodashExports.isNil(i)||i===""||h.lodashExports.isArray(i)&&!i.length}function eS({name:i,config:e}){const t=e,n=qt(t.validation);return h.jsxRuntimeExports.jsx(Dr,{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 yo({label:i="Add more",shape:e,onClick:t}){const[,n]=M.useStyletron();return h.jsxRuntimeExports.jsx(U.Button,{type:"button",kind:U.KIND.secondary,size:U.SIZE.compact,shape:e,startEnhancer:h.jsxRuntimeExports.jsx(h.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 tS({row:i,keyConfig:e,valueConfig:t,readOnly:n,disabled:s,deletable:r=!0,size:o,keyError:l,onChange:a,onDelete:c,onFocus:u,onBlur:d}){const[f,p]=M.useStyletron(),m=i.key&&i.value?d:void 0;return h.jsxRuntimeExports.jsxs("div",{className:f({display:"flex",alignItems:"flex-start",gap:p.sizing.scale300,width:"100%"}),children:[h.jsxRuntimeExports.jsx(Qe.Input,{value:i.key,onChange:g=>a({...i,key:g.currentTarget.value}),onFocus:u,onBlur:m,placeholder:(e==null?void 0:e.placeholder)??"Key","aria-label":(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}}}),h.jsxRuntimeExports.jsx(Qe.Input,{value:i.value,onChange:g=>a({...i,value:g.currentTarget.value}),onFocus:u,onBlur:m,placeholder:(t==null?void 0:t.placeholder)??"Value","aria-label":(t==null?void 0:t.placeholder)??"Value",readOnly:n,disabled:s,size:o,overrides:{Root:{style:{flex:3}}}}),!n&&r&&h.jsxRuntimeExports.jsx(U.Button,{type:"button","aria-label":"Delete",kind:U.KIND.tertiary,shape:U.SHAPE.circle,onClick:()=>c(i),overrides:{BaseButton:{style:{marginBottom:p.sizing.scale600}}},children:h.jsxRuntimeExports.jsx(h.Icon,{name:"trashCan",kind:h.IconKind.TERTIARY})})]})}const iS={},nS="cannot have duplicated values";function sS({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:c,labelEndEnhancer:u,format:d,parse:f,keyConfig:p,valueConfig:m,singleValue:g,creatable:x=!0,deletable:y=!0,emptyMessage:b,size:S}){const[E,v]=M.useStyletron(),{input:C,meta:k}=ke(i,{required:s,validate:r,defaultValue:t??iS,initialValue:n,label:e,format:d,parse:f}),O=A.useRef(0),[w,D]=A.useState(()=>{const B=rS(C.value);return O.current=B.length,g&&B.length===0?(O.current=1,[{id:0,key:"",value:""}]):B}),N=A.useCallback(B=>{D(W=>{const ee=W.map(ae=>ae.id===B.id?B:ae);return C.onChange(fu(ee)),ee})},[C]),F=()=>{D(B=>[...B,{id:O.current++,key:"",value:""}])},_=A.useCallback(B=>{D(W=>{const ee=W.filter(ae=>ae.id!==B.id);return C.onChange(fu(ee)),ee})},[C]),P=new Set(w.map(B=>B.key).filter((B,W,ee)=>B&&ee.indexOf(B)!==W));return h.jsxRuntimeExports.jsx(Ue,{label:e,required:s,description:a,labelEndEnhancer:u,caption:c,error:k.touched&&k.error?k.error:void 0,children:h.jsxRuntimeExports.jsxs("div",{className:E({display:"flex",flexDirection:"column",gap:v.sizing.scale300}),children:[w.length===0&&b&&h.jsxRuntimeExports.jsx("div",{className:E({...v.typography.ParagraphSmall,marginBottom:v.sizing.scale200}),children:b}),w.map(B=>h.jsxRuntimeExports.jsx(tS,{row:B,keyConfig:p,valueConfig:m,readOnly:o,disabled:l,deletable:y&&!g,size:S,keyError:P.has(B.key)?`${(p==null?void 0:p.placeholder)??"Keys"} ${nS}`:void 0,onChange:N,onDelete:_,onFocus:C.onFocus,onBlur:C.onBlur},B.id)),!g&&!o&&x&&h.jsxRuntimeExports.jsx(yo,{onClick:F,label:"Add more"})]})})}function rS(i){return Object.entries(i??{}).map(([e,t],n)=>({id:n,key:e,value:t}))}function fu(i){return Object.fromEntries(i.map(e=>[e.key,e.value]))}function oS({name:i,config:e}){const t=e,n=qt(t.validation);return h.jsxRuntimeExports.jsx(sS,{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 lf=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:c,caption:u,labelEndEnhancer:d,format:f,parse:p,rows:m,maxLength:g})=>{var v;const{input:x,meta:y}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p}),[b,S]=M.useStyletron(),E=((v=x.value)==null?void 0:v.length)??0;return h.jsxRuntimeExports.jsx(Ue,{label:e,required:s,description:c,labelEndEnhancer:d,caption:u,error:y.touched&&y.error?y.error:void 0,counter:g?{length:E,maxLength:g}:void 0,children:o?h.jsxRuntimeExports.jsx("div",{className:b({...S.typography.font300,minHeight:String(S.typography.font300.lineHeight),border:`${S.sizing.scale0} solid ${S.colors.borderOpaque}`,borderRadius:S.borders.radius300,paddingTop:S.sizing.scale400,paddingBottom:S.sizing.scale400,paddingLeft:S.sizing.scale550,paddingRight:S.sizing.scale550}),children:h.jsxRuntimeExports.jsx(h.Markdown,{children:x.value})}):h.jsxRuntimeExports.jsx(Ed.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,disabled:l,rows:m,maxLength:g,overrides:{Input:{style:{resize:"vertical"}}}})})};function lS({name:i,config:e}){const t=e,n=qt(t.validation);return h.jsxRuntimeExports.jsx(lf,{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 pn=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:c,caption:u,labelEndEnhancer:d,format:f,parse:p})=>{const{input:m,meta:g}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p});return h.jsxRuntimeExports.jsx(Ue,{label:e,required:s,description:c,labelEndEnhancer:d,caption:u,error:g.touched&&g.error?g.error:void 0,children:h.jsxRuntimeExports.jsx(Qe.Input,{id:m.name,type:"number",value:m.value==null?"":String(m.value),name:m.name,onChange:x=>m.onChange(aS(x.currentTarget.value)),onBlur:m.onBlur,onFocus:m.onFocus,placeholder:a,readOnly:o,disabled:l})})};function aS(i){if(i==="")return;const e=Number(i);return isNaN(e)?void 0:e}function cS({name:i,config:e}){const t=e,n=qt(t.validation);return h.jsxRuntimeExports.jsx(pn,{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 uS={RadioMarkOuter:{style:({$disabled:i,$theme:e})=>i?{backgroundColor:e.colors.tickFillSelected}:{}}},hS={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}}},dS=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:c,labelEndEnhancer:u,format:d,parse:f,options:p})=>{const[,m]=M.useStyletron(),{input:g,meta:x}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:d,parse:f}),y=A.useMemo(()=>p.findIndex(S=>S.value===g.value),[p,g]),b=A.useCallback((S,E)=>{S.preventDefault(),S.stopPropagation(),g.onChange(p[E].value)},[g,p]);return h.jsxRuntimeExports.jsx(Ue,{label:e,required:s,description:a,labelEndEnhancer:u,caption:c,error:x.touched&&x.error?x.error:void 0,children:h.jsxRuntimeExports.jsx(Pi.TileGroup,{kind:Pi.TILE_GROUP_KIND.singleSelect,onClick:b,selected:y,disabled:l||o,overrides:uS,children:p.map(S=>h.jsxRuntimeExports.jsx(Pi.Tile,{tileKind:Pi.TILE_KIND.selection,leadingContent:()=>h.jsxRuntimeExports.jsx(ge.LabelMedium,{$style:{textAlign:"left"},children:S.label}),headerAlignment:Pi.ALIGNMENT.left,bodyAlignment:Pi.ALIGNMENT.left,overrides:hS,children:h.jsxRuntimeExports.jsx(Pi.StyledParagraph,{$style:{textAlign:"left",marginBottom:m.sizing.scale600},children:S.description})},String(S.value)))})})},af=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:c,labelEndEnhancer:u,format:d,parse:f,options:p,align:m=Lo.ALIGN.horizontal})=>{var S;const{input:g,meta:x}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:d,parse:f}),y=p.every(({value:E})=>typeof E=="boolean"),b=A.useCallback(E=>{const v=E.currentTarget.value;g.onChange(y?v==="true":v)},[g,y]);return o?h.jsxRuntimeExports.jsx(Ue,{label:e,required:s,description:a,labelEndEnhancer:u,caption:c,error:x.touched&&x.error?x.error:void 0,children:h.jsxRuntimeExports.jsx(Qe.Input,{id:g.name,readOnly:!0,value:((S=p.find(E=>E.value===g.value))==null?void 0:S.label)??"",overrides:{InputContainer:{style:({$theme:E})=>({backgroundColor:E.colors.backgroundPrimary})}}})}):h.jsxRuntimeExports.jsx(Ue,{label:e,required:s,description:a,labelEndEnhancer:u,caption:c,error:x.touched&&x.error?x.error:void 0,children:h.jsxRuntimeExports.jsx(Lo.RadioGroup,{name:g.name,value:typeof g.value=="boolean"?String(g.value):g.value,align:m,disabled:l,onChange:b,onBlur:g.onBlur,onFocus:g.onFocus,overrides:{RadioGroupRoot:{style:({$theme:E})=>({gap:E.sizing.scale600})}},children:p.map(E=>h.jsxRuntimeExports.jsx(Lo.Radio,{value:typeof E.value=="boolean"?String(E.value):E.value,disabled:E.disabled,overrides:{RadioMarkOuter:{style:({$theme:v})=>({height:v.sizing.scale600,width:v.sizing.scale600})},RadioMarkInner:{style:({$checked:v,$theme:C})=>({height:v?C.sizing.scale100:C.sizing.scale400,width:v?C.sizing.scale100:C.sizing.scale400,transform:"none"})}},children:E.label},String(E.value)))})})},Za=i=>i.options.some(t=>!!t.description)?h.jsxRuntimeExports.jsx(dS,{...i}):h.jsxRuntimeExports.jsx(af,{...i});function fS({name:i,config:e}){const t=e,n=qt(t.validation);return h.jsxRuntimeExports.jsx(Za,{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 pS(i,e,t){const n={Popover:{props:{ignoreBoundary:!0}},Input:{props:{name:i}},Tag:{props:{overrides:{Text:{style:{maxWidth:"none"}}}}}};return e?M.mergeOverrides(n,{Tag:{props:{closeable:!1,disabled:!1}}}):t?M.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 mS(i){return i?Array.isArray(i)?i:[i]:[]}function Xo(i){return JSON.stringify(i,(e,t)=>h.isRecord(t)?Object.fromEntries(Object.entries(t).sort(([n],[s])=>n.localeCompare(s))):t)}function dt({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,description:a,caption:c,labelEndEnhancer:u,placeholder:d,format:f,parse:p,options:m,visibleOptionLimit:g,isLoading:x=!1,clearable:y=!0,searchable:b=!0,multi:S=!1,creatable:E=!1,getOptionContent:v}){const{input:C,meta:k}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p}),{baseUiOptions:O,findByValue:w,findByKey:D}=A.useMemo(()=>{const _=new Map;return{baseUiOptions:m.map(B=>{const W=Xo(B.id);return _.set(W,B),{id:W,label:B.label,disabled:B.disabled}}),findByValue:B=>_.get(Xo(B)),findByKey:B=>_.get(B)}},[m]);A.useEffect(()=>{if(x||E)return;const _=C.value;if(!(!_||Array.isArray(_)&&_.length===0))if(S){const P=_,B=P.filter(W=>w(W));B.length!==P.length&&C.onChange(B)}else w(_)||C.onChange("")},[w,x]);const N=_=>{var B;const P=_.value;S?C.onChange(P.map(W=>{var ee;return((ee=D(W.id))==null?void 0:ee.id)??W.id})):P.length>0?C.onChange(((B=D(P[0].id))==null?void 0:B.id)??P[0].id):C.onChange("")},F=A.useMemo(()=>{const _=[];for(const P of mS(C.value)){const B=Xo(P),W=D(B);W?_.push({id:B,label:W.label,disabled:W.disabled}):E&&_.push({id:B,label:String(P)})}return _},[C.value,D,E]);return h.jsxRuntimeExports.jsx(Ue,{label:e,required:s,description:a,labelEndEnhancer:u,caption:c,error:k.touched&&k.error?k.error:void 0,children:h.jsxRuntimeExports.jsx(dn.Select,{id:i,value:F,options:O,onChange:N,onBlur:C.onBlur,onFocus:C.onFocus,placeholder:!l&&!o?d:"",disabled:l,clearable:!l&&!o&&y,searchable:b,multi:S,overrides:pS(i,l,o),creatable:E,filterOptions:(_,P,B,W)=>dn.filterOptions(_,P,B,W).slice(0,g),isLoading:x,getOptionLabel:({option:_})=>{if(!v)return _.label;const P=D(String(_.id));return P?v(P):_.label},getValueLabel:({option:_})=>_.label})})}function gS({name:i,config:e}){const t=e,n=qt(t.validation);return h.jsxRuntimeExports.jsx(dt,{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 xS(i){const{closeable:e,index:t,onRemove:n,readOnly:s,updateValue:r,value:o}=i,[,l]=M.useStyletron(),[a,c]=A.useState(!1),[u,d]=A.useState(o),f={paddingTop:l.sizing.scale100,paddingRight:l.sizing.scale100,paddingBottom:l.sizing.scale100,paddingLeft:l.sizing.scale100},p=()=>{d(o),c(!1)},m=()=>{r(u,t),c(!1)},g=x=>{x.key==="Enter"&&m()};return a&&!s?h.jsxRuntimeExports.jsx(h.Tag,{contentMaxWidth:"100%",overrides:{ActionIcon:{component:h.Icon,props:{name:"check",onMouseDown:m,size:l.sizing.scale500}},Root:{style:f}},behavior:h.TAG_BEHAVIOR.selection,hierarchy:vn.HIERARCHY.secondary,children:h.jsxRuntimeExports.jsx(Qe.StyledInput,{$adjoined:Qe.ADJOINED.none,autoFocus:!0,onBlur:p,onChange:x=>d(x.target.value),onKeyDown:g,size:u.length+1,$size:Qe.SIZE.compact,style:{padding:0},value:u})}):h.jsxRuntimeExports.jsx(h.Tag,{closeable:e,onActionClick:n,onClick:()=>c(!0),overrides:{Root:{style:f}},hierarchy:vn.HIERARCHY.primary,children:o})}const yS=A.forwardRef(function(e,t){const{clear:n,readOnly:s,removeValue:r,updateValue:o,value:l,valueList:a,...c}=e,[,u]=M.useStyletron(),d=()=>{var p;n(),t&&typeof t!="function"&&((p=t.current)==null||p.focus())},f=p=>{var m;p.target===p.currentTarget&&t&&typeof t!="function"&&((m=t.current)==null||m.focus())};return h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[h.jsxRuntimeExports.jsxs(dn.StyledValueContainer,{$multi:!0,$style:{gap:u.sizing.scale100},onClick:f,children:[a.map((p,m)=>h.jsxRuntimeExports.jsx(xS,{value:p,index:m,closeable:!s,onRemove:()=>r(m),readOnly:s,updateValue:o},m)),h.jsxRuntimeExports.jsx(Qe.StyledInput,{...c,$adjoined:Qe.ADJOINED.none,readOnly:s,ref:t,size:String(l??"").length+1,$size:Qe.SIZE.compact,value:l})]}),a.length>0&&!s&&h.jsxRuntimeExports.jsx(dn.StyledIconsContainer,{children:h.jsxRuntimeExports.jsx(dn.StyledClearIcon,{onClick:d,children:h.jsxRuntimeExports.jsx(Sx.DeleteAlt,{})})})]})});function bS({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:c,caption:u,labelEndEnhancer:d,format:f,parse:p}){const{input:m,meta:g}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p}),[x,y]=A.useState(""),b=Array.isArray(m.value)?m.value:[],S=w=>{m.onChange([...b,w]),y("")},E=w=>m.onChange(b.filter((D,N)=>N!==w)),v=(w,D)=>{const N=[...b];N[D]=w,m.onChange(N)},C=()=>{m.onChange([]),y("")},k=w=>{if(o)return;const D=w.key==="Enter"&&x,N=w.key==="Backspace"&&b.length>0&&!x;D?(w.preventDefault(),S(x)):N&&E(b.length-1)},O=()=>{m.onBlur(),x&&S(x)};return h.jsxRuntimeExports.jsx(Ue,{label:e,required:s,description:c,labelEndEnhancer:d,caption:u,error:g.touched&&g.error?g.error:void 0,children:h.jsxRuntimeExports.jsx(Qe.Input,{...m,id:i,value:x,onChange:w=>y(w.currentTarget.value),onBlur:O,placeholder:!l&&!o&&b.length===0?a:"",readOnly:o,disabled:l,overrides:{InputContainer:{style:({$theme:w})=>o&&!l?{backgroundColor:w.colors.backgroundPrimary}:{}},Input:{component:yS,props:{clear:C,onKeyDown:k,readOnly:o,removeValue:E,updateValue:v,valueList:b},style:{width:"auto",flexGrow:1,padding:0}}}})})}function SS({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:c,caption:u,labelEndEnhancer:d,format:f,parse:p,maxLength:m}){var b;const{input:g,meta:x}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p}),y=((b=g.value)==null?void 0:b.length)??0;return h.jsxRuntimeExports.jsx(Ue,{label:e,required:s,description:c,labelEndEnhancer:d,caption:u,error:x.touched&&x.error?x.error:void 0,counter:m?{length:y,maxLength:m}:void 0,children:h.jsxRuntimeExports.jsx(Qe.Input,{id:g.name,value:g.value??"",name:g.name,onChange:S=>g.onChange(S.currentTarget.value),onBlur:g.onBlur,onFocus:g.onFocus,placeholder:a,readOnly:o,disabled:l,maxLength:m})})}function Be(i){return i.multi?h.jsxRuntimeExports.jsx(bS,{...i}):h.jsxRuntimeExports.jsx(SS,{...i})}function vS({name:i,config:e}){const t=e,n=qt(t.validation);return h.jsxRuntimeExports.jsx(Be,{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 Ts=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,readOnly:o,disabled:l,placeholder:a,description:c,caption:u,labelEndEnhancer:d,format:f,parse:p,rows:m,maxLength:g})=>{var S;const{input:x,meta:y}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:f,parse:p}),b=((S=x.value)==null?void 0:S.length)??0;return h.jsxRuntimeExports.jsx(Ue,{label:e,required:s,description:c,labelEndEnhancer:d,caption:u,error:y.touched&&y.error?y.error:void 0,counter:g?{length:b,maxLength:g}:void 0,children:h.jsxRuntimeExports.jsx(Ed.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,readOnly:o,disabled:l,rows:m,maxLength:g,overrides:{Input:{style:{resize:"vertical"}}}})})};function ES({name:i,config:e}){const t=e;return h.jsxRuntimeExports.jsx(Ts,{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 cf=({name:i,label:e,defaultValue:t,initialValue:n,required:s,validate:r,description:o,caption:l,labelEndEnhancer:a,format:c,parse:u,placeholder:d,urlName:f})=>{const{input:p,meta:m}=ke(i,{required:s,validate:r,defaultValue:t,initialValue:n,label:e,format:c,parse:u}),g=p.value;return h.jsxRuntimeExports.jsx(Ue,{label:e,required:s,description:o,labelEndEnhancer:a,caption:l,error:m.touched&&m.error?m.error:void 0,children:h.isNavigableUrl(g)?h.jsxRuntimeExports.jsx(h.Link,{href:g,children:h.jsxRuntimeExports.jsx(h.TruncatedText,{children:f??e??g})}):h.jsxRuntimeExports.jsx("span",{children:d})})};function CS({name:i,config:e}){const t=e,n=qt(t.validation);return h.jsxRuntimeExports.jsx(cf,{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 RS={string:vS,number:cS,boolean:Kb,select:gS,checkbox:Yb,radio:fS,date:eS,textarea:ES,url:CS,map:oS,markdown:lS},wS=A.createContext(null),kS=()=>A.useContext(wS);function TS(i){const e=kS();return(e==null?void 0:e.renderers[i])??RS[i]}function AS({fieldPath:i,config:e}){const t=TS((e==null?void 0:e.type)??"");return!t||!e?null:h.jsxRuntimeExports.jsx(t,{name:i,config:e})}function Qo(i){return i==null||i===""||Array.isArray(i)&&!i.length}function uf(i,e){return"is"in i?e===i.is:"isNot"in i?!Qo(e)&&e!==i.isNot:"isEmpty"in i?i.isEmpty?Qo(e):!Qo(e):"containsAny"in i?Array.isArray(e)?i.containsAny.some(t=>e.includes(t)):i.containsAny.some(t=>e===t):!0}function jS({layout:i,children:e}){const{input:t}=mo(i.when,{subscription:{value:!0}});return uf(i,t.value)?h.jsxRuntimeExports.jsx(h.jsxRuntimeExports.Fragment,{children:e}):null}const IS=({children:i})=>{const[e,t]=M.useStyletron();return h.jsxRuntimeExports.jsx("div",{className:e({display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gridColumnGap:t.sizing.scale800}),children:i})},ec=({children:i,title:e,description:t,expanded:n,defaultExpanded:s=!1,onToggle:r,disabled:o=!1,overrides:l={}})=>{const[a,c]=A.useState(s),u=n!==void 0,d=u?n:a;A.useEffect(()=>{u&&!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.")},[u,r]);const f=()=>{if(o)return;const x=!d;u||c(x),r==null||r(x)},[p,m]=M.getOverrides(l.HeaderTitle,h.StyledBoxTitle),g=e?h.jsxRuntimeExports.jsxs("div",{children:[h.jsxRuntimeExports.jsx(p,{...m,children:e}),t&&h.jsxRuntimeExports.jsx(h.DescriptionText,{children:t})]}):void 0;return h.jsxRuntimeExports.jsx(vx.Panel,{expanded:d,onChange:f,title:g,overrides:M.mergeOverrides({PanelContainer:{component:h.StyledBoxContainer,style:({$expanded:x,$theme:y})=>({...!x&&{gap:0},transitionProperty:"gap",transitionDuration:y.animation.timing500})},Header:{style:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight: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})},ji=({title:i,description:e,tooltip:t,collapsible:n=!1,expanded:s,onToggle:r,endEnhancer:o,overrides:l={},children:a})=>{const[c,u]=M.useStyletron(),d=i&&t?h.jsxRuntimeExports.jsxs("div",{className:c({display:"flex",alignItems:"center",gap:u.sizing.scale100}),children:[i,h.jsxRuntimeExports.jsx(h.HelpTooltip,{text:t})]}):i,f=d&&o?h.jsxRuntimeExports.jsxs("div",{className:c({display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"}),children:[d,o]}):d,p=e?h.jsxRuntimeExports.jsx(h.Markdown,{children:e}):void 0;return n?h.jsxRuntimeExports.jsx(ec,{title:f,description:p,expanded:s,defaultExpanded:!1,onToggle:r,overrides:{Content:{style:{paddingTop:0}}},children:a}):h.jsxRuntimeExports.jsx(h.Box,{title:f,description:p,overrides:M.mergeOverrides({BoxContainer:{style:{marginBottom:u.sizing.scale600}}},l),children:a})},rs=({name:i,span:e,children:t})=>{const[n,s]=M.useStyletron(),r=A.Children.toArray(t),o=(e==null?void 0:e.reduce((l,a)=>l+a,0))??r.length;return h.jsxRuntimeExports.jsxs("div",{className:n({flexGrow:1,boxSizing:"border-box"}),children:[i&&h.jsxRuntimeExports.jsx("div",{className:n(s.typography.LabelMedium),children:i}),h.jsxRuntimeExports.jsx(Tr.Grid,{gridColumns:o,gridMargins:[0],gridMaxWidth:0,children:r.map((l,a)=>h.jsxRuntimeExports.jsx(Tr.Cell,{span:e==null?void 0:e[a],children:l},a))})]})};function OS({config:i,fields:e}){const t=h.jsxRuntimeExports.jsx(hf,{items:i.items,fields:e});switch(i.type){case"group":return h.jsxRuntimeExports.jsx(ji,{title:i.title,description:i.description,tooltip:i.tooltip,collapsible:i.collapsible,children:t});case"row":return h.jsxRuntimeExports.jsx(rs,{name:i.name,span:i.span,children:t});case"grid":return h.jsxRuntimeExports.jsx(IS,{children:t});case"condition":return h.jsxRuntimeExports.jsx(jS,{layout:i,children:t})}}function hf({items:i,fields:e}){return h.jsxRuntimeExports.jsx(h.jsxRuntimeExports.Fragment,{children:i.map((t,n)=>typeof t=="string"?h.jsxRuntimeExports.jsx(AS,{fieldPath:t,config:e[t]},t):h.jsxRuntimeExports.jsx(OS,{config:t,fields:e},n))})}function MS(i,e){const t=h.lodashExports.cloneDeep(i);return PS(t,e),t}function PS(i,e){const t=h.lodashExports.toPath(e);if(t.length===0)return;do h.lodashExports.unset(i,t),t.pop();while(t.length>0&&h.lodashExports.isEmpty(h.lodashExports.get(i,t)));const n=h.lodashExports.get(i,t);Array.isArray(n)&&h.lodashExports.set(i,t,n.filter(s=>s!==void 0))}function DS(i,e){return df(e.layout,i)}function df(i,e){return i.reduce((t,n)=>typeof n=="string"?t:n.type==="condition"&&!uf(n,h.lodashExports.get(t,n.when))?ff(n.items,t):df(n.items,t),e)}function ff(i,e){return i.reduce((t,n)=>typeof n=="string"?MS(t,n):ff(n.items,t),e)}const Jo={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 LS(){const[i,e]=A.useState();return h.jsxRuntimeExports.jsxs(tn,{children:[h.jsxRuntimeExports.jsx(ge.HeadingXXLarge,{children:"Component Sandbox"}),h.jsxRuntimeExports.jsx(Bs.Block,{marginBottom:"24px",children:"This is a sandbox for testing WIP components and features."}),h.jsxRuntimeExports.jsx(Bs.Block,{width:"400px",children:h.jsxRuntimeExports.jsxs(ii,{initialValues:{mode:"basic"},onSubmit:t=>{const n=DS(t,Jo);e(n)},children:[h.jsxRuntimeExports.jsx(hf,{items:Jo.layout,fields:Jo.fields}),h.jsxRuntimeExports.jsx(Xa,{children:"Submit"})]})}),i?h.jsxRuntimeExports.jsxs(Bs.Block,{marginTop:"24px",children:[h.jsxRuntimeExports.jsx(ge.LabelMedium,{marginBottom:"scale300",children:"Last submitted values"}),h.jsxRuntimeExports.jsx(Bs.Block,{as:"pre",backgroundColor:"backgroundSecondary",padding:"12px",children:JSON.stringify(i,null,2)})]}):null]})}var st=(i=>(i.PRIMARY="primary",i.SECONDARY="secondary",i.TERTIARY="tertiary",i))(st||{});function NS(){var a;const{fieldRegistry:i}=Qa(),{submitErrors:e,errors:t,touched:n}=go({submitErrors:!0,errors:!0,touched:!0}),s=e==null?void 0:e[ss],r=s instanceof Error?s.message:s,o=r?[{fieldPath:ss,errorMessage:r}]:[];if(!t)return o;const l=[];for(const[c,u]of Object.entries(n??{})){if(!u)continue;const d=h.lodashExports.get(t,c);typeof d=="string"&&l.push({fieldPath:c,fieldLabel:(a=i.get(c))==null?void 0:a.label,errorMessage:d,focus:()=>{var f;(f=document.querySelector(`[name="${c}"]`))==null||f.focus()}})}return[...o,...l]}function pf(){const[i,e]=M.useStyletron(),t=NS();return t.length===0?null:h.jsxRuntimeExports.jsx(h.Banner,{kind:"negative",children:t.map(n=>h.jsxRuntimeExports.jsxs("div",{className:i({...e.typography.ParagraphSmall,textAlign:"left"}),children:[n.fieldLabel&&h.jsxRuntimeExports.jsx(Ex.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&&h.jsxRuntimeExports.jsx(h.jsxRuntimeExports.Fragment,{children:" "}),h.jsxRuntimeExports.jsx(h.Markdown,{children:n.errorMessage})]},n.fieldPath))})}const As=({isOpen:i,onDismiss:e,heading:t,size:n=Ar.SIZE.large,onSubmit:s,initialValues:r,submitLabel:o="Submit",children:l})=>{const a=A.useId(),c=async u=>{try{await s(u),e()}catch(d){return{[ss]:d instanceof Error?d:new Error(String(d))}}};return h.jsxRuntimeExports.jsxs(ii,{id:a,initialValues:r,onSubmit:c,render:u=>h.jsxRuntimeExports.jsx(h.Dialog,{isOpen:i,onDismiss:e,heading:t,size:n,placement:Ar.PLACEMENT.topCenter,buttonDock:{primaryAction:h.jsxRuntimeExports.jsx(Xa,{formId:a,children:o}),dismissiveAction:h.jsxRuntimeExports.jsx(U.Button,{kind:U.KIND.tertiary,onClick:e,overrides:{BaseButton:{style:{minWidth:"150px"}}},children:"Cancel"})},children:u}),children:[l,h.jsxRuntimeExports.jsx(pf,{})]})},FS=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,BS=i=>(Array.isArray(i)?i:[]).every(n=>typeof n=="string"&&FS.test(n))?void 0:"Must be a valid email.";var $l=(i=>(i[i.EMAIL=1]="EMAIL",i[i.SLACK=2]="SLACK",i))($l||{}),nn=(i=>(i[i.PIPELINE_RUN_STATE_SUCCEEDED=1]="PIPELINE_RUN_STATE_SUCCEEDED",i[i.PIPELINE_RUN_STATE_KILLED=2]="PIPELINE_RUN_STATE_KILLED",i[i.PIPELINE_RUN_STATE_FAILED=3]="PIPELINE_RUN_STATE_FAILED",i[i.PIPELINE_RUN_STATE_SKIPPED=4]="PIPELINE_RUN_STATE_SKIPPED",i[i.PIPELINE_RUN_STATE_STARTED=11]="PIPELINE_RUN_STATE_STARTED",i))(nn||{}),zl=(i=>(i[i.PIPELINE_RUN=1]="PIPELINE_RUN",i))(zl||{}),Lr=(i=>(i[i.QUEUED=0]="QUEUED",i[i.PENDING=1]="PENDING",i[i.RUNNING=2]="RUNNING",i[i.SUCCEEDED=3]="SUCCEEDED",i[i.KILLED=4]="KILLED",i[i.FAILED=5]="FAILED",i[i.SKIPPED=6]="SKIPPED",i))(Lr||{});const mf=new Set([3,4,5,6]),gf="michelangelo/environment",VS={development:"Development",production:"Production",testing:"Testing"};function xf(i){const e=i==null?void 0:i[gf];return e?VS[e.toLowerCase()]??"":""}const pu="-",_S=8,tc=(i={withDate:!1})=>{const e=`${pu}${crypto.randomUUID().substring(0,_S)}`;if(i.withDate){const t=new Date().toISOString(),n=h.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`${pu}${o}-${l}${e}`}return e},yf={0:"Pending",1:"Pending",2:"Running",3:"Success",4:"Killed",5:"Failed",6:"Skipped"},bf={0:"gray",1:"blue",2:"blue",3:"green",4:"red",5:"red",6:"gray"},Sf={0:"Queued",1:"Pending",2:"Running",3:"Succeeded",4:"Killed",5:"Failed",6:"Skipped"},$S={0:"gray",1:"blue",2:"blue",3:"green",4:"red",5:"red",6:"gray"},vf={id:"metadata.creationTimestamp.seconds",label:"Created",type:h.CellType.DATE},Ef={id:"spec.pipeline.name",label:"Pipeline",items:[{id:"spec.pipeline.name",type:h.CellType.TEXT},{id:"spec.revision.name",type:h.CellType.DESCRIPTION}]},Cf={id:"spec.actor.name",label:"Started by",type:h.CellType.TEXT},Rf={id:"status.state",label:"State",type:h.CellType.STATE,stateTextMap:Sf,stateColorMap:$S},Hl="pipelinerun.michelangelo/triggered-by",ic={id:`metadata.labels['${Hl}']`,label:"Triggered by",type:h.CellType.LINK,url:He(({studio:i,data:e})=>{var n,s;const t=(s=(n=e==null?void 0:e.metadata)==null?void 0:n.labels)==null?void 0:s[Hl];return t?`/${i.projectId}/${i.phase}/triggers/${t}`:""})},nc=[vf,Ef,Cf,ic,Rf];function wf(i){var n,s,r,o,l,a,c,u;const e=(n=i==null?void 0:i.status)==null?void 0:n.sourcePipeline,t=((r=(s=e==null?void 0:e.pipeline)==null?void 0:s.spec)==null?void 0:r.manifest)??((l=(o=e==null?void 0:e.draftPipeline)==null?void 0:o.spec)==null?void 0:l.manifest)??((c=(a=i==null?void 0:i.spec)==null?void 0:a.pipelineSpec)==null?void 0:c.manifest);return(u=t==null?void 0:t.content)==null?void 0:u.value}const zS=({step:i})=>{var a,c,u,d;const[e,t]=M.useStyletron();if(!i)return null;const n=h.timestampToString((a=i.startTime)==null?void 0:a.seconds),s=h.timestampToString((c=i.endTime)==null?void 0:c.seconds),r=h.formatElapsedSeconds((u=i.startTime)==null?void 0:u.seconds,(d=i.endTime)==null?void 0:d.seconds),o=i.state??0,l=e({...t.typography.ParagraphXSmall});return h.jsxRuntimeExports.jsxs("div",{className:e({display:"grid",gridTemplateColumns:"1.5fr 1fr 1fr 0.5fr auto",alignItems:"center",gap:t.sizing.scale400,width:"100%"}),children:[h.jsxRuntimeExports.jsx("span",{children:i.displayName}),h.jsxRuntimeExports.jsx("span",{className:l,children:n??"—"}),h.jsxRuntimeExports.jsx("span",{className:l,children:s??"—"}),h.jsxRuntimeExports.jsx("span",{className:l,children:r??"—"}),h.jsxRuntimeExports.jsx(h.Tag,{size:h.TAG_SIZE.xSmall,hierarchy:vn.HIERARCHY.secondary,behavior:h.TAG_BEHAVIOR.display,closeable:!1,color:bf[o]??"gray",children:yf[o]??"Unknown"})]})},kf=1,Tf="pipeline_run.pipeline_name",sc={id:"status.state",label:"State",type:h.CellType.STATE,stateTextMap:{0:"Invalid",1:"Created",2:"Building",3:"Ready",4:"Error"},stateColorMap:{0:"red",1:"green",2:"yellow",3:"green",4:"red"}},rc={id:"spec.type",label:"Type",type:h.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"}},mu="spec.resume.pipelineRun.name",HS="spec.resume.resumeFrom",GS="Execute Workflow",US=25;function WS(i){return{listOptionsExt:{operation:{criterion:[{fieldName:Tf,operator:kf,matchValue:i}]}}}}const qS=({pipelineName:i})=>{const[e,t]=A.useState(!1),n=y=>t(y),{input:s}=ke(mu),r=s.value,{data:o,isLoading:l}=h.useStudioQuery({queryName:"ListPipelineRun",serviceOptions:WS(i),clientOptions:{enabled:e}}),{data:a,isLoading:c}=h.useStudioQuery({queryName:"GetPipelineRun",serviceOptions:{name:r},clientOptions:{enabled:!!r}}),u=A.useMemo(()=>{var y;return KS((y=o==null?void 0:o.pipelineRunList)==null?void 0:y.items,i)},[o,i]),d=A.useMemo(()=>XS(a==null?void 0:a.pipelineRun),[a]),f=A.useMemo(()=>d.map(y=>({id:y.displayName??"",label:y.displayName??""})),[d]),p=A.useMemo(()=>{const y=new Map;for(const b of d)b.displayName&&y.set(b.displayName,b);return y},[d]),m=!!r,g=m&&!c&&d.length===0;let x="Leave empty to continue from where the source run stopped, reusing all cached outputs.";return m?g&&(x="This run has no recorded workflow tasks to resume from."):x="Choose a pipeline run above first.",h.jsxRuntimeExports.jsxs(ji,{collapsible:!0,title:"Select run to resume from",description:"Continue a previous run instead of starting over. Completed tasks are reused from the source run.",onToggle:n,children:[h.jsxRuntimeExports.jsx(dt,{name:mu,label:"Pipeline run",options:u,isLoading:l,caption:!l&&u.length===0?"This pipeline has no finished runs to resume from.":void 0}),h.jsxRuntimeExports.jsx(dt,{multi:!0,name:HS,label:"Steps",options:f,isLoading:c,disabled:!m||g,creatable:!1,getOptionContent:y=>h.jsxRuntimeExports.jsx(zS,{step:p.get(y.id)}),caption:x})]})};function KS(i,e){return i?i.filter(t=>{var n,s,r,o;return((s=(n=t.spec)==null?void 0:n.pipeline)==null?void 0:s.name)===e&&((r=t.status)==null?void 0:r.state)!==void 0&&mf.has(t.status.state)&&!!((o=t.metadata)!=null&&o.name)}).sort((t,n)=>{var s,r,o,l;return Number(((r=(s=n.metadata)==null?void 0:s.creationTimestamp)==null?void 0:r.seconds)??0)-Number(((l=(o=t.metadata)==null?void 0:o.creationTimestamp)==null?void 0:l.seconds)??0)}).slice(0,US).map(t=>{var n;return{id:((n=t.metadata)==null?void 0:n.name)??"",label:YS(t)}}):[]}function YS(i){var n,s,r,o;const e=Sf[((n=i.status)==null?void 0:n.state)??0]??"Unknown",t=h.timestampToString((r=(s=i.metadata)==null?void 0:s.creationTimestamp)==null?void 0:r.seconds);return[(o=i.metadata)==null?void 0:o.name,e,t].filter(Boolean).join(" · ")}function XS(i){var t,n;const e=(n=(t=i==null?void 0:i.status)==null?void 0:t.steps)==null?void 0:n.find(s=>s.name===GS);return((e==null?void 0:e.subSteps)??[]).filter(s=>!!s.displayName)}const gu=[nn.PIPELINE_RUN_STATE_STARTED,nn.PIPELINE_RUN_STATE_SUCCEEDED,nn.PIPELINE_RUN_STATE_FAILED,nn.PIPELINE_RUN_STATE_KILLED,nn.PIPELINE_RUN_STATE_SKIPPED],QS=({record:i,onClose:e})=>{var l;const{projectId:t}=h.useStudioParams("base"),n=((l=i==null?void 0:i.metadata)==null?void 0:l.name)??"",s=h.useStudioMutation({mutationName:"CreatePipelineRun"}),r=async a=>{if(s.isPending)return;const c=JS(a,t);await s.mutateAsync({metadata:c.metadata,spec:{...c.spec,notifications:a.notifyOnCompletion?ZS(a):[]}})},o={metadata:{name:`run${tc({withDate:!0})}`,namespace:t},spec:{pipeline:{name:n,namespace:t}}};return h.jsxRuntimeExports.jsxs(As,{isOpen:!0,onDismiss:e,heading:"Start new pipeline run",onSubmit:r,submitLabel:"Run",initialValues:o,children:[h.jsxRuntimeExports.jsx(Be,{name:"spec.pipeline.name",label:"Pipeline to run",readOnly:!0}),h.jsxRuntimeExports.jsx(af,{name:`metadata.labels.${gf}`,label:"Which environment do you want to use?",required:!0,options:[{value:"development",label:"Development"},{value:"production",label:"Production"}]}),h.jsxRuntimeExports.jsx(Ts,{name:"spec.description",label:"Description",description:"Optional. Helps identify this run in the pipeline run list."}),h.jsxRuntimeExports.jsx(qS,{pipelineName:n}),h.jsxRuntimeExports.jsxs(ji,{title:"Set Up Notifications (Optional)",children:[h.jsxRuntimeExports.jsx(xo,{name:"notifyOnCompletion",checkboxLabel:"Do you want to receive notifications when pipeline run completed?",toggle:!0}),h.jsxRuntimeExports.jsx(Sb,{name:"notifyOnCompletion",subscription:{value:!0},children:({input:a})=>a.value?h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[h.jsxRuntimeExports.jsx(Be,{name:"notificationEmails",label:"Emails",multi:!0,validate:BS,placeholder:"e.g. name@example.com"}),h.jsxRuntimeExports.jsx(Be,{name:"notificationSlackDestinations",label:"Slack Channels or Users",multi:!0,placeholder:"e.g. #channel or @user"})]}):null})]})]})};function JS(i,e){var o,l,a,c;const t=(a=(l=(o=i.spec)==null?void 0:o.resume)==null?void 0:l.pipelineRun)==null?void 0:a.name,{resume:n,...s}=i.spec;if(!t)return{...i,spec:s};const r=((c=i.spec.resume)==null?void 0:c.resumeFrom)??[];return{...i,spec:{...s,resume:{pipelineRun:{name:t,namespace:e},...r.length>0&&{resumeFrom:r}}}}}function ZS(i){const e=r=>(r==null?void 0:r.filter(o=>o.trim()!==""))??[],t=e(i.notificationEmails),n=e(i.notificationSlackDestinations),s=[];return t.length>0&&s.push({notificationType:$l.EMAIL,eventTypes:gu,resourceType:zl.PIPELINE_RUN,emails:t,slackDestinations:[]}),n.length>0&&s.push({notificationType:$l.SLACK,eventTypes:gu,resourceType:zl.PIPELINE_RUN,emails:[],slackDestinations:n}),s}const oc={id:"status.state",label:"State",type:h.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"}},Af={id:"spec.pipeline.name",label:"Pipeline",items:[{id:"spec.pipeline.name",type:h.CellType.TEXT},{id:"spec.revision.name",type:h.CellType.DESCRIPTION}]},ev=[{unit:"day",seconds:86400},{unit:"hour",seconds:3600},{unit:"minute",seconds:60}],jf=i=>{var t;const e=i==null?void 0:i.triggerType;switch(e==null?void 0:e.case){case"cronSchedule":return e.value.cron?`cron ${e.value.cron}`:"";case"intervalSchedule":return tv((t=e.value.interval)==null?void 0:t.seconds);case"batchRerun":return"batch rerun";default:return""}};function tv(i){const e=Number(i??0);if(!Number.isFinite(e)||e<=0)return"";for(const{unit:t,seconds:n}of ev)if(e%n===0){const s=e/n;return s===1?`every ${t}`:`every ${s} ${t}s`}return`every ${e} seconds`}const iv={type:"detail",metadata:[{id:"metadata.creationTimestamp.seconds",label:"Created",type:h.CellType.DATE},{id:"spec.owner.name",label:"Owner",type:h.CellType.TEXT},rc,{id:"spec.commit.branch",label:"Branch",type:h.CellType.TEXT},sc],pages:[{id:"runs",label:"Runs",type:"table",queryConfig:{endpoint:"list",service:"pipelineRun",serviceOptions:{listOptionsExt:{operation:{criterion:[{fieldName:Tf,operator:kf,matchValue:"${page.metadata.name}"}]}}}},tableConfig:{columns:[{id:"metadata.name",label:"Name",url:"/${studio.projectId}/${studio.phase}/runs/${row.metadata.name}"},...nc]}},{id:"triggers",label:"Triggers",type:"table",queryConfig:{endpoint:"list",service:"triggerRun",serviceOptions:{listOptions:{fieldSelector:"pipeline_name=${page.metadata.name}"}}},tableConfig:{columns:[{id:"metadata.name",label:"Name",url:"/${studio.projectId}/${studio.phase}/triggers/${row.metadata.name}"},{id:"metadata.creationTimestamp.seconds",label:"Created",type:h.CellType.DATE},{id:"spec.actor.name",label:"Started by",type:h.CellType.TEXT},{id:"schedule",label:"Schedule",type:h.CellType.TEXT,accessor:i=>{var e;return jf((e=i.spec)==null?void 0:e.trigger)}},oc]}}]},nv=12,sv=[{id:"spec.baseResource.name",label:"Name",type:h.CellType.MULTI,items:[{id:"spec.baseResource.name",url:"/${studio.projectId}/${studio.phase}/pipelines/${data.spec.baseResource.name}?revisionId=${data.spec.revisionId}"},{id:"spec.revisionId",type:h.CellType.DESCRIPTION,hierarchy:h.DescriptionHierarchy.PRIMARY,accessor:i=>{var e;return ov((e=i.spec)==null?void 0:e.revisionId)}}]},{id:"metadata.creationTimestamp.seconds",label:"Created",type:h.CellType.DATE},{...rc,id:"spec.content.spec.type"},{id:"spec.owner.name",label:"Owner",type:h.CellType.TEXT},{id:"spec.gitCommit.branch",label:"Branch",type:h.CellType.TEXT},{...sc,id:"spec.content.status.state"}],rv={columns:sv,actions:[]};function ov(i){return i?`Revision ${i.slice(0,nv)}`:""}const lv=[{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:h.CellType.DATE},rc,{id:"spec.commit.branch",label:"Branch",type:h.CellType.TEXT},sc],av={type:"list",tableConfig:{columns:lv},variants:[{id:"pipelines",label:"Pipelines"},{id:"revisions",label:"Revisions",service:"revision",tableConfig:rv}]};function cv({triggerMap:i}){const{input:e}=ke("sourceTriggerName"),{input:t}=ke("isBackfill"),{input:n}=ke("startTimestamp"),{input:s}=ke("endTimestamp"),r=i[e.value],o=!!t.value,l=Object.keys((r==null?void 0:r.parametersMap)??{}).map(a=>({id:a,label:a}));return h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[h.jsxRuntimeExports.jsx(Za,{name:"autoFlip",label:"Automatically switch to the latest revision once changes are applied? (Coming soon)",caption:"Coming soon — not yet available.",options:[{value:!0,label:"Yes"},{value:!1,label:"No"}],initialValue:!1,disabled:!0}),h.jsxRuntimeExports.jsx(xo,{name:"isBackfill",checkboxLabel:"Is this a backfill run?",toggle:!0}),o?h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[h.jsxRuntimeExports.jsx(Dr,{name:"startTimestamp",label:"Execution start date & time",dateFormat:vi.EPOCH_SECONDS,noFutureDate:!0,required:!0,validate:a=>s.value&&Number(a)>Number(s.value)?"Start date & time must be before end date & time.":void 0}),h.jsxRuntimeExports.jsx(Dr,{name:"endTimestamp",label:"Execution end date & time",dateFormat:vi.EPOCH_SECONDS,noFutureDate:!0,required:!0,validate:a=>n.value&&Number(a)<Number(n.value)?"End date & time must be after start date & time.":void 0}),h.jsxRuntimeExports.jsx(dt,{name:"selectedParams",label:"Parameter IDs",multi:!0,options:l,caption:"Selecting no parameters runs every parameter."}),h.jsxRuntimeExports.jsx(pn,{name:"maxConcurrencyOverride",label:"Max concurrency",initialValue:r==null?void 0:r.maxConcurrency,description:"Overrides the trigger's default max concurrency for this run only."})]}):null]})}const uv=({record:i,onClose:e})=>{var u,d,f,p;const{projectId:t}=h.useStudioParams("base"),n=((u=i==null?void 0:i.metadata)==null?void 0:u.name)??"",{data:s,isLoading:r}=h.useStudioQuery({queryName:"GetPipeline",serviceOptions:{name:n},clientOptions:{enabled:!!n}}),o=((p=(f=(d=s==null?void 0:s.pipeline)==null?void 0:d.spec)==null?void 0:f.manifest)==null?void 0:p.triggerMap)??{},l=Object.keys(o).sort().map(m=>{const g=jf(o[m]);return{id:m,label:g?`${m} — ${g}`:m}}),a=h.useStudioMutation({mutationName:"CreateTriggerRun",successOperations:[{type:"invalidate",targets:["ListTriggerRun"]}]}),c=async m=>{if(a.isPending)return;const g=o[m.sourceTriggerName];if(!g)throw new Error(`Trigger "${m.sourceTriggerName}" is no longer defined on this pipeline. Close this dialog and try again.`);await a.mutateAsync({metadata:{name:hv(g,m.isBackfill),namespace:t},spec:{pipeline:{name:n,namespace:t},trigger:fv(g,m),sourceTriggerName:m.sourceTriggerName,autoFlip:!!m.autoFlip,...pv(m)}})};return h.jsxRuntimeExports.jsxs(As,{isOpen:!0,onDismiss:e,heading:"Run trigger",onSubmit:c,submitLabel:"Run",children:[h.jsxRuntimeExports.jsx(Be,{name:"pipelineName",label:"Pipeline",initialValue:n,readOnly:!0}),h.jsxRuntimeExports.jsx(dt,{name:"sourceTriggerName",label:"Trigger",options:l,isLoading:r,required:!0,caption:!r&&l.length===0?"This pipeline declares no triggers. Add one to its manifest to run it.":"The pipeline runs on the schedule this trigger defines."}),h.jsxRuntimeExports.jsx(cv,{triggerMap:o})]})};function hv(i,e){return`${dv(i,e)}${tc({withDate:!0})}`}function dv(i,e){var t,n;return((t=i.triggerType)==null?void 0:t.case)==="batchRerun"?"batch-rerun":e?"backfill":((n=i.triggerType)==null?void 0:n.case)==="intervalSchedule"?"interval":"cron"}function fv(i,e){var n;if(!e.isBackfill)return i;const t={...i};return e.maxConcurrencyOverride!=null&&(t.maxConcurrency=e.maxConcurrencyOverride),(n=e.selectedParams)!=null&&n.length&&i.parametersMap&&(t.parametersMap=Object.fromEntries(Object.entries(i.parametersMap).filter(([s])=>{var r;return(r=e.selectedParams)==null?void 0:r.includes(s)}))),t}function pv(i){return!i.isBackfill||!i.startTimestamp||!i.endTimestamp?{}:{startTimestamp:{seconds:i.startTimestamp},endTimestamp:{seconds:i.endTimestamp}}}const mv=i=>{var t;const e=(t=i.spec)==null?void 0:t.manifest;return!!e&&Object.keys(e.triggerMap??{}).length===0},bo={id:"pipelines",name:"pipelines",service:"pipeline",state:"active",views:[av,iv],actions:[{display:{label:"Run",icon:"playerPlay"},hierarchy:st.PRIMARY,modal:{type:"custom",component:QS}},{display:{label:"Run trigger",icon:"calendarRepeat"},hierarchy:st.SECONDARY,disabled:[{condition:He(({data:i})=>mv(i)),message:"No triggers defined for this pipeline"}],modal:{type:"custom",component:uv}},{display:{label:"Delete",icon:"trashCan"},hierarchy:st.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:He(({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"},If={[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"}},gv={[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"}},Of=1024;let xv=0,Zo=class{constructor(e,t){this.from=e,this.to=t}};class ie{constructor(e={}){this.id=xv++,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=rt.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}}ie.closedBy=new ie({deserialize:i=>i.split(" ")});ie.openedBy=new ie({deserialize:i=>i.split(" ")});ie.group=new ie({deserialize:i=>i.split(" ")});ie.isolate=new ie({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});ie.contextHash=new ie({perNode:!0});ie.lookAhead=new ie({perNode:!0});ie.mounted=new ie({perNode:!0});class Nr{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[ie.mounted.id]}}const yv=Object.create(null);class rt{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):yv,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new rt(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(ie.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(ie.group),r=-1;r<(s?s.length:0);r++){let o=t[r<0?n.name:s[r]];if(o)return o}}}}rt.none=new rt("",Object.create(null),0,8);class lc{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 rt(n.name,s,n.id,n.flags):n)}return new lc(t)}}const Hs=new WeakMap,xu=new WeakMap;var Pe;(function(i){i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays"})(Pe||(Pe={}));class Te{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=Nr.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=Hs.get(this)||this.topNode,r=new Ul(s);return r.moveTo(e,t),Hs.set(this,r._tree),r}get topNode(){return new yt(this,0,0,null)}resolve(e,t=0){let n=os(Hs.get(this)||this.topNode,e,t,!1);return Hs.set(this,n),n}resolveInner(e,t=0){let n=os(xu.get(this)||this.topNode,e,t,!0);return xu.set(this,n),n}resolveStack(e,t=0){return vv(this,e,t)}iterate(e){let{enter:t,leave:n,from:s=0,to:r=this.length}=e,o=e.mode||0,l=(o&Pe.IncludeAnonymous)>0;for(let a=this.cursor(o|Pe.IncludeAnonymous);;){let c=!1;if(a.from<=r&&a.to>=s&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;c=!0}for(;c&&n&&(l||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;c=!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:uc(rt.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,s)=>new Te(this.type,t,n,s,this.propValues),e.makeTree||((t,n,s)=>new Te(rt.none,t,n,s)))}static build(e){return Ev(e)}}Te.empty=new Te(rt.none,[],[],0);class ac{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 ac(this.buffer,this.index)}}class Ri{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return rt.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&&!(Mf(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 c=r[a++]=s[l++]-n;r[a++]=s[l++]-e,o=Math.max(o,c)}return new Ri(r,o,this.set)}}function Mf(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 os(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 yt&&i.index<0?null:i.parent;if(!o)return i;i=o}let r=n?0:Pe.IgnoreOverlays;if(n)for(let o=i,l=o.parent;l;o=l,l=o.parent)o instanceof yt&&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=yu(this,e,t,n);return s.length?s[0]:null}getChildren(e,t=null,n=null){return yu(this,e,t,n)}resolve(e,t=0){return os(this,e,t,!1)}resolveInner(e,t=0){return os(this,e,t,!0)}matchContext(e){return Gl(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 yt 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,c=t>0?l.length:-1;e!=c;e+=t){let u=l[e],d=a[e]+o.from;if(Mf(s,n,d,d+u.length)){if(u instanceof Ri){if(r&Pe.ExcludeBuffers)continue;let f=u.findChild(0,u.buffer.length,t,n-d,s);if(f>-1)return new xi(new bv(o,u,e,d),null,f)}else if(r&Pe.IncludeAnonymous||!u.type.isAnonymous||cc(u)){let f;if(!(r&Pe.IgnoreMounts)&&(f=Nr.get(u))&&!f.overlay)return new yt(f.tree,d,e,o);let p=new yt(u,d,e,o);return r&Pe.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?u.children.length-1:0,t,n,s)}}}if(r&Pe.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&Pe.IgnoreOverlays)&&(s=Nr.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 yt(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 yu(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 Gl(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 bv{constructor(e,t,n,s){this.parent=e,this.buffer=t,this.index=n,this.start=s}}class xi 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 xi(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&Pe.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 xi(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 xi(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 xi(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 Te(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 yt&&t.index<0?null:t.parent,s=i.slice();return n?s[e]=n:s.splice(e,1),new Sv(s,t)}class Sv{constructor(e,t){this.heads=e,this.node=t}get next(){return Df(this.heads)}}function vv(i,e,t){let n=i.resolveInner(e,t),s=null;for(let r=n instanceof yt?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=Nr.get(r.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new yt(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[n])).push(os(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 yt)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 yt?(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&Pe.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pe.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pe.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&Pe.IncludeAnonymous||l instanceof Ri||!l.type.isAnonymous||cc(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 xi(this.buffer,t,this.stack[s]);return this.bufferNode=new xi(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 Gl(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 Gl(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 cc(i){return i.children.some(e=>e instanceof Ri||!e.type.isAnonymous||cc(e))}function Ev(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:s=Of,reused:r=[],minRepeatType:o=n.types.length}=i,l=Array.isArray(t)?new ac(t,t.length):t,a=n.types,c=0,u=0;function d(v,C,k,O,w,D){let{id:N,start:F,end:_,size:P}=l,B=u,W=c;if(P<0)if(l.next(),P==-1){let q=r[N];k.push(q),O.push(F-v);return}else if(P==-3){c=N;return}else if(P==-4){u=N;return}else throw new RangeError(`Unrecognized record size: ${P}`);let ee=a[N],ae,ne,te=F-v;if(_-F<=s&&(ne=x(l.pos-C,w))){let q=new Uint16Array(ne.size-ne.skip),R=l.pos-ne.size,I=q.length;for(;l.pos>R;)I=y(ne.start,q,I);ae=new Ri(q,_-ne.start,n),te=ne.start-v}else{let q=l.pos-P;l.next();let R=[],I=[],L=N>=o?N:-1,V=0,Q=_;for(;l.pos>q;)L>=0&&l.id==L&&l.size>=0?(l.end<=Q-s&&(m(R,I,F,V,l.end,Q,L,B,W),V=R.length,Q=l.end),l.next()):D>2500?f(F,q,R,I):d(F,q,R,I,L,D+1);if(L>=0&&V>0&&V<R.length&&m(R,I,F,V,F,Q,L,B,W),R.reverse(),I.reverse(),L>-1&&V>0){let Z=p(ee,W);ae=uc(ee,R,I,0,R.length,0,_-F,Z,Z)}else ae=g(ee,R,I,_-F,B-_,W)}k.push(ae),O.push(te)}function f(v,C,k,O){let w=[],D=0,N=-1;for(;l.pos>C;){let{id:F,start:_,end:P,size:B}=l;if(B>4)l.next();else{if(N>-1&&_<N)break;N<0&&(N=P-s),w.push(F,_,P),D++,l.next()}}if(D){let F=new Uint16Array(D*4),_=w[w.length-2];for(let P=w.length-3,B=0;P>=0;P-=3)F[B++]=w[P],F[B++]=w[P+1]-_,F[B++]=w[P+2]-_,F[B++]=B;k.push(new Ri(F,w[2]-_,n)),O.push(_-v)}}function p(v,C){return(k,O,w)=>{let D=0,N=k.length-1,F,_;if(N>=0&&(F=k[N])instanceof Te){if(!N&&F.type==v&&F.length==w)return F;(_=F.prop(ie.lookAhead))&&(D=O[N]+F.length+_)}return g(v,k,O,w,D,C)}}function m(v,C,k,O,w,D,N,F,_){let P=[],B=[];for(;v.length>O;)P.push(v.pop()),B.push(C.pop()+k-w);v.push(g(n.types[N],P,B,D-w,F-D,_)),C.push(w-k)}function g(v,C,k,O,w,D,N){if(D){let F=[ie.contextHash,D];N=N?[F].concat(N):[F]}if(w>25){let F=[ie.lookAhead,w];N=N?[F].concat(N):[F]}return new Te(v,C,k,O,N)}function x(v,C){let k=l.fork(),O=0,w=0,D=0,N=k.end-s,F={size:0,start:0,skip:0};e:for(let _=k.pos-v;k.pos>_;){let P=k.size;if(k.id==C&&P>=0){F.size=O,F.start=w,F.skip=D,D+=4,O+=4,k.next();continue}let B=k.pos-P;if(P<0||B<_||k.start<N)break;let W=k.id>=o?4:0,ee=k.start;for(k.next();k.pos>B;){if(k.size<0)if(k.size==-3)W+=4;else break e;else k.id>=o&&(W+=4);k.next()}w=ee,O+=P,D+=W}return(C<0||O==v)&&(F.size=O,F.start=w,F.skip=D),F.size>4?F:void 0}function y(v,C,k){let{id:O,start:w,end:D,size:N}=l;if(l.next(),N>=0&&O<o){let F=k;if(N>4){let _=l.pos-(N-4);for(;l.pos>_;)k=y(v,C,k)}C[--k]=F,C[--k]=D-v,C[--k]=w-v,C[--k]=O}else N==-3?c=O:N==-4&&(u=O);return k}let b=[],S=[];for(;l.pos>0;)d(i.start||0,i.bufferStart||0,b,S,-1,0);let E=(e=i.length)!==null&&e!==void 0?e:b.length?S[0]+b[0].length:0;return new Te(a[i.topID],b.reverse(),S.reverse(),E)}const bu=new WeakMap;function gr(i,e){if(!i.isAnonymous||e instanceof Ri||e.type!=i)return 1;let t=bu.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof Te)){t=1;break}t+=gr(i,n)}bu.set(e,t)}return t}function uc(i,e,t,n,s,r,o,l,a){let c=0;for(let m=n;m<s;m++)c+=gr(i,e[m]);let u=Math.ceil(c*1.5/8),d=[],f=[];function p(m,g,x,y,b){for(let S=x;S<y;){let E=S,v=g[S],C=gr(i,m[S]);for(S++;S<y;S++){let k=gr(i,m[S]);if(C+k>=u)break;C+=k}if(S==E+1){if(C>u){let k=m[E];p(k.children,k.positions,0,k.children.length,g[E]+b);continue}d.push(m[E])}else{let k=g[S-1]+m[S-1].length-v;d.push(uc(i,m,g,E,S,v,k,null,a))}f.push(v+b-r)}}return p(e,t,n,s,0),(l||a)(d,f,o)}class Hi{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 Hi(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,c=0;;l++){let u=l<t.length?t[l]:null,d=u?u.fromA:1e9;if(d-a>=n)for(;o&&o.from<d;){let f=o;if(a>=f.from||d<=f.to||c){let p=Math.max(f.from,a)-c,m=Math.min(f.to,d)-c;f=p>=m?null:new Hi(p,m,f.tree,f.offset+c,l>0,!!u)}if(f&&s.push(f),o.to>d)break;o=r<e.length?e[r++]:null}if(!u)break;a=u.toA,c=u.toA-u.toB}return s}}class Lf{startParse(e,t,n){return typeof e=="string"&&(e=new Cv(e)),n=n?n.length?n.map(s=>new Zo(s.from,s.to)):[new Zo(0,0)]:[new Zo(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 Cv{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 ie({perNode:!0});class Fr{constructor(e,t,n,s,r,o,l,a,c,u=0,d){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=c,this.lookAhead=u,this.parent=d}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 Su(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),c=a?this.stack[a-2]:this.p.ranges[0].from,u=this.reducePos-c;u>=2e3&&!(!((t=this.p.parser.nodeSet.types[s])===null||t===void 0)&&t.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=u));let d=a?this.stack[a-1]:0,f=this.bufferBase+this.buffer.length-d;if(s<r.minRepeatTerm||e&131072){let p=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,c,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,c)}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 Rv(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,c=this.stack.length-l*3;if(c>=0&&e.getGoto(this.stack[c],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 Su(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 Su{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class Rv{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 Br{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 Br(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 Br(this.stack,this.pos,this.index)}}function Gs(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 xr{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const vu=new xr;class wv{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=vu,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=vu,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 mn{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;kv(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}mn.prototype.contextual=mn.prototype.fallback=mn.prototype.extend=!1;mn.prototype.fallback=mn.prototype.extend=!1;function kv(i,e,t,n,s,r){let o=0,l=1<<n,{dialect:a}=t.p.parser;e:for(;(l&i[o])!=0;){let c=i[o+1];for(let p=o+3;p<c;p+=2)if((i[p+1]&l)>0){let m=i[p];if(a.allows(m)&&(e.token.value==-1||e.token.value==m||Tv(m,e.token.value,s,r))){e.acceptToken(m);break}}let u=e.next,d=0,f=i[o+2];if(e.next<0&&f>d&&i[c+f*3-3]==65535){o=i[c+f*3-1];continue e}for(;d<f;){let p=d+f>>1,m=c+p+(p<<1),g=i[m],x=i[m+1]||65536;if(u<g)f=p;else if(u>=x)d=p+1;else{o=i[m+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 Tv(i,e,t,n){let s=Eu(t,n,e);return s<0||Eu(t,n,i)<s}const ot=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG);let el=null;function Cu(i,e,t){let n=i.cursor(Pe.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 Av{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?Cu(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Cu(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 Te){if(o==e){if(o<this.safeFrom)return null;let l=o+r.length;if(l<=this.safeTo){let a=r.prop(ie.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 jv{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new xr)}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 c=0;c<r.length;c++){if((1<<c&o)==0)continue;let u=r[c],d=this.tokens[c];if(!(n&&!u.fallback)&&((u.contextual||d.start!=e.pos||d.mask!=o||d.context!=l)&&(this.updateCachedToken(d,u,e),d.mask=o,d.context=l),d.lookAhead>d.end+25&&(a=Math.max(d.lookAhead,a)),d.value!=0)){let f=t;if(d.extended>-1&&(t=this.addActions(e,d.extended,d.end,t)),t=this.addActions(e,d.value,d.end,t),!u.extend&&(n=d,t>f))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!n&&e.pos==this.stream.end&&(n=new xr,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 xr,{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 c=o.stateSlot(r,a?2:1);;c+=3){if(l[c]==65535)if(l[c+1]==1)c=Zt(l,c+2);else{s==0&&l[c+1]==2&&(s=this.putAction(Zt(l,c+2),t,n,s));break}l[c]==t&&(s=this.putAction(Zt(l,c+1),t,n,s))}return s}}class Iv{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 wv(t,s),this.tokens=new jv(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 Av(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&&Mv(s);if(o)return ot&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw ot&&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 ot&&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 c=n[a];if(l.sameState(c)||l.buffer.length>500&&c.buffer.length>500)if((l.score-c.score||l.buffer.length-c.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=ot?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let d=this.fragments.nodeAt(s);d;){let f=this.parser.nodeSet.types[d.type.id]==d.type?r.getGoto(e.state,d.type.id):-1;if(f>-1&&d.length&&(!c||(d.prop(ie.contextHash)||0)==u))return e.useNode(d,f),ot&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(d.type.id)})`),!0;if(!(d instanceof Te)||d.children.length==0||d.positions[0]>0)break;let p=d.children[0];if(p instanceof Te&&d.positions[0]==0)d=p;else break}}let l=r.stateSlot(e.state,4);if(l>0)return e.reduce(l),ot&&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 c=0;c<a.length;){let u=a[c++],d=a[c++],f=a[c++],p=c==a.length||!n,m=p?e:e.split(),g=this.tokens.mainToken;if(m.apply(u,d,g?g.start:m.pos,f),ot&&console.log(o+this.stackID(m)+` (via ${(u&65536)==0?"shift":`reduce of ${r.getName(u&65535)}`} for ${r.getName(d)} @ ${s}${m==e?"":", split"})`),p)return!0;m.pos>s?t.push(m):n.push(m)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return Ru(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],c=t[(o<<1)+1],u=ot?this.stackID(l)+" -> ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),ot&&console.log(u+this.stackID(l)+" (restarted)"),this.advanceFully(l,n))))continue;let d=l.split(),f=u;for(let p=0;p<10&&d.forceReduce()&&(ot&&console.log(f+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,n));p++)ot&&(f=this.stackID(d)+" -> ");for(let p of l.recoverByInsert(a))ot&&console.log(u+this.stackID(p)+" (via recover-insert)"),this.advanceFully(p,n);this.stream.end>l.pos?(c==l.pos&&(c++,a=0),l.recoverByDelete(a,c),ot&&console.log(u+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),Ru(l,n)):(!s||s.score<l.score)&&(s=l)}return s}stackToTree(e){return e.close(),Te.build({buffer:Br.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=(el||(el=new WeakMap)).get(e);return t||el.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function Ru(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 Ov{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}}class Vr 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,c){s[l].push([a,a.deserialize(String(c))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=ie[a]);for(let c=1;c<l.length;){let u=l[c++];if(u>=0)r(u,a,l[c++]);else{let d=l[c+-u];for(let f=-u;f>0;f--)r(l[c++],a,d);c++}}}this.nodeSet=new lc(t.map((l,a)=>rt.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=Gs(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(wu),this.states=Gs(e.states,Uint32Array),this.data=Gs(e.stateData),this.goto=Gs(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new mn(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 Iv(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 c=r+(o>>1);r<c;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=Zt(n,r+2)];else{if(n[r+1]==2)return Zt(n,r+2);break}if(o==t||o==0)return Zt(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=Zt(this.data,r+2);else break;s=t(Zt(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=Zt(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(Vr.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]=wu(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 Ov(e,n,s)}static deserialize(e){return new Vr(e)}}function Zt(i,e){return i[e]|i[e+1]<<16}function Mv(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 wu(i){if(i.external){let e=i.extend?1:0;return(t,n)=>i.external(t,n)<<1|e}return i.get}let Pv=0;class mt{constructor(e,t,n,s){this.name=e,this.set=t,this.base=n,this.modified=s,this.id=Pv++}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 mt&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let s=new mt(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 _r(e);return n=>n.modified.indexOf(t)>-1?n:_r.get(n.base||n,n.modified.concat(t).sort((s,r)=>s.id-r.id))}}let Dv=0;class _r{constructor(e){this.name=e,this.instances=[],this.id=Dv++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(l=>l.base==e&&Lv(t,l.modified));if(n)return n;let s=[],r=new mt(e.name,s,e,t);for(let l of t)l.instances.push(r);let o=Nv(t);for(let l of e.set)if(!l.modified.length)for(let a of o)s.push(_r.get(l,a));return r}}function Lv(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function Nv(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 Nf(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 d=0;;){if(l=="..."&&d>0&&d+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]),d+=f[0].length,d==s.length)break;let p=s[d++];if(d==s.length&&p=="!"){o=0;break}if(p!="/")throw new RangeError("Invalid path: "+s);l=s.slice(d)}let a=r.length-1,c=r[a];if(!c)throw new RangeError("Invalid path: "+s);let u=new ls(n,o,a>0?r.slice(0,a):null);e[c]=u.sort(e[c])}}return Ff.add(e)}const Ff=new ie({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 ls(s.tags,s.mode,s.context);t?t.next=r:n=r,t=r}return n}});class ls{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}}ls.empty=new ls([],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 c=t[a.id];if(c){o=o?o+" "+c:c;break}}return o},scope:n}}function Fv(i,e){let t=null;for(let n of i){let s=n.style(e);s&&(t=t?t+" "+s:s)}return t}function Bv(i,e,t,n=0,s=i.length){let r=new Vv(n,Array.isArray(e)?e:[e],t);r.highlightRange(i.cursor(),n,s,"",r.highlighters),r.flush(s)}class Vv{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 c=s,u=_v(e)||ls.empty,d=Fv(r,u.tags);if(d&&(c&&(c+=" "),c+=d,u.mode==1&&(s+=(s?" ":"")+d)),this.startSpan(Math.max(t,l),c),u.opaque)return;let f=e.tree&&e.tree.prop(ie.mounted);if(f&&f.overlay){let p=e.node.enter(f.overlay[0].from+l,1),m=this.highlighters.filter(x=>!x.scope||x.scope(f.tree.type)),g=e.firstChild();for(let x=0,y=l;;x++){let b=x<f.overlay.length?f.overlay[x]:null,S=b?b.from+l:a,E=Math.max(t,y),v=Math.min(n,S);if(E<v&&g)for(;e.from<v&&(this.highlightRange(e,E,v,s,r),this.startSpan(Math.min(v,e.to),c),!(e.to>=S||!e.nextSibling())););if(!b||S>n)break;y=b.to+l,y>t&&(this.highlightRange(p.cursor(),Math.max(t,b.from+l),Math.min(n,y),"",m),this.startSpan(Math.min(n,y),c))}g&&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),c)}while(e.nextSibling());e.parent()}}}function _v(i){let e=i.type.prop(Ff);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}const $=mt.define,Us=$(),fi=$(),ku=$(fi),Tu=$(fi),pi=$(),Ws=$(pi),tl=$(pi),Lt=$(),Di=$(Lt),Ot=$(),Mt=$(),Wl=$(),Fn=$(Wl),qs=$(),T={comment:Us,lineComment:$(Us),blockComment:$(Us),docComment:$(Us),name:fi,variableName:$(fi),typeName:ku,tagName:$(ku),propertyName:Tu,attributeName:$(Tu),className:$(fi),labelName:$(fi),namespace:$(fi),macroName:$(fi),literal:pi,string:Ws,docString:$(Ws),character:$(Ws),attributeValue:$(Ws),number:tl,integer:$(tl),float:$(tl),bool:$(pi),regexp:$(pi),escape:$(pi),color:$(pi),url:$(pi),keyword:Ot,self:$(Ot),null:$(Ot),atom:$(Ot),unit:$(Ot),modifier:$(Ot),operatorKeyword:$(Ot),controlKeyword:$(Ot),definitionKeyword:$(Ot),moduleKeyword:$(Ot),operator:Mt,derefOperator:$(Mt),arithmeticOperator:$(Mt),logicOperator:$(Mt),bitwiseOperator:$(Mt),compareOperator:$(Mt),updateOperator:$(Mt),definitionOperator:$(Mt),typeOperator:$(Mt),controlOperator:$(Mt),punctuation:Wl,separator:$(Wl),bracket:Fn,angleBracket:$(Fn),squareBracket:$(Fn),paren:$(Fn),brace:$(Fn),content:Lt,heading:Di,heading1:$(Di),heading2:$(Di),heading3:$(Di),heading4:$(Di),heading5:$(Di),heading6:$(Di),contentSeparator:$(Lt),list:$(Lt),quote:$(Lt),emphasis:$(Lt),strong:$(Lt),link:$(Lt),monospace:$(Lt),strikethrough:$(Lt),inserted:$(),deleted:$(),changed:$(),invalid:$(),meta:qs,documentMeta:$(qs),annotation:$(qs),processingInstruction:$(qs),definition:mt.defineModifier("definition"),constant:mt.defineModifier("constant"),function:mt.defineModifier("function"),standard:mt.defineModifier("standard"),local:mt.defineModifier("local"),special:mt.defineModifier("special")};for(let i in T){let e=T[i];e instanceof mt&&(e.name=i)}Bf([{tag:T.link,class:"tok-link"},{tag:T.heading,class:"tok-heading"},{tag:T.emphasis,class:"tok-emphasis"},{tag:T.strong,class:"tok-strong"},{tag:T.keyword,class:"tok-keyword"},{tag:T.atom,class:"tok-atom"},{tag:T.bool,class:"tok-bool"},{tag:T.url,class:"tok-url"},{tag:T.labelName,class:"tok-labelName"},{tag:T.inserted,class:"tok-inserted"},{tag:T.deleted,class:"tok-deleted"},{tag:T.literal,class:"tok-literal"},{tag:T.string,class:"tok-string"},{tag:T.number,class:"tok-number"},{tag:[T.regexp,T.escape,T.special(T.string)],class:"tok-string2"},{tag:T.variableName,class:"tok-variableName"},{tag:T.local(T.variableName),class:"tok-variableName tok-local"},{tag:T.definition(T.variableName),class:"tok-variableName tok-definition"},{tag:T.special(T.variableName),class:"tok-variableName2"},{tag:T.definition(T.propertyName),class:"tok-propertyName tok-definition"},{tag:T.typeName,class:"tok-typeName"},{tag:T.namespace,class:"tok-namespace"},{tag:T.className,class:"tok-className"},{tag:T.macroName,class:"tok-macroName"},{tag:T.propertyName,class:"tok-propertyName"},{tag:T.operator,class:"tok-operator"},{tag:T.comment,class:"tok-comment"},{tag:T.meta,class:"tok-meta"},{tag:T.invalid,class:"tok-invalid"},{tag:T.punctuation,class:"tok-punctuation"}]);const $v=Nf({String:T.string,Number:T.number,"True False":T.bool,PropertyName:T.propertyName,Null:T.null,", :":T.separator,"[ ]":T.squareBracket,"{ }":T.brace}),zv=Vr.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:[$v],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 ql=[],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:ql).push(t=t+i[e])})();function Hv(i){if(i<768)return!1;for(let e=0,t=ql.length;;){let n=e+t>>1;if(i<ql[n])t=n;else if(i>=Vf[n])e=n+1;else return!0;if(e==t)return!1}}function Au(i){return i>=127462&&i<=127487}const ju=8205;function Gv(i,e,t=!0,n=!0){return(t?_f:Uv)(i,e,n)}function _f(i,e,t){if(e==i.length)return e;e&&$f(i.charCodeAt(e))&&zf(i.charCodeAt(e-1))&&e--;let n=il(i,e);for(e+=Iu(n);e<i.length;){let s=il(i,e);if(n==ju||s==ju||t&&Hv(s))e+=Iu(s),n=s;else if(Au(s)){let r=0,o=e-2;for(;o>=0&&Au(il(i,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function Uv(i,e,t){for(;e>0;){let n=_f(i,e-2,t);if(n<e)return n;e--}return 0}function il(i,e){let t=i.charCodeAt(e);if(!zf(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 zf(i){return i>=55296&&i<56320}function Iu(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]=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),Ft.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),Ft.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 Yn(this),r=new Yn(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 Yn(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]?oe.empty:e.length<=32?new Ee(e):Ft.from(Ee.split(e,[]))}}class Ee extends oe{constructor(e,t=Wv(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 qv(s,l,n,o);s=l+1,n++}}decompose(e,t,n,s){let r=e<=0&&t>=this.length?this:new Ee(Ou(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=n.pop(),l=yr(r.text,o.text.slice(),0,r.length);if(l.length<=32)n.push(new Ee(l,o.length+r.length));else{let a=l.length>>1;n.push(new Ee(l.slice(0,a)),new Ee(l.slice(a)))}}else n.push(r)}replace(e,t,n){if(!(n instanceof Ee))return super.replace(e,t,n);[e,t]=Cn(this,e,t);let s=yr(this.text,yr(n.text,Ou(this.text,0,e)),t),r=this.length+n.length-(t-e);return s.length<=32?new Ee(s,r):Ft.from(Ee.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 Ee(n,s)),n=[],s=-1);return s>-1&&t.push(new Ee(n,s)),t}}class Ft 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 c=s&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!c?n.push(l):l.decompose(e-o,t-o,n,c)}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),c=this.lines-o.lines+a.lines;if(a.lines<c>>4&&a.lines>c>>6){let u=this.children.slice();return u[s]=a,new Ft(u,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 Ft))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],c=e.children[r];if(a!=c)return n+a.scanIdentical(c,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 m of e)m.flatten(p);return new Ee(p,t)}let s=Math.max(32,n>>5),r=s<<1,o=s>>1,l=[],a=0,c=-1,u=[];function d(p){let m;if(p.lines>r&&p instanceof Ft)for(let g of p.children)d(g);else p.lines>o&&(a>o||!a)?(f(),l.push(p)):p instanceof Ee&&a&&(m=u[u.length-1])instanceof Ee&&p.lines+m.lines<=32?(a+=p.lines,c+=p.length+1,u[u.length-1]=new Ee(m.text.concat(p.text),m.length+1+p.length)):(a+p.lines>s&&f(),a+=p.lines,c+=p.length+1,u.push(p))}function f(){a!=0&&(l.push(u.length==1?u[0]:Ft.from(u,c)),c=-1,a=u.length=0)}for(let p of e)d(p);return f(),l.length==1?l[0]:new Ft(l,t)}}oe.empty=new Ee([""],0);function Wv(i){let e=-1;for(let t of i)e+=t.length+1;return e}function yr(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 Ou(i,e,t){return yr(i,[""],e,t)}class Yn{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 Ee?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 Ee?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 Ee){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 Ee?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 Yn(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"&&(oe.prototype[Symbol.iterator]=function(){return this.iter()},Yn.prototype[Symbol.iterator]=Hf.prototype[Symbol.iterator]=Gf.prototype[Symbol.iterator]=function(){return this});class qv{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 Gv(i,e,t,n)}function Kv(i){return i>=56320&&i<57344}function Yv(i){return i>=55296&&i<56320}function et(i,e){let t=i.charCodeAt(e);if(!Yv(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return Kv(n)?(t-55296<<10)+(n-56320)+65536:t}function hc(i){return i<=65535?String.fromCharCode(i):(i-=65536,String.fromCharCode((i>>10)+55296,(i&1023)+56320))}function Bt(i){return i<65536?1:2}const Kl=/\r\n?|\n/;var Xe=(function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i})(Xe||(Xe={}));class Ht{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){Yl(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 Ht(e)}composeDesc(e){return this.empty?e:e.empty?this:Uf(this,e)}mapDesc(e,t=!1){return e.empty?this:Xl(this,e,t)}mapPos(e,t=-1,n=Xe.Simple){let s=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],c=s+l;if(a<0){if(c>e)return r+(e-s);r+=l}else{if(n!=Xe.Simple&&c>=e&&(n==Xe.TrackDel&&s<e&&c>e||n==Xe.TrackBefore&&s<e||n==Xe.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=c}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 Ht(e)}static create(e){return new Ht(e)}}class je extends Ht{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 Yl(this,(t,n,s,r,o)=>e=e.replace(s,s+(n-t),o),!1),e}mapDesc(e,t=!1){return Xl(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 je(t,n)}compose(e){return this.empty?e:e.empty?this:Uf(this,e,!0)}map(e,t=!1){return e.empty?this:Xl(this,e,t,!0)}iterChanges(e,t=!1){Yl(this,e,t)}get desc(){return Ht.create(this.sections)}filter(e){let t=[],n=[],s=[],r=new as(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 u=Math.min(r.len,a-l);ze(s,u,-1);let d=r.ins==-1?-1:r.off==0?r.ins:0;ze(t,u,d),d>0&&yi(n,t,r.text),r.forward(u),l+=u}let c=e[o++];for(;l<c;){if(r.done)break e;let u=Math.min(r.len,c-l);ze(t,u,-1),ze(s,u,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(u),l+=u}}return{changes:new je(t,n),filtered:Ht.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(u=!1){if(!u&&!s.length)return;o<t&&ze(s,t-o,-1);let d=new je(s,r);l=l?l.compose(d.map(l)):d,s=[],r=[],o=0}function c(u){if(Array.isArray(u))for(let d of u)c(d);else if(u instanceof je){if(u.length!=t)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${t})`);a(),l=l?l.compose(u.map(l)):u}else{let{from:d,to:f=d,insert:p}=u;if(d>f||d<0||f>t)throw new RangeError(`Invalid change range ${d} to ${f} (in doc of length ${t})`);let m=p?typeof p=="string"?oe.of(p.split(n||Kl)):p:oe.empty,g=m.length;if(d==f&&g==0)return;d<o&&a(),d>o&&ze(s,d-o,-1),ze(s,f-d,g),yi(r,s,m),o=f}}return c(e),a(!l),l}static empty(e){return new je(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 je(t,n)}static createSet(e,t){return new je(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 yi(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 Yl(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 c=s,u=r,d=oe.empty;for(;c+=l,u+=a,a&&n&&(d=d.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,c,r,u,d),s=c,r=u}}}function Xl(i,e,t,n=!1){let s=[],r=n?[]:null,o=new as(i),l=new as(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 c=Math.min(o.len,l.len);ze(s,c,-1),o.forward(c),l.forward(c)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let c=l.len;for(ze(s,l.ins,-1);c;){let u=Math.min(o.len,c);o.ins>=0&&a<o.i&&o.len<=u&&(ze(s,0,o.ins),r&&yi(r,s,o.text),a=o.i),o.forward(u),c-=u}l.next()}else if(o.ins>=0){let c=0,u=o.len;for(;u;)if(l.ins==-1){let d=Math.min(u,l.len);c+=d,u-=d,l.forward(d)}else if(l.ins==0&&l.len<u)u-=l.len,l.next();else break;ze(s,c,a<o.i?o.ins:0),r&&a<o.i&&yi(r,s,o.text),a=o.i,o.forward(o.len-u)}else{if(o.done&&l.done)return r?je.createSet(s,r):Ht.create(s);throw new Error("Mismatched change set lengths")}}}function Uf(i,e,t=!1){let n=[],s=t?[]:null,r=new as(i),o=new as(e);for(let l=!1;;){if(r.done&&o.done)return s?je.createSet(n,s):Ht.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&&yi(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),c=n.length;if(r.ins==-1){let u=o.ins==-1?-1:o.off?0:o.ins;ze(n,a,u,l),s&&u&&yi(s,n,o.text)}else o.ins==-1?(ze(n,r.off?0:r.len,a,l),s&&yi(s,n,r.textBit(a))):(ze(n,r.off?0:r.len,o.off?0:o.ins,l),s&&!o.off&&yi(s,n,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||n.length>c),r.forward2(a),o.forward(a)}}}}class as{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 _i{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 _i(n,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return j.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return j.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 j.range(e.anchor,e.head)}static create(e,t,n){return new _i(e,t,n)}}class j{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:j.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 j([this.main],0)}addRange(e,t=!0){return j.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,j.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 j(e.ranges.map(t=>_i.fromJSON(t)),e.main)}static single(e,t=e){return new j([j.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 j.normalized(e.slice(),t);n=r.to}return new j(e,t)}static cursor(e,t=0,n,s){return _i.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?_i.create(t,e,48|r):_i.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?j.range(a,l):j.range(l,a))}}return new j(e,t)}}function Wf(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let dc=0;class G{constructor(e,t,n,s,r){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=s,this.id=dc++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new G(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:fc),!!e.static,e.enables)}of(e){return new br([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new br(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new br(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}}function fc(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}class br{constructor(e,t,n,s){this.dependencies=e,this.facet=t,this.type=n,this.value=s,this.id=dc++}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,c=!1,u=[];for(let d of this.dependencies)d=="doc"?a=!0:d=="selection"?c=!0:(((t=e[d.id])!==null&&t!==void 0?t:1)&1)==0&&u.push(e[d.id]);return{create(d){return d.values[o]=n(d),1},update(d,f){if(a&&f.docChanged||c&&(f.docChanged||f.selection)||Ql(d,u)){let p=n(d);if(l?!Mu(p,d.values[o],s):!s(p,d.values[o]))return d.values[o]=p,1}return 0},reconfigure:(d,f)=>{let p,m=f.config.address[r];if(m!=null){let g=zr(f,m);if(this.dependencies.every(x=>x instanceof G?f.facet(x)===d.facet(x):x instanceof Ve?f.field(x,!1)==d.field(x,!1):!0)||(l?Mu(p=n(d),g,s):s(p=n(d),g)))return d.values[o]=g,0}else p=n(d);return d.values[o]=p,1}}}}function Mu(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 Ql(i,e){let t=!1;for(let n of e)Xn(i,n)&1&&(t=!0);return t}function Xv(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 c=[];for(let u=0;u<n.length;u++){let d=zr(a,n[u]);if(s[u]==2)for(let f of d)c.push(f);else c.push(d)}return e.combine(c)}return{create(a){for(let c of n)Xn(a,c);return a.values[o]=l(a),1},update(a,c){if(!Ql(a,r))return 0;let u=l(a);return e.compare(u,a.values[o])?0:(a.values[o]=u,1)},reconfigure(a,c){let u=Ql(a,n),d=c.config.facets[e.id],f=c.facet(e);if(d&&!u&&fc(t,d))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 Ks=G.define({static:!0});class Ve{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 Ve(dc++,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(Ks).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(Ks),o=s.facet(Ks),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,Ks.of({field:this,create:e})]}get extension(){return this}}const Ni={lowest:4,low:3,default:2,high:1,highest:0};function Bn(i){return e=>new qf(e,i)}const Qi={highest:Bn(Ni.highest),high:Bn(Ni.high),default:Bn(Ni.default),low:Bn(Ni.low),lowest:Bn(Ni.lowest)};class qf{constructor(e,t){this.inner=e,this.prec=t}}class So{of(e){return new Jl(this,e)}reconfigure(e){return So.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Jl{constructor(e,t){this.compartment=e,this.inner=t}}class $r{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 Qv(e,t,o))f instanceof Ve?s.push(f):(r[f.facet.id]||(r[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],c=[];for(let f of s)l[f.id]=c.length<<1,c.push(p=>f.slot(p));let u=n==null?void 0:n.config.facets;for(let f in r){let p=r[f],m=p[0].facet,g=u&&u[f]||[];if(p.every(x=>x.type==0))if(l[m.id]=a.length<<1|1,fc(g,p))a.push(n.facet(m));else{let x=m.combine(p.map(y=>y.value));a.push(n&&m.compare(x,n.facet(m))?n.facet(m):x)}else{for(let x of p)x.type==0?(l[x.id]=a.length<<1|1,a.push(x.value)):(l[x.id]=c.length<<1,c.push(y=>x.dynamicSlot(y)));l[m.id]=c.length<<1,c.push(x=>Xv(x,m,p))}}let d=c.map(f=>f(l));return new $r(e,o,d,l,a,r)}}function Qv(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 c=n[a].indexOf(o);c>-1&&n[a].splice(c,1),o instanceof Jl&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let c of o)r(c,l);else if(o instanceof Jl){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;t.set(o.compartment,c),r(c,l)}else if(o instanceof qf)r(o.inner,o.prec);else if(o instanceof Ve)n[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof br)n[l].push(o),o.facet.extensions&&r(o.facet.extensions,Ni.default);else{let c=o.extension;if(!c)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(c,l)}}return r(i,Ni.default),n.reduce((o,l)=>o.concat(l))}function Xn(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 zr(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}const Kf=G.define(),Zl=G.define({combine:i=>i.some(e=>e),static:!0}),Yf=G.define({combine:i=>i.length?i[0]:void 0,static:!0}),Xf=G.define(),Qf=G.define(),Jf=G.define(),Zf=G.define({combine:i=>i.length?i[0]:!1});class Kt{constructor(e,t){this.type=e,this.value=t}static define(){return new Jv}}class Jv{of(e){return new Kt(this,e)}}class Zv{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 Zv(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 Ie{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&&Wf(n,t.newLength),r.some(l=>l.type==Ie.time)||(this.annotations=r.concat(Ie.time.of(Date.now())))}static create(e,t,n,s,r,o){return new Ie(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(Ie.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Ie.time=Kt.define();Ie.userEvent=Kt.define();Ie.addToHistory=Kt.define();Ie.remote=Kt.define();function eE(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 ep(i,e,t){var n;let s,r,o;return t?(s=e.changes,r=je.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 ea(i,e,t){let n=e.selection,s=gn(e.annotations);return e.userEvent&&(s=s.concat(Ie.userEvent.of(e.userEvent))),{changes:e.changes instanceof je?e.changes:je.of(e.changes||[],t,i.facet(Yf)),selection:n&&(n instanceof j?n:j.single(n.anchor,n.head)),effects:gn(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function tp(i,e,t){let n=ea(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=ep(n,ea(i,e[r],o?n.changes.newLength:i.doc.length),o)}let s=Ie.create(i,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return iE(t?tE(s):s)}function tE(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:eE(t,r))}if(t!==!0){let s,r;if(t===!1)r=i.changes.invertedDesc,s=je.empty(e.doc.length);else{let o=i.changes.filter(t);s=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}i=Ie.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 Ie?i=r:Array.isArray(r)&&r.length==1&&r[0]instanceof Ie?i=r[0]:i=tp(e,gn(r),!1)}return i}function iE(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=ep(n,ea(e,r,i.changes.newLength),!0))}return n==i?i:Ie.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}const nE=[];function gn(i){return i==null?nE:Array.isArray(i)?i:[i]}var Se=(function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i})(Se||(Se={}));const sE=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ta;try{ta=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function rE(i){if(ta)return ta.test(i);for(let e=0;e<i.length;e++){let t=i[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||sE.test(t)))return!0}return!1}function oE(i){return e=>{if(!/\S/.test(e))return Se.Space;if(rE(e))return Se.Word;for(let t=0;t<i.length;t++)if(e.indexOf(i[t])>-1)return Se.Word;return Se.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++)Xn(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 Xn(this,n),zr(this,n)}update(...e){return tp(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:s}=t;for(let l of e.effects)l.is(So.reconfigure)?(t&&(s=new Map,t.compartments.forEach((a,c)=>s.set(c,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=gn(n).concat(l.value));let r;t?r=e.startState.values.slice():(t=$r.resolve(n,s,this),r=new se(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,c)=>c.reconfigure(a,this),null).values);let o=e.startState.facet(Zl)?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:j.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=gn(n.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),c=this.changes(a.changes),u=c.map(s);for(let f=0;f<l;f++)r[f]=r[f].map(u);let d=s.mapDesc(c,!0);r.push(a.range.map(d)),s=s.compose(u),o=J.mapEffects(o,u).concat(J.mapEffects(gn(a.effects),d))}return{changes:s,selection:j.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof je?e:je.of(e,this.doc.length,this.facet(se.lineSeparator))}toText(e){return oe.of(e.split(this.facet(se.lineSeparator)||Kl))}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:(Xn(this,t),zr(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 Ve&&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:j.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=$r.resolve(e.extensions||[],new Map),n=e.doc instanceof oe?e.doc:oe.of((e.doc||"").split(t.staticFacet(se.lineSeparator)||Kl)),s=e.selection?e.selection instanceof j?e.selection:j.single(e.selection.anchor,e.selection.head):j.single(0);return Wf(s,n.length),t.staticFacet(Zl)||(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(Zf)}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(Kf))for(let o of r(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){return oE(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))!=Se.Word)break;o=a}for(;l<s;){let a=Fe(t,l);if(r(t.slice(l,a))!=Se.Word)break;l=a}return o==l?null:j.range(o+n,l+n)}}se.allowMultipleSelections=Zl;se.tabSize=G.define({combine:i=>i.length?i[0]:4});se.lineSeparator=Yf;se.readOnly=Zf;se.phrases=G.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=Kf;se.changeFilter=Xf;se.transactionFilter=Qf;se.transactionExtender=Jf;So.reconfigure=J.define();function Yt(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 Ui{eq(e){return this==e}range(e,t=e){return cs.create(e,t,this)}}Ui.prototype.startSide=Ui.prototype.endSide=0;Ui.prototype.point=!1;Ui.prototype.mapMode=Xe.TrackDel;class cs{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new cs(e,t,n)}}function ia(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}class pc{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,c=r[a]-e||(n?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return c>=0?o:l;c>=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 c=this.value[a],u=this.from[a]+e,d=this.to[a]+e,f,p;if(u==d){let m=t.mapPos(u,c.startSide,c.mapMode);if(m==null||(f=p=m,c.startSide!=c.endSide&&(p=t.mapPos(u,c.endSide),p<f)))continue}else if(f=t.mapPos(u,c.startSide),p=t.mapPos(d,c.endSide),f>p||f==p&&c.startSide>0&&c.endSide<=0)continue;(p-f||c.endSide-c.startSide)<0||(o<0&&(o=f),c.point&&(l=Math.max(l,p-f)),n.push(c),s.push(f-o),r.push(p-o))}return{mapped:n.length?new pc(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(ia)),this.isEmpty)return t.length?re.of(t):this;let l=new ip(this,null,-1).goto(0),a=0,c=[],u=new ri;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let d=t[a++];u.addInner(d.from,d.to,d.value)||c.push(d)}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])&&u.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))&&(u.addInner(l.from,l.to,l.value)||c.push(cs.create(l.from,l.to,l.value))),l.next());return u.finishInner(this.nextLayer.isEmpty&&!c.length?re.empty:this.nextLayer.update({add:c,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],c=e.touchesRange(l,l+a.length);if(c===!1)s=Math.max(s,a.maxPoint),t.push(a),n.push(e.mapPos(l));else if(c===!0){let{mapped:u,pos:d}=a.map(l,e);u&&(s=Math.max(s,u.maxPoint),t.push(u),n.push(d))}}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 us.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return us.from(e).goto(t)}static compare(e,t,n,s,r=-1){let o=e.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=r),l=t.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=r),a=Pu(o,l,n),c=new Vn(o,a,r),u=new Vn(l,a,r);n.iterGaps((d,f,p)=>Du(c,d,u,f,p,s)),n.empty&&n.length==0&&Du(c,0,u,0,0,s)}static eq(e,t,n=0,s){s==null&&(s=999999999);let r=e.filter(u=>!u.isEmpty&&t.indexOf(u)<0),o=t.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=Pu(r,o),a=new Vn(r,l,0).goto(n),c=new Vn(o,l,0).goto(n);for(;;){if(a.to!=c.to||!na(a.active,c.active)||a.point&&(!c.point||!a.point.eq(c.point)))return!1;if(a.to>s)return!0;a.next(),c.next()}}static spans(e,t,n,s,r=-1){let o=new Vn(e,null,r).goto(t),l=t,a=o.openStart;for(;;){let c=Math.min(o.to,n);if(o.point){let u=o.activeForPoint(o.to),d=o.pointFrom<t?u.length+1:o.point.startSide<0?u.length:Math.min(u.length,a);s.point(l,c,o.point,u,d,o.pointRank),a=Math.min(o.openEnd(c),u.length)}else c>l&&(s.span(l,c,o.active,a),a=o.openEnd(c));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 ri;for(let s of e instanceof cs?[e]:t?lE(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 lE(i){if(i.length>1)for(let e=i[0],t=1;t<i.length;t++){let n=i[t];if(ia(e,n)>0)return i.slice().sort(ia);e=n}return i}re.empty.nextLayer=re.empty;class ri{finishChunk(e){this.chunks.push(new pc(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 ri)).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 Pu(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 ip{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 us{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 ip(o,t,n,r));return s.length==1?s[0]:new us(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--)nl(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--)nl(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(),nl(this.heap,0)}}}function nl(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 Vn{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=us.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){Ys(this.active,e),Ys(this.activeTo,e),Ys(this.activeRank,e),this.minActive=Lu(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++;Xs(this.active,t,n),Xs(this.activeTo,t,s),Xs(this.activeRank,t,r),e&&Xs(e,t,this.cursor.from),this.minActive=Lu(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&&Ys(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 Du(i,e,t,n,s,r){i.goto(e),t.goto(n);let o=n+s,l=n,a=n-e;for(;;){let c=i.to+a-t.to,u=c||i.endSide-t.endSide,d=u<0?i.to+a:t.to,f=Math.min(d,o);if(i.point||t.point?i.point&&t.point&&(i.point==t.point||i.point.eq(t.point))&&na(i.activeForPoint(i.to),t.activeForPoint(t.to))||r.comparePoint(l,f,i.point,t.point):f>l&&!na(i.active,t.active)&&r.compareRange(l,f,i.active,t.active),d>o)break;(c||i.openEnd!=t.openEnd)&&r.boundChange&&r.boundChange(d),l=d,u<=0&&i.next(),u>=0&&t.next()}}function na(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 Ys(i,e){for(let t=e,n=i.length-1;t<n;t++)i[t]=i[t+1];i.pop()}function Xs(i,e,t){for(let n=i.length-1;n>=e;n--)i[n+1]=i[n];i[e]=t}function Lu(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 On(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 sa(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 ra="ͼ",Nu=typeof Symbol>"u"?"__"+ra:Symbol.for(ra),oa=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Fu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class wi{constructor(e,t){this.rules=[];let{finish:n}=t||{};function s(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,a,c){let u=[],d=/^@(\w+)\b/.exec(o[0]),f=d&&d[1]=="keyframes";if(d&&l==null)return a.push(o[0]+";");for(let p in l){let m=l[p];if(/&/.test(p))r(p.split(/,\s*/).map(g=>o.map(x=>g.replace(/&/,x))).reduce((g,x)=>g.concat(x)),m,a);else if(m&&typeof m=="object"){if(!d)throw new RangeError("The value of a property ("+p+") should be a primitive value.");r(s(p),m,u,f)}else m!=null&&u.push(p.replace(/_.*/,"").replace(/[A-Z]/g,g=>"-"+g.toLowerCase())+": "+m+";")}(u.length||f)&&a.push((n&&!d&&!c?o.map(n):o).join(", ")+" {"+u.join(" ")+"}")}for(let o in e)r(s(o),e[o],this.rules)}getRules(){return this.rules.join(`
|
|
28
|
+
`)}static newName(){let e=Fu[Nu]||1;return Fu[Nu]=e+1,ra+e.toString(36)}static mount(e,t,n){let s=e[oa],r=n&&n.nonce;s?r&&s.setNonce(r):s=new aE(e,r),s.mount(Array.isArray(t)?t:[t],e)}}let Bu=new Map;class aE{constructor(e,t){let n=e.ownerDocument||e,s=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let r=Bu.get(n);if(r)return e[oa]=r;this.sheet=new s.CSSStyleSheet,Bu.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[oa]=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 c=0;c<l.rules.length;c++)n.insertRule(l.rules[c],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 ki={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:"'"},hs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},cE=typeof navigator<"u"&&/Mac/.test(navigator.platform),uE=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ne=0;Ne<10;Ne++)ki[48+Ne]=ki[96+Ne]=String(Ne);for(var Ne=1;Ne<=24;Ne++)ki[Ne+111]="F"+Ne;for(var Ne=65;Ne<=90;Ne++)ki[Ne]=String.fromCharCode(Ne+32),hs[Ne]=String.fromCharCode(Ne);for(var sl in ki)hs.hasOwnProperty(sl)||(hs[sl]=ki[sl]);function hE(i){var e=cE&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||uE&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?hs:ki)[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++)np(i,arguments[e]);return i}function np(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++)np(i,e[t]);else throw new RangeError("Unsupported child node: "+e)}let Ye=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},la=typeof document<"u"?document:{documentElement:{style:{}}};const aa=/Edge\/(\d+)/.exec(Ye.userAgent),sp=/MSIE \d/.test(Ye.userAgent),ca=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ye.userAgent),vo=!!(sp||ca||aa),Vu=!vo&&/gecko\/(\d+)/i.test(Ye.userAgent),rl=!vo&&/Chrome\/(\d+)/.exec(Ye.userAgent),dE="webkitFontSmoothing"in la.documentElement.style,ua=!vo&&/Apple Computer/.test(Ye.vendor),_u=ua&&(/Mobile\/\w+/.test(Ye.userAgent)||Ye.maxTouchPoints>2);var H={mac:_u||/Mac/.test(Ye.platform),windows:/Win/.test(Ye.platform),linux:/Linux|X11/.test(Ye.platform),ie:vo,ie_version:sp?la.documentMode||6:ca?+ca[1]:aa?+aa[1]:0,gecko:Vu,gecko_version:Vu?+(/Firefox\/(\d+)/.exec(Ye.userAgent)||[0,0])[1]:0,chrome:!!rl,chrome_version:rl?+rl[1]:0,ios:_u,android:/Android\b/.test(Ye.userAgent),webkit_version:dE?+(/\bAppleWebKit\/(\d+)/.exec(Ye.userAgent)||[0,0])[1]:0,safari:ua,safari_version:ua?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Ye.userAgent)||[0,0])[1]:0,tabSize:la.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function ds(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function ha(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function Sr(i,e){if(!e.anchorNode)return!1;try{return ha(i,e.anchorNode)}catch{return!1}}function Rn(i){return i.nodeType==3?qi(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function Qn(i,e,t,n){return t?$u(i,e,t,n,-1)||$u(i,e,t,n,1):!1}function Wi(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function Hr(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function $u(i,e,t,n,s){for(;;){if(i==t&&e==n)return!0;if(e==(s<0?0:Ut(i))){if(i.nodeName=="DIV")return!1;let r=i.parentNode;if(!r||r.nodeType!=1)return!1;e=Wi(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?Ut(i):0}else return!1}}function Ut(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function js(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function fE(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 rp(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 pE(i,e,t,n,s,r,o,l){let a=i.ownerDocument,c=a.defaultView||window;for(let u=i,d=!1;u&&!d;)if(u.nodeType==1){let f,p=u==a.body,m=1,g=1;if(p)f=fE(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let b=u.getBoundingClientRect();({scaleX:m,scaleY:g}=rp(u,b)),f={left:b.left,right:b.left+u.clientWidth*m,top:b.top,bottom:b.top+u.clientHeight*g}}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,S=f.bottom-f.top;y=(s=="center"&&b<=S?e.top+b/2-S/2:s=="start"||s=="center"&&t<0?e.top-o:e.bottom-S+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)c.scrollBy(x,y);else{let b=0,S=0;if(y){let E=u.scrollTop;u.scrollTop+=y/g,S=(u.scrollTop-E)*g}if(x){let E=u.scrollLeft;u.scrollLeft+=x/m,b=(u.scrollLeft-E)*m}e={left:e.left-b,top:e.top-S,right:e.right-b,bottom:e.bottom-S},b&&Math.abs(b-x)<1&&(n="nearest"),S&&Math.abs(S-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)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function mE(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 gE{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?Ut(t):0),n,Math.min(e.focusOffset,n?Ut(n):0))}set(e,t,n,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=s}}let Li=null;H.safari&&H.safari_version>=26&&(Li=!1);function op(i){if(i.setActive)return i.setActive();if(Li)return i.focus(Li);let e=[];for(let t=i;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(i.focus(Li==null?{get preventScroll(){return Li={preventScroll:!0},!0}}:void 0),!Li){Li=!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 zu;function qi(i,e,t=e){let n=zu||(zu=document.createRange());return n.setEnd(i,t),n.setStart(i,e),n}function xn(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 xE(i){for(;i;){if(i&&(i.nodeType==9||i.nodeType==11&&i.host))return i;i=i.assignedSlot||i.parentNode}return null}function lp(i){for(;i.attributes.length;)i.removeAttributeNode(i.attributes[0])}function yE(i,e){let t=e.focusNode,n=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=n)return!1;for(n=Math.min(n,Ut(t));;)if(n){if(t.nodeType!=1)return!1;let s=t.childNodes[n-1];s.contentEditable=="false"?n--:(t=s,n=Ut(t))}else{if(t==i)return!0;n=Wi(t),t=t.parentNode}}function ap(i){return i.scrollTop>Math.max(1,i.scrollHeight-i.clientHeight-4)}function cp(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=Ut(t)}else if(t.parentNode&&!Hr(t))n=Wi(t),t=t.parentNode;else return null}}function up(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&&!Hr(t))n=Wi(t)+1,t=t.parentNode;else return null}}class Ge{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new Ge(e.parentNode,Wi(e),t)}static after(e,t){return new Ge(e.parentNode,Wi(e)+1,t)}}const mc=[];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=Hu(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=Hu(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=Ut(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,c=n,u=n;a<this.children.length;a++){let d=this.children[a],f=c+d.length;if(c<e&&f>t)return d.domBoundsAround(e,t,c);if(f>=e&&s==-1&&(s=a,r=c),c>t&&d.dom.parentNode==this.dom){o=a,l=u;break}u=f,c=f+d.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=mc){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 hp(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 Hu(i){let e=i.nextSibling;return i.parentNode.removeChild(i),e}class hp{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 dp(i,e,t,n,s,r,o,l,a){let{children:c}=i,u=c.length?c[e]:null,d=r.length?r[r.length-1]:null,f=d?d.breakAfter:o;if(!(e==n&&u&&!o&&!f&&r.length<2&&u.merge(t,s,r.length?d:null,t==0,l,a))){if(n<c.length){let p=c[n];p&&(s<p.length||p.breakAfter&&(d!=null&&d.breakAfter))?(e==n&&(p=p.split(s),s=0),!f&&d&&p.merge(0,s,d,!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&&(d?d.breakAfter=1:o=1),n++}for(u&&(u.breakAfter=o,t>0&&(!o&&r.length&&u.merge(t,u.length,r[0],!1,l,0)?u.breakAfter=r.shift().breakAfter:(t<u.length||u.children.length&&u.children[u.children.length-1].length==0)&&u.merge(t,u.length,null,!1,l,0),e++));e<n&&r.length;)if(c[n-1].become(r[r.length-1]))n--,r.pop(),a=r.length?0:l;else if(c[e].become(r[0]))e++,r.shift(),l=r.length?0:a;else break;!r.length&&e&&n<c.length&&!c[e-1].breakAfter&&c[n].merge(0,0,c[e-1],!1,l,a)&&e--,(e<n||r.length)&&i.replaceChildren(e,n,r)}}function fp(i,e,t,n,s,r){let o=i.childCursor(),{i:l,off:a}=o.findPos(t,1),{i:c,off:u}=o.findPos(e,-1),d=e-t;for(let f of n)d+=f.length;i.length+=d,dp(i,c,u,l,a,n,0,s,r)}const bE=256;class kt 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 kt)||this.length-(t-e)+n.length>bE||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 kt(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 Ge(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 SE(this.dom,e,t)}}class oi 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(lp(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 oi&&n.mark.eq(this.mark))||e&&r<=0||t<this.length&&o<=0)?!1:(fp(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 oi(this.mark,t,o)}domAtPos(e){return pp(this,e)}coordsAt(e,t){return gp(this,e,t)}}function SE(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?H.chrome||H.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):t<0?s--:r<n&&r++;let l=qi(i,s,r).getClientRects();if(!l.length)return null;let a=l[(o?o<0:t>=0)?0:l.length-1];return H.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,c=>c.width)||a),o?js(a,o<0):a||null}class ti extends de{static create(e,t,n){return new ti(e,t,n)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}split(e){let t=ti.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 ti)||!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 ti&&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)?Ge.before(this.dom):Ge.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 js(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 wn extends de{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof wn&&e.side==this.side}split(){return new wn(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?Ge.before(this.dom):Ge.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return oe.empty}get isHidden(){return!0}}kt.prototype.children=ti.prototype.children=wn.prototype.children=mc;function pp(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 Ge(t,0)}function mp(i,e,t){let n,{children:s}=i;t>0&&e instanceof oi&&s.length&&(n=s[s.length-1])instanceof oi&&n.mark.eq(e.mark)?mp(n,e.children[0],t-1):(s.push(e),e.setParent(i)),i.length+=e.length}function gp(i,e,t){let n=null,s=-1,r=null,o=-1;function l(c,u){for(let d=0,f=0;d<c.children.length&&f<=u;d++){let p=c.children[d],m=f+p.length;m>=u&&(p.children.length?l(p,u-f):(!r||r.isHidden&&(t>0||EE(r,p)))&&(m>u||f==m&&p.getSide()>0)?(r=p,o=u-f):(f<u||f==m&&p.getSide()<0&&!p.isHidden)&&(n=p,s=u-f)),f=m}}l(i,e);let a=(t<0?n:r)||n||r;return a?a.coordsAt(Math.max(0,a==n?s:o),t):vE(i)}function vE(i){let e=i.dom.lastChild;if(!e)return i.dom.getBoundingClientRect();let t=Rn(e);return t[t.length-1]||null}function EE(i,e){let t=i.coordsAt(0,1),n=e.coordsAt(0,1);return t&&n&&n.top<t.bottom}function da(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 Gu=Object.create(null);function Gr(i,e,t){if(i==e)return!0;i||(i=Gu),e||(e=Gu);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 fa(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 CE(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 ai{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 Je=(function(i){return i[i.Text=0]="Text",i[i.WidgetBefore=1]="WidgetBefore",i[i.WidgetAfter=2]="WidgetAfter",i[i.WidgetRange=3]="WidgetRange",i})(Je||(Je={}));class K extends Ui{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 Is(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 Ti(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}=xp(e,t);n=(r?t?-3e8:-1:5e8)-1,s=(o?t?2e8:1:-6e8)+1}return new Ti(e,n,s,t,e.widget||null,!0)}static line(e){return new Os(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 Is extends K{constructor(e){let{start:t,end:n}=xp(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 Is&&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))&&Gr(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)}}Is.prototype.point=!1;class Os extends K{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Os&&this.spec.class==e.spec.class&&Gr(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)}}Os.prototype.mapMode=Xe.TrackBefore;Os.prototype.point=!0;class Ti 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?Xe.TrackBefore:Xe.TrackAfter:Xe.TrackDel}get type(){return this.startSide!=this.endSide?Je.WidgetRange:this.startSide<=0?Je.WidgetBefore:Je.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Ti&&RE(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)}}Ti.prototype.point=!0;function xp(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 RE(i,e){return i==e||!!(i&&e&&i.compare(e))}function vr(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 we 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 we))return!1;this.dom||n.transferDOM(this)}return s&&this.setDeco(n?n.attrs:null),fp(this,e,t,n?n.children.slice():[],r,o),!0}split(e){let t=new we;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){Gr(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){mp(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=da(t,this.attrs||{})),n&&(this.attrs=da({class:n},this.attrs||{}))}domAtPos(e){return pp(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(lp(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&&(fa(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 oi;)s=s.lastChild;if(!s||!this.length||s.nodeName!="BR"&&((n=de.get(s))===null||n===void 0?void 0:n.isEditable)==!1&&(!H.ios||!this.children.some(r=>r instanceof kt))){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 kt)||/[^ -~]/.test(n.text))return null;let s=Rn(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=gp(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 we&&this.children.length==0&&e.children.length==0&&Gr(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 we)return r;if(o>t)break}s=o+r.breakAfter}return null}}class ni 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 ni)||!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?Ge.before(this.dom):Ge.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new ni(this.widget,t,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return mc}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 ni&&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 pa?null:js(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 pa extends ai{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 Jn{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 ni&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new we),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Qs(new wn(-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 ni)&&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(Qs(new kt(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 Ti){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 Ti)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new ni(n.widget||kn.block,l,n));else{let a=ti.create(n.widget||kn.inline,l,l?0:n.startSide),c=this.atCursorPos&&!a.isEditable&&r<=s.length&&(e<t||n.startSide>0),u=!a.isEditable&&(e<t||r>s.length||n.startSide<=0),d=this.getLine();this.pendingBuffer==2&&!c&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(s),c&&(d.append(Qs(new wn(1),s),r),r=s.length+Math.max(0,r-s.length)),d.append(Qs(a,s),r),this.atCursorPos=u,this.pendingBuffer=u?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 Jn(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 Qs(i,e){for(let t of e)i=new oi(t,[i],i.length);return i}class kn extends ai{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}}kn.inline=new kn("span");kn.block=new kn("div");var be=(function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i})(be||(be={}));const Ki=be.LTR,gc=be.RTL;function yp(i){let e=[];for(let t=0;t<i.length;t++)e.push(1<<+i[t]);return e}const wE=yp("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),kE=yp("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),ma=Object.create(null),Pt=[];for(let i of["()","[]","{}"]){let e=i.charCodeAt(0),t=i.charCodeAt(1);ma[e]=t,ma[t]=-e}function bp(i){return i<=247?wE[i]:1424<=i&&i<=1524?2:1536<=i&&i<=1785?kE[i-1536]:1774<=i&&i<=2220?4:8192<=i&&i<=8204?256:64336<=i&&i<=65023?4:1}const TE=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class bi{get dir(){return this.level%2?gc:Ki}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 Sp(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||!Sp(n.inner,s.inner))return!1}return!0}const pe=[];function AE(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 c=o,u=a,d=a;c<l;c++){let f=bp(i.charCodeAt(c));f==512?f=u:f==8&&d==4&&(f=16),pe[c]=f==4?2:f,f&7&&(d=f),u=f}for(let c=o,u=a,d=a;c<l;c++){let f=pe[c];if(f==128)c<l-1&&u==pe[c+1]&&u&24?f=pe[c]=u:pe[c]=256;else if(f==64){let p=c+1;for(;p<l&&pe[p]==64;)p++;let m=c&&u==8||p<t&&pe[p]==8?d==1?1:8:256;for(let g=c;g<p;g++)pe[g]=m;c=p-1}else f==8&&d==1&&(pe[c]=1);u=f,f&7&&(d=f)}}}function jE(i,e,t,n,s){let r=s==1?2:1;for(let o=0,l=0,a=0;o<=n.length;o++){let c=o?n[o-1].to:e,u=o<n.length?n[o].from:t;for(let d=c,f,p,m;d<u;d++)if(p=ma[f=i.charCodeAt(d)])if(p<0){for(let g=l-3;g>=0;g-=3)if(Pt[g+1]==-p){let x=Pt[g+2],y=x&2?s:x&4?x&1?r:s:0;y&&(pe[d]=pe[Pt[g]]=y),l=g;break}}else{if(Pt.length==189)break;Pt[l++]=d,Pt[l++]=f,Pt[l++]=a}else if((m=pe[d])==2||m==1){let g=m==s;a=g?0:1;for(let x=l-3;x>=0;x-=3){let y=Pt[x+2];if(y&2)break;if(g)Pt[x+2]|=2;else{if(y&4)break;Pt[x+2]|=4}}}}}function IE(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 c=pe[a];if(c==256){let u=a+1;for(;;)if(u==l){if(s==t.length)break;u=t[s++].to,l=s<t.length?t[s].from:e}else if(pe[u]==256)u++;else break;let d=r==1,f=(u<e?pe[u]:n)==1,p=d==f?d?1:2:n;for(let m=u,g=s,x=g?t[g-1].to:i;m>a;)m==x&&(m=t[--g].from,x=g?t[g-1].to:i),pe[--m]=p;a=u}else r=c,a++}}}function ga(i,e,t,n,s,r,o){let l=n%2?2:1;if(n%2==s%2)for(let a=e,c=0;a<t;){let u=!0,d=!1;if(c==r.length||a<r[c].from){let g=pe[a];g!=l&&(u=!1,d=g==16)}let f=!u&&l==1?[]:null,p=u?n:n+1,m=a;e:for(;;)if(c<r.length&&m==r[c].from){if(d)break e;let g=r[c];if(!u)for(let x=g.to,y=c+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(c++,f)f.push(g);else{g.from>a&&o.push(new bi(a,g.from,p));let x=g.direction==Ki!=!(p%2);xa(i,x?n+1:n,s,g.inner,g.from,g.to,o),a=g.to}m=g.to}else{if(m==t||(u?pe[m]!=l:pe[m]==l))break;m++}f?ga(i,a,m,n+1,s,f,o):a<m&&o.push(new bi(a,m,p)),a=m}else for(let a=t,c=r.length;a>e;){let u=!0,d=!1;if(!c||a>r[c-1].to){let g=pe[a-1];g!=l&&(u=!1,d=g==16)}let f=!u&&l==1?[]:null,p=u?n:n+1,m=a;e:for(;;)if(c&&m==r[c-1].to){if(d)break e;let g=r[--c];if(!u)for(let x=g.from,y=c;;){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(f)f.push(g);else{g.to<a&&o.push(new bi(g.to,a,p));let x=g.direction==Ki!=!(p%2);xa(i,x?n+1:n,s,g.inner,g.from,g.to,o),a=g.from}m=g.from}else{if(m==e||(u?pe[m-1]!=l:pe[m-1]==l))break;m--}f?ga(i,m,a,n+1,s,f,o):m<a&&o.push(new bi(m,a,p)),a=m}}function xa(i,e,t,n,s,r,o){let l=e%2?2:1;AE(i,s,r,n,l),jE(i,s,r,n,l),IE(s,r,n,l),ga(i,s,r,e,t,n,o)}function OE(i,e,t){if(!i)return[new bi(0,0,e==gc?1:0)];if(e==Ki&&!t.length&&!TE.test(i))return vp(i.length);if(t.length)for(;i.length>pe.length;)pe[pe.length]=256;let n=[],s=e==Ki?0:1;return xa(i,s,s,t,0,i.length,n),n}function vp(i){return[new bi(0,i,0)]}let Ep="";function ME(i,e,t,n,s){var r;let o=n.head-i.from,l=bi.find(e,o,(r=n.bidiLevel)!==null&&r!==void 0?r:-1,n.assoc),a=e[l],c=a.side(s,t);if(o==c){let f=l+=s?1:-1;if(f<0||f>=e.length)return null;a=e[l=f],o=a.side(!s,t),c=a.side(s,t)}let u=Fe(i.text,o,a.forward(s,t));(u<a.from||u>a.to)&&(u=c),Ep=i.text.slice(Math.min(o,u),Math.max(o,u));let d=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return d&&u==c&&d.level+(s?0:1)<a.level?j.cursor(d.side(!s,t)+i.from,d.forward(s,t)?1:-1,d.level):j.cursor(u+i.from,a.forward(s,t)?-1:1,a.level)}function PE(i,e,t){for(let n=e;n<t;n++){let s=bp(i.charCodeAt(n));if(s==1)return Ki;if(s==2||s==4)return gc}return Ki}const Cp=G.define(),Rp=G.define(),wp=G.define(),kp=G.define(),ya=G.define(),Tp=G.define(),Ap=G.define(),xc=G.define(),yc=G.define(),jp=G.define({combine:i=>i.some(e=>e)}),Ip=G.define({combine:i=>i.some(e=>e)}),Op=G.define();class yn{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 yn(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 yn(j.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Js=J.define({map:(i,e)=>i.map(e)}),Mp=J.define();function it(i,e,t){let n=i.facet(kp);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 ei=G.define({combine:i=>i.length?i[0]:!0});let DE=0;const an=G.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(an.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(an.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:s,provide:r,decorations:o}=t||{};return new Ce(DE++,e,n,s,l=>{let a=[];return o&&a.push(fs.of(c=>{let u=c.plugin(l);return u?o(u):K.none})),r&&a.push(r(l)),a})}static fromClass(e,t){return Ce.define((n,s)=>new e(n,s),t)}}class ol{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(it(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){it(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){it(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Pp=G.define(),bc=G.define(),fs=G.define(),Dp=G.define(),Ms=G.define(),Lp=G.define();function Uu(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 c=r-e.from,u=o-e.from,d=s;for(let f=l.length-1;f>=0;f--,a--){let p=l[f].spec.bidiIsolate,m;if(p==null&&(p=PE(e.text,c,u)),a>0&&d.length&&(m=d[d.length-1]).to==c&&m.direction==p)m.to=u,d=m.inner;else{let g={from:c,to:u,direction:p,inner:[]};d.push(g),d=g.inner}}}}),s}const Np=G.define();function Sc(i){let e=0,t=0,n=0,s=0;for(let r of i.state.facet(Np)){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 Hn=G.define();class bt{constructor(e,t,n,s){this.fromA=e,this.toA=t,this.fromB=n,this.toB=s}join(e){return new bt(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],c=o-l,u=a?a.fromB:1e9;for(;r<t.length&&t[r]<u;){let d=t[r],f=t[r+1],p=Math.max(l,d),m=Math.min(u,f);if(p<=m&&new bt(p+c,m+c,p,m).addToSet(n),f>u)break;r+=2}if(!a)return n;new bt(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),o=a.toA,l=a.toB}}}class Ur{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=je.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 bt(r,o,l,a))),this.changedRanges=s}static create(e,t,n){return new Ur(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 Wu 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 we],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new bt(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:c,toA:u})=>u<this.minWidthFrom||c>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:!$E(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let r=s>-1?NE(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:c,to:u}=this.hasComposition;n=new bt(c,u,e.changes.mapPos(c,-1),e.changes.mapPos(u,1)).addToSet(n.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(H.ie||H.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=VE(o,l,e.changes);return n=bt.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=H.chrome||H.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 ni&&o.widget instanceof pa&&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:c,fromB:u,toB:d}=l,f,p,m,g;if(n&&n.range.fromB<d&&n.range.toB>u){let E=Jn.build(this.view.state.doc,u,n.range.fromB,this.decorations,this.dynamicDecorationMap),v=Jn.build(this.view.state.doc,n.range.toB,d,this.decorations,this.dynamicDecorationMap);p=E.breakAtStart,m=E.openStart,g=v.openEnd;let C=this.compositionView(n);v.breakAtStart?C.breakAfter=1:v.content.length&&C.merge(C.length,C.length,v.content[0],!1,v.openStart,0)&&(C.breakAfter=v.content[0].breakAfter,v.content.shift()),E.content.length&&C.merge(0,0,E.content[E.content.length-1],!0,0,E.openEnd)&&E.content.pop(),f=E.content.concat(C).concat(v.content)}else({content:f,breakAtStart:p,openStart:m,openEnd:g}=Jn.build(this.view.state.doc,u,d,this.decorations,this.dynamicDecorationMap));let{i:x,off:y}=r.findPos(c,1),{i:b,off:S}=r.findPos(a,-1);dp(this,b,S,x,y,f,p,m,g)}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(Mp)&&(this.editContextFormatting=n.value)}compositionView(e){let t=new kt(e.text.nodeValue);t.flags|=8;for(let{deco:s}of e.marks)t=new oi(s,[t],t.length);let n=new we;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(ei)||this.dom.tabIndex>-1)&&Sr(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)),c=l.empty?a:this.moveToLine(this.domAtPos(l.head));if(H.gecko&&l.empty&&!this.hasComposition&&LE(a)){let d=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(d,a.node.childNodes[a.offset]||null)),a=c=new Ge(d,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!Qn(a.node,a.offset,u.anchorNode,u.anchorOffset)||!Qn(c.node,c.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,l))&&(this.view.observer.ignore(()=>{H.android&&H.chrome&&this.dom.contains(u.focusNode)&&_E(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let d=ds(this.view.root);if(d)if(l.empty){if(H.gecko){let f=FE(a.node,a.offset);if(f&&f!=3){let p=(f==1?cp:up)(a.node,a.offset);p&&(a=new Ge(p.node,p.offset))}}d.collapse(a.node,a.offset),l.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=l.bidiLevel)}else if(d.extend){d.collapse(a.node,a.offset);try{d.extend(c.node,c.offset)}catch{}}else{let f=document.createRange();l.anchor>l.head&&([a,c]=[c,a]),f.setEnd(c.node,c.offset),f.setStart(a.node,a.offset),d.removeAllRanges(),d.addRange(f)}r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(a,c)),this.impreciseAnchor=a.precise?null:new Ge(u.anchorNode,u.anchorOffset),this.impreciseHead=c.precise?null:new Ge(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Qn(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=ds(e.root),{anchorNode:s,anchorOffset:r}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let o=we.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),c=this.coordsAt(t.head,1);if(!a||!c||a.bottom>c.top)return;let u=this.domAtPos(t.head+t.assoc);n.collapse(u.node,u.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let d=e.observer.selectionRange;e.docView.posFromDOM(d.anchorNode,d.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 we&&(n=r.domAtPos(0))}for(let s=e.offset-1;!n&&s>=0;s--){let r=de.get(t.childNodes[s]);r instanceof we&&(n=r.domAtPos(r.length))}return n?new Ge(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 we)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,c=a-l.length;if(a<e)break;if(c<=e&&(c<e||l.covers(-1))&&(a>e||l.covers(1))&&(!n||l instanceof we&&!(n instanceof we&&t>=0)))n=l,s=c;else if(n&&c==e&&a==e&&l instanceof ni&&Math.abs(t)<2){if(l.deco.startSide<0)break;o&&(n=null)}r=c}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 we))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 kt))return null;let r=Fe(s.text,n);if(r==n)return null;let o=qi(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==be.LTR;for(let c=0,u=0;u<this.children.length;u++){let d=this.children[u],f=c+d.length;if(f>s)break;if(c>=n){let p=d.dom.getBoundingClientRect();if(t.push(p.height),o){let m=d.dom.lastChild,g=m?Rn(m):[];if(g.length){let x=g[g.length-1],y=a?x.right-p.left:p.right-x.left;y>l&&(l=y,this.minWidth=r,this.minWidthFrom=c,this.minWidthTo=f)}}}c=f+d.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?be.RTL:be.LTR}measureTextSize(){for(let r of this.children)if(r instanceof we){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=Rn(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 hp(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 pa(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(fs).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),n=!1,s=this.view.state.facet(Dp).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 c=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=c.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let c of this.view.state.facet(Op))try{if(c(this.view,e.range,e))return!0}catch(u){it(this.view.state,u,"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=Sc(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;pE(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==be.LTR)}lineHasWidget(e){let{i:t}=this.childCursor().findPos(e);if(t==this.children.length)return!1;let n=s=>s instanceof ti||s.children.some(n);return n(this.children[t])}}function LE(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 Fp(i,e){let t=i.observer.selectionRange;if(!t.focusNode)return null;let n=cp(t.focusNode,t.focusOffset),s=up(t.focusNode,t.focusOffset),r=n||s;if(s&&n&&s.node!=n.node){let l=de.get(s.node);if(!l||l instanceof kt&&l.text!=s.node.nodeValue)r=s;else if(i.docView.lastCompositionAfterCursor){let a=de.get(n.node);!a||a instanceof kt&&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 NE(i,e,t){let n=Fp(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,c=new bt(a.mapPos(r),a.mapPos(o),r,o),u=[];for(let d=s.parentNode;;d=d.parentNode){let f=de.get(d);if(f instanceof oi)u.push({node:d,deco:f.mark});else{if(f instanceof we||d.nodeName=="DIV"&&d.parentNode==i.contentDOM)return{range:c,text:s,marks:u,line:d};if(d!=i.contentDOM)u.push({node:d,deco:new Is({inclusive:!0,attributes:CE(d),tagName:d.tagName.toLowerCase()})});else return null}}}function FE(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 BE=class{constructor(){this.changes=[]}compareRange(e,t){vr(e,t,this.changes)}comparePoint(e,t){vr(e,t,this.changes)}boundChange(e){vr(e,e,this.changes)}};function VE(i,e,t){let n=new BE;return re.compare(i,e,t,n),n.changes}function _E(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 $E(i,e){let t=!1;return e&&i.iterChangedRanges((n,s)=>{n<e.to&&s>e.from&&(t=!0)}),t}function zE(i,e,t=1){let n=i.charCategorizer(e),s=i.doc.lineAt(e),r=e-s.from;if(s.length==0)return j.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 c=Fe(s.text,o,!1);if(n(s.text.slice(c,o))!=a)break;o=c}for(;l<s.length;){let c=Fe(s.text,l);if(n(s.text.slice(l,c))!=a)break;l=c}return j.range(o+s.from,l+s.from)}function HE(i,e){return e.left>i?e.left-i:Math.max(0,i-e.right)}function GE(i,e){return e.top>i?e.top-i:Math.max(0,i-e.bottom)}function ll(i,e){return i.top<e.bottom-1&&i.bottom>e.top+1}function qu(i,e){return e<i.top?{top:e,left:i.left,right:i.right,bottom:i.bottom}:i}function Ku(i,e){return e>i.bottom?{top:i.top,left:i.left,right:i.right,bottom:e}:i}function ba(i,e,t){let n,s,r,o,l=!1,a,c,u,d;for(let m=i.firstChild;m;m=m.nextSibling){let g=Rn(m);for(let x=0;x<g.length;x++){let y=g[x];s&&ll(s,y)&&(y=qu(Ku(y,s.bottom),s.top));let b=HE(e,y),S=GE(t,y);if(b==0&&S==0)return m.nodeType==3?Yu(m,e,t):ba(m,e,t);(!n||o>S||o==S&&r>b)&&(n=m,s=y,r=b,o=S,l=b?e<y.left?x>0:x<g.length-1:!0),b==0?t>y.bottom&&(!u||u.bottom<y.bottom)?(a=m,u=y):t<y.top&&(!d||d.top>y.top)&&(c=m,d=y):u&&ll(u,y)?u=Ku(u,y.bottom):d&&ll(d,y)&&(d=qu(d,y.top))}}if(u&&u.bottom>=t?(n=a,s=u):d&&d.top<=t&&(n=c,s=d),!n)return{node:i,offset:0};let f=Math.max(s.left,Math.min(s.right,e));if(n.nodeType==3)return Yu(n,f,t);if(l&&n.contentEditable!="false")return ba(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 Yu(i,e,t){let n=i.nodeValue.length,s=-1,r=1e9,o=0;for(let l=0;l<n;l++){let a=qi(i,l,l+1).getClientRects();for(let c=0;c<a.length;c++){let u=a[c];if(u.top==u.bottom)continue;o||(o=e-u.left);let d=(u.top>t?u.top-t:t-u.bottom)-1;if(u.left-1<=e&&u.right+1>=e&&d<r){let f=e>=(u.left+u.right)/2,p=f;if((H.chrome||H.gecko)&&qi(i,l).getBoundingClientRect().left==u.right&&(p=!f),d<=0)return{node:i,offset:l+(p?1:0)};s=l+(p?1:0),r=d}}}return{node:i,offset:s>-1?s:o>0?i.nodeValue.length:0}}function Bp(i,e,t,n=-1){var s,r;let o=i.contentDOM.getBoundingClientRect(),l=o.top+i.viewState.paddingTop,a,{docHeight:c}=i.viewState,{x:u,y:d}=e,f=d-l;if(f<0)return 0;if(f>c)return i.state.doc.length;for(let E=i.viewState.heightOracle.textHeight/2,v=!1;a=i.elementAtHeight(f),a.type!=Je.Text;)for(;f=n>0?a.bottom+E:a.top-E,!(f>=0&&f<=c);){if(v)return t?null:0;v=!0,n=-n}d=l+f;let p=a.from;if(p<i.viewport.from)return i.viewport.from==0?0:t?null:Xu(i,o,a,u,d);if(p>i.viewport.to)return i.viewport.to==i.state.doc.length?i.state.doc.length:t?null:Xu(i,o,a,u,d);let m=i.dom.ownerDocument,g=i.root.elementFromPoint?i.root:m,x=g.elementFromPoint(u,d);x&&!i.contentDOM.contains(x)&&(x=null),x||(u=Math.max(o.left+1,Math.min(o.right-1,u)),x=g.elementFromPoint(u,d),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(m.caretPositionFromPoint){let E=m.caretPositionFromPoint(u,d);E&&({offsetNode:y,offset:b}=E)}else if(m.caretRangeFromPoint){let E=m.caretRangeFromPoint(u,d);E&&({startContainer:y,startOffset:b}=E)}y&&(!i.contentDOM.contains(y)||H.safari&&UE(y,b,u)||H.chrome&&WE(y,b,u))&&(y=void 0),y&&(b=Math.min(Ut(y),b))}if(!y||!i.docView.dom.contains(y)){let E=we.find(i.docView,p);if(!E)return f>a.top+a.height/2?a.to:a.from;({node:y,offset:b}=ba(E.dom,u,d))}let S=i.docView.nearest(y);if(!S)return null;if(S.isWidget&&((r=S.dom)===null||r===void 0?void 0:r.nodeType)==1){let E=S.dom.getBoundingClientRect();return e.y<E.top||e.y<=E.bottom&&e.x<=(E.left+E.right)/2?S.posAtStart:S.posAtEnd}else return S.localPosFromDOM(y,b)+S.posAtStart}function Xu(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+sa(o,r,i.state.tabSize)}function Vp(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 qi(i,n-1,n).getBoundingClientRect().right>t}function UE(i,e,t){return Vp(i,e,t)}function WE(i,e,t){if(e!=0)return Vp(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():qi(i,0,Math.max(i.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function Sa(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==Je.Text&&(s.type!=r.type||(t<0?r.from<e:r.to>e)))&&(s=r)}}return s||n}return n}function qE(i,e,t,n){let s=Sa(i,e.head,e.assoc||-1),r=!n||s.type!=Je.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==be.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return j.cursor(a,t?-1:1)}return j.cursor(t?s.to:s.from,t?-1:1)}function Qu(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 c=ME(s,r,o,l,t),u=Ep;if(!c){if(s.number==(t?i.state.doc.lines:1))return l;u=`
|
|
30
|
+
`,s=i.state.doc.line(s.number+(t?1:-1)),r=i.bidiSpans(s),c=i.visualLineSide(s,!t)}if(a){if(!a(u))return l}else{if(!n)return c;a=n(u)}l=c}}function KE(i,e,t){let n=i.state.charCategorizer(e),s=n(t);return r=>{let o=n(r);return s==Se.Space&&(s=o),s==o}}function YE(i,e,t,n){let s=e.head,r=t?1:-1;if(s==(t?i.state.doc.length:0))return j.cursor(s,e.assoc);let o=e.goalColumn,l,a=i.contentDOM.getBoundingClientRect(),c=i.coordsAtPos(s,e.assoc||-1),u=i.documentTop;if(c)o==null&&(o=c.left-a.left),l=r<0?c.top:c.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)+u}let d=a.left+o,f=n??i.viewState.heightOracle.textHeight>>1;for(let p=0;;p+=10){let m=l+(f+p)*r,g=Bp(i,{x:d,y:m},!1,r);if(m<a.top||m>a.bottom||(r<0?g<s:g>s)){let x=i.docView.coordsForChar(g),y=!x||m<x.top?-1:1;return j.cursor(g,y,void 0,o)}}}function Zn(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 _p(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=Zn(i,s.from,0);o!=s.from&&(r=j.cursor(o,-1))}else{let o=Zn(i,s.from,-1),l=Zn(i,s.to,1);(o!=s.from||l!=s.to)&&(r=j.range(s.from==s.anchor?o:l,s.from==s.head?o:l))}r&&(t||(t=e.ranges.slice()),t[n]=r)}return t?j.create(t,e.mainIndex):e}function al(i,e,t){let n=Zn(i.state.facet(Ms).map(s=>s(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:j.cursor(n,n<t.from?1:-1)}const Gn="";class XE{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(se.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Gn}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:Hr(s))||Hr(o)&&(s.nodeName!="BR"||s.cmIgnore)&&this.text.length>r)&&!JE(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+(QE(e,n.node,n.offset)?t:0))}}function QE(i,e,t){for(;;){if(!e||t<Ut(e))return!1;if(e==i)return!0;t=Wi(e)+1,e=e.parentNode}}function JE(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 Ju{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class ZE{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?[]:tC(e),a=new XE(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=iC(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!ha(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),c=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!ha(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),u=e.viewport;if((H.ios||H.chrome)&&e.state.selection.main.empty&&a!=c&&(u.from>0||u.to<e.state.doc.length)){let d=Math.min(a,c),f=Math.max(a,c),p=u.from-d,m=u.to-f;(p==0||p==1||d==0)&&(m==0||m==-1||f==e.state.doc.length)&&(a=0,c=e.state.doc.length)}this.newSel=j.single(c,a)}}}function $p(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,c=null;(r===8||H.android&&e.text.length<l-o)&&(a=s.to,c="end");let u=zp(i.state.doc.sliceString(o,l,Gn),e.text,a-o,c);u&&(H.chrome&&r==13&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==Gn+Gn&&u.toB--,t={from:o+u.from,to:o+u.toA,insert:oe.of(e.text.slice(u.from,u.toB).split(Gn))})}else n&&(!i.hasFocus&&i.state.facet(ei)||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)}:(H.mac||H.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=j.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)}:H.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==`
|
|
31
|
+
`&&i.lineWrapping&&(n&&(n=j.single(n.main.anchor-1,n.main.head-1)),t={from:s.from,to:s.to,insert:oe.of([" "])}),t)return vc(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=_p(i.state.facet(Ms).map(a=>a(i)),n))),i.dispatch({selection:n,scrollIntoView:o,userEvent:l}),!0}else return!1}function vc(i,e,t,n=-1){if(H.ios&&i.inputState.flushIOSKey(e))return!0;let s=i.state.selection.main;if(H.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&&xn(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)&&xn(i.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&xn(i.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let o,l=()=>o||(o=eC(i,e,t));return i.state.facet(Tp).some(a=>a(i,e.from,e.to,r,l))||i.dispatch(l()),!0}function eC(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,c=a<0?r.from:r.to,u=Zn(s.facet(Ms).map(d=>d(i)),c,a);e.from==u&&(o=u)}if(o>-1)n={changes:e,selection:j.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):"",c=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)+c))}else{let a=s.changes(e),c=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 u=i.state.sliceDoc(e.from,e.to),d,f=t&&Fp(i,t.main.head);if(f){let g=e.insert.length-(e.to-e.from);d={from:f.from,to:f.to-g}}else d=i.state.doc.lineAt(r.head);let p=r.to-e.to,m=r.to-r.from;n=s.changeByRange(g=>{if(g.from==r.from&&g.to==r.to)return{changes:a,range:c||g.map(a)};let x=g.to-p,y=x-u.length;if(g.to-g.from!=m||i.state.sliceDoc(y,x)!=u||g.to>=d.from&&g.from<=d.to)return{range:g};let b=s.changes({from:y,to:x,insert:e.insert}),S=g.to-r.to;return{changes:b,range:c?j.range(Math.max(0,c.anchor+S),Math.max(0,c.head+S)):g.map(b)}})}else n={changes:a,selection:c&&s.selection.replaceRange(c)}}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 zp(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 tC(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 Ju(t,n)),(s!=t||r!=n)&&e.push(new Ju(s,r))),e}function iC(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?j.single(t+e,n+e):null}class nC{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,H.safari&&e.contentDOM.addEventListener("input",()=>null),H.gecko&&bC(e.contentDOM.ownerDocument)}handleEvent(e){!hC(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=sC(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&&Gp.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),H.android&&H.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return H.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=Hp.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||rC.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,xn(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:H.safari&&!H.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 Zu(i,e){return(t,n)=>{try{return e.call(i,n,t)}catch(s){it(t.state,s)}}}function sC(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(Zu(n.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(Zu(n.value,a))}}for(let n in Tt)t(n).handlers.push(Tt[n]);for(let n in vt)t(n).observers.push(vt[n]);return e}const Hp=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],rC="dthko",Gp=[16,17,18,20,91,92,224,225],Zs=6;function er(i){return Math.max(0,i)*.7+8}function oC(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}class lC{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=mE(e.contentDOM),this.atoms=e.state.facet(Ms).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)&&aC(e,t),this.dragging=uC(e,t)&&qp(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&&oC(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=Sc(this.view);e.clientX-a.left<=s+Zs?t=-er(s-e.clientX):e.clientX+a.right>=o-Zs&&(t=er(e.clientX-o)),e.clientY-a.top<=r+Zs?n=-er(r-e.clientY):e.clientY+a.bottom>=l-Zs&&(n=er(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=_p(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 aC(i,e){let t=i.state.facet(Cp);return t.length?t[0](e):H.mac?e.metaKey:e.ctrlKey}function cC(i,e){let t=i.state.facet(Rp);return t.length?t[0](e):H.mac?!e.altKey:!e.ctrlKey}function uC(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let n=ds(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 hC(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 Tt=Object.create(null),vt=Object.create(null),Up=H.ie&&H.ie_version<15||H.ios&&H.webkit_version<604;function dC(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(),Wp(i,t.value)},50)}function Eo(i,e,t){for(let n of i.facet(e))t=n(t,i);return t}function Wp(i,e){e=Eo(i.state,xc,e);let{state:t}=i,n,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(va!=null&&t.selection.ranges.every(a=>a.empty)&&va==r.toString()){let a=-1;n=t.changeByRange(c=>{let u=t.doc.lineAt(c.from);if(u.from==a)return{range:c};a=u.from;let d=t.toText((o?r.line(s++).text:e)+t.lineBreak);return{changes:{from:u.from,insert:d},range:j.cursor(c.from+d.length)}})}else o?n=t.changeByRange(a=>{let c=r.line(s++);return{changes:{from:a.from,to:a.to,insert:c.text},range:j.cursor(a.from+c.length)}}):n=t.replaceSelection(r);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}vt.scroll=i=>{i.inputState.lastScrollTop=i.scrollDOM.scrollTop,i.inputState.lastScrollLeft=i.scrollDOM.scrollLeft};Tt.keydown=(i,e)=>(i.inputState.setSelectionOrigin("select"),e.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);vt.touchstart=(i,e)=>{i.inputState.lastTouchTime=Date.now(),i.inputState.setSelectionOrigin("select.pointer")};vt.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};Tt.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(wp))if(t=n(i,e),t)break;if(!t&&e.button==0&&(t=mC(i,e)),t){let n=!i.hasFocus;i.inputState.startMouseSelection(new lC(i,e,t,n)),n&&i.observer.ignore(()=>{op(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 eh(i,e,t,n){if(n==1)return j.cursor(e,t);if(n==2)return zE(i.state,e,t);{let s=we.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++,j.range(o,l)}}let th=(i,e,t)=>e>=t.top&&e<=t.bottom&&i>=t.left&&i<=t.right;function fC(i,e,t,n){let s=we.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&&th(t,n,o))return-1;let l=s.coordsAt(r,1);return l&&th(t,n,l)?1:o&&o.bottom>=n?-1:1}function ih(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:fC(i,t,e.clientX,e.clientY)}}const pC=H.ie&&H.ie_version<=11;let nh=null,sh=0,rh=0;function qp(i){if(!pC)return i.detail;let e=nh,t=rh;return nh=i,rh=Date.now(),sh=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(sh+1)%3:1}function mC(i,e){let t=ih(i,e),n=qp(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=ih(i,r),c,u=eh(i,a.pos,a.bias,n);if(t.pos!=a.pos&&!o){let d=eh(i,t.pos,t.bias,n),f=Math.min(d.from,u.from),p=Math.max(d.to,u.to);u=f<u.from?j.range(f,p):j.range(p,f)}return o?s.replaceRange(s.main.extend(u.from,u.to)):l&&n==1&&s.ranges.length>1&&(c=gC(s,a.pos))?c:l?s.addRange(u):j.create([u])}}}function gC(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 j.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}Tt.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=j.range(r,o))}}let{inputState:n}=i;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",Eo(i.state,yc,i.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Tt.dragend=i=>(i.inputState.draggedContent=null,!1);function oh(i,e,t,n){if(t=Eo(i.state,xc,t),!t)return;let s=i.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=i.inputState,o=n&&r&&cC(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}Tt.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&&oh(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 oh(i,e,n,!0),!0}return!1};Tt.paste=(i,e)=>{if(i.state.readOnly)return!0;i.observer.flush();let t=Up?null:e.clipboardData;return t?(Wp(i,t.getData("text/plain")||t.getData("text/uri-list")),!0):(dC(i),!1)};function xC(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 yC(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:Eo(i,yc,e.join(i.lineBreak)),ranges:t,linewise:n}}let va=null;Tt.copy=Tt.cut=(i,e)=>{let{text:t,ranges:n,linewise:s}=yC(i.state);if(!t&&!s)return!1;va=s?t:null,e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=Up?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(xC(i,t),!1)};const Kp=Kt.define();function Yp(i,e){let t=[];for(let n of i.facet(Ap)){let s=n(i,e);s&&t.push(s)}return t.length?i.update({effects:t,annotations:Kp.of(!0)}):null}function Xp(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=Yp(i.state,e);t?i.dispatch(t):i.update([])}},10)}vt.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),Xp(i)};vt.blur=i=>{i.observer.clearSelectionRange(),Xp(i)};vt.compositionstart=vt.compositionupdate=i=>{i.observer.editContext||(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0))};vt.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,H.chrome&&H.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50))};vt.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};Tt.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),c=i.posAtDOM(l.endContainer,l.endOffset);return vc(i,{from:a,to:c,insert:i.state.toText(r)},null),!0}}let s;if(H.chrome&&H.android&&(s=Hp.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 H.ios&&e.inputType=="deleteContentForward"&&i.observer.flushSoon(),H.safari&&e.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>vt.compositionend(i,e),20),!1};const lh=new Set;function bC(i){lh.has(i)||(lh.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}const ah=["pre-wrap","normal","pre-line","break-spaces"];let Tn=!1;function ch(){Tn=!1}class SC{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 ah.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=ah.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 c=0;c<o.length;c++){let u=o[c];u<0?c++:this.heightSamples[Math.floor(u*10)]=!0}}return a}}class vC{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Vt{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"?Je.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 Ti?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 Vt(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var ye=(function(i){return i[i.ByPos=0]="ByPos",i[i.ByHeight=1]="ByHeight",i[i.ByPosNoHeight=2]="ByPosNoHeight",i})(ye||(ye={}));const Er=.001;class Ze{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)>Er&&(Tn=!0),this.height=e)}replace(e,t,n){return Ze.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:c,fromB:u,toB:d}=s[l],f=r.lineAt(a,ye.ByPosNoHeight,n.setDoc(t),0,0),p=f.to>=c?f:r.lineAt(c,ye.ByPosNoHeight,n,0,0);for(d+=p.to-c,c=p.to;l>0&&f.from<=s[l-1].toA;)a=s[l-1].fromA,u=s[l-1].fromB,l--,a<f.from&&(f=r.lineAt(a,ye.ByPosNoHeight,n,0,0));u+=f.from-a,a=f.from;let m=Ec.build(n.setDoc(o),e,u,d);r=Wr(r,r.replace(a,c,m))}return r.updateHeight(n,0)}static empty(){return new ct(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 EC(Ze.of(e.slice(0,t)),o,Ze.of(e.slice(n)))}}function Wr(i,e){return i==e?i:(i.constructor!=e.constructor&&(Tn=!0),e)}Ze.prototype.size=1;class Qp extends Ze{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,s){return new Vt(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 ct extends Qp{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,s){return new Vt(s,this.length,n,this.height,this.breaks)}replace(e,t,n){let s=n[0];return n.length==1&&(s instanceof ct||s instanceof Le&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof Le?s=new ct(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):Ze.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 Le extends Ze{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 c=s+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),u=t.doc.lineAt(c),d=l+u.length*a,f=Math.max(n,e-d/2);return new Vt(u.from,u.length,f,d,0)}else{let c=Math.max(0,Math.min(o-r,Math.floor((e-n)/l))),{from:u,length:d}=t.doc.line(r+c);return new Vt(u,d,n+l*c,l,0)}}lineAt(e,t,n,s,r){if(t==ye.ByHeight)return this.blockAt(e,n,s,r);if(t==ye.ByPosNoHeight){let{from:p,to:m}=n.doc.lineAt(e);return new Vt(p,m-p,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(n,r),c=n.doc.lineAt(e),u=l+c.length*a,d=c.number-o,f=s+l*d+a*(c.from-r-d);return new Vt(c.from,c.length,Math.max(s,Math.min(f,s+this.height-u)),u,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:c}=this.heightMetrics(n,r);for(let u=e,d=s;u<=t;){let f=n.doc.lineAt(u);if(u==e){let m=f.number-l;d+=a*m+c*(e-r-m)}let p=a+c*f.length;o(new Vt(f.from,f.length,d,p,0)),d+=p,u=f.to+1}}replace(e,t,n){let s=this.length-t;if(s>0){let r=n[n.length-1];r instanceof Le?n[n.length-1]=new Le(r.length+s):n.push(null,new Le(s-1))}if(e>0){let r=n[0];r instanceof Le?n[0]=new Le(e+r.length):n.unshift(new Le(e-1),null)}return Ze.of(n)}decomposeLeft(e,t){t.push(new Le(e-1),null)}decomposeRight(e,t){t.push(null,new Le(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 Le(s.from-t-1).updateHeight(e,t));l<=r&&s.more;){let u=e.doc.lineAt(l).length;o.length&&o.push(null);let d=s.heights[s.index++];a==-1?a=d:Math.abs(d-a)>=Er&&(a=-2);let f=new ct(u,d);f.outdated=!1,o.push(f),l+=u+1}l<=r&&o.push(null,new Le(r-l).updateHeight(e,l));let c=Ze.of(o);return(a<0||Math.abs(c.height-this.height)>=Er||Math.abs(a-this.heightMetrics(e,t).perLine)>=Er)&&(Tn=!0),Wr(this,c)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class EC extends Ze{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==ye.ByHeight?e<o:e<l,c=a?this.left.lineAt(e,t,n,s,r):this.right.lineAt(e,t,n,o,l);if(this.break||(a?c.to<l:c.from>l))return c;let u=t==ye.ByPosNoHeight?ye.ByPosNoHeight:ye.ByPos;return a?c.join(this.right.lineAt(l,u,n,o,l)):this.left.lineAt(l,u,n,s,r).join(c)}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 c=this.lineAt(a,ye.ByPos,n,s,r);e<c.from&&this.left.forEachLine(e,c.from-1,n,s,r,o),c.to>=e&&c.from<=t&&o(c),t>c.to&&this.right.forEachLine(c.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&&uh(r,o-1),t<this.length){let l=r.length;this.decomposeRight(t,r),uh(r,l)}return Ze.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?Ze.of(this.break?[e,null,t]:[e,t]):(this.left=Wr(this.left,e),this.right=Wr(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 uh(i,e){let t,n;i[e]==null&&(t=i[e-1])instanceof Le&&(n=i[e+1])instanceof Le&&i.splice(e-1,3,new Le(t.length+1+n.length))}const CC=5;class Ec{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 ct?s.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new ct(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 Qp(o,s,n)):(o||r||s>=CC)&&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 ct(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new Le(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 ct)return e;let t=new ct(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 ct)&&!this.isCovered?this.nodes.push(new ct(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 ct&&s.updateHeight(this.oracle,n),n+=s?s.length:1;return this.nodes}static build(e,t,n,s){let r=new Ec(n,e);return re.spans(t,n,s,r,0),r.finish(n)}}function RC(i,e,t){let n=new wC;return re.compare(i,e,t,n,0),n.changes}class wC{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,s){(e<t||n&&n.heightRelevant||s&&s.heightRelevant)&&vr(e,t,this.changes,5)}}function kC(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 c=i.parentNode;c&&c!=n.body;)if(c.nodeType==1){let u=c,d=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&d.overflow!="visible"){let f=u.getBoundingClientRect();r=Math.max(r,f.left),o=Math.min(o,f.right),l=Math.max(l,f.top),a=Math.min(c==i.parentNode?s.innerHeight:a,f.bottom)}c=d.position=="absolute"||d.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.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 TC(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 AC(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class cl{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 jC(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class jC extends ai{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 hh{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=dh,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=be.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(bc).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new SC(t),this.stateDeco=e.facet(fs).filter(n=>typeof n!="function"),this.heightMap=Ze.empty().applyChanges(this.stateDeco,oe.empty,this.heightOracle.setDoc(e.doc),[new bt(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 tr(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?dh:new Cc(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(Un(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(fs).filter(u=>typeof u!="function");let s=e.changedRanges,r=bt.extendWithRanges(s,RC(n,this.stateDeco,e?e.changes:je.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);ch(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||Tn)&&(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 c=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(c||!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"?be.RTL:be.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 c=0,u=0;if(l.width&&l.height){let{scaleX:E,scaleY:v}=rp(t,l);(E>.005&&Math.abs(this.scaleX-E)>.005||v>.005&&Math.abs(this.scaleY-v)>.005)&&(this.scaleX=E,this.scaleY=v,c|=16,o=a=!0)}let d=(parseInt(n.paddingTop)||0)*this.scaleY,f=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=d||this.paddingBottom!=f)&&(this.paddingTop=d,this.paddingBottom=f,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let p=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=p&&(this.scrollAnchorHeight=-1,this.scrollTop=p),this.scrolledToBottom=ap(e.scrollDOM);let m=(this.printing?AC:kC)(t,this.paddingTop),g=m.top-this.pixelViewport.top,x=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;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&&!TC(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,c|=16),a){let E=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(E)&&(o=!0),o||s.lineWrapping&&Math.abs(b-this.contentDOMWidth)>s.charWidth){let{lineHeight:v,charWidth:C,textHeight:k}=e.docView.measureTextSize();o=v>0&&s.refresh(r,v,C,k,Math.max(5,b/C),E),o&&(e.docView.minWidth=0,c|=16)}g>0&&x>0?u=Math.max(g,x):g<0&&x<0&&(u=Math.min(g,x)),ch();for(let v of this.viewports){let C=v.from==this.viewport.from?E:e.docView.measureVisibleLineHeights(v);this.heightMap=(o?Ze.empty().applyChanges(this.stateDeco,oe.empty,this.heightOracle,[new bt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new vC(v.from,C))}Tn&&(c|=2)}let S=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return S&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),c|=this.updateForViewport()),(c&2||S)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}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 tr(s.lineAt(o-n*1e3,ye.ByHeight,r,0,0).from,s.lineAt(l+(1-n)*1e3,ye.ByHeight,r,0,0).to);if(t){let{head:c}=t.range;if(c<a.from||c>a.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),d=s.lineAt(c,ye.ByPos,r,0,0),f;t.y=="center"?f=(d.top+d.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&c<a.from?f=d.top:f=d.bottom-u,a=new tr(s.lineAt(f-1e3/2,ye.ByHeight,r,0,0).from,s.lineAt(f+u+1e3/2,ye.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 tr(this.heightMap.lineAt(n,ye.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,ye.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,ye.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,ye.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 cl(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!=be.LTR&&!n)return[];let l=[],a=(u,d,f,p)=>{if(d-u<r)return;let m=this.state.selection.main,g=[m.from];m.empty||g.push(m.to);for(let y of g)if(y>u&&y<d){a(u,y-10,f,p),a(y+10,d,f,p);return}let x=OC(e,y=>y.from>=f.from&&y.to<=f.to&&Math.abs(y.from-u)<r&&Math.abs(y.to-d)<r&&!g.some(b=>y.from<b&&y.to>b));if(!x){if(d<f.to&&t&&n&&t.visibleRanges.some(S=>S.from<=d&&S.to>=d)){let S=t.moveToLineBoundary(j.cursor(d),!1,!0).head;S>u&&(d=S)}let y=this.gapSize(f,u,d,p),b=n||y<2e6?y:2e6;x=new cl(u,d,y,b)}l.push(x)},c=u=>{if(u.length<o||u.type!=Je.Text)return;let d=IC(u.from,u.to,this.stateDeco);if(d.total<o)return;let f=this.scrollTarget?this.scrollTarget.range.head:null,p,m;if(n){let g=s/this.heightOracle.lineLength*this.heightOracle.lineHeight,x,y;if(f!=null){let b=nr(d,f),S=((this.visibleBottom-this.visibleTop)/2+g)/u.height;x=b-S,y=b+S}else x=(this.visibleTop-u.top-g)/u.height,y=(this.visibleBottom-u.top+g)/u.height;p=ir(d,x),m=ir(d,y)}else{let g=d.total*this.heightOracle.charWidth,x=s*this.heightOracle.charWidth,y=0;if(g>2e6)for(let C of e)C.from>=u.from&&C.from<u.to&&C.size!=C.displaySize&&C.from*this.heightOracle.charWidth+y<this.pixelViewport.left&&(y=C.size-C.displaySize);let b=this.pixelViewport.left+y,S=this.pixelViewport.right+y,E,v;if(f!=null){let C=nr(d,f),k=((S-b)/2+x)/g;E=C-k,v=C+k}else E=(b-x)/g,v=(S+x)/g;p=ir(d,E),m=ir(d,v)}p>u.from&&a(u.from,p,u,d),m<u.to&&a(m,u.to,u,d)};for(let u of this.viewportLines)Array.isArray(u.type)?u.type.forEach(c):c(u);return l}gapSize(e,t,n,s){let r=nr(s,n)-nr(s,t);return this.heightOracle.lineWrapping?e.height*r:s.total*this.heightOracle.charWidth*r}updateLineGaps(e){cl.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)||Un(this.heightMap.lineAt(e,ye.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)||Un(this.heightMap.lineAt(this.scaler.fromDOM(e),ye.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 Un(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 tr{constructor(e,t){this.from=e,this.to=t}}function IC(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 ir({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 nr(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 OC(i,e){for(let t of i)if(e(t))return t}const dh={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}};class Cc{constructor(e,t,n){let s=0,r=0,o=0;this.viewports=n.map(({from:l,to:a})=>{let c=t.lineAt(l,ye.ByPos,e,0,0).top,u=t.lineAt(a,ye.ByPos,e,0,0).bottom;return s+=u-c,{from:l,to:a,top:c,bottom:u,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 Cc?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 Un(i,e){if(e.scale==1)return i;let t=e.toDOM(i.top),n=e.toDOM(i.bottom);return new Vt(i.from,i.length,t,n-t,Array.isArray(i._content)?i._content.map(s=>Un(s,e)):i._content)}const sr=G.define({combine:i=>i.join(" ")}),Ea=G.define({combine:i=>i.indexOf(!0)>-1}),Ca=wi.newName(),Jp=wi.newName(),Zp=wi.newName(),em={"&light":"."+Jp,"&dark":"."+Zp};function Ra(i,e,t){return new wi(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 MC=Ra("."+Ca,{"&":{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"}},em),PC={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},ul=H.ie&&H.ie_version<=11;class DC{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new gE,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);(H.ie&&H.ie_version<=11||H.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&&H.android&&e.constructor.EDIT_CONTEXT!==!1&&!(H.chrome&&H.chrome_version<126)&&(this.editContext=new NC(e),e.state.facet(ei)&&(e.contentDOM.editContext=this.editContext.editContext)),ul&&(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(ei)?n.root.activeElement!=this.dom:!Sr(this.dom,s))return;let r=s.anchorNode&&n.docView.nearest(s.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(H.ie&&H.ie_version<=11||H.android&&H.chrome)&&!n.state.selection.main.empty&&s.focusNode&&Qn(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=ds(e.root);if(!t)return!1;let n=H.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&LC(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let s=Sr(this.dom,n);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&yE(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,PC),ul&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),ul&&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&&xn(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&&Sr(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 ZE(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=$p(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=fh(t,e.previousSibling||e.target.previousSibling,-1),s=fh(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(ei)!=e.state.facet(ei)&&(e.view.contentDOM.editContext=e.state.facet(ei)?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 fh(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 ph(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 Qn(o.node,o.offset,s,r)&&([t,n,s,r]=[s,r,t,n]),{anchorNode:t,anchorOffset:n,focusNode:s,focusOffset:r}}function LC(i,e){if(e.getComposedRanges){let s=e.getComposedRanges(i.root)[0];if(s)return ph(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?ph(i,t):null}class NC{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 c=a-l>n.text.length;l==this.from&&r<this.from?l=r:a==this.to&&r>this.to&&(a=r);let u=zp(e.state.sliceDoc(l,a),n.text,(c?s.from:s.to)-l,c?"end":null);if(!u){let f=j.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));f.main.eq(s)||e.dispatch({selection:f,userEvent:"select"});return}let d={from:u.from+l,to:u.toA+l,insert:oe.of(n.text.slice(u.from,u.toB).split(`
|
|
32
|
+
`))};if((H.mac||H.android)&&d.from==o-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(d={from:l,to:a,insert:oe.of([n.text.replace("."," ")])}),this.pendingContextChange=d,!e.state.readOnly){let f=this.to-this.from+(d.to-d.from+d.insert.length);vc(e,d,j.single(this.toEditorPos(n.selectionStart,f),this.toEditorPos(n.selectionEnd,f)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),d.from<d.to&&!d.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),c=this.toEditorPos(r.rangeEnd);if(a<c){let u=`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:u}}).range(a,c))}}}e.dispatch({effects:Mp.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=ds(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,c)=>{if(n)return;let u=c.length-(o-r);if(s&&o>=s.to)if(s.from==r&&s.to==o&&s.insert.eq(c)){s=this.pendingContextChange=null,t+=u,this.to+=u;return}else s=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=u,this.to+=u;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),c.toString()),this.to+=u}t+=u}),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 z{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||xE(e.parent)||document,this.viewState=new hh(e.state||se.create(e)),e.scrollTo&&e.scrollTo.is(Js)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(an).map(s=>new ol(s));for(let s of this.plugins)s.update(this);this.observer=new DC(this),this.inputState=new nC(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Wu(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 Ie?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(Kp))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Yp(r,o),a||(l=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(u=null)):this.observer.clear(),r.facet(se.phrases)!=this.state.facet(se.phrases))return this.setState(r);s=Ur.create(this,r,e),s.flags|=l;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(d&&(d=d.map(f.changes)),f.scrollIntoView){let{main:p}=f.state.selection;d=new yn(p.empty?p:j.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of f.effects)p.is(Js)&&(d=p.value.clip(this.state))}this.viewState.update(s,d),this.bidiCache=qr.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(Hn)!=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(sr)!=s.state.facet(sr)&&(this.viewState.mustMeasureContent=!0),(t||n||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let f of this.state.facet(ya))try{f(s)}catch(p){it(this.state,p,"update listener")}(a||u)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),u&&!$p(this,u)&&c.force&&xn(this.contentDOM,c.key,c.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 hh(e),this.plugins=e.facet(an).map(n=>new ol(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new Wu(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(an),n=e.state.facet(an);if(t!=n){let s=[];for(let r of n){let o=t.indexOf(r);if(o<0)s.push(new ol(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){it(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(ap(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 c=[];a&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(p=>{try{return p.read(this)}catch(m){return it(this.state,m),mh}}),d=Ur.create(this,this.state,[]),f=!1;d.flags|=a,t?t.flags|=a:t=d,this.updateState=2,d.empty||(this.updatePlugins(d),this.inputState.update(d),this.updateAttrs(),f=this.docView.update(d),f&&this.docViewUpdate());for(let p=0;p<c.length;p++)if(u[p]!=mh)try{let m=c[p];m.write&&m.write(u[p],this)}catch(m){it(this.state,m)}if(f&&this.docView.updateSelection(!0),!d.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 m=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-o;if(m>1||m<-1){s=s+m,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(ya))l(t)}get themeClasses(){return Ca+" "+(this.state.facet(Ea)?Zp:Jp)+" "+this.state.facet(sr)}updateAttrs(){let e=gh(this,Pp,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(ei)?"true":"false",class:"cm-content",style:`${H.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),gh(this,bc,t);let n=this.observer.ignore(()=>{let s=fa(this.contentDOM,this.contentAttrs,t),r=fa(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(z.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(Hn);let e=this.state.facet(z.cspNonce);wi.mount(this.root,this.styleModules.concat(MC).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 al(this,e,Qu(this,e,t,n))}moveByGroup(e,t){return al(this,e,Qu(this,e,t,n=>KE(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 j.cursor(r.side(t,s)+e.from,r.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,n=!0){return qE(this,e,t,n)}moveVertically(e,t,n){return al(this,e,YE(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(),Bp(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[bi.find(r,e-s.from,-1,t)];return js(n,o.dir==be.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(jp)||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>FC)return vp(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||Sp(r.isolates,n=Uu(this,e))))return r.order;n||(n=Uu(this,e));let s=OE(e.text,t,n);return this.bidiCache.push(new qr(e.from,e.to,t,n,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||H.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{op(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 Js.of(new yn(typeof e=="number"?j.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 Js.of(new yn(j.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=wi.newName(),s=[sr.of(n),Hn.of(Ra(`.${n}`,e))];return t&&t.dark&&s.push(Ea.of(!0)),s}static baseTheme(e){return Qi.lowest(Hn.of(Ra("."+Ca,e,em)))}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}}z.styleModule=Hn;z.inputHandler=Tp;z.clipboardInputFilter=xc;z.clipboardOutputFilter=yc;z.scrollHandler=Op;z.focusChangeEffect=Ap;z.perLineTextDirection=jp;z.exceptionSink=kp;z.updateListener=ya;z.editable=ei;z.mouseSelectionStyle=wp;z.dragMovesSelection=Rp;z.clickAddsSelectionRange=Cp;z.decorations=fs;z.outerDecorations=Dp;z.atomicRanges=Ms;z.bidiIsolatedRanges=Lp;z.scrollMargins=Np;z.darkTheme=Ea;z.cspNonce=G.define({combine:i=>i.length?i[0]:""});z.contentAttributes=bc;z.editorAttributes=Pp;z.lineWrapping=z.contentAttributes.of({class:"cm-lineWrapping"});z.announce=J.define();const FC=4096,mh={};class qr{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:be.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 qr(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function gh(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&&da(o,t)}return t}const BC=H.mac?"mac":H.windows?"win":H.linux?"linux":"key";function VC(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 c=t[a];if(/^(cmd|meta|m)$/i.test(c))l=!0;else if(/^a(lt)?$/i.test(c))s=!0;else if(/^(c|ctrl|control)$/i.test(c))r=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))e=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+c)}return s&&(n="Alt-"+n),r&&(n="Ctrl-"+n),l&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function rr(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 _C=Qi.default(z.domEventHandlers({keydown(i,e){return im(tm(e.state),i,e,"editor")}})),Co=G.define({enables:_C}),xh=new WeakMap;function tm(i){let e=i.facet(Co),t=xh.get(e);return t||xh.set(e,t=HC(e.reduce((n,s)=>n.concat(s),[]))),t}function $C(i,e,t){return im(tm(i.state),e,i,t)}let mi=null;const zC=4e3;function HC(i,e=BC){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,c,u)=>{var d,f;let p=t[o]||(t[o]=Object.create(null)),m=l.split(/ (?!$)/).map(y=>VC(y,e));for(let y=1;y<m.length;y++){let b=m.slice(0,y).join(" ");s(b,!0),p[b]||(p[b]={preventDefault:!0,stopPropagation:!1,run:[S=>{let E=mi={view:S,prefix:b,scope:o};return setTimeout(()=>{mi==E&&(mi=null)},zC),!0}]})}let g=m.join(" ");s(g,!1);let x=p[g]||(p[g]={preventDefault:!1,stopPropagation:!1,run:((f=(d=p._any)===null||d===void 0?void 0:d.run)===null||f===void 0?void 0:f.slice())||[]});a&&x.run.push(a),c&&(x.preventDefault=!0),u&&(x.stopPropagation=!0)};for(let o of i){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of l){let u=t[c]||(t[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:d}=o;for(let f in u)u[f].run.push(p=>d(p,wa))}let a=o[e]||o.key;if(a)for(let c of l)r(c,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(c,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}let wa=null;function im(i,e,t,n){wa=e;let s=hE(e),r=et(s,0),o=Bt(r)==s.length&&s!=" ",l="",a=!1,c=!1,u=!1;mi&&mi.view==t&&mi.scope==n&&(l=mi.prefix+" ",Gp.indexOf(e.keyCode)<0&&(c=!0,mi=null));let d=new Set,f=x=>{if(x){for(let y of x.run)if(!d.has(y)&&(d.add(y),y(t)))return x.stopPropagation&&(u=!0),!0;x.preventDefault&&(x.stopPropagation&&(u=!0),c=!0)}return!1},p=i[n],m,g;return p&&(f(p[l+rr(s,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(H.windows&&e.ctrlKey&&e.altKey)&&!(H.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(m=ki[e.keyCode])&&m!=s?(f(p[l+rr(m,e,!0)])||e.shiftKey&&(g=hs[e.keyCode])!=s&&g!=m&&f(p[l+rr(g,e,!1)]))&&(a=!0):o&&e.shiftKey&&f(p[l+rr(s,e,!0)])&&(a=!0),!a&&f(p._any)&&(a=!0)),c&&(a=!0),a&&u&&e.stopPropagation(),wa=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=nm(e);return[new Ps(t,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return GC(e,t,n)}}function nm(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==be.LTR?e.left:e.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:e.top-i.scrollDOM.scrollTop*i.scaleY}}function yh(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 GC(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==be.LTR,o=i.contentDOM,l=o.getBoundingClientRect(),a=nm(i),c=o.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),d=l.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=l.right-(u?parseInt(u.paddingRight):0),p=Sa(i,n,1),m=Sa(i,s,-1),g=p.type==Je.Text?p:null,x=m.type==Je.Text?m:null;if(g&&(i.lineWrapping||p.widgetLineBreaks)&&(g=yh(i,n,1,g)),x&&(i.lineWrapping||m.widgetLineBreaks)&&(x=yh(i,s,-1,x)),g&&x&&g.from==x.from&&g.to==x.to)return b(S(t.from,t.to,g));{let v=g?S(t.from,null,g):E(p,!1),C=x?S(null,t.to,x):E(m,!0),k=[];return(g||p).to<(x||m).from-(g&&x?1:0)||p.widgetLineBreaks>1&&v.bottom+i.defaultLineHeight/2<C.top?k.push(y(d,v.bottom,f,C.top)):v.bottom<C.top&&i.elementAtHeight((v.bottom+C.top)/2).type==Je.Text&&(v.bottom=C.top=(v.bottom+C.top)/2),b(v).concat(k).concat(b(C))}function y(v,C,k,O){return new Ps(e,v-a.left,C-a.top,k-v,O-C)}function b({top:v,bottom:C,horizontal:k}){let O=[];for(let w=0;w<k.length;w+=2)O.push(y(k[w],v,k[w+1],C));return O}function S(v,C,k){let O=1e9,w=-1e9,D=[];function N(P,B,W,ee,ae){let ne=i.coordsAtPos(P,P==k.to?-2:2),te=i.coordsAtPos(W,W==k.from?2:-2);!ne||!te||(O=Math.min(ne.top,te.top,O),w=Math.max(ne.bottom,te.bottom,w),ae==be.LTR?D.push(r&&B?d:ne.left,r&&ee?f:te.right):D.push(!r&&ee?d:te.left,!r&&B?f:ne.right))}let F=v??k.from,_=C??k.to;for(let P of i.visibleRanges)if(P.to>F&&P.from<_)for(let B=Math.max(P.from,F),W=Math.min(P.to,_);;){let ee=i.state.doc.lineAt(B);for(let ae of i.bidiSpans(ee)){let ne=ae.from+ee.from,te=ae.to+ee.from;if(ne>=W)break;te>B&&N(Math.max(ne,B),v==null&&ne<=F,Math.min(te,W),C==null&&te>=_,ae.dir)}if(B=ee.to+1,B>=W)break}return D.length==0&&N(F,v==null,_,C==null,i.textDirection),{top:O,bottom:w,horizontal:D}}function E(v,C){let k=l.top+(C?v.top:v.bottom);return{top:k,bottom:k,horizontal:[]}}}function UC(i,e){return i.constructor==e.constructor&&i.eq(e)}class WC{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(Cr)!=e.state.facet(Cr)&&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(Cr);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)=>!UC(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,H.safari&&H.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 Cr=G.define();function sm(i){return[Ce.define(e=>new WC(e,i)),Cr.of(i)]}const ps=G.define({combine(i){return Yt(i,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function qC(i={}){return[ps.of(i),KC,YC,XC,Ip.of(!0)]}function rm(i){return i.startState.facet(ps)!=i.state.facet(ps)}const KC=sm({above:!0,markers(i){let{state:e}=i,t=e.facet(ps),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:j.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=rm(i);return t&&bh(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){bh(e.state,i)},class:"cm-cursorLayer"});function bh(i,e){e.style.animationDuration=i.facet(ps).cursorBlinkRate+"ms"}const YC=sm({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||rm(i)},class:"cm-selectionLayer"}),XC=Qi.highest(z.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"}}}})),om=J.define({map(i,e){return i==null?null:e.mapPos(i)}}),Wn=Ve.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(om)?n.value:t,i)}}),QC=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(Wn);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(Wn)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:i}=this,e=i.state.field(Wn),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(Wn)!=i&&this.view.dispatch({effects:om.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 JC(){return[Wn,QC]}function Sh(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 ZC(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 eR{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,c,u)=>s(u,c,c+l[0].length,l,a);else if(typeof n=="function")this.addMatch=(l,a,c,u)=>{let d=n(l,a,c);d&&u(c,c+l[0].length,d)};else if(n)this.addMatch=(l,a,c,u)=>u(c,c+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 ri,n=t.add.bind(t);for(let{from:s,to:r}of ZC(e,this.maxLength))Sh(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),c=a.to<l?e.state.doc.lineAt(l):a,u=Math.max(r.from,a.from),d=Math.min(r.to,c.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){u=o;break}for(;l<c.to;l++)if(this.boundary.test(c.text[l-c.from])){d=l;break}}let f=[],p,m=(g,x,y)=>f.push(y.range(g,x));if(a==c)for(this.regexp.lastIndex=u-a.from;(p=this.regexp.exec(a.text))&&p.index<d-a.from;)this.addMatch(p,e,p.index+a.from,m);else Sh(e.state.doc,this.regexp,u,d,(g,x)=>this.addMatch(x,e,g,m));t=t.update({filterFrom:u,filterTo:d,filter:(g,x)=>g<u||x>d,add:f})}}return t}}const ka=/x/.unicode!=null?"gu":"g",tR=new RegExp(`[\0-\b
|
|
33
|
+
--\u2028\u2029\uFEFF-]`,ka),iR={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 hl=null;function nR(){var i;if(hl==null&&typeof document<"u"&&document.body){let e=document.body.style;hl=((i=e.tabSize)!==null&&i!==void 0?i:e.MozTabSize)!=null}return hl||!1}const Rr=G.define({combine(i){let e=Yt(i,{render:null,specialChars:tR,addSpecialChars:null});return(e.replaceTabs=!nR())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,ka)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,ka)),e}});function sR(i={}){return[Rr.of(i),rR()]}let vh=null;function rR(){return vh||(vh=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 eR({regexp:i.specialChars,decoration:(e,t,n)=>{let{doc:s}=t.state,r=et(e[0],0);if(r==9){let o=s.lineAt(n),l=t.state.tabSize,a=On(o.text,l,n-o.from);return K.replace({widget:new cR((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=K.replace({widget:new aR(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 oR="•";function lR(i){return i>=32?oR:i==10?"":String.fromCharCode(9216+i)}class aR extends ai{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=lR(this.code),n=e.state.phrase("Control character")+" "+(iR[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 cR extends ai{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 uR(){return dR}const hR=K.line({class:"cm-activeLine"}),dR=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(hR.range(s.from)),e=s.from)}return K.set(t)}},{decorations:i=>i.decorations});class fR extends ai{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?Rn(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),s=js(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 pR(i){let e=Ce.fromClass(class{constructor(t){this.view=t,this.placeholder=i?K.set([K.widget({widget:new fR(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,z.contentAttributes.of({"aria-placeholder":i})]:e}const Ta=2e3;function mR(i,e,t){let n=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>Ta||t.off>Ta||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 c=i.doc.line(a);c.length<=l&&r.push(j.range(c.from+o,c.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 c=i.doc.line(a),u=sa(c.text,o,i.tabSize,!0);if(u<0)r.push(j.cursor(c.to));else{let d=sa(c.text,l,i.tabSize);r.push(j.range(c.from+u,c.from+d))}}}return r}function gR(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function Eh(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>Ta?-1:s==n.length?gR(i,e.clientX):On(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:r,off:s}}function xR(i,e){let t=Eh(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=Eh(i,s);if(!l)return n;let a=mR(i.state,t,l);return a.length?o?j.create(a.concat(n.ranges)):j.create(a):n}}:null}function yR(i){let e=(t=>t.altKey&&t.button==0);return z.mouseSelectionStyle.of((t,n)=>e(n)?xR(t,n):null)}const bR={Alt:[18,i=>!!i.altKey],Control:[17,i=>!!i.ctrlKey],Shift:[16,i=>!!i.shiftKey],Meta:[91,i=>!!i.metaKey]},SR={style:"cursor: crosshair"};function vR(i={}){let[e,t]=bR[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,z.contentAttributes.of(s=>{var r;return!((r=s.plugin(n))===null||r===void 0)&&r.isDown?SR:null})]}const or="-10000px";class lm{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 c=r[a],u=-1;if(c){for(let d=0;d<this.tooltips.length;d++){let f=this.tooltips[d];f&&f.create==c.create&&(u=d)}if(u<0)o[a]=this.createTooltipView(c,a?o[a-1]:null),l&&(l[a]=!!c.above);else{let d=o[a]=this.tooltipViews[u];l&&(l[a]=t[u]),d.update&&d.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,c)=>t[c]=a),t.length=l.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}}function ER(i){let e=i.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const dl=G.define({combine:i=>{var e,t,n;return{position:H.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)||ER}}}),Ch=new WeakMap,Rc=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(dl);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 lm(i,wc,(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(dl);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=or,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(H.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=Sc(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(dl).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],c=this.manager.tooltipViews[l],{dom:u}=c,d=i.pos[l],f=i.size[l];if(!d||a.clip!==!1&&(d.bottom<=Math.max(t.top,n.top)||d.top>=Math.min(t.bottom,n.bottom)||d.right<Math.max(t.left,n.left)-.1||d.left>Math.min(t.right,n.right)+.1)){u.style.top=or;continue}let p=a.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,m=p?7:0,g=f.right-f.left,x=(e=Ch.get(c))!==null&&e!==void 0?e:f.bottom-f.top,y=c.offset||RR,b=this.view.textDirection==be.LTR,S=f.width>n.right-n.left?b?n.left:n.right-f.width:b?Math.max(n.left,Math.min(d.left-(p?14:0)+y.x,n.right-g)):Math.min(Math.max(n.left,d.left-g+(p?14:0)-y.x),n.right-g),E=this.above[l];!a.strictSide&&(E?d.top-x-m-y.y<n.top:d.bottom+x+m+y.y>n.bottom)&&E==n.bottom-d.bottom>d.top-n.top&&(E=this.above[l]=!E);let v=(E?d.top-n.top:n.bottom-d.bottom)-m;if(v<x&&c.resize!==!1){if(v<this.view.defaultLineHeight){u.style.top=or;continue}Ch.set(c,x),u.style.height=(x=v)/r+"px"}else u.style.height&&(u.style.height="");let C=E?d.top-x-m-y.y:d.bottom+m+y.y,k=S+g;if(c.overlap!==!0)for(let O of o)O.left<k&&O.right>S&&O.top<C+x&&O.bottom>C&&(C=E?O.top-x-2-m:O.bottom+m+2);if(this.position=="absolute"?(u.style.top=(C-i.parent.top)/r+"px",Rh(u,(S-i.parent.left)/s)):(u.style.top=C/r+"px",Rh(u,S/s)),p){let O=d.left+(b?y.x:-y.x)-(S+14-7);p.style.left=O/s+"px"}c.overlap!==!0&&o.push({left:S,top:C,right:k,bottom:C+x}),u.classList.toggle("cm-tooltip-above",E),u.classList.toggle("cm-tooltip-below",!E),c.positioned&&c.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=or}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Rh(i,e){let t=parseInt(i.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(i.style.left=e+"px")}const CR=z.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"}}}),RR={x:0,y:0},wc=G.define({enables:[Rc,CR]}),Kr=G.define({combine:i=>i.reduce((e,t)=>e.concat(t),[])});class Ro{static create(e){return new Ro(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new lm(e,Kr,(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 wR=wc.compute([Kr],i=>{let e=i.facet(Kr);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:Ro.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class kR{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 ti)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(u=>u.from<=s&&u.to>=s),c=a&&a.dir==be.RTL?-1:1;r=t.x<l.left?-c:c}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=>it(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(Rc),t=e?e.manager.tooltips.findIndex(n=>n.create==Ro.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&&!TR(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:!AR(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 lr=4;function TR(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-lr&&e.clientX<=n+lr&&e.clientY>=s-lr&&e.clientY<=r+lr}function AR(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 jR(i,e={}){let t=J.define(),n=Ve.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,Xe.TrackDel);if(a!=null){let c=Object.assign(Object.create(null),l);c.pos=a,c.end!=null&&(c.end=r.changes.mapPos(c.end)),o.push(c)}}s=o}for(let o of r.effects)o.is(t)&&(s=o.value),o.is(IR)&&(s=[]);return s},provide:s=>Kr.from(s)});return{active:n,extension:[n,Ce.define(s=>new kR(s,i,n,t,e.hoverTime||300)),wR]}}function am(i,e){let t=i.plugin(Rc);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}const IR=J.define(),wh=G.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 ms(i,e){let t=i.plugin(cm),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}const cm=Ce.fromClass(class{constructor(i){this.input=i.state.facet(gs),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(wh);this.top=new ar(i,!0,e.topContainer),this.bottom=new ar(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(wh);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new ar(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new ar(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(gs);if(t!=this.input){let n=t.filter(a=>a),s=[],r=[],o=[],l=[];for(let a of n){let c=this.specs.indexOf(a),u;c<0?(u=a(i.view),l.push(u)):(u=this.panels[c],u.update&&u.update(i)),s.push(u),(u.top?r:o).push(u)}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=>z.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class ar{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=kh(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=kh(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 kh(i){let e=i.nextSibling;return i.remove(),e}const gs=G.define({enables:cm});class li extends Ui{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}li.prototype.elementClass="";li.prototype.toDOM=void 0;li.prototype.mapMode=Xe.TrackBefore;li.prototype.startSide=li.prototype.endSide=-1;li.prototype.point=!0;const wr=G.define(),OR=G.define(),MR={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>re.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},es=G.define();function PR(i){return[um(),es.of({...MR,...i})]}const Th=G.define({combine:i=>i.some(e=>e)});function um(i){return[DR]}const DR=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(es).map(e=>new jh(i,e)),this.fixed=!i.state.facet(Th);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(Th)!=!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(wr),this.view.viewport.from),n=[],s=this.gutters.map(r=>new LR(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==Je.Text&&o){Aa(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==Je.Text){Aa(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(es),t=i.state.facet(es),n=i.docChanged||i.heightChanged||i.viewportChanged||!re.eq(i.startState.facet(wr),i.state.facet(wr),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 jh(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=>z.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==be.LTR?{left:n,right:s}:{right:n,left:s}})});function Ah(i){return Array.isArray(i)?i:[i]}function Aa(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}class LR{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 hm(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=[];Aa(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(OR)){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 jh{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=Ah(t.markers(e)),t.initialSpacer&&(this.spacer=new hm(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=Ah(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 hm{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":""),NR(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,c=!1;if(a){let u=a.elementClass;u&&(n+=" "+u);for(let d=o;d<this.markers.length;d++)if(this.markers[d].compare(a)){l=d,c=!0;break}}else l=this.markers.length;for(;o<l;){let u=this.markers[o++];if(u.toDOM){u.destroy(s);let d=s.nextSibling;s.remove(),s=d}}if(!a)break;a.toDOM&&(c?s=s.nextSibling:this.dom.insertBefore(a.toDOM(e),s)),c&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}}function NR(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 FR=G.define(),BR=G.define(),cn=G.define({combine(i){return Yt(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,c)=>r(l,a,c)||o(l,a,c):o}return n}})}});class fl extends li{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function pl(i,e){return i.state.facet(cn).formatNumber(e,i.state)}const VR=es.compute([cn],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(FR)},lineMarker(e,t,n){return n.some(s=>s.toDOM)?null:new fl(pl(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let s of e.state.facet(BR)){let r=s(e,t,n);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(cn)!=e.state.facet(cn),initialSpacer(e){return new fl(pl(e,Ih(e.state.doc.lines)))},updateSpacer(e,t){let n=pl(t.view,Ih(t.view.state.doc.lines));return n==e.number?e:new fl(n)},domEventHandlers:i.facet(cn).domEventHandlers,side:"before"}));function _R(i={}){return[cn.of(i),um(),VR]}function Ih(i){let e=9;for(;e<i;)e=e*10+9;return e}const $R=new class extends li{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},zR=wr.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($R.range(s)))}return re.of(e)});function HR(){return zR}var ml;const un=new ie;function GR(i){return G.define({combine:i?e=>e.concat(i):void 0})}const UR=new ie;class Rt{constructor(e,t,n=[],s=""){this.data=e,this.name=s,se.prototype.hasOwnProperty("tree")||Object.defineProperty(se.prototype,"tree",{get(){return We(this)}}),this.parser=t,this.extension=[Ai.of(this),se.languageData.of((r,o,l)=>{let a=Oh(r,o,l),c=a.type.prop(un);if(!c)return[];let u=r.facet(c),d=a.type.prop(UR);if(d){let f=a.resolve(o-a.from,l);for(let p of d)if(p.test(f,r)){let m=r.facet(p.facet);return p.type=="replace"?m:m.concat(u)}}return u})].concat(n)}isActiveAt(e,t,n=-1){return Oh(e,t,n).type.prop(un)==this.data}findRegions(e){let t=e.facet(Ai);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(un)==this.data){n.push({from:o,to:o+r.length});return}let l=r.prop(ie.mounted);if(l){if(l.tree.prop(un)==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 c=r.children[a];c instanceof Te&&s(c,r.positions[a]+o)}};return s(We(e),0),n}get allowsNesting(){return!0}}Rt.setState=J.define();function Oh(i,e,t){let n=i.facet(Ai),s=We(i).topNode;if(!n||n.allowsNesting)for(let r=s;r;r=r.enter(e,t,Pe.ExcludeBuffers))r.type.isTop&&(s=r);return s}class Yr extends Rt{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=GR(e.languageData);return new Yr(t,e.parser.configure({props:[un.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new Yr(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function We(i){let e=i.field(Rt.state,!1);return e?e.tree:Te.empty}class WR{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 _n=null;class Xr{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 Xr(e,t,[],Te.empty,0,n,[],null)}startParse(){return this.parser.startParse(new WR(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Te.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(Hi.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(Hi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=_n;_n=this;try{return e()}finally{_n=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Mh(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((c,u,d,f)=>a.push({fromA:c,toA:u,fromB:d,toB:f})),n=Hi.applyChanges(n,a),s=Te.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),d=e.mapPos(c.to,-1);u<d&&l.push({from:u,to:d})}}}return new Xr(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=Mh(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=_n;if(a){for(let c of s)a.tempSkipped.push(c);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Te(rt.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 _n}}function Mh(i,e,t){return Hi.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}class An{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 An(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Xr.create(e.facet(Ai).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new An(n)}}Rt.state=Ve.define({create:An.init,update(i,e){for(let t of e.effects)if(t.is(Rt.setState))return t.value;return e.startState.facet(Ai)!=e.state.facet(Ai)?An.init(e.state):i.apply(e)}});let dm=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(dm=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const gl=typeof navigator<"u"&&(!((ml=navigator.scheduling)===null||ml===void 0)&&ml.isInputPending)?()=>navigator.scheduling.isInputPending():null,qR=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(Rt.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(Rt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=dm(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(Rt.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!gl?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<s&&n.doc.length>s+1e3,a=r.context.work(()=>gl&&gl()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Rt.setState.of(new An(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=>it(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()}}}),Ai=G.define({combine(i){return i.length?i[0]:null},enables:i=>[Rt.state,qR,z.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});class KR{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const YR=G.define(),wo=G.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 Qr(i){let e=i.facet(wo);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function xs(i,e){let t="",n=i.tabSize,s=i.facet(wo)[0];if(s==" "){for(;e>=n;)t+=" ",e-=n;s=" "}for(let r=0;r<e;r++)t+=s;return t}function kc(i,e){i instanceof se&&(i=new ko(i));for(let n of i.state.facet(YR)){let s=n(i,e);if(s!==void 0)return s}let t=We(i.state);return t.length>=e?XR(i,t,e):null}class ko{constructor(e,t={}){this.state=e,this.options=t,this.unit=Qr(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 On(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 fm=new ie;function XR(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 pm(n,i,t)}function pm(i,e,t){for(let n=i;n;n=n.next){let s=JR(n.node);if(s)return s(Tc.create(e,t,n))}return 0}function QR(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function JR(i){let e=i.type.prop(fm);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(ie.closedBy))){let s=i.lastChild,r=s&&n.indexOf(s.name)>-1;return o=>i1(o,!0,1,void 0,r&&!QR(o)?s.from:void 0)}return i.parent==null?ZR:null}function ZR(){return 0}class Tc extends ko{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 Tc(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(e1(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return pm(this.context.next,this.base,this.pos)}}function e1(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function t1(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 c=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+c}}l=a.to}}function i1(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=t1(i);return a?l?i.column(a.from):i.column(a.to):i.baseIndent+(l?0:i.unit*t)}function Ph({except:i,units:e=1}={}){return t=>{let n=i&&i.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}const n1=200;function s1(){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+n1)return i;let r=t.sliceString(s.from,n);if(!e.some(c=>c.test(r)))return i;let{state:o}=i,l=-1,a=[];for(let{head:c}of o.selection.ranges){let u=o.doc.lineAt(c);if(u.from==l)continue;l=u.from;let d=kc(o,u.from);if(d==null)continue;let f=/^\s*/.exec(u.text)[0],p=xs(o,d);f!=p&&a.push({from:u.from,to:u.from+f.length,insert:p})}return a.length?[i,{changes:a,sequential:!0}]:i})}const r1=G.define(),mm=new ie;function o1(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 l1(i,e,t){let n=We(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(mm);if(a&&(l.to<n.length-50||n.length==i.doc.length||!a1(l))){let c=a(l,i);c&&c.from<=t&&c.from>=e&&c.to>t&&(r=c)}}return r}function a1(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function Jr(i,e,t){for(let n of i.facet(r1)){let s=n(i,e,t);if(s)return s}return l1(i,e,t)}function gm(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 To=J.define({map:gm}),Ds=J.define({map:gm});function xm(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 Yi=Ve.define({create(){return K.none},update(i,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((t,n)=>i=Dh(i,t,n)),i=i.map(e.changes);for(let t of e.effects)if(t.is(To)&&!c1(i,t.value.from,t.value.to)){let{preparePlaceholder:n}=e.state.facet(Sm),s=n?K.replace({widget:new g1(n(e.state,t.value))}):Lh;i=i.update({add:[s.range(t.value.from,t.value.to)]})}else t.is(Ds)&&(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=Dh(i,e.selection.main.head)),i},provide:i=>z.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(Lh.range(n,s))}return K.set(e,!0)}});function Dh(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 Zr(i,e,t){var n;let s=null;return(n=i.field(Yi,!1))===null||n===void 0||n.between(e,t,(r,o)=>{(!s||s.from>r)&&(s={from:r,to:o})}),s}function c1(i,e,t){let n=!1;return i.between(e,e,(s,r)=>{s==e&&r==t&&(n=!0)}),n}function ym(i,e){return i.field(Yi,!1)?e:e.concat(J.appendConfig.of(vm()))}const u1=i=>{for(let e of xm(i)){let t=Jr(i.state,e.from,e.to);if(t)return i.dispatch({effects:ym(i.state,[To.of(t),bm(i,t)])}),!0}return!1},h1=i=>{if(!i.state.field(Yi,!1))return!1;let e=[];for(let t of xm(i)){let n=Zr(i.state,t.from,t.to);n&&e.push(Ds.of(n),bm(i,n,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function bm(i,e,t=!0){let n=i.state.doc.lineAt(e.from).number,s=i.state.doc.lineAt(e.to).number;return z.announce.of(`${i.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${i.state.phrase("to")} ${s}.`)}const d1=i=>{let{state:e}=i,t=[];for(let n=0;n<e.doc.length;){let s=i.lineBlockAt(n),r=Jr(e,s.from,s.to);r&&t.push(To.of(r)),n=(r?i.lineBlockAt(r.to):s).to+1}return t.length&&i.dispatch({effects:ym(i.state,t)}),!!t.length},f1=i=>{let e=i.state.field(Yi,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,i.state.doc.length,(n,s)=>{t.push(Ds.of({from:n,to:s}))}),i.dispatch({effects:t}),!0},p1=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:u1},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:h1},{key:"Ctrl-Alt-[",run:d1},{key:"Ctrl-Alt-]",run:f1}],m1={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Sm=G.define({combine(i){return Yt(i,m1)}});function vm(i){return[Yi,b1]}function Em(i,e){let{state:t}=i,n=t.facet(Sm),s=o=>{let l=i.lineBlockAt(i.posAtDOM(o.target)),a=Zr(i.state,l.from,l.to);a&&i.dispatch({effects:Ds.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 Lh=K.replace({widget:new class extends ai{toDOM(i){return Em(i,null)}}});class g1 extends ai{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Em(e,this.value)}}const x1={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class xl extends li{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 y1(i={}){let e={...x1,...i},t=new xl(e,!0),n=new xl(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(Ai)!=o.state.facet(Ai)||o.startState.field(Yi,!1)!=o.state.field(Yi,!1)||We(o.startState)!=We(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new ri;for(let a of o.viewportLineBlocks){let c=Zr(o.state,a.from,a.to)?n:Jr(o.state,a.from,a.to)?t:null;c&&l.add(a.from,a.from,c)}return l.finish()}}),{domEventHandlers:r}=e;return[s,PR({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 xl(e,!1)},domEventHandlers:{...r,click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let c=Zr(o.state,l.from,l.to);if(c)return o.dispatch({effects:Ds.of(c)}),!0;let u=Jr(o.state,l.from,l.to);return u?(o.dispatch({effects:To.of(u)}),!0):!1}}}),vm()]}const b1=z.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 Ls{constructor(e,t){this.specs=e;let n;function s(l){let a=wi.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 Rt?l=>l.prop(un)==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 wi(n):null,this.themeType=t.themeType}static define(e,t){return new Ls(e,t||{})}}const ja=G.define(),Cm=G.define({combine(i){return i.length?[i[0]]:null}});function yl(i){let e=i.facet(ja);return e.length?e:i.facet(Cm)}function Rm(i,e){let t=[v1],n;return i instanceof Ls&&(i.module&&t.push(z.styleModule.of(i.module)),n=i.themeType),e!=null&&e.fallback?t.push(Cm.of(i)):n?t.push(ja.computeN([z.darkTheme],s=>s.facet(z.darkTheme)==(n=="dark")?[i]:[])):t.push(ja.of(i)),t}class S1{constructor(e){this.markCache=Object.create(null),this.tree=We(e.state),this.decorations=this.buildDeco(e,yl(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=We(e.state),n=yl(e.state),s=n!=yl(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 ri;for(let{from:s,to:r}of e.visibleRanges)Bv(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 v1=Qi.high(Ce.fromClass(S1,{decorations:i=>i.decorations})),E1=Ls.define([{tag:T.meta,color:"#404740"},{tag:T.link,textDecoration:"underline"},{tag:T.heading,textDecoration:"underline",fontWeight:"bold"},{tag:T.emphasis,fontStyle:"italic"},{tag:T.strong,fontWeight:"bold"},{tag:T.strikethrough,textDecoration:"line-through"},{tag:T.keyword,color:"#708"},{tag:[T.atom,T.bool,T.url,T.contentSeparator,T.labelName],color:"#219"},{tag:[T.literal,T.inserted],color:"#164"},{tag:[T.string,T.deleted],color:"#a11"},{tag:[T.regexp,T.escape,T.special(T.string)],color:"#e40"},{tag:T.definition(T.variableName),color:"#00f"},{tag:T.local(T.variableName),color:"#30a"},{tag:[T.typeName,T.namespace],color:"#085"},{tag:T.className,color:"#167"},{tag:[T.special(T.variableName),T.macroName],color:"#256"},{tag:T.definition(T.propertyName),color:"#00c"},{tag:T.comment,color:"#940"},{tag:T.invalid,color:"#f00"}]),C1=z.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),wm=1e4,km="()[]{}",Tm=G.define({combine(i){return Yt(i,{afterCursor:!0,brackets:km,maxScanDistance:wm,renderMatch:k1})}}),R1=K.mark({class:"cm-matchingBracket"}),w1=K.mark({class:"cm-nonmatchingBracket"});function k1(i){let e=[],t=i.matched?R1:w1;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 T1=Ve.define({create(){return K.none},update(i,e){if(!e.docChanged&&!e.selection)return i;let t=[],n=e.state.facet(Tm);for(let s of e.state.selection.ranges){if(!s.empty)continue;let r=_t(e.state,s.head,-1,n)||s.head>0&&_t(e.state,s.head-1,1,n)||n.afterCursor&&(_t(e.state,s.head,1,n)||s.head<e.state.doc.length&&_t(e.state,s.head+1,-1,n));r&&(t=t.concat(n.renderMatch(r,e.state)))}return K.set(t,!0)},provide:i=>z.decorations.from(i)}),A1=[T1,C1];function j1(i={}){return[Tm.of(i),A1]}const I1=new ie;function Ia(i,e,t){let n=i.prop(e<0?ie.openedBy:ie.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 Oa(i){let e=i.type.prop(I1);return e?e(i.node):i}function _t(i,e,t,n={}){let s=n.maxScanDistance||wm,r=n.brackets||km,o=We(i),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let c=Ia(a.type,t,r);if(c&&a.from<a.to){let u=Oa(a);if(u&&(t>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return O1(i,e,t,a,u,c,r)}}return M1(i,e,t,o,l.type,s,r)}function O1(i,e,t,n,s,r,o){let l=n.parent,a={from:s.from,to:s.to},c=0,u=l==null?void 0:l.cursor();if(u&&(t<0?u.childBefore(n.from):u.childAfter(n.to)))do if(t<0?u.to<=n.from:u.from>=n.to){if(c==0&&r.indexOf(u.type.name)>-1&&u.from<u.to){let d=Oa(u);return{start:a,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if(Ia(u.type,t,o))c++;else if(Ia(u.type,-t,o)){if(c==0){let d=Oa(u);return{start:a,end:d&&d.from<d.to?{from:d.from,to:d.to}:void 0,matched:!1}}c--}}while(t<0?u.prevSibling():u.nextSibling());return{start:a,matched:!1}}function M1(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 c={from:t<0?e-1:e,to:t>0?e+1:e},u=i.doc.iterRange(e,t>0?i.doc.length:0),d=0;for(let f=0;!u.next().done&&f<=r;){let p=u.value;t<0&&(f+=p.length);let m=e+f*t;for(let g=t>0?0:p.length-1,x=t>0?p.length:-1;g!=x;g+=t){let y=o.indexOf(p[g]);if(!(y<0||n.resolveInner(m+g,1).type!=s))if(y%2==0==t>0)d++;else{if(d==1)return{start:c,end:{from:m+g,to:m+g+1},matched:y>>1==a>>1};d--}}t>0&&(f+=p.length)}return u.done?{start:c,matched:!1}:null}const P1=Object.create(null),Nh=[rt.none],Fh=[],Bh=Object.create(null),D1=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"]])D1[i]=L1(P1,e);function bl(i,e){Fh.indexOf(i)>-1||(Fh.push(i),console.warn(e))}function L1(i,e){let t=[];for(let l of e.split(" ")){let a=[];for(let c of l.split(".")){let u=i[c]||T[c];u?typeof u=="function"?a.length?a=a.map(u):bl(c,`Modifier ${c} used at start of tag`):a.length?bl(c,`Tag ${c} used as modifier`):a=Array.isArray(u)?u:[u]:bl(c,`Unknown highlighting tag ${c}`)}for(let c of a)t.push(c)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+t.map(l=>l.id),r=Bh[s];if(r)return r.id;let o=Bh[s]=rt.define({id:Nh.length,name:n,props:[Nf({[n]:t})]});return Nh.push(o),o.id}be.RTL,be.LTR;const N1=Yr.define({name:"json",parser:zv.configure({props:[fm.add({Object:Ph({except:/^\s*\}/}),Array:Ph({except:/^\s*\]/})}),mm.add({"Object Array":o1})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function F1(){return new KR(N1)}const B1=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=jc(i.state,t.from);return n.line?V1(i):n.block?$1(i):!1};function Ac(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 V1=Ac(G1,0),_1=Ac(Am,0),$1=Ac((i,e)=>Am(i,e,H1(e)),0);function jc(i,e){let t=i.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const $n=50;function z1(i,{open:e,close:t},n,s){let r=i.sliceDoc(n-$n,n),o=i.sliceDoc(s,s+$n),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,c=r.length-l;if(r.slice(c-e.length,c)==e&&o.slice(a,a+t.length)==t)return{open:{pos:n-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let u,d;s-n<=2*$n?u=d=i.sliceDoc(n,s):(u=i.sliceDoc(n,n+$n),d=i.sliceDoc(s-$n,s));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-t.length;return u.slice(f,f+e.length)==e&&d.slice(m,m+t.length)==t?{open:{pos:n+f+e.length,margin:/\s/.test(u.charAt(f+e.length))?1:0},close:{pos:s-p-t.length,margin:/\s/.test(d.charAt(m-1))?1:0}}:null}function H1(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 Am(i,e,t=e.selection.ranges){let n=t.map(r=>jc(e,r.from).block);if(!n.every(r=>r))return null;let s=t.map((r,o)=>z1(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:c,close:u}=l;r.push({from:c.pos-a.open.length,to:c.pos+c.margin},{from:u.pos-u.margin,to:u.pos+a.close.length})}return{changes:r}}return null}function G1(i,e,t=e.selection.ranges){let n=[],s=-1;for(let{from:r,to:o}of t){let l=n.length,a=1e9,c=jc(e,r).line;if(c){for(let u=r;u<=o;){let d=e.doc.lineAt(u);if(d.from>s&&(r==o||o>d.from)){s=d.from;let f=/^\s*/.exec(d.text)[0].length,p=f==d.length,m=d.text.slice(f,f+c.length)==c?f:-1;f<d.text.length&&f<a&&(a=f),n.push({line:d,comment:m,token:c,indent:f,empty:p,single:!1})}u=d.to+1}if(a<1e9)for(let u=l;u<n.length;u++)n[u].indent<n[u].line.text.length&&(n[u].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:c,empty:u,single:d}of n)(d||!u)&&r.push({from:l.from+c,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 c=o.from+l,u=c+a.length;o.text[u-o.from]==" "&&u++,r.push({from:c,to:u})}return{changes:r}}return null}const Ma=Kt.define(),U1=Kt.define(),W1=G.define(),jm=G.define({combine(i){return Yt(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)})}}),Im=Ve.define({create(){return $t.empty},update(i,e){let t=e.state.facet(jm),n=e.annotation(Ma);if(n){let a=nt.fromTransaction(e,n.selection),c=n.side,u=c==0?i.undone:i.done;return a?u=eo(u,u.length,t.minDepth,a):u=Pm(u,e.startState.selection),new $t(c==0?n.rest:u,c==0?u:n.rest)}let s=e.annotation(U1);if((s=="full"||s=="before")&&(i=i.isolate()),e.annotation(Ie.addToHistory)===!1)return e.changes.empty?i:i.addMapping(e.changes.desc);let r=nt.fromTransaction(e),o=e.annotation(Ie.time),l=e.annotation(Ie.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 $t(i.done.map(nt.fromJSON),i.undone.map(nt.fromJSON))}});function q1(i={}){return[Im,jm.of(i),z.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?Om:e.inputType=="historyRedo"?Pa:null;return n?(e.preventDefault(),n(t)):!1}})]}function Ao(i,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let s=t.field(Im,!1);if(!s)return!1;let r=s.pop(i,t,e);return r?(n(r),!0):!1}}const Om=Ao(0,!1),Pa=Ao(1,!1),K1=Ao(0,!0),Y1=Ao(1,!0);class nt{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 nt(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 nt(e.changes&&je.fromJSON(e.changes),[],e.mapped&&Ht.fromJSON(e.mapped),e.startSelection&&j.fromJSON(e.startSelection),e.selectionsAfter.map(j.fromJSON))}static fromTransaction(e,t){let n=gt;for(let s of e.startState.facet(W1)){let r=s(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new nt(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,gt)}static selection(e){return new nt(void 0,gt,void 0,void 0,e)}}function eo(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 X1(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 c=t[a++],u=t[a++];l>=c&&o<=u&&(n=!0)}}),n}function Q1(i,e){return i.ranges.length==e.ranges.length&&i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function Mm(i,e){return i.length?e.length?i.concat(e):i:e}const gt=[],J1=200;function Pm(i,e){if(i.length){let t=i[i.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-J1));return n.length&&n[n.length-1].eq(e)?i:(n.push(e),eo(i,i.length-1,1e9,t.setSelAfter(n)))}else return[nt.selection([e])]}function Z1(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 Sl(i,e){if(!i.length)return i;let t=i.length,n=gt;for(;t;){let s=ew(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?[nt.selection(n)]:gt}function ew(i,e,t){let n=Mm(i.selectionsAfter.length?i.selectionsAfter.map(l=>l.map(e)):gt,t);if(!i.changes)return nt.selection(n);let s=i.changes.map(e),r=e.mapDesc(i.changes,!0),o=i.mapped?i.mapped.composeDesc(r):r;return new nt(s,J.mapEffects(i.effects,e),o,i.startSelection.map(r),n)}const tw=/^(input\.type|delete)($|\.)/;class $t{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 $t(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||tw.test(n))&&(!l.selectionsAfter.length&&t-this.prevTime<s.newGroupDelay&&s.joinToEvent(r,X1(l.changes,e.changes))||n=="input.type.compose")?o=eo(o,o.length-1,s.minDepth,new nt(e.changes.compose(l.changes),Mm(J.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,gt)):o=eo(o,o.length,s.minDepth,e),new $t(o,gt,t,n)}addSelection(e,t,n,s){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:gt;return r.length>0&&t-this.prevTime<s&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&Q1(r[r.length-1],e)?this:new $t(Pm(this.done,e),this.undone,t,n)}addMapping(e){return new $t(Sl(this.done,e),Sl(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:Ma.of({side:e,rest:Z1(s),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=s.length==1?gt:s.slice(0,s.length-1);return r.mapped&&(l=Sl(l,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:Ma.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}$t.empty=new $t(gt,gt);const iw=[{key:"Mod-z",run:Om,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Pa,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Pa,preventDefault:!0},{key:"Mod-u",run:K1,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Y1,preventDefault:!0}];function Mn(i,e){return j.create(i.ranges.map(e),i.mainIndex)}function At(i,e){return i.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function jt({state:i,dispatch:e},t){let n=Mn(i.selection,t);return n.eq(i.selection,!0)?!1:(e(At(i,n)),!0)}function jo(i,e){return j.cursor(e?i.to:i.from)}function Dm(i,e){return jt(i,t=>t.empty?i.moveByChar(t,e):jo(t,e))}function qe(i){return i.textDirectionAt(i.state.selection.main.head)==be.LTR}const Lm=i=>Dm(i,!qe(i)),Nm=i=>Dm(i,qe(i));function Fm(i,e){return jt(i,t=>t.empty?i.moveByGroup(t,e):jo(t,e))}const nw=i=>Fm(i,!qe(i)),sw=i=>Fm(i,qe(i));function rw(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=We(i).resolveInner(e.head),s=t?ie.closedBy:ie.openedBy;for(let a=e.head;;){let c=t?n.childAfter(a):n.childBefore(a);if(!c)break;rw(i,c,s)?n=c:a=t?c.to:c.from}let r=n.type.prop(s),o,l;return r&&(o=t?_t(i,n.from,1):_t(i,n.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?n.to:n.from,j.cursor(l,t?-1:1)}const ow=i=>jt(i,e=>Io(i.state,e,!qe(i))),lw=i=>jt(i,e=>Io(i.state,e,qe(i)));function Bm(i,e){return jt(i,t=>{if(!t.empty)return jo(t,e);let n=i.moveVertically(t,e);return n.head!=t.head?n:i.moveToLineBoundary(t,e)})}const Vm=i=>Bm(i,!1),_m=i=>Bm(i,!0);function $m(i){let e=i.scrollDOM.clientHeight<i.scrollDOM.scrollHeight-2,t=0,n=0,s;if(e){for(let r of i.state.facet(z.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 zm(i,e){let t=$m(i),{state:n}=i,s=Mn(n.selection,o=>o.empty?i.moveVertically(o,e,t.height):jo(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,c=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<c&&(r=z.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-a}))}return i.dispatch(At(n,s),{effects:r}),!0}const Vh=i=>zm(i,!1),Da=i=>zm(i,!0);function Ii(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=j.cursor(n.from+r))}return s}const aw=i=>jt(i,e=>Ii(i,e,!0)),cw=i=>jt(i,e=>Ii(i,e,!1)),uw=i=>jt(i,e=>Ii(i,e,!qe(i))),hw=i=>jt(i,e=>Ii(i,e,qe(i))),dw=i=>jt(i,e=>j.cursor(i.lineBlockAt(e.head).from,1)),fw=i=>jt(i,e=>j.cursor(i.lineBlockAt(e.head).to,-1));function pw(i,e,t){let n=!1,s=Mn(i.selection,r=>{let o=_t(i,r.head,-1)||_t(i,r.head,1)||r.head>0&&_t(i,r.head-1,1)||r.head<i.doc.length&&_t(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 j.cursor(l)});return n?(e(At(i,s)),!0):!1}const mw=({state:i,dispatch:e})=>pw(i,e);function Et(i,e){let t=Mn(i.state.selection,n=>{let s=e(n);return j.range(n.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return t.eq(i.state.selection)?!1:(i.dispatch(At(i.state,t)),!0)}function Hm(i,e){return Et(i,t=>i.moveByChar(t,e))}const Gm=i=>Hm(i,!qe(i)),Um=i=>Hm(i,qe(i));function Wm(i,e){return Et(i,t=>i.moveByGroup(t,e))}const gw=i=>Wm(i,!qe(i)),xw=i=>Wm(i,qe(i)),yw=i=>Et(i,e=>Io(i.state,e,!qe(i))),bw=i=>Et(i,e=>Io(i.state,e,qe(i)));function qm(i,e){return Et(i,t=>i.moveVertically(t,e))}const Km=i=>qm(i,!1),Ym=i=>qm(i,!0);function Xm(i,e){return Et(i,t=>i.moveVertically(t,e,$m(i).height))}const _h=i=>Xm(i,!1),$h=i=>Xm(i,!0),Sw=i=>Et(i,e=>Ii(i,e,!0)),vw=i=>Et(i,e=>Ii(i,e,!1)),Ew=i=>Et(i,e=>Ii(i,e,!qe(i))),Cw=i=>Et(i,e=>Ii(i,e,qe(i))),Rw=i=>Et(i,e=>j.cursor(i.lineBlockAt(e.head).from)),ww=i=>Et(i,e=>j.cursor(i.lineBlockAt(e.head).to)),zh=({state:i,dispatch:e})=>(e(At(i,{anchor:0})),!0),Hh=({state:i,dispatch:e})=>(e(At(i,{anchor:i.doc.length})),!0),Gh=({state:i,dispatch:e})=>(e(At(i,{anchor:i.selection.main.anchor,head:0})),!0),Uh=({state:i,dispatch:e})=>(e(At(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),kw=({state:i,dispatch:e})=>(e(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),Tw=({state:i,dispatch:e})=>{let t=Oo(i).map(({from:n,to:s})=>j.range(n,Math.min(s+1,i.doc.length)));return e(i.update({selection:j.create(t),userEvent:"select"})),!0},Aw=({state:i,dispatch:e})=>{let t=Mn(i.selection,n=>{let s=We(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 j.range(l.to,l.from)}return n});return t.eq(i.selection)?!1:(e(At(i,t)),!0)};function Qm(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(c=>c.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(At(t,j.create(s,s.length-1))),!0)}const jw=i=>Qm(i,!1),Iw=i=>Qm(i,!0),Ow=({state:i,dispatch:e})=>{let t=i.selection,n=null;return t.ranges.length>1?n=j.create([t.main]):t.main.empty||(n=j.create([j.cursor(t.main.head)])),n?(e(At(i,n)),!0):!1};function Ns(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=cr(i,a,!1)):a>o&&(t="delete.forward",a=cr(i,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=cr(i,o,!1),l=cr(i,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:j.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"?z.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function cr(i,e,t){if(i instanceof z)for(let n of i.state.facet(z.atomicRanges).map(s=>s(i)))n.between(e,e,(s,r)=>{s<e&&r>e&&(e=t?r:s)});return e}const Jm=(i,e,t)=>Ns(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 c=On(l,r.tabSize),u=c%Qr(r)||Qr(r);for(let d=0;d<u&&l[l.length-1-d]==" ";d++)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}),La=i=>Jm(i,!1,!0),Zm=i=>Jm(i,!0,!1),eg=(i,e)=>Ns(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,c=r.text.slice(Math.min(n,a)-r.from,Math.max(n,a)-r.from),u=o(c);if(l!=null&&u!=l)break;(c!=" "||n!=t.head)&&(l=u),n=a}return n}),tg=i=>eg(i,!1),Mw=i=>eg(i,!0),Pw=i=>Ns(i,e=>{let t=i.lineBlockAt(e.head).to;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)}),Dw=i=>Ns(i,e=>{let t=i.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),Lw=i=>Ns(i,e=>{let t=i.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)}),Nw=({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:j.cursor(n.from)}));return e(i.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Fw=({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:j.cursor(l)}});return t.changes.empty?!1:(e(i.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Oo(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 Oo(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(j.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(j.range(a.anchor-l,a.head-l))}}return n.length?(e(i.update({changes:n,scrollIntoView:!0,selection:j.create(s,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Bw=({state:i,dispatch:e})=>ig(i,e,!1),Vw=({state:i,dispatch:e})=>ig(i,e,!0);function ng(i,e,t){if(i.readOnly)return!1;let n=[];for(let s of Oo(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 _w=({state:i,dispatch:e})=>ng(i,e,!1),$w=({state:i,dispatch:e})=>ng(i,e,!0),zw=i=>{if(i.state.readOnly)return!1;let{state:e}=i,t=e.changes(Oo(e).map(({from:s,to:r})=>(s>0?s--:r<e.doc.length&&r++,{from:s,to:r}))),n=Mn(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 Hw(i,e){if(/\(\)|\[\]|\{\}/.test(i.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=We(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(ie.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 Wh=sg(!1),Gw=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&&Hw(e,r);i&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let c=new ko(e,{simulateBreak:r,simulateDoubleBreak:!!a}),u=kc(c,r);for(u==null&&(u=On(/^\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 d=["",xs(e,u)];return a&&d.push(xs(e,c.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:oe.of(d)},range:j.cursor(r+1+d[1].length)}});return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ic(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:j.range(r.mapPos(n.anchor,1),r.mapPos(n.head,1))}})}const Uw=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=Object.create(null),n=new ko(i,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=Ic(i,(r,o,l)=>{let a=kc(n,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let c=/^\s*/.exec(r.text)[0],u=xs(i,a);(c!=u||l.from<r.from+c.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+c.length,insert:u}))});return s.changes.empty||e(i.update(s,{userEvent:"indent"})),!0},rg=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(Ic(i,(t,n)=>{n.push({from:t.from,insert:i.facet(wo)})}),{userEvent:"input.indent"})),!0),og=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(Ic(i,(t,n)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=On(s,i.tabSize),o=0,l=xs(i,Math.max(0,r-Qr(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),Ww=i=>(i.setTabFocusMode(),!0),qw=[{key:"Ctrl-b",run:Lm,shift:Gm,preventDefault:!0},{key:"Ctrl-f",run:Nm,shift:Um},{key:"Ctrl-p",run:Vm,shift:Km},{key:"Ctrl-n",run:_m,shift:Ym},{key:"Ctrl-a",run:dw,shift:Rw},{key:"Ctrl-e",run:fw,shift:ww},{key:"Ctrl-d",run:Zm},{key:"Ctrl-h",run:La},{key:"Ctrl-k",run:Pw},{key:"Ctrl-Alt-h",run:tg},{key:"Ctrl-o",run:Nw},{key:"Ctrl-t",run:Fw},{key:"Ctrl-v",run:Da}],Kw=[{key:"ArrowLeft",run:Lm,shift:Gm,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:nw,shift:gw,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:uw,shift:Ew,preventDefault:!0},{key:"ArrowRight",run:Nm,shift:Um,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:sw,shift:xw,preventDefault:!0},{mac:"Cmd-ArrowRight",run:hw,shift:Cw,preventDefault:!0},{key:"ArrowUp",run:Vm,shift:Km,preventDefault:!0},{mac:"Cmd-ArrowUp",run:zh,shift:Gh},{mac:"Ctrl-ArrowUp",run:Vh,shift:_h},{key:"ArrowDown",run:_m,shift:Ym,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Hh,shift:Uh},{mac:"Ctrl-ArrowDown",run:Da,shift:$h},{key:"PageUp",run:Vh,shift:_h},{key:"PageDown",run:Da,shift:$h},{key:"Home",run:cw,shift:vw,preventDefault:!0},{key:"Mod-Home",run:zh,shift:Gh},{key:"End",run:aw,shift:Sw,preventDefault:!0},{key:"Mod-End",run:Hh,shift:Uh},{key:"Enter",run:Wh,shift:Wh},{key:"Mod-a",run:kw},{key:"Backspace",run:La,shift:La,preventDefault:!0},{key:"Delete",run:Zm,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:tg,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Mw,preventDefault:!0},{mac:"Mod-Backspace",run:Dw,preventDefault:!0},{mac:"Mod-Delete",run:Lw,preventDefault:!0}].concat(qw.map(i=>({mac:i.key,run:i.run,shift:i.shift}))),Yw=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ow,shift:yw},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:lw,shift:bw},{key:"Alt-ArrowUp",run:Bw},{key:"Shift-Alt-ArrowUp",run:_w},{key:"Alt-ArrowDown",run:Vw},{key:"Shift-Alt-ArrowDown",run:$w},{key:"Mod-Alt-ArrowUp",run:jw},{key:"Mod-Alt-ArrowDown",run:Iw},{key:"Escape",run:Ow},{key:"Mod-Enter",run:Gw},{key:"Alt-l",mac:"Ctrl-l",run:Tw},{key:"Mod-i",run:Aw,preventDefault:!0},{key:"Mod-[",run:og},{key:"Mod-]",run:rg},{key:"Mod-Alt-\\",run:Uw},{key:"Shift-Mod-k",run:zw},{key:"Shift-Mod-\\",run:mw},{key:"Mod-/",run:B1},{key:"Alt-A",run:_1},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Ww}].concat(Kw),Xw={key:"Tab",run:rg,shift:og},qh=typeof String.prototype.normalize=="function"?i=>i.normalize("NFKD"):i=>i;class jn{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(qh(l)):qh,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 et(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=hc(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Bt(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"&&(jn.prototype[Symbol.iterator]=function(){return this});const lg={from:-1,to:-1,match:/.*/.exec("")},Oc="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 cg(e,t,n,s,r);this.re=new RegExp(t,Oc+(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=to(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=to(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 vl=new WeakMap;class bn{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let s=vl.get(e);if(!s||s.from>=n||s.to<=t){let l=new bn(t,e.sliceString(t,n));return vl.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)),vl.set(e,new bn(o,r)),new bn(t,r.slice(t-o,n-o))}}class cg{constructor(e,t,n,s,r){this.text=e,this.to=r,this.done=!1,this.value=lg,this.matchPos=to(e,s),this.re=new RegExp(t,Oc+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.flat=bn.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=to(this.text,s+(n==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=bn.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(ag.prototype[Symbol.iterator]=cg.prototype[Symbol.iterator]=function(){return this});function Qw(i){try{return new RegExp(i,Oc),!0}catch{return!1}}function to(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 Na(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:ts.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:ts.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,c,u,d]=r,f=u?+u.slice(1):0,p=c?+c:l.number;if(c&&d){let x=p/100;a&&(x=x*(a=="-"?-1:1)+l.number/o.doc.lines),p=Math.round(o.doc.lines*x)}else c&&a&&(p=p*(a=="-"?-1:1)+l.number);let m=o.doc.line(Math.max(1,Math.min(o.doc.lines,p))),g=j.cursor(m.from+Math.max(0,Math.min(f,m.length)));i.dispatch({effects:[ts.of(!1),z.scrollIntoView(g.from,{y:"center"})],selection:g}),i.focus()}return{dom:n}}const ts=J.define(),Kh=Ve.define({create(){return!0},update(i,e){for(let t of e.effects)t.is(ts)&&(i=t.value);return i},provide:i=>gs.from(i,e=>e?Na:null)}),Jw=i=>{let e=ms(i,Na);if(!e){let t=[ts.of(!0)];i.state.field(Kh,!1)==null&&t.push(J.appendConfig.of([Kh,Zw])),i.dispatch({effects:t}),e=ms(i,Na)}return e&&e.dom.querySelector("input").select(),!0},Zw=z.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"}}}),ek={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},tk=G.define({combine(i){return Yt(i,ek,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function ik(i){return[lk,ok]}const nk=K.mark({class:"cm-selectionMatch"}),sk=K.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Yh(i,e,t,n){return(t==0||i(e.sliceDoc(t-1,t))!=Se.Word)&&(n==e.doc.length||i(e.sliceDoc(n,n+1))!=Se.Word)}function rk(i,e,t,n){return i(e.sliceDoc(t,t+1))==Se.Word&&i(e.sliceDoc(n-1,n))==Se.Word}const ok=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(tk),{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),!(Yh(o,t,s.from,s.to)&&rk(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 c=new jn(t.doc,r,a.from,a.to);for(;!c.next().done;){let{from:u,to:d}=c.value;if((!o||Yh(o,t,u,d))&&(s.empty&&u<=s.from&&d>=s.to?l.push(sk.range(u,d)):(u>=s.to||d<=s.from)&&l.push(nk.range(u,d)),l.length>e.maxMatches))return K.none}}return K.set(l)}},{decorations:i=>i.decorations}),lk=z.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),ak=({state:i,dispatch:e})=>{let{selection:t}=i,n=j.create(t.ranges.map(s=>i.wordAt(s.head)||j.cursor(s.head)),t.mainIndex);return n.eq(t)?!1:(e(i.update({selection:n})),!0)};function ck(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 jn(i.doc,e,n[n.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new jn(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 uk=({state:i,dispatch:e})=>{let{ranges:t}=i.selection;if(t.some(r=>r.from===r.to))return ak({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=ck(i,n);return s?(e(i.update({selection:i.selection.addRange(j.range(s.from,s.to),!1),effects:z.scrollIntoView(s.to)})),!0):!1},Pn=G.define({combine(i){return Yt(i,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Ek(e),scrollToMatch:e=>z.scrollIntoView(e)})}});class ug{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||Qw(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 pk(this):new dk(this)}getCursor(e,t=0,n){let s=e.doc?e:se.create({doc:e});return n==null&&(n=s.doc.length),this.regexp?rn(this,s,t,n):sn(this,s,t,n)}}class hg{constructor(e){this.spec=e}}function sn(i,e,t,n){return new jn(e.doc,i.unquoted,t,n,i.caseSensitive?void 0:s=>s.toLowerCase(),i.wholeWord?hk(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function hk(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(io(s,t-r))!=Se.Word||e(no(s,t-r))!=Se.Word)&&(e(no(s,n-r))!=Se.Word||e(io(s,n-r))!=Se.Word))}class dk extends hg{constructor(e){super(e)}nextMatch(e,t,n){let s=sn(this.spec,e,n,e.doc.length).nextOverlapping();if(s.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);s=sn(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=sn(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=sn(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=sn(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 rn(i,e,t,n){return new ag(e.doc,i.search,{ignoreCase:!i.caseSensitive,test:i.wholeWord?fk(e.charCategorizer(e.selection.main.head)):void 0},t,n)}function io(i,e){return i.slice(Fe(i,e,!1),e)}function no(i,e){return i.slice(e,Fe(i,e))}function fk(i){return(e,t,n)=>!n[0].length||(i(io(n.input,n.index))!=Se.Word||i(no(n.input,n.index))!=Se.Word)&&(i(no(n.input,n.index+n[0].length))!=Se.Word||i(io(n.input,n.index+n[0].length))!=Se.Word)}class pk extends hg{nextMatch(e,t,n){let s=rn(this.spec,e,n,e.doc.length).next();return s.done&&(s=rn(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=rn(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=rn(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=rn(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 ys=J.define(),Mc=J.define(),Ei=Ve.define({create(i){return new El(Fa(i).create(),null)},update(i,e){for(let t of e.effects)t.is(ys)?i=new El(t.value.create(),i.panel):t.is(Mc)&&(i=new El(i.query,t.value?Pc:null));return i},provide:i=>gs.from(i,e=>e.panel)});class El{constructor(e,t){this.query=e,this.panel=t}}const mk=K.mark({class:"cm-searchMatch"}),gk=K.mark({class:"cm-searchMatch cm-searchMatch-selected"}),xk=Ce.fromClass(class{constructor(i){this.view=i,this.decorations=this.highlight(i.state.field(Ei))}update(i){let e=i.state.field(Ei);(e!=i.startState.field(Ei)||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 ri;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,(c,u)=>{let d=t.state.selection.ranges.some(f=>f.from==c&&f.to==u);n.add(c,u,d?gk:mk)})}return n.finish()}},{decorations:i=>i.decorations});function Fs(i){return e=>{let t=e.state.field(Ei,!1);return t&&t.query.spec.valid?i(e,t):pg(e)}}const so=Fs((i,{query:e})=>{let{to:t}=i.state.selection.main,n=e.nextMatch(i.state,t,t);if(!n)return!1;let s=j.single(n.from,n.to),r=i.state.facet(Pn);return i.dispatch({selection:s,effects:[Dc(i,n),r.scrollToMatch(s.main,i)],userEvent:"select.search"}),fg(i),!0}),ro=Fs((i,{query:e})=>{let{state:t}=i,{from:n}=t.selection.main,s=e.prevMatch(t,n,n);if(!s)return!1;let r=j.single(s.from,s.to),o=i.state.facet(Pn);return i.dispatch({selection:r,effects:[Dc(i,s),o.scrollToMatch(r.main,i)],userEvent:"select.search"}),fg(i),!0}),yk=Fs((i,{query:e})=>{let t=e.matchAll(i.state,1e3);return!t||!t.length?!1:(i.dispatch({selection:j.create(t.map(n=>j.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),bk=({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 jn(i.doc,i.sliceDoc(n,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==n&&(o=r.length),r.push(j.range(l.value.from,l.value.to))}return e(i.update({selection:j.create(r,o),userEvent:"select.search.matches"})),!0},Xh=Fs((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,c,u=[];o.from==n&&o.to==s&&(c=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:c}),o=e.nextMatch(t,o.from,o.to),u.push(z.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(n).number)+".")));let d=i.state.changes(l);return o&&(a=j.single(o.from,o.to).map(d),u.push(Dc(i,o)),u.push(t.facet(Pn).scrollToMatch(a.main,i))),i.dispatch({changes:d,selection:a,effects:u,userEvent:"input.replace"}),!0}),Sk=Fs((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:z.announce.of(n),userEvent:"input.replace.all"}),!0});function Pc(i){return i.state.facet(Pn).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 c=i.facet(Pn);return new ug({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:c.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:c.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:c.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function dg(i){let e=ms(i,Pc);return e&&e.dom.querySelector("[main-field]")}function fg(i){let e=dg(i);e&&e==i.root.activeElement&&e.select()}const pg=i=>{let e=i.state.field(Ei,!1);if(e&&e.panel){let t=dg(i);if(t&&t!=i.root.activeElement){let n=Fa(i.state,e.query.spec);n.valid&&i.dispatch({effects:ys.of(n)}),t.focus(),t.select()}}else i.dispatch({effects:[Mc.of(!0),e?ys.of(Fa(i.state,e.query.spec)):J.appendConfig.of(Rk)]});return!0},mg=i=>{let e=i.state.field(Ei,!1);if(!e||!e.panel)return!1;let t=ms(i,Pc);return t&&t.dom.contains(i.root.activeElement)&&i.focus(),i.dispatch({effects:Mc.of(!1)}),!0},vk=[{key:"Mod-f",run:pg,scope:"editor search-panel"},{key:"F3",run:so,shift:ro,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:so,shift:ro,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:mg,scope:"editor search-panel"},{key:"Mod-Shift-l",run:bk},{key:"Mod-Alt-g",run:Jw},{key:"Mod-d",run:uk,preventDefault:!0}];class Ek{constructor(e){this.view=e;let t=this.query=e.state.field(Ei).query.spec;this.commit=this.commit.bind(this),this.searchField=fe("input",{value:t.search,placeholder:lt(e,"Find"),"aria-label":lt(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:lt(e,"Replace"),"aria-label":lt(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",()=>so(e),[lt(e,"next")]),n("prev",()=>ro(e),[lt(e,"previous")]),n("select",()=>yk(e),[lt(e,"all")]),fe("label",null,[this.caseField,lt(e,"match case")]),fe("label",null,[this.reField,lt(e,"regexp")]),fe("label",null,[this.wordField,lt(e,"by word")]),...e.state.readOnly?[]:[fe("br"),this.replaceField,n("replace",()=>Xh(e),[lt(e,"replace")]),n("replaceAll",()=>Sk(e),[lt(e,"replace all")])],fe("button",{name:"close",onclick:()=>mg(e),"aria-label":lt(e,"close"),type:"button"},["×"])])}commit(){let e=new ug({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:ys.of(e)}))}keydown(e){$C(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ro:so)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Xh(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(ys)&&!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(Pn).top}}function lt(i,e){return i.state.phrase(e)}const ur=30,hr=/[\s\.,:;?!]/;function Dc(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-ur),o=Math.min(s,t+ur),l=i.state.sliceDoc(r,o);if(r!=n.from){for(let a=0;a<ur;a++)if(!hr.test(l[a+1])&&hr.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-ur;a--)if(!hr.test(l[a-1])&&hr.test(l[a])){l=l.slice(0,a);break}}return z.announce.of(`${i.state.phrase("current match")}. ${l} ${i.state.phrase("on line")} ${n.number}.`)}const Ck=z.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"}}),Rk=[Ei,Qi.low(xk),Ck];class gg{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=We(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 Qh(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 wk(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=Qh(e)+Qh(t)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function kk(i){let e=i.map(s=>typeof s=="string"?{label:s}:s),[t,n]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:wk(e);return s=>{let r=s.matchBefore(n);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}class Jh{constructor(e,t,n,s){this.completion=e,this.source=t,this.match=n,this.score=s}}function Gi(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=Kt.define();function Tk(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:j.cursor(l.from+r+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Zh=new WeakMap;function Ak(i){if(!Array.isArray(i))return i;let e=Zh.get(i);return e||Zh.set(i,e=kk(i)),e}const oo=J.define(),bs=J.define();class jk{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=et(e,t),s=Bt(n);this.chars.push(n);let r=e.slice(t,t+s),o=r.toUpperCase();this.folded.push(et(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=et(e,0),S=Bt(b),E=S==e.length?0:-100;if(b!=t[0])if(b==n[0])E+=-200;else return null;return this.ret(E,[0,S])}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,c=0;if(l<0){for(let b=0,S=Math.min(e.length,200);b<S&&c<a;){let E=et(e,b);(E==t[c]||E==n[c])&&(s[c++]=b),b+=Bt(E)}if(c<a)return null}let u=0,d=0,f=!1,p=0,m=-1,g=-1,x=/[a-z]/.test(e),y=!0;for(let b=0,S=Math.min(e.length,200),E=0;b<S&&d<a;){let v=et(e,b);l<0&&(u<a&&v==t[u]&&(r[u++]=b),p<a&&(v==t[p]||v==n[p]?(p==0&&(m=b),g=b+1,p++):p=0));let C,k=v<255?v>=48&&v<=57||v>=97&&v<=122?2:v>=65&&v<=90?1:0:(C=hc(v))!=C.toLowerCase()?1:C!=C.toUpperCase()?2:0;(!b||k==1&&x||E==0&&k!=0)&&(t[d]==v||n[d]==v&&(f=!0)?o[d++]=b:o.length&&(y=!1)),E=k,b+=Bt(v)}return d==a&&o[0]==0&&y?this.result(-100+(f?-200:0),o,e):p==a&&m==0?this.ret(-200-e.length+(g==e.length?0:-100),[0,g]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):p==a?this.ret(-900-e.length,[m,g]):d==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?Bt(et(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 Ik{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 De=G.define({combine(i){return Yt(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:Ok,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=>ed(e(n),t(n)),optionClass:(e,t)=>n=>ed(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function ed(i,e){return i?e?i+" "+e:i:e}function Ok(i,e,t,n,s,r){let o=i.textDirection==be.RTL,l=o,a=!1,c="top",u,d,f=e.left-s.left,p=s.right-e.right,m=n.right-n.left,g=n.bottom-n.top;if(l&&f<Math.min(m,p)?l=!1:!l&&p<Math.min(m,f)&&(l=!0),m<=(l?f:p))u=Math.max(s.top,Math.min(t.top,s.bottom-g))-e.top,d=Math.min(400,l?f:p);else{a=!0,d=Math.min(400,(o?e.right:s.right-e.left)-30);let b=s.bottom-e.bottom;b>=g||b>e.top?u=t.bottom-e.top:(c="bottom",u=e.bottom-t.top)}let x=(e.bottom-e.top)/r.offsetHeight,y=(e.right-e.left)/r.offsetWidth;return{style:`${c}: ${u/x}px; max-width: ${d/y}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function Mk(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 c=0;c<r.length;){let u=r[c++],d=r[c++];u>a&&o.appendChild(document.createTextNode(l.slice(a,u)));let f=o.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(l.slice(u,d))),f.className="cm-completionMatchedText",a=d}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 Cl(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 Pk{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(De);this.optionContent=Mk(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=Cl(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:c}=e.state.field(t).open;for(let u=a.target,d;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(d=/-(\d+)$/.exec(u.id))&&+d[1]<c.length){this.applyCompletion(e,c[+d[1]]),a.preventDefault();return}}),this.dom.addEventListener("focusout",a=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(De).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:bs.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=Cl(r.length,o,e.state.facet(De).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=Cl(t.options.length,t.selected,this.view.state.facet(De).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=>it(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&&Lk(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(De).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:c}=l;if(c){let f=typeof c=="string"?c:c.name;if(f!=r&&(o>n.from||n.from==0))if(r=f,typeof c!="string"&&c.header)s.appendChild(c.header(c));else{let p=s.appendChild(document.createElement("completion-section"));p.textContent=f}}const u=s.appendChild(document.createElement("li"));u.id=t+"-"+o,u.setAttribute("role","option");let d=this.optionClass(l);d&&(u.className=d);for(let f of this.optionContent){let p=f(l,this.view.state,this.view,a);p&&u.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 Dk(i,e){return t=>new Pk(t,i,e)}function Lk(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 td(i){return(i.boost||0)*100+(i.apply?10:0)+(i.info?5:0)+(i.type?1:0)}function Nk(i,e){let t=[],n=null,s=null,r=u=>{t.push(u);let{section:d}=u.completion;if(d){n||(n=[]);let f=typeof d=="string"?d:d.name;n.some(p=>p.name==f)||n.push(typeof d=="string"?{name:f}:d)}},o=e.facet(De);for(let u of i)if(u.hasResult()){let d=u.result.getMatch;if(u.result.filter===!1)for(let f of u.result.options)r(new Jh(f,u.source,d?d(f):[],1e9-t.length));else{let f=e.sliceDoc(u.from,u.to),p,m=o.filterStrict?new Ik(f):new jk(f);for(let g of u.result.options)if(p=m.match(g.label)){let x=g.displayLabel?d?d(g,p.matched):[]:p.matched,y=p.score+(g.boost||0);if(r(new Jh(g,u.source,x,y)),typeof g.section=="object"&&g.section.rank==="dynamic"){let{name:b}=g.section;s||(s=Object.create(null)),s[b]=Math.max(y,s[b]||-1e9)}}}}if(n){let u=Object.create(null),d=0,f=(p,m)=>(p.rank==="dynamic"&&m.rank==="dynamic"?s[m.name]-s[p.name]:0)||(typeof p.rank=="number"?p.rank:1e9)-(typeof m.rank=="number"?m.rank:1e9)||(p.name<m.name?-1:1);for(let p of n.sort(f))d-=1e5,u[p.name]=d;for(let p of t){let{section:m}=p.completion;m&&(p.score+=u[typeof m=="string"?m:m.name])}}let l=[],a=null,c=o.compareCompletions;for(let u of t.sort((d,f)=>f.score-d.score||c(d.completion,f.completion))){let d=u.completion;!a||a.label!=d.label||a.detail!=d.detail||a.type!=null&&d.type!=null&&a.type!=d.type||a.apply!=d.apply||a.boost!=d.boost?l.push(u):td(u.completion)>td(a)&&(l[l.length-1]=u),a=u.completion}return l}class hn{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 hn(this.options,id(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,s,r,o){if(s&&!o&&e.some(c=>c.isPending))return s.setDisabled();let l=Nk(e,t);if(!l.length)return s&&e.some(c=>c.isPending)?s.setDisabled():null;let a=t.facet(De).selectOnOpen?0:-1;if(s&&s.selected!=a&&s.selected!=-1){let c=s.options[s.selected].completion;for(let u=0;u<l.length;u++)if(l[u].completion==c){a=u;break}}return new hn(l,id(n,a),{pos:e.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:zk,above:r.aboveCursor},s?s.timestamp:Date.now(),a,!1)}map(e){return new hn(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new hn(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class lo{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new lo(_k,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(De),r=(n.override||t.languageDataAt("autocomplete",Gi(t)).map(Ak)).map(a=>(this.active.find(u=>u.source==a)||new xt(a,this.active.some(u=>u.state!=0)?1:0)).update(e,n));r.length==this.active.length&&r.every((a,c)=>a==this.active[c])&&(r=this.active);let o=this.open,l=e.effects.some(a=>a.is(Lc));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!Fk(r,this.active)||l?o=hn.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 xt(a.source,0):a));for(let a of e.effects)a.is(Sg)&&(o=o&&o.setSelected(a.value,this.id));return r==this.active&&o==this.open?this:new lo(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Bk:Vk}}function Fk(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 Bk={"aria-autocomplete":"list"},Vk={};function id(i,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":i};return e>-1&&(t["aria-activedescendant"]=i+"-"+e),t}const _k=[];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 xt{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 xt(s.source,0)),n&4&&s.state==0&&(s=new xt(this.source,1)),s=s.updateFor(e,n);for(let r of e.effects)if(r.is(oo))s=new xt(s.source,1,r.value);else if(r.is(bs))s=new xt(s.source,0);else if(r.is(Lc))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(Gi(e.state))}}class Sn extends xt{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=Gi(e.state);if(l>o||!s||t&2&&(Gi(e.startState)==this.from||l<this.limit))return new xt(this.source,t&4?1:0);let a=e.changes.mapPos(this.limit);return $k(s.validFor,e.state,r,o)?new Sn(this.source,this.explicit,a,s,r,o):s.update&&(s=s.update(s,r,o,new gg(e.state,l,!1)))?new Sn(this.source,this.explicit,a,s,s.from,(n=s.to)!==null&&n!==void 0?n:Gi(e.state)):new xt(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new Sn(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new xt(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function $k(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 Lc=J.define({map(i,e){return i.map(t=>t.map(e))}}),Sg=J.define(),tt=Ve.define({create(){return lo.start()},update(i,e){return i.update(e)},provide:i=>[wc.from(i,e=>e.tooltip),z.contentAttributes.from(i,e=>e.attrs)]});function Nc(i,e){const t=e.completion.apply||e.completion.label;let n=i.state.field(tt).active.find(s=>s.source==e.source);return n instanceof Sn?(typeof t=="string"?i.dispatch({...Tk(i.state,t,n.from,n.to),annotations:yg.of(e.completion)}):t(i,e.completion,n.from,n.to),!0):!1}const zk=Dk(tt,Nc);function dr(i,e="option"){return t=>{let n=t.state.field(tt,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<t.state.facet(De).interactionDelay)return!1;let s=1,r;e=="page"&&(r=am(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:Sg.of(l)}),!0}}const Hk=i=>{let e=i.state.field(tt,!1);return i.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<i.state.facet(De).interactionDelay?!1:Nc(i,e.open.options[e.open.selected])},Rl=i=>i.state.field(tt,!1)?(i.dispatch({effects:oo.of(!0)}),!0):!1,Gk=i=>{let e=i.state.field(tt,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(i.dispatch({effects:bs.of(null)}),!0)};class Uk{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Wk=50,qk=1e3,Kk=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(tt).active)e.isPending&&this.startQuery(e)}update(i){let e=i.state.field(tt),t=i.state.facet(De);if(!i.selectionSet&&!i.docChanged&&i.startState.field(tt)==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>Wk&&Date.now()-o.time>qk){for(let l of o.context.abortListeners)try{l()}catch(a){it(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(oo)))&&(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(tt);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(De).updateSyncTime))}startQuery(i){let{state:e}=this.view,t=Gi(e),n=new gg(e,t,i.explicit,this.view),s=new Uk(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:bs.of(null)}),it(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(De).updateSyncTime))}accept(){var i;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(De),n=this.view.state.field(tt);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=Gi(r.updates.length?r.updates[0].startState:this.view.state),a=Math.min(l,r.done.from+(r.active.explicit?0:1)),c=new Sn(r.active.source,r.active.explicit,a,r.done,r.done.from,(i=r.done.to)!==null&&i!==void 0?i:l);for(let u of r.updates)c=c.update(u,t);if(c.hasResult()){e.push(c);continue}}let o=n.active.find(l=>l.source==r.active.source);if(o&&o.isPending)if(r.done==null){let l=new xt(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:Lc.of(e)})}},{eventHandlers:{blur(i){let e=this.view.state.field(tt,!1);if(e&&e.tooltip&&this.view.state.facet(De).closeOnBlur){let t=e.open&&am(this.view,e.open.tooltip);(!t||!t.dom.contains(i.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:bs.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:oo.of(!1)}),20),this.composing=0}}}),Yk=typeof navigator=="object"&&/Win/.test(navigator.platform),Xk=Qi.highest(z.domEventHandlers({keydown(i,e){let t=e.state.field(tt,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||i.key.length>1||i.ctrlKey&&!(Yk&&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&&Nc(e,n),!1}})),Qk=z.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"}}}),Ss={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},$i=J.define({map(i,e){let t=e.mapPos(i,-1,Xe.TrackAfter);return t??void 0}}),Fc=new class extends Ui{};Fc.startSide=1;Fc.endSide=-1;const vg=Ve.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($i)&&(i=i.update({add:[Fc.range(t.value,t.value+1)]}));return i}});function Jk(){return[eT,vg]}const wl="()[]{}<>«»»«[]{}";function Eg(i){for(let e=0;e<wl.length;e+=2)if(wl.charCodeAt(e)==i)return wl.charAt(e+1);return hc(i<128?i:i+1)}function Cg(i,e){return i.languageDataAt("closeBrackets",e)[0]||Ss}const Zk=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),eT=z.inputHandler.of((i,e,t,n)=>{if((Zk?i.composing:i.compositionStarted)||i.state.readOnly)return!1;let s=i.state.selection.main;if(n.length>2||n.length==2&&Bt(et(n,0))==1||e!=s.from||t!=s.to)return!1;let r=nT(i.state,n);return r?(i.dispatch(r),!0):!1}),tT=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let n=Cg(i,i.selection.main.head).brackets||Ss.brackets,s=null,r=i.changeByRange(o=>{if(o.empty){let l=sT(i.doc,o.head);for(let a of n)if(a==l&&Mo(i.doc,o.head)==Eg(et(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:j.cursor(o.head-a.length)}}return{range:s=o}});return s||e(i.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},iT=[{key:"Backspace",run:tT}];function nT(i,e){let t=Cg(i,i.selection.main.head),n=t.brackets||Ss.brackets;for(let s of n){let r=Eg(et(s,0));if(e==s)return r==s?lT(i,s,n.indexOf(s+s+s)>-1,t):rT(i,s,r,t.before||Ss.before);if(e==r&&Rg(i,i.selection.main.from))return oT(i,s,r)}return null}function Rg(i,e){let t=!1;return i.field(vg).between(0,i.doc.length,n=>{n==e&&(t=!0)}),t}function Mo(i,e){let t=i.sliceString(e,e+2);return t.slice(0,Bt(et(t,0)))}function sT(i,e){let t=i.sliceString(e-2,e);return Bt(et(t,0))==t.length?t:t.slice(1)}function rT(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:$i.of(o.to+e.length),range:j.range(o.anchor+e.length,o.head+e.length)};let l=Mo(i.doc,o.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:$i.of(o.head+e.length),range:j.cursor(o.head+e.length)}:{range:s=o}});return s?null:i.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function oT(i,e,t){let n=null,s=i.changeByRange(r=>r.empty&&Mo(i.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:j.cursor(r.head+t.length)}:n={range:r});return n?null:i.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function lT(i,e,t,n){let s=n.stringPrefixes||Ss.stringPrefixes,r=null,o=i.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:$i.of(l.to+e.length),range:j.range(l.anchor+e.length,l.head+e.length)};let a=l.head,c=Mo(i.doc,a),u;if(c==e){if(nd(i,a))return{changes:{insert:e+e,from:a},effects:$i.of(a+e.length),range:j.cursor(a+e.length)};if(Rg(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:j.cursor(a+f.length)}}}else{if(t&&i.sliceDoc(a-2*e.length,a)==e+e&&(u=sd(i,a-2*e.length,s))>-1&&nd(i,u))return{changes:{insert:e+e+e+e,from:a},effects:$i.of(a+e.length),range:j.cursor(a+e.length)};if(i.charCategorizer(a)(c)!=Se.Word&&sd(i,a,s)>-1&&!aT(i,a,e,s))return{changes:{insert:e+e,from:a},effects:$i.of(a+e.length),range:j.cursor(a+e.length)}}return{range:r=l}});return r?null:i.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function nd(i,e){let t=We(i).resolveInner(e+1);return t.parent&&t.from==e}function aT(i,e,t,n){let s=We(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 u=s.firstChild;for(;u&&u.from==s.from&&u.to-u.from>t.length+a;){if(i.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let c=s.to==e&&s.parent;if(!c)break;s=c}return!1}function sd(i,e,t){let n=i.charCategorizer(e);if(n(i.sliceDoc(e-1,e))!=Se.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))!=Se.Word)return r}return-1}function cT(i={}){return[Xk,tt,De.of(i),Kk,uT,Qk]}const wg=[{key:"Ctrl-Space",run:Rl},{mac:"Alt-`",run:Rl},{mac:"Alt-i",run:Rl},{key:"Escape",run:Gk},{key:"ArrowDown",run:dr(!0)},{key:"ArrowUp",run:dr(!1)},{key:"PageDown",run:dr(!0,"page")},{key:"PageUp",run:dr(!1,"page")},{key:"Enter",run:Hk}],uT=Qi.highest(Co.computeN([De],i=>i.facet(De).defaultKeymap?[wg]:[]));class rd{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class Fi{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let s=n.facet(vs).markerFilter;s&&(e=s(e,n));let r=e.slice().sort((p,m)=>p.from-m.from||p.to-m.to),o=new ri,l=[],a=0,c=n.doc.iter(),u=0,d=n.doc.length;for(let p=0;;){let m=p==r.length?null:r[p];if(!m&&!l.length)break;let g,x;if(l.length)g=a,x=l.reduce((S,E)=>Math.min(S,E.to),m&&m.from>g?m.from:1e8);else{if(g=m.from,g>d)break;x=m.to,l.push(m),p++}for(;p<r.length;){let S=r[p];if(S.from==g&&(S.to>S.from||S.to==g))l.push(S),p++,x=Math.min(S.to,x);else{x=Math.min(S.from,x);break}}x=Math.min(x,d);let y=!1;if(l.some(S=>S.from==g&&(S.to==x||x==d))&&(y=g==x,!y&&x-g<10)){let S=g-(u+c.value.length);S>0&&(c.next(S),u=g);for(let E=g;;){if(E>=x){y=!0;break}if(!c.lineBreak&&u+c.value.length>E)break;E=u+c.value.length,u+=c.value.length,c.next()}}let b=CT(l);if(y)o.add(g,g,K.widget({widget:new bT(b),diagnostics:l.slice()}));else{let S=l.reduce((E,v)=>v.markClass?E+" "+v.markClass:E,"");o.add(g,x,K.mark({class:"cm-lintRange cm-lintRange-"+b+S,diagnostics:l.slice(),inclusiveEnd:l.some(E=>E.to>x)}))}if(a=x,a==d)break;for(let S=0;S<l.length;S++)l[S].to<=a&&l.splice(S--,1)}let f=o.finish();return new Fi(f,t,In(f))}}function In(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 rd(s,r,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new rd(n.from,r,n.diagnostic)}}),n}function hT(i,e){let t=e.pos,n=e.end||t,s=i.state.facet(vs).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 dT(i,e){return i.field(ut,!1)?e:e.concat(J.appendConfig.of(RT))}const kg=J.define(),Bc=J.define(),Tg=J.define(),ut=Ve.define({create(){return new Fi(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=In(t,i.selected.diagnostic,r)||In(t,null,r)}!t.size&&s&&e.state.facet(vs).autoPanel&&(s=null),i=new Fi(t,s,n)}for(let t of e.effects)if(t.is(kg)){let n=e.state.facet(vs).autoPanel?t.value.length?Es.open:null:i.panel;i=Fi.init(t.value,n,e.state)}else t.is(Bc)?i=new Fi(i.diagnostics,t.value?Es.open:null,i.selected):t.is(Tg)&&(i=new Fi(i.diagnostics,i.panel,t.value));return i},provide:i=>[gs.from(i,e=>e.panel),z.decorations.from(i,e=>e.diagnostics)]}),fT=K.mark({class:"cm-lintRange cm-lintRange-active"});function pT(i,e,t){let{diagnostics:n}=i.state.field(ut),s,r=-1,o=-1;n.between(e-(t<0?1:0),e+(t>0?1:0),(a,c,{spec:u})=>{if(e>=a&&e<=c&&(a==c||(e>a||t>0)&&(e<c||t<0)))return s=u.diagnostics,r=a,o=c,!1});let l=i.state.facet(vs).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:mT(i,s)}}}:null}function mT(i,e){return fe("ul",{class:"cm-tooltip-lint"},e.map(t=>jg(i,t,!1)))}const gT=i=>{let e=i.state.field(ut,!1);(!e||!e.panel)&&i.dispatch({effects:dT(i.state,[Bc.of(!0)])});let t=ms(i,Es.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},od=i=>{let e=i.state.field(ut,!1);return!e||!e.panel?!1:(i.dispatch({effects:Bc.of(!1)}),!0)},xT=i=>{let e=i.state.field(ut,!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)},yT=[{key:"Mod-Shift-m",run:gT,preventDefault:!0},{key:"F8",run:xT}],vs=G.define({combine(i){return{sources:i.map(e=>e.source).filter(e=>e!=null),...Yt(i.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:ld,tooltipFilter:ld,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 ld(i,e){return i?e?(t,n)=>e(i(t,n),n):i:e}function Ag(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 jg(i,e,t){var n;let s=t?Ag(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 m=In(i.state.field(ut).diagnostics,e);m&&r.apply(i,m.from,m.to)},{name:c}=r,u=s[o]?c.indexOf(s[o]):-1,d=u<0?c:[c.slice(0,u),fe("u",c.slice(u,u+1)),c.slice(u+1)],f=r.markClass?" "+r.markClass:"";return fe("button",{type:"button",class:"cm-diagnosticAction"+f,onclick:a,onmousedown:a,"aria-label":` Action: ${c}${u<0?"":` (access key "${s[o]})"`}.`},d)}),e.source&&fe("div",{class:"cm-diagnosticSource"},e.source))}class bT extends ai{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 ad{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=jg(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Es{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)od(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=Ag(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=In(this.view.state.field(ut).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:()=>od(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(ut).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(ut),n=0,s=!1,r=null,o=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:c})=>{for(let u of c.diagnostics){if(o.has(u))continue;o.add(u);let d=-1,f;for(let p=n;p<this.items.length;p++)if(this.items[p].diagnostic==u){d=p;break}d<0?(f=new ad(this.view,u),this.items.splice(n,0,f),s=!0):(f=this.items[d],d>n&&(this.items.splice(n,d-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 ad(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 c=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/c:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/c)}})):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(ut),n=In(t.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:Tg.of(n)})}static open(e){return new Es(e)}}function ST(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 fr(i){return ST(`<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 vT=z.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:fr("#d11")},".cm-lintRange-warning":{backgroundImage:fr("orange")},".cm-lintRange-info":{backgroundImage:fr("#999")},".cm-lintRange-hint":{backgroundImage:fr("#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 ET(i){return i=="error"?4:i=="warning"?3:i=="info"?2:1}function CT(i){let e="hint",t=1;for(let n of i){let s=ET(n.severity);s>t&&(t=s,e=n.severity)}return e}const RT=[ut,z.decorations.compute([ut],i=>{let{selected:e,panel:t}=i.field(ut);return!e||!t||e.from==e.to?K.none:K.set([fT.range(e.from,e.to)])}),jR(pT,{hideOn:hT}),vT];var cd=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(iT)),e.defaultKeymap!==!1&&(n=n.concat(Yw)),e.searchKeymap!==!1&&(n=n.concat(vk)),e.historyKeymap!==!1&&(n=n.concat(iw)),e.foldKeymap!==!1&&(n=n.concat(p1)),e.completionKeymap!==!1&&(n=n.concat(wg)),e.lintKeymap!==!1&&(n=n.concat(yT));var s=[];return e.lineNumbers!==!1&&s.push(_R()),e.highlightActiveLineGutter!==!1&&s.push(HR()),e.highlightSpecialChars!==!1&&s.push(sR()),e.history!==!1&&s.push(q1()),e.foldGutter!==!1&&s.push(y1()),e.drawSelection!==!1&&s.push(qC()),e.dropCursor!==!1&&s.push(JC()),e.allowMultipleSelections!==!1&&s.push(se.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&s.push(s1()),e.syntaxHighlighting!==!1&&s.push(Rm(E1,{fallback:!0})),e.bracketMatching!==!1&&s.push(j1()),e.closeBrackets!==!1&&s.push(Jk()),e.autocompletion!==!1&&s.push(cT()),e.rectangularSelection!==!1&&s.push(yR()),t!==!1&&s.push(vR()),e.highlightActiveLine!==!1&&s.push(uR()),e.highlightSelectionMatches!==!1&&s.push(ik()),e.tabSize&&typeof e.tabSize=="number"&&s.push(wo.of(" ".repeat(e.tabSize))),s.concat([Co.of(n.flat())]).filter(Boolean)};const wT="#e5c07b",ud="#e06c75",kT="#56b6c2",TT="#ffffff",kr="#abb2bf",Ba="#7d8799",AT="#61afef",jT="#98c379",hd="#d19a66",IT="#c678dd",OT="#21252b",dd="#2c313a",fd="#282c34",kl="#353a42",MT="#3E4451",pd="#528bff",PT=z.theme({"&":{color:kr,backgroundColor:fd},".cm-content":{caretColor:pd},".cm-cursor, .cm-dropCursor":{borderLeftColor:pd},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:MT},".cm-panels":{backgroundColor:OT,color:kr},".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:fd,color:Ba,border:"none"},".cm-activeLineGutter":{backgroundColor:dd},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:kl},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:kl,borderBottomColor:kl},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:dd,color:kr}}},{dark:!0}),DT=Ls.define([{tag:T.keyword,color:IT},{tag:[T.name,T.deleted,T.character,T.propertyName,T.macroName],color:ud},{tag:[T.function(T.variableName),T.labelName],color:AT},{tag:[T.color,T.constant(T.name),T.standard(T.name)],color:hd},{tag:[T.definition(T.name),T.separator],color:kr},{tag:[T.typeName,T.className,T.number,T.changed,T.annotation,T.modifier,T.self,T.namespace],color:wT},{tag:[T.operator,T.operatorKeyword,T.url,T.escape,T.regexp,T.link,T.special(T.string)],color:kT},{tag:[T.meta,T.comment],color:Ba},{tag:T.strong,fontWeight:"bold"},{tag:T.emphasis,fontStyle:"italic"},{tag:T.strikethrough,textDecoration:"line-through"},{tag:T.link,color:Ba,textDecoration:"underline"},{tag:T.heading,fontWeight:"bold",color:ud},{tag:[T.atom,T.bool,T.special(T.variableName)],color:hd},{tag:[T.processingInstruction,T.string,T.inserted],color:jT},{tag:T.invalid,color:TT}]),LT=[PT,Rm(DT)];var NT=z.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),FT=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(Co.of([Xw])),l&&(typeof l=="boolean"?a.unshift(cd()):a.unshift(cd(l))),o&&a.unshift(pR(o)),r){case"light":a.push(NT);break;case"dark":a.push(LT);break;case"none":break;default:a.push(r);break}return n===!1&&a.push(z.editable.of(!1)),s&&a.push(se.readOnly.of(!0)),[...a]},BT=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 VT{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 md{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 Tl=null,_T=()=>typeof window>"u"?new md:(Tl||(Tl=new md),Tl),gd=Kt.define(),$T=200,zT=[];function HT(i){var{value:e,selection:t,onChange:n,onStatistics:s,onCreateEditor:r,onUpdate:o,extensions:l=zT,autoFocus:a,theme:c="light",height:u=null,minHeight:d=null,maxHeight:f=null,width:p=null,minWidth:m=null,maxWidth:g=null,placeholder:x="",editable:y=!0,readOnly:b=!1,indentWithTab:S=!0,basicSetup:E=!0,root:v,initialState:C}=i,[k,O]=A.useState(),[w,D]=A.useState(),[N,F]=A.useState(),_=A.useState(()=>({current:null}))[0],P=A.useState(()=>({current:null}))[0],B=z.theme({"&":{height:u,minHeight:d,maxHeight:f,width:p,minWidth:m,maxWidth:g},"& .cm-scroller":{height:"100% !important"}}),W=z.updateListener.of(ne=>{if(ne.docChanged&&typeof n=="function"&&!ne.transactions.some(R=>R.annotation(gd))){_.current?_.current.reset():(_.current=new VT(()=>{if(P.current){var R=P.current;P.current=null,R()}_.current=null},$T),_T().add(_.current));var te=ne.state.doc,q=te.toString();n(q,ne)}s&&s(BT(ne))}),ee=FT({theme:c,editable:y,readOnly:b,placeholder:x,indentWithTab:S,basicSetup:E}),ae=[W,B,...ee];return o&&typeof o=="function"&&ae.push(z.updateListener.of(o)),ae=ae.concat(l),A.useLayoutEffect(()=>{if(k&&!N){var ne={doc:e,selection:t,extensions:ae},te=C?se.fromJSON(C.json,ne,C.fields):se.create(ne);if(F(te),!w){var q=new z({state:te,parent:k,root:v});D(q),r&&r(q,te)}}return()=>{w&&(F(void 0),D(void 0))}},[k,N]),A.useEffect(()=>{i.container&&O(i.container)},[i.container]),A.useEffect(()=>()=>{w&&(w.destroy(),D(void 0)),_.current&&(_.current.cancel(),_.current=null)},[w]),A.useEffect(()=>{a&&w&&w.focus()},[a,w]),A.useEffect(()=>{w&&w.dispatch({effects:J.reconfigure.of(ae)})},[c,l,u,d,f,p,m,g,x,y,b,S,E,n,o]),A.useEffect(()=>{if(e!==void 0){var ne=w?w.state.doc.toString():"";if(w&&e!==ne){var te=_.current&&!_.current.isDone,q=()=>{w&&e!==w.state.doc.toString()&&w.dispatch({changes:{from:0,to:w.state.doc.toString().length,insert:e||""},annotations:[gd.of(!0)]})};te?P.current=q:q()}}},[e,w]),{state:N,setState:F,view:w,setView:D,container:k,setContainer:O}}var GT=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Ig=A.forwardRef((i,e)=>{var{className:t,value:n="",selection:s,extensions:r=[],onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:c,autoFocus:u,theme:d="light",height:f,minHeight:p,maxHeight:m,width:g,minWidth:x,maxWidth:y,basicSetup:b,placeholder:S,indentWithTab:E,editable:v,readOnly:C,root:k,initialState:O}=i,w=ws(i,GT),D=A.useRef(null),{state:N,view:F,container:_,setContainer:P}=HT({root:k,value:n,autoFocus:u,theme:d,height:f,minHeight:p,maxHeight:m,width:g,minWidth:x,maxWidth:y,basicSetup:b,placeholder:S,indentWithTab:E,editable:v,readOnly:C,selection:s,onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:c,extensions:r,initialState:O});A.useImperativeHandle(e,()=>({editor:D.current,state:N,view:F}),[D,_,N,F]);var B=A.useCallback(ee=>{D.current=ee,P(ee)},[P]);if(typeof n!="string")throw new Error("value must be typeof string but got "+typeof n);var W=typeof d=="string"?"cm-theme-"+d:"cm-theme";return h.jsxRuntimeExports.jsx("div",me({ref:B,className:""+W+(t?" "+t:"")},w))});Ig.displayName="CodeMirror";function Vc({value:i,language:e,readOnly:t=!1,height:n="300px",foldable:s=!1,onChange:r}){const[o]=M.useStyletron(),l=e==="json"?[F1()]:[],a=z.theme({"&":{fontSize:"14px",fontFamily:"monospace"},".cm-content":{padding:"12px"},".cm-editor":{backgroundColor:t?"#F8F8F8":"#FFFFFF"},".cm-editor.cm-focused":{outline:"none"}});return h.jsxRuntimeExports.jsx("div",{className:o({border:"1px solid #E0E0E0",borderRadius:"4px",overflow:"hidden",height:n}),children:h.jsxRuntimeExports.jsx(Ig,{value:i,height:n,extensions:[...l,a],onChange:r,editable:!t,basicSetup:{lineNumbers:!0,foldGutter:s,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!1,bracketMatching:!0,closeBrackets:!1,autocompletion:!1,highlightSelectionMatches:!1,searchKeymap:!1}})})}function UT({data:i,isLoading:e}){const[,t]=M.useStyletron(),s=wf(i);return e?h.jsxRuntimeExports.jsx(Si.Skeleton,{animation:!0,height:"400px",width:"100%"}):s?h.jsxRuntimeExports.jsxs("section",{children:[h.jsxRuntimeExports.jsx(ge.HeadingSmall,{marginTop:"0",marginBottom:t.sizing.scale600,children:"General"}),h.jsxRuntimeExports.jsx(h.Box,{title:"Manifest content",children:h.jsxRuntimeExports.jsx(Vc,{value:JSON.stringify(s,null,2),language:"json",readOnly:!0,foldable:!0,height:"auto"})})]}):h.jsxRuntimeExports.jsx(Gt,{illustration:h.jsxRuntimeExports.jsx(si,{height:t.sizing.scale1600,width:t.sizing.scale1600,kind:St.PRIMARY}),title:"No configuration available",description:"This pipeline run has no configuration attached to its manifest"})}function WT(i){return i.filter(e=>!!e.name&&!!e.url).map(e=>({id:e.name,accessor:()=>e.name,url:e.url,tooltip:e.tooltip}))}function _c(i){const{links:e,title:t,isLoading:n=!1}=i;return h.jsxRuntimeExports.jsx(h.Box,{title:t,children:h.jsxRuntimeExports.jsx(h.Row,{items:WT(e),loading:n})})}const Zi={boolValue:"boolValue",listValue:"listValue",nullValue:"nullValue",numberValue:"numberValue",stringValue:"stringValue",structValue:"structValue"};function $c(i){return!!i&&typeof i=="object"&&"fields"in i&&typeof i.fields=="object"&&!Array.isArray(i.fields)}function qT(i){const e=Object.entries(i),[t,n]=e[0]||[];return{kind:t,kindValue:n}}function KT(i){const e={};for(const[t,n]of Object.entries(i))e[t]=Cs(n);return e}function Cs(i){if(i==null)return i;if($c(i))return KT(i.fields);if(typeof i=="object"&&i!==null){const e=i,{kind:t,kindValue:n}=qT(e);switch(t){case Zi.listValue:return n&&typeof n=="object"&&"values"in n?n.values.map(r=>Cs(r)):[];case Zi.nullValue:return null;case Zi.structValue:return n?Cs(n):{};case Zi.boolValue:case Zi.numberValue:case Zi.stringValue:return n;default:return i}}return i}const YT="Execute Workflow",XT="michelangelo/environment",QT="pipelinerun.michelangelo/execution-timestamp",JT="pipelinerun.michelangelo/parameter-id";function ZT({data:i,isLoading:e}){var y,b,S,E,v,C,k,O,w,D,N;const[t,n]=M.useStyletron(),{projectId:s,phase:r}=h.useStudioParams("detail"),o=i,l=(S=(b=(y=o==null?void 0:o.spec)==null?void 0:y.resume)==null?void 0:b.pipelineRun)==null?void 0:S.name,a=[{name:"Michelangelo pipeline run logs",url:(v=eA((E=o==null?void 0:o.status)==null?void 0:E.steps,YT))==null?void 0:v.logUrl},{name:l?`Resumed from ${l}`:void 0,url:l?`/${s}/${r}/runs/${l}`:void 0}],c=(C=o==null?void 0:o.status)==null?void 0:C.errorMessage,u=wf(o),d=tA((k=o==null?void 0:o.spec)==null?void 0:k.input),f=[{id:"duration",label:"Duration",value:nA(o)??""},{id:"execution-timestamp",label:"Execution Timestamp",value:h.timestampToString(iA(o),h.TimeZone.Local)??""}],p=[{id:"environment",label:"Environment",value:((w=(O=o==null?void 0:o.metadata)==null?void 0:O.labels)==null?void 0:w[XT])??""},{id:"parameter-id",label:"Parameter ID",value:((N=(D=o==null?void 0:o.metadata)==null?void 0:D.labels)==null?void 0:N[JT])??""}],m=t({display:"flex",flexDirection:"column",gap:n.sizing.scale600}),g=F=>h.jsxRuntimeExports.jsx(ii,{onSubmit:()=>{},initialValues:Object.fromEntries(F.map(_=>[_.id,_.value])),children:h.jsxRuntimeExports.jsx("div",{className:m,children:F.map(_=>e?h.jsxRuntimeExports.jsx(Si.Skeleton,{animation:!0,height:"48px",width:"100%"},_.id):h.jsxRuntimeExports.jsx(Be,{name:_.id,label:_.label,readOnly:!0},_.id))})}),x=(F,_)=>e?h.jsxRuntimeExports.jsx(Si.Skeleton,{animation:!0,height:"200px",width:"100%"}):h.jsxRuntimeExports.jsx(h.Box,{title:F,children:h.jsxRuntimeExports.jsx(Vc,{value:JSON.stringify(_,null,2),language:"json",readOnly:!0,foldable:!0,height:"auto"})});return h.jsxRuntimeExports.jsxs("div",{className:m,children:[h.jsxRuntimeExports.jsx(_c,{title:"Useful links",links:a,isLoading:e}),c&&!e&&h.jsxRuntimeExports.jsxs("section",{children:[h.jsxRuntimeExports.jsx(ge.HeadingSmall,{marginTop:"0",marginBottom:n.sizing.scale600,children:"Message"}),h.jsxRuntimeExports.jsx(h.Box,{children:h.jsxRuntimeExports.jsx(ii,{onSubmit:()=>{},initialValues:{"error-message":c},children:h.jsxRuntimeExports.jsx(Ts,{name:"error-message",label:"Error message",readOnly:!0})})})]}),h.jsxRuntimeExports.jsxs("section",{children:[h.jsxRuntimeExports.jsx(ge.HeadingSmall,{marginTop:"0",marginBottom:n.sizing.scale600,children:"Key status indicators"}),h.jsxRuntimeExports.jsx(h.Box,{children:g(f)})]}),h.jsxRuntimeExports.jsxs("section",{children:[h.jsxRuntimeExports.jsx(ge.HeadingSmall,{marginTop:"0",marginBottom:n.sizing.scale600,children:"Configuration"}),h.jsxRuntimeExports.jsxs("div",{className:m,children:[h.jsxRuntimeExports.jsx(h.Box,{children:g(p)}),u!==void 0&&x("Content",u),d!==void 0&&x("Input",d)]})]})]})}function eA(i,e){return i==null?void 0:i.find(t=>t.name===e)}function tA(i){if(i==null)return;const e=$c(i)?Cs(i):i;if(!(typeof e=="object"&&e!==null&&Object.keys(e).length===0))return e}function iA(i){var t,n,s,r;const e=(n=(t=i==null?void 0:i.metadata)==null?void 0:t.labels)==null?void 0:n[QT];return e&&!isNaN(Number(e))?e:(r=(s=i==null?void 0:i.metadata)==null?void 0:s.creationTimestamp)==null?void 0:r.seconds}function nA(i){var n,s,r,o;const e=Number((s=(n=i==null?void 0:i.metadata)==null?void 0:n.creationTimestamp)==null?void 0:s.seconds),t=(r=i==null?void 0:i.status)==null?void 0:r.state;if(isNaN(e)||t===void 0)return null;if(mf.has(t)){const l=(((o=i==null?void 0:i.status)==null?void 0:o.steps)??[]).map(a=>{var c;return Number((c=a.endTime)==null?void 0:c.seconds)}).filter(a=>!isNaN(a));return l.length===0?null:xd(Math.max(...l)-e)}return t===Lr.RUNNING?xd(Math.floor(Date.now()/1e3)-e):null}function xd(i){const e=Math.max(0,Math.round(i)),t=[],n=Math.floor(e/3600),s=Math.floor(e%3600/60),r=e%60;return n>0&&t.push(`${n} ${n===1?"hour":"hours"}`),s>0&&t.push(`${s} ${s===1?"minute":"minutes"}`),(r>0||t.length===0)&&t.push(`${r} ${r===1?"second":"seconds"}`),t.join(" ")}const sA={type:"detail",metadata:nc,pages:[{id:"information",label:"Information",type:"custom",component:ZT},{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:h.CellType.DATE},{id:"endTime.seconds",label:"End time",type:h.CellType.DATE},{id:"duration",label:"Duration",type:h.CellType.TEXT,accessor:i=>{var e,t;return h.formatElapsedSeconds((e=i.startTime)==null?void 0:e.seconds,(t=i.endTime)==null?void 0:t.seconds)}},{id:"logUrl",label:"Logs"},{id:"state",label:"Status",type:h.CellType.STATE,stateTextMap:yf,stateColorMap:bf},{id:"retry",label:"Actions",type:h.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}}}},{id:"configuration",label:"Pipeline Configuration",type:"custom",component:UT}]},rA="michelangelo/SpecUpdateTimestamp",oA="michelangelo/UpdateTimestamp",Og=1e6,ao=63,Mg=/^[a-z0-9]([-a-z0-9]*[a-z0-9])?$/,co="Must only contain lowercase alphanumeric characters, '-', and must start and end with an alphanumeric character";function zc(i){var t,n,s,r;const e=(n=(t=i.metadata)==null?void 0:t.labels)==null?void 0:n[rA];return e?Number(e)/Og:(r=(s=i.metadata)==null?void 0:s.creationTimestamp)==null?void 0:r.seconds}function lA(i){var t,n,s,r;const e=(n=(t=i.metadata)==null?void 0:t.labels)==null?void 0:n[oA];return e?Number(e)/Og:(r=(s=i.metadata)==null?void 0:s.creationTimestamp)==null?void 0:r.seconds}const aA=[{id:"metadata.name",label:"Pipeline run name",items:[{id:"metadata.name",url:"/${studio.projectId}/${studio.phase}/runs/${data.metadata.name}"},{id:"spec.description",type:h.CellType.DESCRIPTION}]},Ef,{id:"metadata",label:"Last Updated",type:h.CellType.DATE,accessor:i=>lA(i)},vf,{id:"metadata.labels",label:"Environment",type:h.CellType.TEXT,accessor:i=>{var t;const e=(t=i==null?void 0:i.metadata)==null?void 0:t.labels;return xf(e)||null}},Cf,ic,Rf],cA={type:"list",tableConfig:{columns:aA}},uA=new Set([Lr.FAILED,Lr.KILLED]),hA=i=>{var t;const e=(t=i.status)==null?void 0:t.state;return e!==void 0&&uA.has(e)},dA=[{source:"metadata.name",destination:"spec.resume.pipelineRun.name",transformation:i=>i},{source:"metadata.namespace",destination:"spec.resume.pipelineRun.namespace",transformation:i=>i},{destination:"spec.resume.resumeFrom",transformation:"unset"},{destination:"spec.retryInfo",transformation:"unset"},{destination:"spec.actor",transformation:"unset"},{destination:"spec.kill",transformation:"unset"},{destination:"status",transformation:"unset"},{destination:"typeMeta",transformation:"unset"},{source:"metadata",destination:"metadata",transformation:i=>({name:`run${tc({withDate:!0})}`,namespace:i.namespace})}],Po={id:"runs",name:"runs",service:"pipelineRun",state:"active",views:[cA,sA],actions:[{display:{label:"Retry",icon:"arrowCircular"},hierarchy:st.PRIMARY,disabled:[{condition:He(({data:i})=>!hA(i)),message:"Only failed or killed runs can be retried"}],operation:{type:"mutation",mutation:{mutationName:"CreatePipelineRun",middleware:{operations:dA},successOperations:[{type:"invalidate",targets:["ListPipelineRun"]},{type:"toast",message:"A new pipeline run has been created from the failed step of this run.",action:{label:"See new run",route:He("/${studio.projectId}/${studio.phase}/runs/${response.pipelineRun.metadata.name}")}}]}},modal:{type:"confirm",header:{title:"Retry Pipeline Run"},body:He(({data:i})=>{var e;return`Retry run **${(e=i.metadata)==null?void 0:e.name}**? This starts a new run that reuses the cached results of every step that already succeeded.`}),button:{label:"Retry"}}}]},Pg={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:[{...bo,state:"disabled"},{...Po,state:"disabled"},{id:"datasources",name:"data sources",state:"disabled",service:"datasource",views:[]}]},fA=1,pA=i=>({operation:{criterion:[{fieldName:"model.model_family_name",operator:fA,matchValue:i}]}}),mA=({modelFamilyReadOnly:i=!1})=>{const e=ks(),{input:t}=ke("spec.modelFamily.name"),n=t.value??"",{data:s,isLoading:r}=h.useStudioQuery({queryName:"ListModelFamily",serviceOptions:{}}),{data:o,isLoading:l}=h.useStudioQuery({queryName:"ListModel",serviceOptions:{listOptionsExt:pA(n)}}),a=((s==null?void 0:s.modelFamilyList.items)??[]).map(d=>({id:d.metadata.name,label:d.spec.name||d.metadata.name})),c=((o==null?void 0:o.modelList.items)??[]).map(d=>({id:d.metadata.name,label:d.metadata.name})),u=A.useRef(n);return A.useEffect(()=>{u.current!==n&&(u.current=n,e.change("spec.desiredRevision.name",""))},[e,n]),h.jsxRuntimeExports.jsxs(ji,{title:"Model",description:"The selected model will be deployed",children:[h.jsxRuntimeExports.jsx(dt,{name:"spec.modelFamily.name",label:"Model family",caption:"Model family the deployed model belongs to",options:a,isLoading:r,clearable:!1,readOnly:i}),h.jsxRuntimeExports.jsx(dt,{name:"spec.desiredRevision.name",label:"Model",required:!0,caption:"Search and select the model to deploy",options:c,isLoading:l,disabled:!n,clearable:!1})]})},Al={UNKNOWN:0,TRUE:1,FALSE:2},at={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},Dt={INVALID:0,INITIALIZING:1,HEALTHY:2,UNHEALTHY:3,EMPTY:4},qn={INFERENCE_SERVER:1,OFFLINE:2,MOBILE:3,SELF_HOSTED:4},gA={[qn.INFERENCE_SERVER]:"Online",[qn.OFFLINE]:"Offline",[qn.MOBILE]:"Mobile",[qn.SELF_HOSTED]:"Self-hosted"},Hc={id:"status.stage",label:"Stage",type:h.CellType.TYPE,typeTextMap:{[at.INVALID]:"Invalid",[at.VALIDATION]:"Validation",[at.PLACEMENT]:"Placement",[at.RESOURCE_ACQUISITION]:"Resource acquisition",[at.ROLLOUT_COMPLETE]:"Rollout complete",[at.ROLLOUT_FAILED]:"Rollout failed",[at.ROLLBACK_IN_PROGRESS]:"Rollback in progress",[at.ROLLBACK_COMPLETE]:"Rollback complete",[at.ROLLBACK_FAILED]:"Rollback failed",[at.CLEAN_UP_IN_PROGRESS]:"Clean up in progress",[at.CLEAN_UP_COMPLETE]:"Clean up complete",[at.CLEAN_UP_FAILED]:"Clean up failed"}},Gc={id:"status.state",label:"State",type:h.CellType.STATE,stateTextMap:{[Dt.INVALID]:"Invalid",[Dt.INITIALIZING]:"Initializing",[Dt.HEALTHY]:"Healthy",[Dt.UNHEALTHY]:"Unhealthy",[Dt.EMPTY]:"Empty"},stateColorMap:{[Dt.INVALID]:"gray",[Dt.INITIALIZING]:"blue",[Dt.HEALTHY]:"green",[Dt.UNHEALTHY]:"red",[Dt.EMPTY]:"gray"}},Dg={id:"spec.definition.type",label:"Type",type:h.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}},Lg={id:"spec.inferenceServer.name",label:"Target",type:h.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}},Ng=({mode:i,record:e,onClose:t})=>{var p,m,g,x,y,b,S,E,v,C;const{projectId:n}=h.useStudioParams("base"),s=i==="update",r=(m=(p=e==null?void 0:e.spec)==null?void 0:p.desiredRevision)==null?void 0:m.name,{data:o,isLoading:l}=h.useStudioQuery({queryName:"ListInferenceServer",serviceOptions:{}}),a=((o==null?void 0:o.inferenceServerList.items)??[]).map(k=>({id:k.metadata.name,label:k.metadata.name})),c=h.useStudioMutation({mutationName:"CreateDeployment",successOperations:[{type:"toast",message:"Deployment created"},{type:"invalidate",targets:["ListDeployment"]}]}),u=h.useStudioMutation({mutationName:"UpdateDeployment",successOperations:[{type:"toast",message:"Deployment update has begun"},{type:"invalidate",targets:["GetDeployment","ListDeployment"],delayMs:2e3}]}),d=async k=>{if(s){if(u.isPending)return;await u.mutateAsync({...e,spec:{...e==null?void 0:e.spec,desiredRevision:{name:k.spec.desiredRevision.name,namespace:n}}});return}c.isPending||await c.mutateAsync({...k,spec:{...k.spec,modelFamily:{...k.spec.modelFamily,namespace:n},desiredRevision:{...k.spec.desiredRevision,namespace:n},target:{case:"inferenceServer",value:{...k.spec.target.value,namespace:n}}}})},f={metadata:{name:((g=e==null?void 0:e.metadata)==null?void 0:g.name)??"",namespace:n},spec:{modelFamily:{name:((y=(x=e==null?void 0:e.spec)==null?void 0:x.modelFamily)==null?void 0:y.name)??"",namespace:n},desiredRevision:{name:r??"",namespace:n},target:{case:"inferenceServer",value:{name:((E=(S=(b=e==null?void 0:e.spec)==null?void 0:b.target)==null?void 0:S.value)==null?void 0:E.name)??"",namespace:n}},strategy:{rolloutStrategy:{case:"rolling",value:{incrementPercentage:0}}},definition:{type:((C=(v=e==null?void 0:e.spec)==null?void 0:v.definition)==null?void 0:C.type)??qn.INFERENCE_SERVER}}};return h.jsxRuntimeExports.jsxs(As,{isOpen:!0,onDismiss:t,heading:s?"Update deployment":"Create deployment",onSubmit:d,submitLabel:s?"Update":"Create",initialValues:f,children:[h.jsxRuntimeExports.jsx(Be,{name:"metadata.name",label:"Name",required:!0,readOnly:s,maxLength:ao,validate:Vi(pt(),Ja(ao),Pr(Mg,co)),caption:co,placeholder:"my-deployment"}),h.jsxRuntimeExports.jsx(dt,{name:"spec.target.value.name",label:"Inference server",required:!0,readOnly:s,validate:pt(),options:a,isLoading:l,clearable:!1,caption:"The target inference server this deployment will serve traffic to"}),h.jsxRuntimeExports.jsx(mA,{modelFamilyReadOnly:s})]})},xA=({onClose:i})=>h.jsxRuntimeExports.jsx(Ng,{mode:"create",onClose:i}),Qt={INVALID:0,CUSTOM:1,REGRESSION:2,BINARY_CLASSIFICATION:3,MULTICLASS_CLASSIFICATION:4,CLUSTERING:5,LLM_COMPLETION:6,LLM_CHAT_COMPLETION:7,LLM_EMBEDDING:8},Uc={[Qt.INVALID]:"Unknown",[Qt.CUSTOM]:"Custom",[Qt.REGRESSION]:"Regression",[Qt.BINARY_CLASSIFICATION]:"Binary Classification",[Qt.MULTICLASS_CLASSIFICATION]:"Multi-class Classification",[Qt.CLUSTERING]:"Clustering",[Qt.LLM_COMPLETION]:"LLM Completion",[Qt.LLM_CHAT_COMPLETION]:"LLM Chat",[Qt.LLM_EMBEDDING]:"LLM Embedding"};function zn({label:i,children:e}){const[,t]=M.useStyletron();return h.jsxRuntimeExports.jsxs("div",{children:[h.jsxRuntimeExports.jsx(ge.LabelSmall,{color:t.colors.contentSecondary,marginBottom:t.sizing.scale200,children:i}),e]})}const jl={BoxContainer:{style:{flexBasis:"320px",flexGrow:1}}};function Il({title:i,revision:e,emptyText:t,isLoading:n}){var m,g,x,y,b,S,E;const[s,r]=M.useStyletron(),{data:o,isLoading:l}=h.useStudioQuery({queryName:"GetModel",serviceOptions:{name:e==null?void 0:e.name,...(e==null?void 0:e.namespace)!=null&&{namespace:e.namespace}},clientOptions:{enabled:!!(e!=null&&e.name)}});if(n||e!=null&&e.name&&l)return h.jsxRuntimeExports.jsx(h.Box,{title:i,overrides:jl,children:h.jsxRuntimeExports.jsx("div",{className:s({display:"flex",justifyContent:"center"}),children:h.jsxRuntimeExports.jsx(Cx.Spinner,{})})});if(!(e!=null&&e.name))return h.jsxRuntimeExports.jsx(h.Box,{title:i,overrides:jl,children:h.jsxRuntimeExports.jsx(h.Banner,{kind:"info",artwork:{type:ns.ARTWORK_TYPE.icon,icon:()=>h.jsxRuntimeExports.jsx(h.Icon,{name:"circleI",size:r.sizing.scale800})},children:t})});const a=o==null?void 0:o.model,c=(g=(m=a==null?void 0:a.spec)==null?void 0:m.owner)==null?void 0:g.name,u=(x=a==null?void 0:a.spec)==null?void 0:x.kind,d=u!=null?Uc[u]:void 0,f=(b=(y=a==null?void 0:a.metadata)==null?void 0:y.creationTimestamp)==null?void 0:b.seconds,p=(E=(S=a==null?void 0:a.spec)==null?void 0:S.sourcePipelineRun)==null?void 0:E.name;return h.jsxRuntimeExports.jsx(h.Box,{title:i,overrides:jl,children:h.jsxRuntimeExports.jsxs("div",{className:s({display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:r.sizing.scale1200,rowGap:r.sizing.scale900}),children:[h.jsxRuntimeExports.jsx(zn,{label:"Model",children:h.jsxRuntimeExports.jsx(ge.ParagraphMedium,{marginTop:"0",marginBottom:"0",children:e.name})}),h.jsxRuntimeExports.jsx(zn,{label:"Owner",children:h.jsxRuntimeExports.jsx(ge.ParagraphMedium,{marginTop:"0",marginBottom:"0",children:c!=null&&c!==""?c:"—"})}),h.jsxRuntimeExports.jsx(zn,{label:"Creation time",children:h.jsxRuntimeExports.jsx(ge.ParagraphMedium,{marginTop:"0",marginBottom:"0",children:f!=null?h.jsxRuntimeExports.jsx(h.DateTime,{timestamp:f}):"—"})}),h.jsxRuntimeExports.jsx(zn,{label:"Type",children:d!=null?h.jsxRuntimeExports.jsx(h.Tag,{size:h.TAG_SIZE.xSmall,behavior:h.TAG_BEHAVIOR.selection,hierarchy:vn.HIERARCHY.secondary,color:h.TAG_COLOR.gray,closeable:!1,children:d}):h.jsxRuntimeExports.jsx(ge.ParagraphMedium,{marginTop:"0",marginBottom:"0",children:"—"})}),h.jsxRuntimeExports.jsx(zn,{label:"Source pipeline run",children:h.jsxRuntimeExports.jsx(ge.ParagraphMedium,{marginTop:"0",marginBottom:"0",children:p!=null&&p!==""?p:"—"})})]})})}function yA({data:i,isLoading:e}){var p,m,g,x,y,b,S;const[t,n]=M.useStyletron(),{projectId:s,phase:r}=h.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"?(m=l.value)==null?void 0:m.name:void 0,c=[{name:a,url:`/${s}/${r}/targets/${a}`}],u=(x=(g=o==null?void 0:o.spec)==null?void 0:g.definition)==null?void 0:x.type,d=[{id:"type-of-deployment",label:"Type of deployment",value:u!=null?gA[u]??"":""}],f=Object.fromEntries(d.map(E=>[E.id,E.value]));return h.jsxRuntimeExports.jsxs("div",{className:t({display:"flex",flexDirection:"column",gap:n.sizing.scale600}),children:[h.jsxRuntimeExports.jsx(_c,{title:"Useful links",links:c,isLoading:e}),h.jsxRuntimeExports.jsxs("section",{children:[h.jsxRuntimeExports.jsx(ge.HeadingSmall,{marginTop:"0",marginBottom:n.sizing.scale600,children:"Key status indicators"}),h.jsxRuntimeExports.jsxs("div",{className:t({display:"flex",gap:n.sizing.scale600,flexWrap:"wrap"}),children:[h.jsxRuntimeExports.jsx(Il,{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}),h.jsxRuntimeExports.jsx(Il,{title:"Candidate model",revision:(b=o==null?void 0:o.status)==null?void 0:b.candidateRevision,emptyText:"No model currently being deployed",isLoading:e}),h.jsxRuntimeExports.jsx(Il,{title:"Desired model to be deployed",revision:(S=o==null?void 0:o.spec)==null?void 0:S.desiredRevision,emptyText:"No model configured to be deployed",isLoading:e})]})]}),h.jsxRuntimeExports.jsxs("section",{children:[h.jsxRuntimeExports.jsx(ge.HeadingSmall,{marginTop:"0",marginBottom:n.sizing.scale600,children:"Configuration"}),h.jsxRuntimeExports.jsx(h.Box,{children:h.jsxRuntimeExports.jsx(ii,{onSubmit:()=>{},initialValues:f,children:h.jsxRuntimeExports.jsx("div",{className:t({display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:n.sizing.scale1200,rowGap:n.sizing.scale600}),children:d.map(E=>e?h.jsxRuntimeExports.jsx(Si.Skeleton,{animation:!0,height:"48px",width:"100%"},E.id):h.jsxRuntimeExports.jsx(Be,{name:E.id,label:E.label,readOnly:!0},E.id))})})})]})]})}const bA={type:"detail",metadata:[{id:"metadata.creationTimestamp.seconds",label:"Created",type:h.CellType.DATE},{id:"spec.owner.name",label:"Owner",type:h.CellType.TEXT},Hc,Gc],pages:[{id:"info",label:"Information",type:"custom",component:yA},{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)===at.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:h.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 Al.TRUE:return le.SUCCESS;case Al.FALSE:return le.ERROR;case Al.UNKNOWN:default:return le.RUNNING}}}}]},SA=[{id:"metadata.name",label:"Name",type:h.CellType.TEXT,url:"/${studio.projectId}/${studio.phase}/deployments/${row.metadata.name}"},{id:"status.currentRevision.name",label:"Model",type:h.CellType.TEXT},Dg,Hc,Lg,{id:"spec.owner.name",label:"Owner",type:h.CellType.TEXT},Gc],vA={type:"list",tableConfig:{columns:SA}},EA=({record:i,onClose:e})=>h.jsxRuntimeExports.jsx(Ng,{mode:"update",record:i,onClose:e}),CA=i=>{var t,n;const e=i;return!!(((t=e.spec)==null?void 0:t.desiredRevision)??((n=e.status)==null?void 0:n.candidateRevision))},RA=i=>{const e=i;return`Deployed at: **${h.timestampToString(zc(e),h.TimeZone.Local)??"N/A"}**
|
|
35
|
+
|
|
36
|
+
This process might take a few minutes.`},wA={id:"deployments",name:"deployments",service:"deployment",state:"active",views:[vA,bA],actions:[{display:{label:"Update deployment",icon:"pencil"},hierarchy:st.PRIMARY,modal:{type:"custom",component:EA}},{display:{label:"Retire",icon:"circleX"},hierarchy:st.TERTIARY,disabled:[{condition:He(({data:i})=>!CA(i)),message:"Deployment has already been retired"}],operation:{type:"mutation",mutation:{mutationName:"UpdateDeployment",middleware:{operations:[{destination:"spec.desiredRevision",transformation:"unset"}]},successOperations:[{type:"invalidate",targets:["GetDeployment","ListDeployment"],delayMs:2e3},{type:"toast",message:He("Retirement for deployment ${response.deployment.metadata.name} has begun")}]}},modal:{type:"confirm",header:{title:He(({data:i})=>{var e;return`Are you sure you want to retire ${(e=i.metadata)==null?void 0:e.name}`})},body:He(({data:i})=>RA(i)),button:{label:"Yes, retire",icon:"check"}}},{display:{label:"Delete",icon:"trashCan"},hierarchy:st.TERTIARY,operation:{type:"mutation",mutation:{mutationName:"DeleteDeployment",successOperations:[{type:"invalidate",targets:["ListDeployment"],delayMs:2e3},{type:"toast",message:"Deployment has been deleted. This process may take a few seconds."},{type:"route",route:"/${studio.projectId}/${studio.phase}/deployments"}]}},modal:{type:"confirm",header:{title:He(({data:i})=>{var e;return`Are you sure you want to delete “${(e=i.metadata)==null?void 0:e.name}” ?`})},body:"We will perform retirement process first and then the deployment will be deleted. This process will take few minutes to complete.",banner:{content:"If there are any online existing prediction requests or offline pipeline runs in this deployment this call will fail.",kind:"negative",icon:"circleExclamation"},button:{label:"Yes, delete",icon:"trashCan"},destructive:!0}}],createAction:{display:{label:"Create deployment",icon:"plus"},component:xA}},Me={INVALID:0,INITIALIZED:1,CREATE_PENDING:2,SERVING:3,FAILED:4,DELETE_PENDING:5,CREATING:6,DELETING:7,DELETED:8},Ol={UNKNOWN:0,TRUE:1,FALSE:2},Fg={DEDICATED:1,MULTI_TENANT:2},Bg={TRITON:1},kA=[{id:Bg.TRITON,label:"Triton"}],TA="ma-system",Vg={DEFAULT_TRITON:"default_triton"},_g={id:"status.state",label:"State",type:h.CellType.STATE,stateTextMap:{[Me.INVALID]:"Invalid",[Me.INITIALIZED]:"Initialized",[Me.CREATE_PENDING]:"Create pending",[Me.SERVING]:"Serving",[Me.FAILED]:"Failed",[Me.DELETE_PENDING]:"Delete pending",[Me.CREATING]:"Initializing",[Me.DELETING]:"Deleting",[Me.DELETED]:"Deleted"},stateColorMap:{[Me.INVALID]:"gray",[Me.INITIALIZED]:"blue",[Me.CREATE_PENDING]:"blue",[Me.SERVING]:"green",[Me.FAILED]:"red",[Me.DELETE_PENDING]:"blue",[Me.CREATING]:"blue",[Me.DELETING]:"blue",[Me.DELETED]:"gray"}};function AA({clusters:i,isLoading:e}){const t=i.map(n=>{const s=[n.spec.region,n.spec.zone].filter(Boolean).join(" / ");return{id:IA(n),label:s?`${n.metadata.name} (${s})`:n.metadata.name}});return h.jsxRuntimeExports.jsx(dt,{name:"spec.clusterTargets",label:"Cluster targets",multi:!0,required:!0,validate:pt(),options:t,isLoading:e,searchable:!0,clearable:!1,caption:"Clusters this server is provisioned on. Every model deployed to it runs on all of them."})}function jA(){var t;const i=h.useStudioQuery({queryName:"ListCluster",serviceOptions:{namespace:TA}});return{clusters:(((t=i.data)==null?void 0:t.clusterList.items)??[]).filter(OA),isLoading:i.isLoading}}function IA(i){return{clusterId:i.metadata.name,connection:{case:"kubernetes",value:i.spec.cluster.value.rest}}}function OA(i){var e,t,n;return((n=(t=(e=i.spec)==null?void 0:e.cluster)==null?void 0:t.value)==null?void 0:n.rest)!==void 0}const MA=[1,2,3,4].map(i=>({id:i,label:`Tier ${i}`}));function PA(){var e;const{values:i}=go({values:!0});return((e=i==null?void 0:i.spec)==null?void 0:e.tenancyType)!==Fg.MULTI_TENANT?null:h.jsxRuntimeExports.jsxs(ji,{title:"Owner information",children:[h.jsxRuntimeExports.jsx(Be,{name:"spec.ownerSpec.ownerInfo.owningTeam",label:"Owning team",required:!0,validate:pt(),description:"UUID for the team that owns this inference server."}),h.jsxRuntimeExports.jsx(Be,{name:"spec.ownerSpec.ownerInfo.owners",label:"Owners",multi:!0}),h.jsxRuntimeExports.jsx(Be,{name:"spec.ownerSpec.ownerInfo.ownerGroups",label:"Owner groups",multi:!0}),h.jsxRuntimeExports.jsx(dt,{name:"spec.ownerSpec.tier",label:"Tier",required:!0,validate:pt(),options:MA,clearable:!1})]})}const DA=[{id:Vg.DEFAULT_TRITON,label:"Triton"}],LA=/^[0-9]+(\.[0-9]+)?(Ki|Mi|Gi|Ti|K|M|G|T)?$/,NA="Use a Kubernetes quantity such as 4Gi or 512Mi",FA=({onClose:i})=>{const{projectId:e}=h.useStudioParams("base"),{clusters:t,isLoading:n}=jA(),s=h.useStudioMutation({mutationName:"CreateInferenceServer",successOperations:[{type:"toast",message:"Inference server created"},{type:"invalidate",targets:["ListInferenceServer"],delayMs:2e3}]}),r=async l=>{s.isPending||await s.mutateAsync(l)},o=A.useMemo(()=>({metadata:{name:"",namespace:e},spec:{tenancyType:Fg.DEDICATED,backendType:Bg.TRITON,initSpec:{resourceSpec:{cpu:2,memory:"4Gi",diskSize:"",gpu:0},servingSpec:{version:"",containerBuildTemplate:Vg.DEFAULT_TRITON},numInstances:1},clusterTargets:[]}}),[e]);return h.jsxRuntimeExports.jsxs(As,{isOpen:!0,onDismiss:i,heading:"Create target",onSubmit:r,submitLabel:"Create",initialValues:o,children:[h.jsxRuntimeExports.jsx(Be,{name:"metadata.name",label:"Name",required:!0,maxLength:ao,validate:Vi(pt(),Ja(ao),Pr(Mg,co)),caption:co,placeholder:"e.g. my-inference-server"}),h.jsxRuntimeExports.jsx(Ue,{label:"Target type",children:h.jsxRuntimeExports.jsx(Qe.Input,{id:"targetTypeDisplay",value:"Inference Server",readOnly:!0})}),h.jsxRuntimeExports.jsx(dt,{name:"spec.backendType",label:"Backend type",required:!0,validate:pt(),options:kA,clearable:!1,caption:"Serving framework. Triton is the only backend enabled in this environment."}),h.jsxRuntimeExports.jsx(AA,{clusters:t,isLoading:n}),h.jsxRuntimeExports.jsxs(ji,{title:"Initialization",description:"Applied once when the server is provisioned on each cluster target.",children:[h.jsxRuntimeExports.jsxs(rs,{children:[h.jsxRuntimeExports.jsx(dt,{name:"spec.initSpec.servingSpec.containerBuildTemplate",label:"Service type",required:!0,validate:pt(),options:DA,clearable:!1,caption:'Image type for the server. Keep "Triton" if unsure.'}),h.jsxRuntimeExports.jsx(Be,{name:"spec.initSpec.servingSpec.version",label:"Server version",placeholder:"e.g. latest",caption:"Server version or prediction service git sha. Leave empty to let the service choose."})]}),h.jsxRuntimeExports.jsxs(rs,{children:[h.jsxRuntimeExports.jsx(pn,{name:"spec.initSpec.resourceSpec.cpu",label:"CPU cores",required:!0,validate:Vi(pt(),mr(1))}),h.jsxRuntimeExports.jsx(Be,{name:"spec.initSpec.resourceSpec.memory",label:"Memory",required:!0,validate:Vi(pt(),Pr(LA,NA)),placeholder:"e.g. 4Gi"}),h.jsxRuntimeExports.jsx(pn,{name:"spec.initSpec.resourceSpec.gpu",label:"GPUs",validate:mr(0)}),h.jsxRuntimeExports.jsx(pn,{name:"spec.initSpec.numInstances",label:"Replicas",required:!0,validate:Vi(pt(),mr(1))})]})]}),h.jsxRuntimeExports.jsx(PA,{})]})},BA={type:"detail",metadata:[{id:"status.createTime",label:"Created",type:h.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:h.CellType.TEXT},_g],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:h.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 Ol.TRUE:return le.SUCCESS;case Ol.FALSE:return le.ERROR;case Ol.UNKNOWN:default:return le.RUNNING}}}}]},VA=[{id:"metadata.name",label:"Target name",type:h.CellType.TEXT,url:"/${studio.projectId}/${studio.phase}/targets/${row.metadata.name}"},{id:"status.updateTime",label:"Last updated",type:h.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:h.CellType.TAG,accessor:()=>"Inference Server"},_g],_A={type:"list",tableConfig:{columns:VA}},$A={id:"targets",name:"targets",service:"inferenceServer",state:"active",views:[_A,BA],createAction:{display:{label:"Create target",icon:"plus"},component:FA}},zA=nc.filter(i=>i!==ic),HA={type:"detail",metadata:[{id:"metadata.creationTimestamp.seconds",label:"Created",type:h.CellType.DATE},{id:"spec.actor.name",label:"Started by",type:h.CellType.TEXT},Af,oc],pages:[{id:"runs",label:"Recent Runs",type:"table",queryConfig:{endpoint:"list",service:"pipelineRun",serviceOptions:{listOptions:{labelSelector:`${Hl}=\${page.metadata.name}`}}},tableConfig:{columns:[{id:"metadata.name",label:"Name",url:"/${studio.projectId}/${studio.phase}/runs/${row.metadata.name}"},...zA]}}]},GA={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:h.CellType.DATE},{id:"spec.actor.name",label:"Started by",type:h.CellType.TEXT},Af,oc]}};var $g=(i=>(i[i.NO_ACTION=0]="NO_ACTION",i[i.KILL=1]="KILL",i[i.PAUSE=2]="PAUSE",i[i.RESUME=3]="RESUME",i))($g||{}),Va=(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))(Va||{});const yd=i=>{var t;const e=(t=i.status)==null?void 0:t.state;return e===Va.RUNNING||e===Va.PAUSED},Wc={id:"triggers",name:"triggers",service:"triggerRun",state:"active",views:[GA,HA],actions:[{display:{label:"Kill",icon:"stopCircle"},hierarchy:He(({data:i})=>yd(i)?st.SECONDARY:st.TERTIARY),disabled:[{condition:He(({data:i})=>!yd(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:$g.KILL}]}}},modal:{type:"confirm",header:{title:"Kill Trigger Run"},body:He(({data:i})=>`Kill run **${i.metadata.name}** in pipeline **${i.spec.pipeline.name}**? This action cannot be undone.`),button:{label:"Kill"}}}]},zg={id:"deploy",icon:"deploy",name:"Deploy & Predict",description:"Deploy your models and predict new data",state:"active",pipelineTypes:["PIPELINE_TYPE_PREDICTION","PIPELINE_TYPE_SCORER"],entities:[bo,Wc,Po,$A,wA]},Hg={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:[]},Gg={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:[bo,Wc,Po]};function UA(i,e){try{localStorage.setItem(i,JSON.stringify(e))}catch{}}function WA(i,e){try{const t=localStorage.getItem(i);return t===null?e:JSON.parse(t)??e}catch{return e}}const qA={};function Ug(){return WA(Nd,qA)}function KA(i,e){const t=Ug();return h.lodashExports.isEqual(h.lodashExports.get(t,i),e)?!1:(UA(Nd,h.lodashExports.set(h.lodashExports.cloneDeep(t),i,e)),!0)}function en(i,e){const t=Ug(),[n,s]=A.useState(h.getObjectValue(t,i,e)??e);return[n,o=>{const l=o instanceof Function?o(n):o;KA(i,l),s(l)}]}function Do({tableSettingsId:i,filterSettingsId:e,initialState:t}){var O;const n=e??i,[s,r]=en(`${n}.globalFilter`,(t==null?void 0:t.globalFilter)??di.globalFilter),[o,l]=en(`${n}.columnFilters`,(t==null?void 0:t.columnFilters)??di.columnFilters),[a,c]=en(`${i}.pageSize`,((O=t==null?void 0:t.pagination)==null?void 0:O.pageSize)??di.pagination.pageSize),[u,d]=en(`${i}.sorting`,(t==null?void 0:t.sorting)??di.sorting),[f,p]=en(`${i}.columnOrder`,(t==null?void 0:t.columnOrder)??di.columnOrder),[m,g]=en(`${i}.columnVisibility`,(t==null?void 0:t.columnVisibility)??di.columnVisibility),[x,y]=A.useState(0),[b,S]=A.useState({}),[E,v]=A.useState((t==null?void 0:t.rowSelectionEnabled)??di.rowSelectionEnabled),[C,k]=A.useState((t==null?void 0:t.grouping)??di.grouping);return{globalFilter:s,setGlobalFilter:r,columnFilters:o,setColumnFilters:l,pagination:{pageIndex:x,pageSize:a},setPagination:w=>{const N=typeof w=="function"?w({pageIndex:x,pageSize:a}):w;y(N.pageIndex),c(N.pageSize)},sorting:u,setSorting:d,columnOrder:f,setColumnOrder:p,columnVisibility:m,setColumnVisibility:g,rowSelection:b,setRowSelection:S,rowSelectionEnabled:E,setRowSelectionEnabled:v,grouping:C,setGrouping:k}}const YA=({isOpen:i,onDismiss:e,heading:t,onConfirm:n,confirmLabel:s="Confirm",destructive:r=!1,children:o,size:l=Ar.SIZE.small})=>{const[a,c]=A.useState(!1),[u,d]=A.useState(null);A.useEffect(()=>{i||(c(!1),d(null))},[i]);const f=async()=>{c(!0);try{await n(),e()}catch(p){d(p instanceof Error?p.message:"An unexpected error occurred."),c(!1)}};return h.jsxRuntimeExports.jsxs(h.Dialog,{isOpen:i,onDismiss:e,heading:t,size:l,placement:Ar.PLACEMENT.topCenter,buttonDock:{primaryAction:h.jsxRuntimeExports.jsx(U.Button,{isLoading:a,onClick:f,overrides:r?{BaseButton:{style:({$theme:p})=>({backgroundColor:p.colors.backgroundNegative})}}:void 0,children:s}),dismissiveAction:h.jsxRuntimeExports.jsx(U.Button,{kind:U.KIND.tertiary,onClick:e,disabled:a,children:"Cancel"})},children:[o,u&&h.jsxRuntimeExports.jsx(ns.Banner,{kind:ns.KIND.negative,children:u})]})};function XA({action:i,record:e,onClose:t}){const n=Ke.useNavigate(),s=h.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 h.jsxRuntimeExports.jsxs(YA,{isOpen:!0,onDismiss:t,onConfirm:r,heading:o.header.title,confirmLabel:o.button.label,destructive:o.destructive,size:o.size,children:[o.banner&&h.jsxRuntimeExports.jsx(h.Banner,{kind:o.banner.kind,artwork:o.banner.icon?{type:ns.ARTWORK_TYPE.icon,icon:()=>h.jsxRuntimeExports.jsx(h.Icon,{name:o.banner.icon})}:void 0,children:o.banner.content}),o.body&&h.jsxRuntimeExports.jsx(h.Markdown,{children:o.body})]})}function Wg({action:i,record:e,onClose:t}){var n;if(((n=i.modal)==null?void 0:n.type)==="custom"){const s=i.modal.component;return h.jsxRuntimeExports.jsx(s,{record:e,onClose:t})}return QA(i)?h.jsxRuntimeExports.jsx(XA,{action:i,record:e,onClose:t}):null}function QA(i){var e;return((e=i.modal)==null?void 0:e.type)==="confirm"}const qg=A.forwardRef((i,e)=>{const{item:t,onSelectAction:n,onClose:s,hoveredItem:r,setHoveredItem:o,keyboardActive:l,setKeyboardActive:a,...c}=i,u=r===t,d=t.disabled?void 0:()=>n(t),f=h.jsxRuntimeExports.jsx(No.MenuAdapter,{...c,ref:e,role:"option",artwork:t.display.icon?({size:p})=>h.jsxRuntimeExports.jsx(h.Icon,{name:t.display.icon,size:`${p}px`}):void 0,artworkSize:No.ARTWORK_SIZES.MEDIUM,overrides:{Root:{style:{height:"44px",opacity:t.disabled?.4:1}}},$disabled:t.disabled,onClick:d,children:h.jsxRuntimeExports.jsx(No.ListItemLabel,{children:t.display.label})});return!t.disabled||!t.disabledMessage?f:h.jsxRuntimeExports.jsx(zi.Tooltip,{content:t.disabledMessage,autoFocus:!1,accessibilityType:zi.ACCESSIBILITY_TYPE.tooltip,showArrow:!0,placement:zi.PLACEMENT.left,isOpen:!!c.$isHighlighted&&l||u,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})});qg.displayName="ActionMenuItem";function JA({actions:i,onSelectAction:e,onClose:t}){const[n,s]=A.useState(null),[r,o]=A.useState(!1);return h.jsxRuntimeExports.jsx("div",{onKeyDown:()=>{s(null),o(!0)},children:h.jsxRuntimeExports.jsx(Rx.StatefulMenu,{items:i,onItemSelect:({item:l})=>{l.disabled||e(l)},overrides:{Option:{component:qg,props:{onSelectAction:e,onClose:t,hoveredItem:n,setHoveredItem:s,keyboardActive:r,setKeyboardActive:o}},List:{style:({$theme:l})=>({padding:l.sizing.scale600})}}})})}function ZA(i,e){return A.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 Kg({actions:i,buttonProps:e,record:t,popoverProps:n}){const s=A.useRef(!1),[r,o]=A.useState(null),l=Ke.useNavigate(),[,a]=M.useStyletron(),c=ZA(i,f=>{var p;f.modal?o(f):((p=f.operation)==null?void 0:p.type)==="route"&&l(f.operation.route)}),u=()=>{document.body.style.overflow="hidden",s.current=!0},d=()=>{document.body.style.overflow="",s.current=!1};return A.useEffect(()=>()=>{s.current&&(document.body.style.overflow="")},[]),h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[h.jsxRuntimeExports.jsx(zt.StatefulPopover,{focusLock:!0,placement:zt.PLACEMENT.bottomLeft,popperOptions:{modifiers:{preventOverflow:{enabled:!0,boundariesElement:"window",padding:8}}},...n,content:({close:f})=>h.jsxRuntimeExports.jsx(JA,{actions:c,onSelectAction:p=>{p.onClick(),f()},onClose:f}),onClose:d,onOpen:u,children:h.jsxRuntimeExports.jsx(U.Button,{kind:U.KIND.tertiary,shape:U.SHAPE.pill,overrides:{BaseButton:{style:{paddingLeft:a.sizing.scale100,paddingRight:a.sizing.scale100}}},...e,size:U.SIZE.compact,title:"Actions","data-tracking-name":"actions-popover-button",children:h.jsxRuntimeExports.jsx(h.Icon,{name:"overflowMenu"})})}),r&&h.jsxRuntimeExports.jsx(Wg,{action:r,record:t,onClose:()=>o(null)})]})}function ej({actions:i,record:e,...t}){const n=h.useInterpolationResolver(),s=A.useMemo(()=>n(i,{row:e}),[n,i,e]);return h.jsxRuntimeExports.jsx(Kg,{actions:s,record:e,...t})}function qc(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})=>h.jsxRuntimeExports.jsx(ej,{actions:i.actions,record:n.record}):void 0,actionBarConfig:t,disablePagination:i.disablePagination,disableSorting:i.disableSorting,pageSizes:i.pageSizes,enableStickySides:i.enableStickySides,maxHeight:i.maxHeight}}const tj=[{id:"metadata.name",label:"Deployment name",type:h.CellType.TEXT,url:"/${studio.projectId}/deploy/deployments/${row.metadata.name}"},Dg,Hc,Lg,{id:"metadata.creationTimestamp.seconds",label:"Creation time",type:h.CellType.DATE},{id:"spec.owner.name",label:"Owner",type:h.CellType.TEXT},Gc],ij={columns:tj,disableSearch:!0,disableFilters:!0,disablePagination:!0,maxHeight:"420px",emptyState:{title:"Model is not currently deployed"}};function nj({modelName:i,isModelLoading:e}){var u;const{projectId:t,phase:n,entity:s}=h.useStudioParams("detail"),{data:r,isLoading:o,error:l}=h.useStudioQuery({queryName:"ListDeployment",serviceOptions:{listOptions:{fieldSelector:`current_revision_name=${i??""}`}},clientOptions:{enabled:!e&&!!i}}),a=Do({tableSettingsId:`${n}/${s}/deployments`,filterSettingsId:`${t}/${n}/${s}/deployments`}),c=qc(ij,{data:((u=r==null?void 0:r.deploymentList)==null?void 0:u.items)??[],loading:o||e,error:l??void 0});return h.jsxRuntimeExports.jsx(Rs,{...c,state:a})}function sj({data:i,isLoading:e}){var m,g,x,y,b,S,E,v,C,k,O,w;const[t,n]=M.useStyletron(),{projectId:s,phase:r}=h.useStudioParams("detail"),o=i,l=(m=o==null?void 0:o.metadata)==null?void 0:m.name,a=(x=(g=o==null?void 0:o.spec)==null?void 0:g.sourcePipelineRun)==null?void 0:x.name,c=[{name:a,url:a?`/${s}/${r}/runs/${a}`:void 0}],u=[{id:"model-family",label:"Model family",value:((b=(y=o==null?void 0:o.spec)==null?void 0:y.modelFamily)==null?void 0:b.name)??""},{id:"training-framework",label:"Training framework",value:((S=o==null?void 0:o.spec)==null?void 0:S.trainingFramework)??""},{id:"source-platform",label:"Source platform",value:((E=o==null?void 0:o.spec)==null?void 0:E.source)??""}],d=Object.fromEntries(u.map(D=>[D.id,D.value])),f=[{id:"train-evaluation-hive-table",label:"Train evaluation Hive table",value:((C=(v=o==null?void 0:o.spec)==null?void 0:v.predictionResult)==null?void 0:C.trainTableName)??""},{id:"validation-evaluation-hive-table",label:"Validation evaluation Hive table",value:((O=(k=o==null?void 0:o.spec)==null?void 0:k.predictionResult)==null?void 0:O.testTableName)??""}],p=Object.fromEntries(f.map(D=>[D.id,D.value]));return h.jsxRuntimeExports.jsxs("div",{className:t({display:"flex",flexDirection:"column",gap:n.sizing.scale600}),children:[h.jsxRuntimeExports.jsx(_c,{title:"Useful links",links:c,isLoading:e}),h.jsxRuntimeExports.jsx(h.Box,{title:"Description",children:e?h.jsxRuntimeExports.jsx(Si.Skeleton,{animation:!0,height:"96px",width:"100%"}):h.jsxRuntimeExports.jsx(ii,{onSubmit:()=>{},initialValues:{description:((w=o==null?void 0:o.spec)==null?void 0:w.description)??""},children:h.jsxRuntimeExports.jsx(Ts,{name:"description",readOnly:!0,rows:4})})}),h.jsxRuntimeExports.jsxs("section",{children:[h.jsxRuntimeExports.jsx(ge.HeadingSmall,{marginTop:"0",marginBottom:n.sizing.scale600,children:"Key status indicators"}),h.jsxRuntimeExports.jsx(h.Box,{title:"Deployments this model is currently deployed to",children:h.jsxRuntimeExports.jsx(nj,{modelName:l,isModelLoading:e})})]}),h.jsxRuntimeExports.jsxs("section",{children:[h.jsxRuntimeExports.jsx(ge.HeadingSmall,{marginTop:"0",marginBottom:n.sizing.scale600,children:"Configuration"}),h.jsxRuntimeExports.jsx(h.Box,{title:"Model context",children:h.jsxRuntimeExports.jsx(ii,{onSubmit:()=>{},initialValues:d,children:h.jsxRuntimeExports.jsx("div",{className:t({display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:n.sizing.scale1200,rowGap:n.sizing.scale600}),children:u.map(D=>e?h.jsxRuntimeExports.jsx(Si.Skeleton,{animation:!0,height:"48px",width:"100%"},D.id):h.jsxRuntimeExports.jsx(Be,{name:D.id,label:D.label,readOnly:!0},D.id))})})}),h.jsxRuntimeExports.jsx(h.Box,{title:"Training setup",overrides:{BoxContainer:{style:{marginTop:n.sizing.scale600}}},children:h.jsxRuntimeExports.jsx(ii,{onSubmit:()=>{},initialValues:p,children:h.jsxRuntimeExports.jsx("div",{className:t({display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:n.sizing.scale1200,rowGap:n.sizing.scale600}),children:f.map(D=>e?h.jsxRuntimeExports.jsx(Si.Skeleton,{animation:!0,height:"48px",width:"100%"},D.id):h.jsxRuntimeExports.jsx(Be,{name:D.id,label:D.label,readOnly:!0},D.id))})})})]})]})}const rj={type:"detail",metadata:[{id:"spec.sourcePipelineRun.name",label:"Source pipeline run",type:h.CellType.LINK,url:"/${studio.projectId}/${studio.phase}/runs/${page.spec.sourcePipelineRun.name}"},{id:"spec.owner.name",label:"Trained by",type:h.CellType.TEXT},{id:"metadata.creationTimestamp.seconds",label:"Creation time",type:h.CellType.DATE},{id:"lastUpdated",label:"Last updated",type:h.CellType.DATE,accessor:i=>zc(i)},{id:"spec.kind",label:"Type",type:h.CellType.TYPE,typeTextMap:Uc}],pages:[{id:"information",label:"Information",type:"custom",component:sj}]},oj=[{id:"metadata.name",label:"Model",items:[{id:"metadata.name",url:"/${studio.projectId}/${studio.phase}/models/${data.metadata.name}"},{id:"spec.description",type:h.CellType.DESCRIPTION}]},{id:"metadata.labels",label:"Environment",type:h.CellType.TEXT,accessor:i=>{var t;const e=(t=i==null?void 0:i.metadata)==null?void 0:t.labels;return xf(e)||null}},{id:"spec.modelFamily.name",label:"Model Family",type:h.CellType.TEXT},{id:"spec.kind",label:"Type",type:h.CellType.TYPE,typeTextMap:Uc},{id:"metadata",label:"Last Updated",type:h.CellType.DATE,accessor:i=>zc(i)}],lj={type:"list",tableConfig:{columns:oj}},aj={id:"models",name:"trained models",service:"model",state:"active",views:[lj,rj]},Yg={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:[bo,Wc,Po,aj,{id:"evaluations",name:"evaluations",state:"disabled",service:"evaluationReport",views:[]},{id:"notebooks",name:"notebooks",state:"disabled",service:"notebook",views:[]}]},Kc={data:Pg,train:Yg,deploy:zg,retrain:Gg,monitor:Hg},cj=[{id:"core-ml",name:"Core ML",phases:Object.values(Kc)}],uj=M.styled("hr",({$theme:i})=>({border:"none",borderBottom:`2px dashed ${i.colors.contentInverseTertiary}`,margin:`${i.sizing.scale200} 0`})),is=M.styled("div",({$theme:i})=>({display:"flex",flexDirection:"column",gap:i.sizing.scale800}));function Xg(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[If[n].borderColorName]})}},Content:{style:({$theme:l})=>({paddingTop:l.sizing.scale300})},...s};return h.jsxRuntimeExports.jsx(ec,{...r,defaultExpanded:t??!1,overrides:o})}function Qg(i){return`task-${i.name}`}function Jg(i){const e=document.getElementById(Qg(i));if(!e)return;const t=e.getBoundingClientRect();window.scrollTo({top:window.scrollY+t.top-16,behavior:"smooth"})}function Yc(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},...Yc(t.subTasks,t)]}const hj=M.styled("div",({$theme:i})=>({display:"flex",flex:"auto",gap:i.sizing.scale300,flexWrap:"wrap",alignItems:"center"})),Zg=M.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 Xc(i){const{state:e}=i,[,{colors:t,sizing:n}]=M.useStyletron(),s=gv[e];return h.jsxRuntimeExports.jsx(h.Icon,{name:s.name,color:t[s.colorName],size:n.scale700})}const ex={overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},dj=M.styled("div",({$theme:{colors:i,sizing:e},$state:t,role:n})=>{const{colorName:s="contentPrimary",backgroundColorName:r="backgroundPrimary",borderColorName:o}=If[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"}}),fj=M.styled("div",({$theme:{typography:i}})=>({...i.LabelSmall,...ex}));function tx(i){const{task:e,onClick:t}=i,{focused:n,name:s,state:r,subTasks:o}=e,l=!!(o!=null&&o.length),[a]=M.useStyletron();return h.jsxRuntimeExports.jsxs(dj,{$state:r,tabIndex:0,...t?{role:"button",onClick:t}:{},children:[h.jsxRuntimeExports.jsx(Xc,{state:r}),h.jsxRuntimeExports.jsx(fj,{children:s}),l&&n?h.jsxRuntimeExports.jsx("div",{className:a({position:"absolute",bottom:"-25px",left:"50%",transform:"translate(-50%, 0)"}),children:h.jsxRuntimeExports.jsx(Zg,{$color:"contentInverseTertiary",$direction:"up"})}):null]})}function _a({taskList:i,onTaskClick:e}){return h.jsxRuntimeExports.jsx(h.jsxRuntimeExports.Fragment,{children:i.map((t,n)=>h.jsxRuntimeExports.jsxs(A.Fragment,{children:[n>0&&h.jsxRuntimeExports.jsx(Zg,{$color:"contentInverseSecondary",$direction:"right"}),h.jsxRuntimeExports.jsx(tx,{task:t,...e?{onClick:()=>e(t)}:{}})]},n))})}function ix({matrix:i,onTaskClick:e,overrides:t}){const[n,s]=M.getOverrides(t==null?void 0:t.TaskListRenderer,_a),[r,o]=M.getOverrides((t==null?void 0:t.SubTaskListRenderer)??(t==null?void 0:t.TaskListRenderer),_a);return h.jsxRuntimeExports.jsx(h.jsxRuntimeExports.Fragment,{children:i.map((l,a)=>{const c=l.parent?r:n,u=l.parent?o:s;return h.jsxRuntimeExports.jsxs(A.Fragment,{children:[a>0&&h.jsxRuntimeExports.jsx(uj,{}),h.jsxRuntimeExports.jsx(hj,{children:h.jsxRuntimeExports.jsx(c,{taskList:l.taskList,onTaskClick:e,parent:l.parent,...u})})]},a)})})}function pj(i){const{label:e,cells:t,value:n}=i;return h.jsxRuntimeExports.jsx(Xg,{title:h.jsxRuntimeExports.jsx(ge.LabelSmall,{children:e}),children:h.jsxRuntimeExports.jsx(h.Row,{items:t,record:n??void 0})})}function mj(i){const{label:e,value:t}=i,n=$c(t)?Cs(t):t,s=JSON.stringify(n,null,2);return h.jsxRuntimeExports.jsx(ec,{title:h.jsxRuntimeExports.jsx(ge.LabelSmall,{children:e}),children:h.jsxRuntimeExports.jsx(Vc,{readOnly:!0,language:"json",value:s,onChange:()=>null})})}function gj(i){const[e,t]=M.useStyletron(),{label:n,value:s,markdown:r=!0,error:o=!1}=i;if(!s)return null;const l=s.substring(0,1e4);return h.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:[h.jsxRuntimeExports.jsx(ge.LabelSmall,{id:"textarea-title",children:n}),h.jsxRuntimeExports.jsx(ge.ParagraphSmall,{"aria-labelledby":"textarea-title",className:e({marginBottom:0,marginTop:t.sizing.scale100}),children:r?h.jsxRuntimeExports.jsx(h.Markdown,{children:l}):l})]})}function xj(i){const[e,t]=M.useStyletron(),{task:n,bodySchema:s,overrides:r,metadata:o}=i,{subTasks:l}=n,a=h.useInterpolationResolver();if(l!=null&&l.length){const c=Yc(l,n);return h.jsxRuntimeExports.jsxs(is,{children:[h.jsxRuntimeExports.jsx(h.Box,{children:h.jsxRuntimeExports.jsx(ix,{matrix:c,onTaskClick:Jg,overrides:{TaskListRenderer:r==null?void 0:r.TaskListRenderer,SubTaskListRenderer:r==null?void 0:r.SubTaskListRenderer}})}),l.map((u,d)=>h.jsxRuntimeExports.jsx(nx,{task:u,bodySchema:s,overrides:r,metadata:o},d))]})}if(s!=null&&s.length){const c=a(s,{row:n});return h.jsxRuntimeExports.jsx("div",{className:e({display:"flex",flexDirection:"column",gap:t.sizing.scale600}),children:c.map((u,d)=>{const{label:f}=u;if(u.type==="struct"){const p=h.getObjectValue(n.record,u.accessor);return h.jsxRuntimeExports.jsx(mj,{label:f,value:p},d)}if(u.type==="textarea"){const p=h.getObjectValue(n.record,u.accessor),{error:m,markdown:g}=u;return h.jsxRuntimeExports.jsx(gj,{label:f,value:p,error:m,markdown:g},d)}if(u.type==="metadata"){const{cells:p}=u;return h.jsxRuntimeExports.jsx(pj,{label:f,value:n.record,cells:p},d)}return null})})}return h.jsxRuntimeExports.jsxs("div",{children:["No subtasks, no body schema for ",n.name]})}function bd(i){const[e,t]=M.useStyletron(),{task:n,id:s,metadata:r}=i,{name:o,state:l}=n;return h.jsxRuntimeExports.jsxs(is,{id:s,children:[h.jsxRuntimeExports.jsxs("div",{className:e({display:"flex",gap:t.sizing.scale500}),children:[h.jsxRuntimeExports.jsx("div",{className:e({marginTop:"2px"}),children:h.jsxRuntimeExports.jsx(Xc,{state:l})}),h.jsxRuntimeExports.jsx("div",{className:e({...t.typography.LabelLarge,marginBottom:t.sizing.scale100}),children:o})]}),r&&h.jsxRuntimeExports.jsx(h.Row,{items:r,record:n.record})]})}function nx(i){var o;const{task:e,metadata:t,bodySchema:n,overrides:s}=i,r=Qg(e);return(o=e.subTasks)!=null&&o.length||n!=null&&n.length?h.jsxRuntimeExports.jsx(Xg,{id:r,title:h.jsxRuntimeExports.jsx(bd,{task:e,metadata:t}),defaultExpanded:e.focused,state:e.state,children:h.jsxRuntimeExports.jsx(xj,{task:e,bodySchema:n,metadata:t,overrides:s})}):h.jsxRuntimeExports.jsx(bd,{id:r,task:e,metadata:t})}function yj(i,e){const{tasks:t}=i,{accessor:n,subTasksAccessor:s}=t;function r(l,a,c){const u=c.findIndex((p,m)=>{const g=i.tasks.stateBuilder(p,m,c,e);return g!==le.SUCCESS&&g!==le.SKIPPED}),d=h.getObjectValue(l,t.header.heading),f=h.getObjectValue(l,"name");return{name:d!=null&&d.trim()?d:f,state:i.tasks.stateBuilder(l,a,c,e),subTasks:s?h.getObjectValue(l,s,[]).map(r):[],record:l,focused:u===a||u===-1&&a===c.length-1}}return h.getObjectValue(e,n,[]).map(r)}function bj(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 sx(i){const{schema:e,data:t,overrides:n}=i,[s,r]=M.useStyletron(),o=(n==null?void 0:n.taskList)??yj(e,t);if(!o.length)return h.jsxRuntimeExports.jsx(Gt,{illustration:h.jsxRuntimeExports.jsx(si,{height:"64px",width:"64px",kind:St.PRIMARY}),title:e.emptyState.title,description:e.emptyState.description});const l=Yc(o);return h.jsxRuntimeExports.jsxs(is,{children:[h.jsxRuntimeExports.jsx(h.Box,{title:h.jsxRuntimeExports.jsxs("div",{className:s({display:"flex",alignItems:"center",gap:r.sizing.scale500}),children:[h.jsxRuntimeExports.jsx(Xc,{state:bj(o)}),"Overview"]}),children:h.jsxRuntimeExports.jsx(is,{children:h.jsxRuntimeExports.jsx(ix,{matrix:l,onTaskClick:a=>{Jg(a)},overrides:{TaskListRenderer:n==null?void 0:n.TaskListRenderer,SubTaskListRenderer:n==null?void 0:n.SubTaskListRenderer}})})}),h.jsxRuntimeExports.jsx(is,{children:o.map((a,c)=>h.jsxRuntimeExports.jsx(nx,{task:a,metadata:e.tasks.header.metadata,bodySchema:e.tasks.body,overrides:n},c))})]})}function Sj({isDetailViewLoading:i=!1,queryConfig:e,tableConfig:t,pageId:n}){var f,p;const{projectId:s,phase:r,entity:o}=h.useStudioParams("detail"),{data:l,isLoading:a,error:c}=h.useStudioQuery({queryName:`List${h.capitalizeFirstLetter(e.service)}`,serviceOptions:{namespace:s,...e.serviceOptions},clientOptions:{...e.clientOptions,enabled:!i&&((f=e.clientOptions)==null?void 0:f.enabled)}}),u=Do({tableSettingsId:`${r}/${o}/${n}`,filterSettingsId:`${s}/${r}/${o}/${n}`}),d=qc(t,{data:((p=l==null?void 0:l[`${e.service}List`])==null?void 0:p.items)??[],loading:a||i,error:c??void 0});return h.jsxRuntimeExports.jsx(Rs,{...d,state:u})}function vj({page:i,data:e,isLoading:t}){switch(i.type){case"custom":return A.createElement(i.component,{data:e,isLoading:t});case"execution":return h.jsxRuntimeExports.jsx(sx,{schema:i,data:e??{}});case"table":{const n=i;return h.jsxRuntimeExports.jsx(Sj,{isDetailViewLoading:t,queryConfig:n.queryConfig,tableConfig:n.tableConfig,pageId:n.id})}default:return h.jsxRuntimeExports.jsxs("div",{children:["Page type '",i.type,"' not yet supported"]})}}function Ej(i){const e=M.mergeOverrides(i.overrides,{Root:{style:{transform:"unset"}},TabBorder:{style:{zIndex:-1}},TabHighlight:{style:{zIndex:0}}});return h.jsxRuntimeExports.jsx(jr.Tabs,{...i,overrides:e})}function Cj(i){const e=M.mergeOverrides(i.overrides,{TabPanel:{style:({$theme:t})=>({paddingTop:t.sizing.scale950,paddingLeft:0,paddingRight:0})}});return h.jsxRuntimeExports.jsx(jr.Tab,{...i,overrides:e})}function rx({tabs:i,activeTabId:e,onTabSelect:t}){var s;const n=e??((s=i[0])==null?void 0:s.id);return!i||i.length===0?h.jsxRuntimeExports.jsx("div",{children:"No tabs available"}):h.jsxRuntimeExports.jsx(Ej,{activeKey:n,onChange:({activeKey:r})=>t==null?void 0:t(r),children:i.map(r=>h.jsxRuntimeExports.jsx(Cj,{title:r.label,children:r.content},r.id))})}function Sd({action:i,onClick:e,loading:t,kind:n,shape:s,overrides:r}){var u;const[o,l]=M.useStyletron(),a=(u=i.disabled)==null?void 0:u.find(d=>d.condition),c=h.jsxRuntimeExports.jsx(U.Button,{kind:n,shape:s,size:U.SIZE.compact,isLoading:t,disabled:!!a,overrides:r,startEnhancer:i.display.icon?()=>h.jsxRuntimeExports.jsx(h.Icon,{name:i.display.icon,size:l.sizing.scale550,color:"inherit"}):void 0,onClick:e,children:i.display.label});return a!=null&&a.message?h.jsxRuntimeExports.jsx(zi.StatefulTooltip,{content:a.message,accessibilityType:zi.ACCESSIBILITY_TYPE.tooltip,placement:zi.PLACEMENT.bottom,showArrow:!0,children:h.jsxRuntimeExports.jsx("span",{className:o({display:"inline-flex"}),children:c})}):c}function Rj(i){return{primary:i.find(e=>e.hierarchy===st.PRIMARY),secondary:i.filter(e=>e.hierarchy===st.SECONDARY),tertiary:i.filter(e=>!e.hierarchy||e.hierarchy===st.TERTIARY)}}function wj({actions:i,record:e,loading:t}){const[n,s]=M.useStyletron(),[r,o]=A.useState(null),l=Ke.useNavigate();if(i.length===0)return null;const{primary:a,secondary:c,tertiary:u}=Rj(i),d=f=>{var p;f.modal?o(f):((p=f.operation)==null?void 0:p.type)==="route"&&l(f.operation.route)};return h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[h.jsxRuntimeExports.jsxs("div",{className:n({display:"flex",gap:s.sizing.scale300}),children:[a&&h.jsxRuntimeExports.jsx(Sd,{action:a,onClick:()=>d(a),loading:t,kind:U.KIND.primary,overrides:{Root:{style:{width:"200px"}}}}),c.map(f=>h.jsxRuntimeExports.jsx(Sd,{action:f,onClick:()=>d(f),loading:t,kind:U.KIND.secondary,shape:U.SHAPE.pill},f.display.label)),u.length>0&&h.jsxRuntimeExports.jsx(Kg,{actions:u,record:e,popoverProps:{placement:zt.PLACEMENT.bottomRight}})]}),r&&h.jsxRuntimeExports.jsx(Wg,{action:r,record:e,onClose:()=>o(null)})]})}const kj=M.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 Tj({subtitle:i,title:e,titleEnhancer:t,onGoBack:n,children:s,actions:r,record:o,loading:l}){const[a,c]=M.useStyletron(),u=h.useInterpolationResolver(),d=A.useMemo(()=>r?u(r,{page:o}):void 0,[u,r,o]);return h.jsxRuntimeExports.jsxs(kj,{children:[h.jsxRuntimeExports.jsxs("div",{className:a({display:"flex",gap:c.sizing.scale800,justifyContent:"flex-start",alignItems:"flex-end"}),children:[h.jsxRuntimeExports.jsxs("h5",{className:a({margin:0,maxWidth:"50%"}),children:[i&&h.jsxRuntimeExports.jsx("div",{className:a({...c.typography.LabelSmall,color:c.colors.contentTertiary,marginBottom:c.sizing.scale300}),children:i}),h.jsxRuntimeExports.jsxs("div",{className:a({display:"flex",alignItems:"center",gap:c.sizing.scale300}),children:[n&&h.jsxRuntimeExports.jsx(U.Button,{"aria-label":"Go back",onClick:n,kind:U.KIND.tertiary,shape:U.SHAPE.circle,size:U.SIZE.compact,overrides:{BaseButton:{style:({$theme:f})=>({flexShrink:0,":hover":{backgroundColor:f.colors.contentInverseSecondary}})}},children:h.jsxRuntimeExports.jsx(h.Icon,{name:"arrowLeft",size:c.sizing.scale700})}),h.jsxRuntimeExports.jsx("div",{className:a({...c.typography.HeadingSmall,...ex}),children:e})]})]}),t,d&&h.jsxRuntimeExports.jsx("div",{className:a({marginLeft:"auto",flexShrink:0}),children:h.jsxRuntimeExports.jsx(wj,{actions:d,record:o??{},loading:l})})]}),s]})}function ox({title:i,subtitle:e,onGoBack:t,headerContent:n,children:s,actions:r,record:o,loading:l,titleEnhancer:a}){const[c,u]=M.useStyletron();return h.jsxRuntimeExports.jsxs("div",{className:c({display:"flex",flexDirection:"column",gap:u.sizing.scale800}),children:[h.jsxRuntimeExports.jsx(Tj,{title:i,subtitle:e,titleEnhancer:a,onGoBack:t,actions:r,record:o,loading:l,children:n}),s]})}function Aj({phases:i=Kc}){const[,e]=M.useStyletron(),{phase:t,entity:n,entityId:s,projectId:r,entityTab:o}=h.useStudioParams("detail"),l=Ke.useNavigate(),a=i[t].entities.find(b=>b.id===n),c=h.useInterpolationResolver(),{data:u,isLoading:d,error:f}=h.useStudioQuery({queryName:`Get${h.capitalizeFirstLetter((a==null?void 0:a.service)??"")}`,serviceOptions:{namespace:r,name:s},clientOptions:{enabled:!!(a!=null&&a.service)&&!!s}}),p=A.useCallback((b,S)=>{l(`/${r}/${t}/${n}/${s}/${b}`,S)},[l,r,t,n,s]),m=()=>{l(`/${r}/${t}/${n}`)},g=((a==null?void 0:a.views)??[]).find(b=>b.type==="detail")??void 0;if(A.useEffect(()=>{var E;if(f||d||!s||!((E=g==null?void 0:g.pages)!=null&&E.length))return;const b=g.pages.map(v=>v.id),S=b[0];o?b.includes(o)||p(S,{replace:!0}):p(S,{replace:!0})},[o,g,d,f,p]),f)return h.jsxRuntimeExports.jsx(Gt,{title:"Entity not found",description:`Could not load ${n} "${s}". ${f.message}`,illustration:h.jsxRuntimeExports.jsx(si,{kind:St.ERROR,width:e.sizing.scale1600,height:e.sizing.scale1600}),buttonConfig:{onClick:()=>l(`/${r}/${t}/${n}`),content:"Back to list"}});const x=u==null?void 0:u[a.service],y=c(g,{page:x});return h.jsxRuntimeExports.jsx(ox,{subtitle:a.name,title:s,onGoBack:m,actions:a.actions,record:x,loading:d,headerContent:h.jsxRuntimeExports.jsx(h.Row,{items:y.metadata,record:x,loading:d}),children:h.jsxRuntimeExports.jsx(rx,{tabs:y.pages.map(b=>({id:b.id,label:b.label,content:h.jsxRuntimeExports.jsx(vj,{page:b,data:x,isLoading:d})})),activeTabId:o,onTabSelect:p})})}const jj="michelangelo/SourcePipelineType",Ij="michelangelo/PipelineType";function Oj(i,e){const t=e!=null&&e.length?e.join(","):void 0;if(i==="revision")return{fieldSelector:"base_type=Pipeline",...t&&{labelSelector:`${Ij} in (${t})`}};if(t){if(i==="pipeline")return{fieldSelector:`pipeline_type in (${t})`};if(i==="pipelineRun"||i==="triggerRun")return{labelSelector:`${jj} in (${t})`}}}function Mj({service:i,tableConfig:e,tableSettingsId:t,pipelineTypes:n,trailingActions:s,variants:r}){var v;const{projectId:o}=h.useStudioParams("base"),[l,a]=A.useState(),c=Pj(r,l),u=(c==null?void 0:c.service)??i,d=(c==null?void 0:c.tableConfig)??e,f=c?`${t}/${c.id}`:t,p=Oj(u,n),{data:m,isLoading:g,error:x}=h.useStudioQuery({queryName:`List${h.capitalizeFirstLetter(u)}`,serviceOptions:{namespace:o,...p&&{listOptions:p}}}),y=Do({filterSettingsId:`${o}/${f}`,tableSettingsId:f}),b=qc(d,{data:((v=m==null?void 0:m[`${u}List`])==null?void 0:v.items)??[],loading:g,error:x??void 0}),S=({activeKey:C})=>a(String(C)),E=r&&c&&h.jsxRuntimeExports.jsx(iu.SegmentedControl,{activeKey:c.id,onChange:S,overrides:Dj,children:r.map(C=>h.jsxRuntimeExports.jsx(iu.Segment,{label:C.label},C.id))});return h.jsxRuntimeExports.jsx(Rs,{...b,actionBarConfig:{...b.actionBarConfig,middle:E,trailing:s},state:y})}function Pj(i,e){if(i!=null&&i.length)return i.find(t=>t.id===e)??i[0]}const Dj={Root:{style:{borderRadius:"24px"}},Active:{style:{borderRadius:"24px"}},SegmentList:{style:{minHeight:"unset"}}};function Lj({phaseConfig:i,entities:e}){const[t,n]=M.useStyletron(),s=Ke.useNavigate(),{projectId:r,entity:o}=h.useStudioParams("list"),[l,a]=A.useState(!1);A.useEffect(()=>{o||s(`/${r}/${i.id}/${e[0].id}`)},[o,s,r,i.id,e]);const c=e.findIndex(g=>g.id===o),u=c>=0?c.toString():"0",d=({activeKey:g})=>{const x=e[Number(g)];x&&s(`/${r}/${i.id}/${x.id}`)},f=e.find(g=>g.id===o);if(!f)return o?h.jsxRuntimeExports.jsx(Gt,{buttonConfig:{onClick:()=>s(`/${r}`),content:"Go home"},description:`Entity "${o}" not found`,illustration:h.jsxRuntimeExports.jsx(si,{kind:St.ERROR,width:n.sizing.scale1600,height:n.sizing.scale1600}),title:"Entity not found"}):null;const{createAction:p}=f,m=p&&h.jsxRuntimeExports.jsx(U.Button,{kind:U.KIND.primary,onClick:()=>a(!0),startEnhancer:p.display.icon&&h.jsxRuntimeExports.jsx(h.Icon,{name:p.display.icon,size:n.sizing.scale600,color:n.colors.buttonPrimaryText}),children:p.display.label});return h.jsxRuntimeExports.jsxs("div",{className:t({marginTop:n.sizing.scale800}),children:[h.jsxRuntimeExports.jsx(Rd,{icon:i.icon,label:i.name,description:i.description,docUrl:i.docUrl}),p&&l&&h.jsxRuntimeExports.jsx(p.component,{onClose:()=>a(!1)}),h.jsxRuntimeExports.jsx(jr.Tabs,{activeKey:u,onChange:d,overrides:{Root:{style:({$theme:g})=>({marginTop:g.sizing.scale600})}},children:e.map((g,x)=>h.jsxRuntimeExports.jsx(jr.Tab,{title:h.formatEntityName(g.name,"nav"),children:String(x)===u&&h.jsxRuntimeExports.jsx(Mj,{service:g.service,tableConfig:{...f.views[0].tableConfig,actions:g.actions},tableSettingsId:`${i.id}/${g.id}`,pipelineTypes:i.pipelineTypes,trailingActions:m,variants:f.views[0].variants})},String(x)))})]})}function Nj(i){return i.state==="active"&&i.views.some(e=>e.type==="list")}function Fj({phases:i=Kc}={}){const[,e]=M.useStyletron(),{phase:t,projectId:n}=h.useStudioParams("list"),s=Ke.useNavigate();if(!(t in i))return h.jsxRuntimeExports.jsx(Gt,{title:"Phase not found",description:`Phase "${t}" configuration not found. Available phases: ${Object.keys(i).join(", ")}`,illustration:h.jsxRuntimeExports.jsx(si,{kind:St.ERROR,width:e.sizing.scale1600,height:e.sizing.scale1600}),buttonConfig:{onClick:()=>s(`/${n}`),content:"Go home"}});const r=i[t].entities.filter(Nj);return r.length===0?h.jsxRuntimeExports.jsx(Gt,{title:"Phase has no active entities",description:`Phase "${t}" has no active entities with list views configured.`,illustration:h.jsxRuntimeExports.jsx(si,{kind:St.ERROR,width:e.sizing.scale1600,height:e.sizing.scale1600}),buttonConfig:{onClick:()=>s(`/${n}`),content:"Go home"}}):h.jsxRuntimeExports.jsx(Lj,{phaseConfig:i[t],entities:r})}function Bj({categories:i,topLevelLinks:e}){return h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[h.jsxRuntimeExports.jsx(h.BreadcrumbBar,{categories:i,topLevelLinks:e}),h.jsxRuntimeExports.jsx(Ke.Outlet,{})]})}const Vj=[Pg,Yg,zg,Gg,Hg];function _j(){return h.jsxRuntimeExports.jsxs(Ke.Routes,{children:[h.jsxRuntimeExports.jsx(Ke.Route,{index:!0,element:h.jsxRuntimeExports.jsx(tn,{children:h.jsxRuntimeExports.jsx(zy,{})})}),h.jsxRuntimeExports.jsx(Ke.Route,{path:"sandbox",element:h.jsxRuntimeExports.jsx(tn,{children:h.jsxRuntimeExports.jsx(LS,{})})}),h.jsxRuntimeExports.jsxs(Ke.Route,{element:h.jsxRuntimeExports.jsx(Bj,{categories:cj}),children:[h.jsxRuntimeExports.jsx(Ke.Route,{path:":projectId",element:h.jsxRuntimeExports.jsx(tn,{children:h.jsxRuntimeExports.jsx(Ix,{phases:Vj})})}),h.jsxRuntimeExports.jsx(Ke.Route,{path:":projectId/:phase/:entity/:entityId/:entityTab?",element:h.jsxRuntimeExports.jsx(tn,{children:h.jsxRuntimeExports.jsx(Aj,{})})}),h.jsxRuntimeExports.jsx(Ke.Route,{path:":projectId/:phase/:entity?",element:h.jsxRuntimeExports.jsx(tn,{children:h.jsxRuntimeExports.jsx(Fj,{})})})]})]})}function Qc(i){return i instanceof h.Interpolation||h.StringInterpolation.isInterpolation(i)}function $a(i){return Qc(i)?!0:h.lodashExports.isArray(i)?i.some($a):h.isRecord(i)?h.lodashExports.values(i).some($a):!1}function lx(i){return h.lodashExports.mapValues(i,e=>{if(h.lodashExports.isNil(e)||Array.isArray(e))return e;if(!Qc(e))return h.isRecord(e)?lx(e):e})}function $j({children:i,value:e}){return h.jsxRuntimeExports.jsx(h.InterpolationContext.Provider,{value:e,children:i})}function Jc({children:i,...e}){return h.jsxRuntimeExports.jsx(h.RepeatedLayoutContext.Provider,{value:e,children:i})}function zj(){const{fieldRegistry:i}=Qa(),e=ks();return{fieldRegistry:i,change:e.change,submit:e.submit}}const Hj=({children:i})=>{const[e]=M.useStyletron();return h.jsxRuntimeExports.jsx("div",{className:e({boxSizing:"border-box"}),children:i})},Gj=({title:i,kind:e="info",dismissible:t=!1,content:n})=>{const[s,r]=A.useState(!1),[o,l]=M.useStyletron();return s?null:h.jsxRuntimeExports.jsx(h.Banner,{title:i,artwork:{type:ns.ARTWORK_TYPE.icon,icon:()=>h.jsxRuntimeExports.jsx(h.Icon,{name:e==="info"?"circleI":"circleExclamation",size:l.sizing.scale800})},kind:e,action:t?{label:"Dismiss",icon:()=>h.jsxRuntimeExports.jsx(h.Icon,{name:"x-filled"}),onClick:()=>r(!0)}:void 0,children:typeof n=="string"?h.jsxRuntimeExports.jsx(h.Markdown,{children:n}):n})},Uj=({name:i,description:e,children:t})=>{const[n,s]=M.useStyletron();return h.jsxRuntimeExports.jsxs("section",{children:[h.jsxRuntimeExports.jsxs("div",{className:n({display:"flex",alignItems:"flex-start",flexDirection:"column",gap:s.sizing.scale300,marginBottom:s.sizing.scale600}),children:[h.jsxRuntimeExports.jsx(ge.HeadingSmall,{margin:0,children:i}),e&&h.jsxRuntimeExports.jsx(ge.ParagraphSmall,{margin:0,children:h.jsxRuntimeExports.jsx(h.Markdown,{children:e})})]}),t]})};function uo(){return uo=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},uo.apply(null,arguments)}function vd(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 Wj=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 qj(i){var e=A.useRef();return e.current||(e.current=i()),e.current}var Kj=["length"],Yj=["meta","input"],Xj=Ya.reduce(function(i,e){return i[e]=!0,i},{}),Qj=function(e,t){var n={},s=n.subscription,r=s===void 0?Xj:s,o=n.defaultValue,l=n.initialValue,a=n.isEqual,c=a===void 0?Wj:a,u=n.validate,d=ks("useFieldArray"),f=d.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 m=A.useMemo(function(){return Object.keys(f).reduce(function(O,w){return O[w]=function(){for(var D=arguments.length,N=new Array(D),F=0;F<D;F++)N[F]=arguments[F];return f[w].apply(f,[e].concat(N))},O},{})},[e,f]),g=qj(function(){return function(O,w,D){if(u){var N=u(O,w,D);if(!N||Array.isArray(N))return N;var F=[];return F[fn]=N,F}}}),x=mo(e,{subscription:uo({},r,{length:!0}),defaultValue:o,initialValue:l,isEqual:c,validate:g,format:function(w){return w}}),y=x.meta,b=y.length,S=vd(y,Kj),E=x.input,v=vd(x,Yj),C=function(w){for(var D=b||0,N=0;N<D;N++)w(e+"["+N+"]",N)},k=function(w){for(var D=b||0,N=[],F=0;F<D;F++)N.push(w(e+"["+F+"]",F));return N};return{fields:uo({name:e,forEach:C,length:b||0,map:k},m,v,{value:E.value}),meta:S}};function ax(i,{minItems:e=0,readOnly:t=!1}={}){const{fields:n}=Qj(i),s=A.useRef(Array.from({length:n.length??0},()=>crypto.randomUUID()));A.useEffect(()=>{const a=n.length??0;if(a<e)for(let c=a;c<e;c++)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,c)=>({id:s.current[c],indexedFieldPath:a})),handleItemAdd:o,remove:l,isRemovable:r}}function Jj({rootFieldPath:i,minItems:e=0,readOnly:t=!1,children:n,name:s,span:r,addLabel:o="Add more"}){const[l,a]=M.useStyletron(),{entries:c,handleItemAdd:u,remove:d,isRemovable:f}=ax(i,{minItems:e,readOnly:t});return h.jsxRuntimeExports.jsxs(h.jsxRuntimeExports.Fragment,{children:[c.map(({id:p,indexedFieldPath:m},g)=>{const x=n(m,g),y=A.isValidElement(x)&&x.type===A.Fragment?x.props.children:x;return h.jsxRuntimeExports.jsx(Jc,{index:g,rootFieldPath:i,children:h.jsxRuntimeExports.jsxs("div",{className:l({display:"flex",alignItems:"end",gap:a.sizing.scale300}),children:[h.jsxRuntimeExports.jsx(rs,{name:s,span:r,children:y}),f&&h.jsxRuntimeExports.jsx(U.Button,{type:"button",kind:U.KIND.tertiary,shape:U.SHAPE.circle,size:U.SIZE.default,"aria-label":"Remove",onClick:()=>d(g),children:h.jsxRuntimeExports.jsx(h.Icon,{name:"deleteAlt",kind:h.IconKind.SECONDARY})})]})},p)}),!t&&h.jsxRuntimeExports.jsx(yo,{label:o,onClick:u})]})}function Zj({rootFieldPath:i,groupLabel:e,addLabel:t,minItems:n=0,readOnly:s=!1,children:r,description:o,tooltip:l,collapsible:a}){const{entries:c,handleItemAdd:u,remove:d,isRemovable:f}=ax(i,{minItems:n,readOnly:s}),p=t??(e?`Add ${e.toLowerCase()}`:"Add more"),[m,g]=M.useStyletron();return h.jsxRuntimeExports.jsxs("div",{className:m({display:"flex",flexDirection:"column",gap:g.sizing.scale800}),children:[c.map(({id:x,indexedFieldPath:y},b)=>h.jsxRuntimeExports.jsx(Jc,{index:b,rootFieldPath:i,children:h.jsxRuntimeExports.jsx(ji,{title:e?`${e} ${b+1}`:void 0,description:o,tooltip:l,collapsible:a,endEnhancer:f&&h.jsxRuntimeExports.jsx(U.Button,{type:"button",kind:U.KIND.secondary,shape:U.SHAPE.pill,size:U.SIZE.compact,startEnhancer:h.jsxRuntimeExports.jsx(h.Icon,{name:"trashCan",kind:h.IconKind.PRIMARY}),"aria-label":"Remove",onClick:()=>d(b),children:"Remove"}),overrides:{BoxContainer:{style:{marginBottom:0}}},children:r(y,b)})},x)),!s&&h.jsxRuntimeExports.jsx(yo,{label:p,shape:U.SHAPE.pill,onClick:u})]})}var cx=(i=>(i.Admin="admin",i.Viewer="viewer",i))(cx||{});function eI({dependencies:i}){var e,t;return h.jsxRuntimeExports.jsx(h.ThemeProvider,{icons:i.theme.icons,children:h.jsxRuntimeExports.jsx(fx.LayersManager,{zIndex:200,children:h.jsxRuntimeExports.jsx(px.SnackbarProvider,{children:h.jsxRuntimeExports.jsx(h.ServiceProvider,{...i.service,children:h.jsxRuntimeExports.jsx(h.ErrorProvider,{...i.error,children:h.jsxRuntimeExports.jsx(h.IconProvider,{icons:i.theme.icons,children:h.jsxRuntimeExports.jsxs(h.UserProvider,{...i.user??{timeZone:h.TimeZone.Local},children:[h.jsxRuntimeExports.jsx(Ax,{links:(e=i.navigationBar)==null?void 0:e.links,onSignOut:(t=i.navigationBar)==null?void 0:t.onSignOut}),h.jsxRuntimeExports.jsx(_j,{})]})})})})})})})}exports.ApplicationError=h.ApplicationError;exports.BooleanCell=h.BooleanCell;exports.CellType=h.CellType;exports.DateCell=h.DateCell;exports.DefaultCellRenderer=h.DefaultCellRenderer;exports.DescriptionCell=h.DescriptionCell;exports.DescriptionHierarchy=h.DescriptionHierarchy;exports.GrpcStatusCode=h.GrpcStatusCode;exports.Interpolation=h.Interpolation;exports.LinkCell=h.LinkCell;exports.MultiCell=h.MultiCell;exports.Phase=h.Phase;exports.StateCell=h.StateCell;exports.StringInterpolation=h.StringInterpolation;exports.TagCell=h.TagCell;exports.TextCell=h.TextCell;exports.TimeZone=h.TimeZone;exports.TypeCell=h.TypeCell;exports.capitalizeFirstLetter=h.capitalizeFirstLetter;exports.cellTooltipHoc=h.cellTooltipHoc;exports.formatElapsedSeconds=h.formatElapsedSeconds;exports.formatEntityName=h.formatEntityName;exports.getDateFromEpochSeconds=h.getDateFromEpochSeconds;exports.getEpochSecondsFromDate=h.getEpochSecondsFromDate;exports.getObjectSymbols=h.getObjectSymbols;exports.getObjectValue=h.getObjectValue;exports.isAbsoluteUrl=h.isAbsoluteUrl;exports.isNavigableUrl=h.isNavigableUrl;exports.isRecord=h.isRecord;exports.parseIsoString=h.parseIsoString;exports.safeStringify=h.safeStringify;exports.sentenceCaseEnumValue=h.sentenceCaseEnumValue;exports.timestampToString=h.timestampToString;exports.toFlatDotPathMap=h.toFlatDotPathMap;exports.useCellStyles=h.useCellStyles;exports.useCellToString=h.useCellToString;exports.useErrorNormalizer=h.useErrorNormalizer;exports.useGetCellRenderer=h.useGetCellRenderer;exports.useInterpolationResolver=h.useInterpolationResolver;exports.useRepeatedLayoutContext=h.useRepeatedLayoutContext;exports.useStudioMutation=h.useStudioMutation;exports.useStudioParams=h.useStudioParams;exports.useStudioQuery=h.useStudioQuery;exports.useSuccessOperations=h.useSuccessOperations;exports.useUrlQueryString=h.useUrlQueryString;exports.ActionHierarchy=st;exports.AddButton=yo;exports.ArrayFormGroup=Zj;exports.ArrayFormRow=Jj;exports.BooleanField=xo;exports.CheckboxField=of;exports.CoreApp=eI;exports.DateField=Dr;exports.DateFormat=vi;exports.DetailView=ox;exports.DetailViewPages=rx;exports.Execution=sx;exports.FilterMode=po;exports.Form=ii;exports.FormBanner=Gj;exports.FormColumn=Hj;exports.FormControl=Ue;exports.FormDialog=As;exports.FormErrorBanner=pf;exports.FormGroup=ji;exports.FormRow=rs;exports.FormStep=Uj;exports.FunctionInterpolation=Cd;exports.InterpolationProvider=$j;exports.MarkdownField=lf;exports.NumberField=pn;exports.RadioField=Za;exports.RepeatedLayoutProvider=Jc;exports.SelectField=dt;exports.StringField=Be;exports.SubmitButton=Xa;exports.TASK_STATE=le;exports.Table=Rs;exports.TaskListRenderer=_a;exports.TaskStepCard=tx;exports.TextareaField=Ts;exports.UrlField=cf;exports.UserRole=cx;exports.clearUnresolvedInterpolations=lx;exports.hasInterpolationProperty=$a;exports.interpolate=He;exports.isInterpolation=Qc;exports.useField=ke;exports.useForm=zj;exports.useFormState=go;exports.useLocalStorageTableState=Do;exports.useTableSelectionContext=my;
|