@wecode-team/we0-cms 1.0.35 → 1.0.37

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/index.js CHANGED
@@ -12,5 +12,5 @@ var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toS
12
12
  *
13
13
  * This source code is licensed under the ISC license.
14
14
  * See the LICENSE file in the root directory of this source tree.
15
- */const y=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),w=(t,n)=>{const r=e.forwardRef(({color:r="currentColor",size:i=24,strokeWidth:o=2,absoluteStrokeWidth:s,className:a="",children:l,...c},h)=>e.createElement("svg",{ref:h,...b,width:i,height:i,stroke:r,strokeWidth:s?24*Number(o)/Number(i):o,className:["lucide",`lucide-${y(t)}`,a].join(" "),...c},[...n.map(([t,n])=>e.createElement(t,n)),...Array.isArray(l)?l:[l]]));return r.displayName=`${t}`,r},x=w("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),k=w("CheckCircle2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),S=w("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),E=w("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),C=w("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),O=w("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),N=w("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),A=w("Crown",[["path",{d:"m2 4 3 12h14l3-12-6 7-4-7-4 7-6-7zm3 16h14",key:"zkxr6b"}]]),T=w("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),M=w("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),R=w("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]),D=w("Home",[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]]),P=w("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),L=w("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),B=w("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]),I=w("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]),j=w("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]),_=w("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),F=w("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),W=w("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),z=w("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),H=w("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a2.121 2.121 0 1 1 3 3L12 15l-4 1 1-4Z",key:"1lpok0"}]]),V=w("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]),q=w("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),U=w("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),$=w("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),K=w("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);var Y=function(){return Y=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Y.apply(this,arguments)};function G(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function X(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=X(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function J(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=X(e))&&(r&&(r+=" "),r+=t);return r}"function"==typeof SuppressedError&&SuppressedError;const Q=e=>{const t=ne(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{const n=e.split("-");return""===n[0]&&1!==n.length&&n.shift(),Z(n,t)||te(e)},getConflictingClassGroupIds:(e,t)=>{const i=n[e]||[];return t&&r[e]?[...i,...r[e]]:i}}},Z=(e,t)=>{if(0===e.length)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?Z(e.slice(1),r):void 0;if(i)return i;if(0===t.validators.length)return;const o=e.join("-");return t.validators.find(({validator:e})=>e(o))?.classGroupId},ee=/^\[(.+)\]$/,te=e=>{if(ee.test(e)){const t=ee.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},ne=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return se(Object.entries(e.classGroups),n).forEach(([e,n])=>{re(n,r,e,t)}),r},re=(e,t,n,r)=>{e.forEach(e=>{if("string"==typeof e){return void((""===e?t:ie(t,e)).classGroupId=n)}if("function"==typeof e)return oe(e)?void re(e(r),t,n,r):void t.validators.push({validator:e,classGroupId:n});Object.entries(e).forEach(([e,i])=>{re(i,ie(t,e),n,r)})})},ie=(e,t)=>{let n=e;return t.split("-").forEach(e=>{n.nextPart.has(e)||n.nextPart.set(e,{nextPart:new Map,validators:[]}),n=n.nextPart.get(e)}),n},oe=e=>e.isThemeGetter,se=(e,t)=>t?e.map(([e,n])=>[e,n.map(e=>"string"==typeof e?t+e:"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,n])=>[t+e,n])):e)]):e,ae=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const i=(i,o)=>{n.set(i,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(e){let t=n.get(e);return void 0!==t?t:void 0!==(t=r.get(e))?(i(e,t),t):void 0},set(e,t){n.has(e)?n.set(e,t):i(e,t)}}},le=e=>{const{separator:t,experimentalParseClassName:n}=e,r=1===t.length,i=t[0],o=t.length,s=e=>{const n=[];let s,a=0,l=0;for(let c=0;c<e.length;c++){let h=e[c];if(0===a){if(h===i&&(r||e.slice(c,c+o)===t)){n.push(e.slice(l,c)),l=c+o;continue}if("/"===h){s=c;continue}}"["===h?a++:"]"===h&&a--}const c=0===n.length?e:e.substring(l),h=c.startsWith("!");return{modifiers:n,hasImportantModifier:h,baseClassName:h?c.substring(1):c,maybePostfixModifierPosition:s&&s>l?s-l:void 0}};return n?e=>n({className:e,parseClassName:s}):s},ce=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(e=>{"["===e[0]?(t.push(...n.sort(),e),n=[]):n.push(e)}),t.push(...n.sort()),t},he=/\s+/;function ue(){let e,t,n=0,r="";for(;n<arguments.length;)(e=arguments[n++])&&(t=de(e))&&(r&&(r+=" "),r+=t);return r}const de=e=>{if("string"==typeof e)return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=de(e[r]))&&(n&&(n+=" "),n+=t);return n};function fe(e,...t){let n,r,i,o=function(a){const l=t.reduce((e,t)=>t(e),e());return n=(e=>({cache:ae(e.cacheSize),parseClassName:le(e),...Q(e)}))(l),r=n.cache.get,i=n.cache.set,o=s,s(a)};function s(e){const t=r(e);if(t)return t;const o=((e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,o=[],s=e.trim().split(he);let a="";for(let e=s.length-1;e>=0;e-=1){const t=s[e],{modifiers:l,hasImportantModifier:c,baseClassName:h,maybePostfixModifierPosition:u}=n(t);let d=Boolean(u),f=r(d?h.substring(0,u):h);if(!f){if(!d){a=t+(a.length>0?" "+a:a);continue}if(f=r(h),!f){a=t+(a.length>0?" "+a:a);continue}d=!1}const p=ce(l).join(":"),m=c?p+"!":p,g=m+f;if(o.includes(g))continue;o.push(g);const v=i(f,d);for(let e=0;e<v.length;++e){const t=v[e];o.push(m+t)}a=t+(a.length>0?" "+a:a)}return a})(e,n);return i(e,o),o}return function(){return o(ue.apply(null,arguments))}}const pe=e=>{const t=t=>t[e]||[];return t.isThemeGetter=!0,t},me=/^\[(?:([a-z-]+):)?(.+)\]$/i,ge=/^\d+\/\d+$/,ve=new Set(["px","full","screen"]),be=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ye=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,we=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,xe=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ke=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Se=e=>Ce(e)||ve.has(e)||ge.test(e),Ee=e=>_e(e,"length",Fe),Ce=e=>Boolean(e)&&!Number.isNaN(Number(e)),Oe=e=>_e(e,"number",Ce),Ne=e=>Boolean(e)&&Number.isInteger(Number(e)),Ae=e=>e.endsWith("%")&&Ce(e.slice(0,-1)),Te=e=>me.test(e),Me=e=>be.test(e),Re=new Set(["length","size","percentage"]),De=e=>_e(e,Re,We),Pe=e=>_e(e,"position",We),Le=new Set(["image","url"]),Be=e=>_e(e,Le,He),Ie=e=>_e(e,"",ze),je=()=>!0,_e=(e,t,n)=>{const r=me.exec(e);return!!r&&(r[1]?"string"==typeof t?r[1]===t:t.has(r[1]):n(r[2]))},Fe=e=>ye.test(e)&&!we.test(e),We=()=>!1,ze=e=>xe.test(e),He=e=>ke.test(e),Ve=fe(()=>{const e=pe("colors"),t=pe("spacing"),n=pe("blur"),r=pe("brightness"),i=pe("borderColor"),o=pe("borderRadius"),s=pe("borderSpacing"),a=pe("borderWidth"),l=pe("contrast"),c=pe("grayscale"),h=pe("hueRotate"),u=pe("invert"),d=pe("gap"),f=pe("gradientColorStops"),p=pe("gradientColorStopPositions"),m=pe("inset"),g=pe("margin"),v=pe("opacity"),b=pe("padding"),y=pe("saturate"),w=pe("scale"),x=pe("sepia"),k=pe("skew"),S=pe("space"),E=pe("translate"),C=()=>["auto",Te,t],O=()=>[Te,t],N=()=>["",Se,Ee],A=()=>["auto",Ce,Te],T=()=>["","0",Te],M=()=>[Ce,Te];return{cacheSize:500,separator:":",theme:{colors:[je],spacing:[Se,Ee],blur:["none","",Me,Te],brightness:M(),borderColor:[e],borderRadius:["none","","full",Me,Te],borderSpacing:O(),borderWidth:N(),contrast:M(),grayscale:T(),hueRotate:M(),invert:T(),gap:O(),gradientColorStops:[e],gradientColorStopPositions:[Ae,Ee],inset:C(),margin:C(),opacity:M(),padding:O(),saturate:M(),scale:M(),sepia:T(),skew:M(),space:O(),translate:O()},classGroups:{aspect:[{aspect:["auto","square","video",Te]}],container:["container"],columns:[{columns:[Me]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",Te]}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[m]}],"inset-x":[{"inset-x":[m]}],"inset-y":[{"inset-y":[m]}],start:[{start:[m]}],end:[{end:[m]}],top:[{top:[m]}],right:[{right:[m]}],bottom:[{bottom:[m]}],left:[{left:[m]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Ne,Te]}],basis:[{basis:C()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Te]}],grow:[{grow:T()}],shrink:[{shrink:T()}],order:[{order:["first","last","none",Ne,Te]}],"grid-cols":[{"grid-cols":[je]}],"col-start-end":[{col:["auto",{span:["full",Ne,Te]},Te]}],"col-start":[{"col-start":A()}],"col-end":[{"col-end":A()}],"grid-rows":[{"grid-rows":[je]}],"row-start-end":[{row:["auto",{span:[Ne,Te]},Te]}],"row-start":[{"row-start":A()}],"row-end":[{"row-end":A()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Te]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Te]}],gap:[{gap:[d]}],"gap-x":[{"gap-x":[d]}],"gap-y":[{"gap-y":[d]}],"justify-content":[{justify:["normal","start","end","center","between","around","evenly","stretch"]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[b]}],px:[{px:[b]}],py:[{py:[b]}],ps:[{ps:[b]}],pe:[{pe:[b]}],pt:[{pt:[b]}],pr:[{pr:[b]}],pb:[{pb:[b]}],pl:[{pl:[b]}],m:[{m:[g]}],mx:[{mx:[g]}],my:[{my:[g]}],ms:[{ms:[g]}],me:[{me:[g]}],mt:[{mt:[g]}],mr:[{mr:[g]}],mb:[{mb:[g]}],ml:[{ml:[g]}],"space-x":[{"space-x":[S]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[S]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Te,t]}],"min-w":[{"min-w":[Te,t,"min","max","fit"]}],"max-w":[{"max-w":[Te,t,"none","full","min","max","fit","prose",{screen:[Me]},Me]}],h:[{h:[Te,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Te,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Te,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Te,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Me,Ee]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Oe]}],"font-family":[{font:[je]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Te]}],"line-clamp":[{"line-clamp":["none",Ce,Oe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Se,Te]}],"list-image":[{"list-image":["none",Te]}],"list-style-type":[{list:["none","disc","decimal",Te]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[v]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[v]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","none","wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Se,Ee]}],"underline-offset":[{"underline-offset":["auto",Se,Te]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:O()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Te]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Te]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[v]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",Pe]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",De]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Be]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[p]}],"gradient-via-pos":[{via:[p]}],"gradient-to-pos":[{to:[p]}],"gradient-from":[{from:[f]}],"gradient-via":[{via:[f]}],"gradient-to":[{to:[f]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[v]}],"border-style":[{border:["solid","dashed","dotted","double","none","hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[v]}],"divide-style":[{divide:["solid","dashed","dotted","double","none"]}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["","solid","dashed","dotted","double","none"]}],"outline-offset":[{"outline-offset":[Se,Te]}],"outline-w":[{outline:[Se,Ee]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:N()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[v]}],"ring-offset-w":[{"ring-offset":[Se,Ee]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Me,Ie]}],"shadow-color":[{shadow:[je]}],opacity:[{opacity:[v]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Me,Te]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[h]}],invert:[{invert:[u]}],saturate:[{saturate:[y]}],sepia:[{sepia:[x]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[h]}],"backdrop-invert":[{"backdrop-invert":[u]}],"backdrop-opacity":[{"backdrop-opacity":[v]}],"backdrop-saturate":[{"backdrop-saturate":[y]}],"backdrop-sepia":[{"backdrop-sepia":[x]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Te]}],duration:[{duration:M()}],ease:[{ease:["linear","in","out","in-out",Te]}],delay:[{delay:M()}],animate:[{animate:["none","spin","ping","pulse","bounce",Te]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[w]}],"scale-x":[{"scale-x":[w]}],"scale-y":[{"scale-y":[w]}],rotate:[{rotate:[Ne,Te]}],"translate-x":[{"translate-x":[E]}],"translate-y":[{"translate-y":[E]}],"skew-x":[{"skew-x":[k]}],"skew-y":[{"skew-y":[k]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Te]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Te]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Te]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Se,Ee,Oe]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}});function qe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Ve(J(t))}function Ue(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("animate-pulse rounded-md bg-muted",t)},n))}function $e(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Ke(...e){return t=>{let n=!1;const r=e.map(e=>{const r=$e(e,t);return n||"function"!=typeof r||(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){const n=r[t];"function"==typeof n?n():$e(e[t],null)}}}}function Ye(...e){return s.useCallback(Ke(...e),e)}var Ge=Symbol.for("react.lazy"),Xe=s[" use ".trim().toString()];function Je(e){return null!=e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===Ge&&"_payload"in e&&("object"==typeof(t=e._payload)&&null!==t&&"then"in t);var t}function Qe(e){const n=et(e),r=s.forwardRef((e,r)=>{let{children:i,...o}=e;Je(i)&&"function"==typeof Xe&&(i=Xe(i._payload));const a=s.Children.toArray(i),l=a.find(nt);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}var Ze=Qe("Slot");function et(e){const t=s.forwardRef((e,t)=>{let{children:n,...r}=e;if(Je(n)&&"function"==typeof Xe&&(n=Xe(n._payload)),s.isValidElement(n)){const e=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?Ke(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var tt=Symbol("radix.slottable");function nt(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===tt}const rt=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,it=J,ot=(e,t)=>n=>{var r;if(null==(null==t?void 0:t.variants))return it(e,null==n?void 0:n.class,null==n?void 0:n.className);const{variants:i,defaultVariants:o}=t,s=Object.keys(i).map(e=>{const t=null==n?void 0:n[e],r=null==o?void 0:o[e];if(null===t)return null;const s=rt(t)||rt(r);return i[e][s]}),a=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return void 0===r||(e[n]=r),e},{}),l=null==t||null===(r=t.compoundVariants)||void 0===r?void 0:r.reduce((e,t)=>{let{class:n,className:r,...i}=t;return Object.entries(i).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...o,...a}[t]):{...o,...a}[t]===n})?[...e,n,r]:e},[]);return it(e,s,l,null==n?void 0:n.class,null==n?void 0:n.className)};var st=ot("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),at=s.forwardRef(function(e,t){var n=e.className,r=e.variant,i=e.size,o=e.asChild,a=void 0!==o&&o,l=G(e,["className","variant","size","asChild"]),c=a?Ze:"button";return s.createElement(c,Object.assign({className:qe(st({variant:r,size:i,className:n})),ref:t},l))});at.displayName="Button";var lt=s.forwardRef(function(e,t){var n=e.className,r=e.type,i=G(e,["className","type"]);return s.createElement("input",Object.assign({type:r,className:qe("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:t},i))});lt.displayName="Input";var ct=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=Qe(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),ht="horizontal",ut=["horizontal","vertical"],dt=s.forwardRef((e,n)=>{const{decorative:r,orientation:i=ht,...o}=e,s=function(e){return ut.includes(e)}(i)?i:ht,a=r?{role:"none"}:{"aria-orientation":"vertical"===s?s:void 0,role:"separator"};return t.jsx(ct.div,{"data-orientation":s,...a,...o,ref:n})});dt.displayName="Separator";var ft=dt,pt=s.forwardRef(function(e,t){var n=e.className,r=e.orientation,i=void 0===r?"horizontal":r,o=e.decorative,a=void 0===o||o,l=G(e,["className","orientation","decorative"]);return s.createElement(ft,Object.assign({ref:t,decorative:a,orientation:i,className:qe("shrink-0 bg-border","horizontal"===i?"h-[1px] w-full":"h-full w-[1px]",n)},l))});function mt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function gt(e,n=[]){let r=[];const i=()=>{const t=r.map(e=>s.createContext(e));return function(n){const r=n?.[e]||t;return s.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[function(n,i){const o=s.createContext(i),a=r.length;r=[...r,i];const l=n=>{const{scope:r,children:i,...l}=n,c=r?.[e]?.[a]||o,h=s.useMemo(()=>l,Object.values(l));return t.jsx(c.Provider,{value:h,children:i})};return l.displayName=n+"Provider",[l,function(t,r){const l=r?.[e]?.[a]||o,c=s.useContext(l);if(c)return c;if(void 0!==i)return i;throw new Error(`\`${t}\` must be used within \`${n}\``)}]},vt(i,...n)]}function vt(...e){const t=e[0];if(1===e.length)return t;const n=()=>{const n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){const r=n.reduce((t,{useScope:n,scopeName:r})=>({...t,...n(e)[`__scope${r}`]}),{});return s.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}pt.displayName=ft.displayName;var bt=globalThis?.document?s.useLayoutEffect:()=>{},yt=s[" useId ".trim().toString()]||(()=>{}),wt=0;function xt(e){const[t,n]=s.useState(yt());return bt(()=>{e||n(e=>e??String(wt++))},[e]),e||(t?`radix-${t}`:"")}var kt=s[" useInsertionEffect ".trim().toString()]||bt;function St({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,o,a]=function({defaultProp:e,onChange:t}){const[n,r]=s.useState(e),i=s.useRef(n),o=s.useRef(t);return kt(()=>{o.current=t},[t]),s.useEffect(()=>{i.current!==n&&(o.current?.(n),i.current=n)},[n,i]),[n,r,o]}({defaultProp:t,onChange:n}),l=void 0!==e,c=l?e:i;{const t=s.useRef(void 0!==e);s.useEffect(()=>{const e=t.current;if(e!==l){}t.current=l},[l,r])}const h=s.useCallback(t=>{if(l){const n=function(e){return"function"==typeof e}(t)?t(e):t;n!==e&&a.current?.(n)}else o(t)},[l,e,o,a]);return[c,h]}function Et(e){const n=Ct(e),r=s.forwardRef((e,r)=>{const{children:i,...o}=e,a=s.Children.toArray(i),l=a.find(Nt);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}function Ct(e){const t=s.forwardRef((e,t)=>{const{children:n,...r}=e;if(s.isValidElement(n)){const e=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?Ke(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ot=Symbol("radix.slottable");function Nt(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Ot}var At=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=Et(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function Tt(e){const t=s.useRef(e);return s.useEffect(()=>{t.current=e}),s.useMemo(()=>(...e)=>t.current?.(...e),[])}function Mt(e,t=globalThis?.document){const n=Tt(e);s.useEffect(()=>{const e=e=>{"Escape"===e.key&&n(e)};return t.addEventListener("keydown",e,{capture:!0}),()=>t.removeEventListener("keydown",e,{capture:!0})},[n,t])}var Rt,Dt="dismissableLayer.update",Pt="dismissableLayer.pointerDownOutside",Lt="dismissableLayer.focusOutside",Bt=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),It=s.forwardRef((e,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...h}=e,u=s.useContext(Bt),[d,f]=s.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=s.useState({}),g=Ye(n,e=>f(e)),v=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=d?v.indexOf(d):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(e,t=globalThis?.document){const n=Tt(e),r=s.useRef(!1),i=s.useRef(()=>{});return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){_t(Pt,n,o,{discrete:!0})};const o={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",i.current),i.current=r,t.addEventListener("click",i.current,{once:!0})):r()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",e),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,n=[...u.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),l?.(e),e.defaultPrevented||c?.())},p),E=function(e,t=globalThis?.document){const n=Tt(e),r=s.useRef(!1);return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){_t(Lt,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...u.branches].some(e=>e.contains(t))||(a?.(e),l?.(e),e.defaultPrevented||c?.())},p);return Mt(e=>{w===u.layers.size-1&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},p),s.useEffect(()=>{if(d)return r&&(0===u.layersWithOutsidePointerEventsDisabled.size&&(Rt=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),jt(),()=>{r&&1===u.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=Rt)}},[d,p,r,u]),s.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),jt())},[d,u]),s.useEffect(()=>{const e=()=>m({});return document.addEventListener(Dt,e),()=>document.removeEventListener(Dt,e)},[]),t.jsx(At.div,{...h,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...e.style},onFocusCapture:mt(e.onFocusCapture,E.onFocusCapture),onBlurCapture:mt(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:mt(e.onPointerDownCapture,S.onPointerDownCapture)})});It.displayName="DismissableLayer";function jt(){const e=new CustomEvent(Dt);document.dispatchEvent(e)}function _t(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?function(e,t){e&&a.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}s.forwardRef((e,n)=>{const r=s.useContext(Bt),i=s.useRef(null),o=Ye(n,i);return s.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),t.jsx(At.div,{...e,ref:o})}).displayName="DismissableLayerBranch";var Ft="focusScope.autoFocusOnMount",Wt="focusScope.autoFocusOnUnmount",zt={bubbles:!1,cancelable:!0},Ht=s.forwardRef((e,n)=>{const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...l}=e,[c,h]=s.useState(null),u=Tt(o),d=Tt(a),f=s.useRef(null),p=Ye(n,e=>h(e)),m=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(i){let e=function(e){if(m.paused||!c)return;const t=e.target;c.contains(t)?f.current=t:$t(f.current,{select:!0})},t=function(e){if(m.paused||!c)return;const t=e.relatedTarget;null!==t&&(c.contains(t)||$t(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&$t(c)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[i,c,m.paused]),s.useEffect(()=>{if(c){Kt.add(m);const t=document.activeElement;if(!c.contains(t)){const n=new CustomEvent(Ft,zt);c.addEventListener(Ft,u),c.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if($t(r,{select:t}),document.activeElement!==n)return}((e=Vt(c),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&$t(c))}return()=>{c.removeEventListener(Ft,u),setTimeout(()=>{const e=new CustomEvent(Wt,zt);c.addEventListener(Wt,d),c.dispatchEvent(e),e.defaultPrevented||$t(t??document.body,{select:!0}),c.removeEventListener(Wt,d),Kt.remove(m)},0)}}var e},[c,u,d,m]);const g=s.useCallback(e=>{if(!r&&!i)return;if(m.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){const t=e.currentTarget,[i,o]=function(e){const t=Vt(e),n=qt(t,e),r=qt(t.reverse(),e);return[n,r]}(t);i&&o?e.shiftKey||n!==o?e.shiftKey&&n===i&&(e.preventDefault(),r&&$t(o,{select:!0})):(e.preventDefault(),r&&$t(i,{select:!0})):n===t&&e.preventDefault()}},[r,i,m.paused]);return t.jsx(At.div,{tabIndex:-1,...l,ref:p,onKeyDown:g})});function Vt(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function qt(e,t){for(const n of e)if(!Ut(n,{upTo:t}))return n}function Ut(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function $t(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}Ht.displayName="FocusScope";var Kt=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Yt(e,t),e.unshift(t)},remove(t){e=Yt(e,t),e[0]?.resume()}}}();function Yt(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var Gt=s.forwardRef((e,r)=>{const{container:i,...o}=e,[a,l]=s.useState(!1);bt(()=>l(!0),[]);const c=i||a&&globalThis?.document?.body;return c?n.createPortal(t.jsx(At.div,{...o,ref:r}),c):null});Gt.displayName="Portal";var Xt=e=>{const{present:t,children:n}=e,r=function(e){const[t,n]=s.useState(),r=s.useRef(null),i=s.useRef(e),o=s.useRef("none"),a=e?"mounted":"unmounted",[l,c]=function(e,t){return s.useReducer((e,n)=>t[e][n]??e,e)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.useEffect(()=>{const e=Jt(r.current);o.current="mounted"===l?e:"none"},[l]),bt(()=>{const t=r.current,n=i.current;if(n!==e){const r=o.current,s=Jt(t);if(e)c("MOUNT");else if("none"===s||"none"===t?.display)c("UNMOUNT");else{c(n&&r!==s?"ANIMATION_OUT":"UNMOUNT")}i.current=e}},[e,c]),bt(()=>{if(t){let e;const n=t.ownerDocument.defaultView??window,s=o=>{const s=Jt(r.current).includes(CSS.escape(o.animationName));if(o.target===t&&s&&(c("ANIMATION_END"),!i.current)){const r=t.style.animationFillMode;t.style.animationFillMode="forwards",e=n.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=r)})}},a=e=>{e.target===t&&(o.current=Jt(r.current))};return t.addEventListener("animationstart",a),t.addEventListener("animationcancel",s),t.addEventListener("animationend",s),()=>{n.clearTimeout(e),t.removeEventListener("animationstart",a),t.removeEventListener("animationcancel",s),t.removeEventListener("animationend",s)}}c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:s.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}(t),i="function"==typeof n?n({present:r.isPresent}):s.Children.only(n),o=Ye(r.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof n||r.isPresent?s.cloneElement(i,{ref:o}):null};function Jt(e){return e?.animationName||"none"}Xt.displayName="Presence";var Qt=0;function Zt(){s.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??en()),document.body.insertAdjacentElement("beforeend",e[1]??en()),Qt++,()=>{1===Qt&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Qt--}},[])}function en(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var tn="right-scroll-bar-position",nn="width-before-scroll-bar";function rn(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var on="undefined"!=typeof window?s.useLayoutEffect:s.useEffect,sn=new WeakMap;function an(t,n){var r,i,o,s=(r=n||null,i=function(e){return t.forEach(function(t){return rn(t,e)})},(o=e.useState(function(){return{value:r,callback:i,facade:{get current(){return o.value},set current(e){var t=o.value;t!==e&&(o.value=e,o.callback(e,t))}}}})[0]).callback=i,o.facade);return on(function(){var e=sn.get(s);if(e){var n=new Set(e),r=new Set(t),i=s.current;n.forEach(function(e){r.has(e)||rn(e,null)}),r.forEach(function(e){n.has(e)||rn(e,i)})}sn.set(s,t)},[t]),s}function ln(e){return e}var cn=function(e){var t=e.sideCar,n=G(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return s.createElement(r,Y({},n))};cn.isSideCarExport=!0;var hn=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=ln);var n=[],r=!1;return{read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var o=function(){var n=t;t=[],n.forEach(e)},s=function(){return Promise.resolve().then(o)};s(),n={push:function(e){t.push(e),s()},filter:function(e){return t=t.filter(e),n}}}}}(null);return t.options=Y({async:!0,ssr:!1},e),t}(),un=function(){},dn=s.forwardRef(function(e,t){var n=s.useRef(null),r=s.useState({onScrollCapture:un,onWheelCapture:un,onTouchMoveCapture:un}),i=r[0],o=r[1],a=e.forwardProps,l=e.children,c=e.className,h=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,g=e.inert,v=e.allowPinchZoom,b=e.as,y=void 0===b?"div":b,w=e.gapMode,x=G(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=f,S=an([n,t]),E=Y(Y({},x),i);return s.createElement(s.Fragment,null,u&&s.createElement(k,{sideCar:hn,removeScrollBar:h,shards:d,noRelative:p,noIsolation:m,inert:g,setCallbacks:o,allowPinchZoom:!!v,lockRef:n,gapMode:w}),a?s.cloneElement(s.Children.only(l),Y(Y({},E),{ref:S})):s.createElement(y,Y({},E,{className:c,ref:S}),l))});dn.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},dn.classNames={fullWidth:nn,zeroRight:tn};function fn(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=function(){if("undefined"!=typeof __webpack_nonce__)return __webpack_nonce__}();return t&&e.setAttribute("nonce",t),e}var pn=function(){var e=0,t=null;return{add:function(n){var r,i;0==e&&(t=fn())&&(i=n,(r=t).styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},mn=function(){var e,t=(e=pn(),function(t,n){s.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])});return function(e){var n=e.styles,r=e.dynamic;return t(n,r),null}},gn={left:0,top:0,right:0,gap:0},vn=function(e){return parseInt(e||"",10)||0},bn=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return gn;var t=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],i=t["padding"===e?"paddingRight":"marginRight"];return[vn(n),vn(r),vn(i)]}(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},yn=mn(),wn="data-scroll-locked",xn=function(e,t,n,r){var i=e.left,o=e.top,s=e.right,a=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(a,"px ").concat(r,";\n }\n body[").concat(wn,"] {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===n&&"\n padding-left: ".concat(i,"px;\n padding-top: ").concat(o,"px;\n padding-right: ").concat(s,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(a,"px ").concat(r,";\n "),"padding"===n&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(tn," {\n right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(nn," {\n margin-right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(tn," .").concat(tn," {\n right: 0 ").concat(r,";\n }\n \n .").concat(nn," .").concat(nn," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(wn,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(a,"px;\n }\n")},kn=function(){var e=parseInt(document.body.getAttribute(wn)||"0",10);return isFinite(e)?e:0},Sn=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=void 0===r?"margin":r;s.useEffect(function(){return document.body.setAttribute(wn,(kn()+1).toString()),function(){var e=kn()-1;e<=0?document.body.removeAttribute(wn):document.body.setAttribute(wn,e.toString())}},[]);var o=s.useMemo(function(){return bn(i)},[i]);return s.createElement(yn,{styles:xn(o,!t,i,n?"":"!important")})},En=!1;if("undefined"!=typeof window)try{var Cn=Object.defineProperty({},"passive",{get:function(){return En=!0,!0}});window.addEventListener("test",Cn,Cn),window.removeEventListener("test",Cn,Cn)}catch(e){En=!1}var On=!!En&&{passive:!1},Nn=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&!(n.overflowY===n.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===n[t])},An=function(e,t){var n=t.ownerDocument,r=t;do{if("undefined"!=typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),Tn(e,r)){var i=Mn(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Tn=function(e,t){return"v"===e?function(e){return Nn(e,"overflowY")}(t):function(e){return Nn(e,"overflowX")}(t)},Mn=function(e,t){return"v"===e?function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]}(t):function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t)},Rn=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Dn=function(e){return[e.deltaX,e.deltaY]},Pn=function(e){return e&&"current"in e?e.current:e},Ln=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},Bn=0,In=[];function jn(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var _n,Fn=(_n=function(e){var t=s.useRef([]),n=s.useRef([0,0]),r=s.useRef(),i=s.useState(Bn++)[0],o=s.useState(mn)[0],a=s.useRef(e);s.useEffect(function(){a.current=e},[e]),s.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var t=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}([e.lockRef.current],(e.shards||[]).map(Pn),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=s.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!a.current.allowPinchZoom;var i,o=Rn(e),s=n.current,l="deltaX"in e?e.deltaX:s[0]-o[0],c="deltaY"in e?e.deltaY:s[1]-o[1],h=e.target,u=Math.abs(l)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===u&&"range"===h.type)return!1;var d=window.getSelection(),f=d&&d.anchorNode;if(f&&(f===h||f.contains(h)))return!1;var p=An(u,h);if(!p)return!0;if(p?i=u:(i="v"===u?"h":"v",p=An(u,h)),!p)return!1;if(!r.current&&"changedTouches"in e&&(l||c)&&(r.current=i),!i)return!0;var m=r.current||i;return function(e,t,n,r,i){var o=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),s=o*r,a=n.target,l=t.contains(a),c=!1,h=s>0,u=0,d=0;do{if(!a)break;var f=Mn(e,a),p=f[0],m=f[1]-f[2]-o*p;(p||m)&&Tn(e,a)&&(u+=m,d+=p);var g=a.parentNode;a=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(h&&(i&&Math.abs(u)<1||!i&&s>u)||!h&&(i&&Math.abs(d)<1||!i&&-s>d))&&(c=!0),c}(m,t,e,"h"===m?l:c,!0)},[]),c=s.useCallback(function(e){var n=e;if(In.length&&In[In.length-1]===o){var r="deltaY"in n?Dn(n):Rn(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&(t=e.delta,i=r,t[0]===i[0]&&t[1]===i[1]);var t,i})[0];if(i&&i.should)n.cancelable&&n.preventDefault();else if(!i){var s=(a.current.shards||[]).map(Pn).filter(Boolean).filter(function(e){return e.contains(n.target)});(s.length>0?l(n,s[0]):!a.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),h=s.useCallback(function(e,n,r,i){var o={name:e,delta:n,target:r,should:i,shadowParent:jn(r)};t.current.push(o),setTimeout(function(){t.current=t.current.filter(function(e){return e!==o})},1)},[]),u=s.useCallback(function(e){n.current=Rn(e),r.current=void 0},[]),d=s.useCallback(function(t){h(t.type,Dn(t),t.target,l(t,e.lockRef.current))},[]),f=s.useCallback(function(t){h(t.type,Rn(t),t.target,l(t,e.lockRef.current))},[]);s.useEffect(function(){return In.push(o),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",c,On),document.addEventListener("touchmove",c,On),document.addEventListener("touchstart",u,On),function(){In=In.filter(function(e){return e!==o}),document.removeEventListener("wheel",c,On),document.removeEventListener("touchmove",c,On),document.removeEventListener("touchstart",u,On)}},[]);var p=e.removeScrollBar,m=e.inert;return s.createElement(s.Fragment,null,m?s.createElement(o,{styles:Ln(i)}):null,p?s.createElement(Sn,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},hn.useMedium(_n),cn),Wn=s.forwardRef(function(e,t){return s.createElement(dn,Y({},e,{ref:t,sideCar:Fn}))});Wn.classNames=dn.classNames;var zn=Wn,Hn=new WeakMap,Vn=new WeakMap,qn={},Un=0,$n=function(e){return e&&(e.host||$n(e.parentNode))},Kn=function(e,t,n,r){var i=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=$n(t);return n&&e.contains(n)?n:null}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);qn[n]||(qn[n]=new WeakMap);var o=qn[n],s=[],a=new Set,l=new Set(i),c=function(e){e&&!a.has(e)&&(a.add(e),c(e.parentNode))};i.forEach(c);var h=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(a.has(e))h(e);else try{var t=e.getAttribute(r),i=null!==t&&"false"!==t,l=(Hn.get(e)||0)+1,c=(o.get(e)||0)+1;Hn.set(e,l),o.set(e,c),s.push(e),1===l&&i&&Vn.set(e,!0),1===c&&e.setAttribute(n,"true"),i||e.setAttribute(r,"true")}catch(e){}})};return h(t),a.clear(),Un++,function(){s.forEach(function(e){var t=Hn.get(e)-1,i=o.get(e)-1;Hn.set(e,t),o.set(e,i),t||(Vn.has(e)||e.removeAttribute(r),Vn.delete(e)),i||e.removeAttribute(n)}),--Un||(Hn=new WeakMap,Hn=new WeakMap,Vn=new WeakMap,qn={})}},Yn=function(e,t,n){void 0===n&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=t||function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),Kn(r,i,n,"aria-hidden")):function(){return null}},Gn="Dialog",[Xn,Jn]=gt(Gn),[Qn,Zn]=Xn(Gn),er=e=>{const{__scopeDialog:n,children:r,open:i,defaultOpen:o,onOpenChange:a,modal:l=!0}=e,c=s.useRef(null),h=s.useRef(null),[u,d]=St({prop:i,defaultProp:o??!1,onChange:a,caller:Gn});return t.jsx(Qn,{scope:n,triggerRef:c,contentRef:h,contentId:xt(),titleId:xt(),descriptionId:xt(),open:u,onOpenChange:d,onOpenToggle:s.useCallback(()=>d(e=>!e),[d]),modal:l,children:r})};er.displayName=Gn;var tr="DialogTrigger",nr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=Zn(tr,r),s=Ye(n,o.triggerRef);return t.jsx(At.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":kr(o.open),...i,ref:s,onClick:mt(e.onClick,o.onOpenToggle)})});nr.displayName=tr;var rr="DialogPortal",[ir,or]=Xn(rr,{forceMount:void 0}),sr=e=>{const{__scopeDialog:n,forceMount:r,children:i,container:o}=e,a=Zn(rr,n);return t.jsx(ir,{scope:n,forceMount:r,children:s.Children.map(i,e=>t.jsx(Xt,{present:r||a.open,children:t.jsx(Gt,{asChild:!0,container:o,children:e})}))})};sr.displayName=rr;var ar="DialogOverlay",lr=s.forwardRef((e,n)=>{const r=or(ar,e.__scopeDialog),{forceMount:i=r.forceMount,...o}=e,s=Zn(ar,e.__scopeDialog);return s.modal?t.jsx(Xt,{present:i||s.open,children:t.jsx(hr,{...o,ref:n})}):null});lr.displayName=ar;var cr=Et("DialogOverlay.RemoveScroll"),hr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=Zn(ar,r);return t.jsx(zn,{as:cr,allowPinchZoom:!0,shards:[o.contentRef],children:t.jsx(At.div,{"data-state":kr(o.open),...i,ref:n,style:{pointerEvents:"auto",...i.style}})})}),ur="DialogContent",dr=s.forwardRef((e,n)=>{const r=or(ur,e.__scopeDialog),{forceMount:i=r.forceMount,...o}=e,s=Zn(ur,e.__scopeDialog);return t.jsx(Xt,{present:i||s.open,children:s.modal?t.jsx(fr,{...o,ref:n}):t.jsx(pr,{...o,ref:n})})});dr.displayName=ur;var fr=s.forwardRef((e,n)=>{const r=Zn(ur,e.__scopeDialog),i=s.useRef(null),o=Ye(n,r.contentRef,i);return s.useEffect(()=>{const e=i.current;if(e)return Yn(e)},[]),t.jsx(mr,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:mt(e.onCloseAutoFocus,e=>{e.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:mt(e.onPointerDownOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:mt(e.onFocusOutside,e=>e.preventDefault())})}),pr=s.forwardRef((e,n)=>{const r=Zn(ur,e.__scopeDialog),i=s.useRef(!1),o=s.useRef(!1);return t.jsx(mr,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(i.current||r.triggerRef.current?.focus(),t.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(i.current=!0,"pointerdown"===t.detail.originalEvent.type&&(o.current=!0));const n=t.target,s=r.triggerRef.current?.contains(n);s&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&o.current&&t.preventDefault()}})}),mr=s.forwardRef((e,n)=>{const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:a,...l}=e,c=Zn(ur,r),h=s.useRef(null),u=Ye(n,h);return Zt(),t.jsxs(t.Fragment,{children:[t.jsx(Ht,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:a,children:t.jsx(It,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":kr(c.open),...l,ref:u,onDismiss:()=>c.onOpenChange(!1)})}),t.jsxs(t.Fragment,{children:[t.jsx(Or,{titleId:c.titleId}),t.jsx(Nr,{contentRef:h,descriptionId:c.descriptionId})]})]})}),gr="DialogTitle",vr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=Zn(gr,r);return t.jsx(At.h2,{id:o.titleId,...i,ref:n})});vr.displayName=gr;var br="DialogDescription",yr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=Zn(br,r);return t.jsx(At.p,{id:o.descriptionId,...i,ref:n})});yr.displayName=br;var wr="DialogClose",xr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=Zn(wr,r);return t.jsx(At.button,{type:"button",...i,ref:n,onClick:mt(e.onClick,()=>o.onOpenChange(!1))})});function kr(e){return e?"open":"closed"}xr.displayName=wr;var Sr="DialogTitleWarning",[Er,Cr]=function(e,n){const r=s.createContext(n),i=e=>{const{children:n,...i}=e,o=s.useMemo(()=>i,Object.values(i));return t.jsx(r.Provider,{value:o,children:n})};return i.displayName=e+"Provider",[i,function(t){const i=s.useContext(r);if(i)return i;if(void 0!==n)return n;throw new Error(`\`${t}\` must be used within \`${e}\``)}]}(Sr,{contentName:ur,titleName:gr,docsSlug:"dialog"}),Or=({titleId:e})=>{const t=Cr(Sr),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return s.useEffect(()=>{if(e){document.getElementById(e)}},[n,e]),null},Nr=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Cr("DialogDescriptionWarning").contentName}}.`;return s.useEffect(()=>{const n=e.current?.getAttribute("aria-describedby");if(t&&n){document.getElementById(t)}},[n,e,t]),null},Ar=er,Tr=nr,Mr=sr,Rr=lr,Dr=dr,Pr=vr,Lr=yr,Br=xr,Ir=Ar,jr=Mr,_r=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Rr,Object.assign({className:qe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n)},r,{ref:t}))});_r.displayName=Rr.displayName;var Fr=ot("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Wr=s.forwardRef(function(e,t){var n=e.side,r=void 0===n?"right":n,i=e.className,o=e.children,a=G(e,["side","className","children"]);return s.createElement(jr,null,s.createElement(_r,null),s.createElement(Dr,Object.assign({ref:t,className:qe(Fr({side:r}),i)},a),o,s.createElement(Br,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary"},s.createElement(K,{className:"h-4 w-4"}),s.createElement("span",{className:"sr-only"},"Close"))))});Wr.displayName=Dr.displayName;var zr=function(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("flex flex-col space-y-2 text-center sm:text-left",t)},n))};zr.displayName="SheetHeader";var Hr=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Pr,Object.assign({ref:t,className:qe("text-lg font-semibold text-foreground",n)},r))});Hr.displayName=Pr.displayName;var Vr=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Lr,Object.assign({ref:t,className:qe("text-sm text-muted-foreground",n)},r))});function qr(e){const t=s.forwardRef((e,t)=>{const{children:n,...r}=e;if(s.isValidElement(n)){const e=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?Ke(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}Vr.displayName=Lr.displayName;var Ur=Symbol("radix.slottable");function $r(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Ur}var Kr=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=function(e){const n=qr(e),r=s.forwardRef((e,r)=>{const{children:i,...o}=e,a=s.Children.toArray(i),l=a.find($r);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});var Yr,Gr="dismissableLayer.update",Xr="dismissableLayer.pointerDownOutside",Jr="dismissableLayer.focusOutside",Qr=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Zr=s.forwardRef((e,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...h}=e,u=s.useContext(Qr),[d,f]=s.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=s.useState({}),g=Ye(n,e=>f(e)),v=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=d?v.indexOf(d):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(e,t=globalThis?.document){const n=Tt(e),r=s.useRef(!1),i=s.useRef(()=>{});return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){ti(Xr,n,o,{discrete:!0})};const o={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",i.current),i.current=r,t.addEventListener("click",i.current,{once:!0})):r()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",e),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,n=[...u.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),l?.(e),e.defaultPrevented||c?.())},p),E=function(e,t=globalThis?.document){const n=Tt(e),r=s.useRef(!1);return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){ti(Jr,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...u.branches].some(e=>e.contains(t))||(a?.(e),l?.(e),e.defaultPrevented||c?.())},p);return Mt(e=>{w===u.layers.size-1&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},p),s.useEffect(()=>{if(d)return r&&(0===u.layersWithOutsidePointerEventsDisabled.size&&(Yr=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),ei(),()=>{r&&1===u.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=Yr)}},[d,p,r,u]),s.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),ei())},[d,u]),s.useEffect(()=>{const e=()=>m({});return document.addEventListener(Gr,e),()=>document.removeEventListener(Gr,e)},[]),t.jsx(Kr.div,{...h,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...e.style},onFocusCapture:mt(e.onFocusCapture,E.onFocusCapture),onBlurCapture:mt(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:mt(e.onPointerDownCapture,S.onPointerDownCapture)})});Zr.displayName="DismissableLayer";function ei(){const e=new CustomEvent(Gr);document.dispatchEvent(e)}function ti(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?function(e,t){e&&a.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}s.forwardRef((e,n)=>{const r=s.useContext(Qr),i=s.useRef(null),o=Ye(n,i);return s.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),t.jsx(Kr.div,{...e,ref:o})}).displayName="DismissableLayerBranch";const ni=["top","right","bottom","left"],ri=Math.min,ii=Math.max,oi=Math.round,si=Math.floor,ai=e=>({x:e,y:e}),li={left:"right",right:"left",bottom:"top",top:"bottom"},ci={start:"end",end:"start"};function hi(e,t,n){return ii(e,ri(t,n))}function ui(e,t){return"function"==typeof e?e(t):e}function di(e){return e.split("-")[0]}function fi(e){return e.split("-")[1]}function pi(e){return"x"===e?"y":"x"}function mi(e){return"y"===e?"height":"width"}const gi=new Set(["top","bottom"]);function vi(e){return gi.has(di(e))?"y":"x"}function bi(e){return pi(vi(e))}function yi(e){return e.replace(/start|end/g,e=>ci[e])}const wi=["left","right"],xi=["right","left"],ki=["top","bottom"],Si=["bottom","top"];function Ei(e,t,n,r){const i=fi(e);let o=function(e,t,n){switch(e){case"top":case"bottom":return n?t?xi:wi:t?wi:xi;case"left":case"right":return t?ki:Si;default:return[]}}(di(e),"start"===n,r);return i&&(o=o.map(e=>e+"-"+i),t&&(o=o.concat(o.map(yi)))),o}function Ci(e){return e.replace(/left|right|bottom|top/g,e=>li[e])}function Oi(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function Ni(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Ai(e,t,n){let{reference:r,floating:i}=e;const o=vi(t),s=bi(t),a=mi(s),l=di(t),c="y"===o,h=r.x+r.width/2-i.width/2,u=r.y+r.height/2-i.height/2,d=r[a]/2-i[a]/2;let f;switch(l){case"top":f={x:h,y:r.y-i.height};break;case"bottom":f={x:h,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:u};break;case"left":f={x:r.x-i.width,y:u};break;default:f={x:r.x,y:r.y}}switch(fi(t)){case"start":f[s]-=d*(n&&c?-1:1);break;case"end":f[s]+=d*(n&&c?-1:1)}return f}async function Ti(e,t){var n;void 0===t&&(t={});const{x:r,y:i,platform:o,rects:s,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:h="viewport",elementContext:u="floating",altBoundary:d=!1,padding:f=0}=ui(t,e),p=Oi(f),m=a[d?"floating"===u?"reference":"floating":u],g=Ni(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(m)))||n?m:m.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:h,strategy:l})),v="floating"===u?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,b=await(null==o.getOffsetParent?void 0:o.getOffsetParent(a.floating)),y=await(null==o.isElement?void 0:o.isElement(b))&&await(null==o.getScale?void 0:o.getScale(b))||{x:1,y:1},w=Ni(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:b,strategy:l}):v);return{top:(g.top-w.top+p.top)/y.y,bottom:(w.bottom-g.bottom+p.bottom)/y.y,left:(g.left-w.left+p.left)/y.x,right:(w.right-g.right+p.right)/y.x}}function Mi(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ri(e){return ni.some(t=>e[t]>=0)}const Di=new Set(["left","top"]);function Pi(){return"undefined"!=typeof window}function Li(e){return ji(e)?(e.nodeName||"").toLowerCase():"#document"}function Bi(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Ii(e){var t;return null==(t=(ji(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function ji(e){return!!Pi()&&(e instanceof Node||e instanceof Bi(e).Node)}function _i(e){return!!Pi()&&(e instanceof Element||e instanceof Bi(e).Element)}function Fi(e){return!!Pi()&&(e instanceof HTMLElement||e instanceof Bi(e).HTMLElement)}function Wi(e){return!(!Pi()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof Bi(e).ShadowRoot)}const zi=new Set(["inline","contents"]);function Hi(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=eo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!zi.has(i)}const Vi=new Set(["table","td","th"]);function qi(e){return Vi.has(Li(e))}const Ui=[":popover-open",":modal"];function $i(e){return Ui.some(t=>{try{return e.matches(t)}catch(e){return!1}})}const Ki=["transform","translate","scale","rotate","perspective"],Yi=["transform","translate","scale","rotate","perspective","filter"],Gi=["paint","layout","strict","content"];function Xi(e){const t=Ji(),n=_i(e)?eo(e):e;return Ki.some(e=>!!n[e]&&"none"!==n[e])||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||Yi.some(e=>(n.willChange||"").includes(e))||Gi.some(e=>(n.contain||"").includes(e))}function Ji(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const Qi=new Set(["html","body","#document"]);function Zi(e){return Qi.has(Li(e))}function eo(e){return Bi(e).getComputedStyle(e)}function to(e){return _i(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function no(e){if("html"===Li(e))return e;const t=e.assignedSlot||e.parentNode||Wi(e)&&e.host||Ii(e);return Wi(t)?t.host:t}function ro(e){const t=no(e);return Zi(t)?e.ownerDocument?e.ownerDocument.body:e.body:Fi(t)&&Hi(t)?t:ro(t)}function io(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const i=ro(e),o=i===(null==(r=e.ownerDocument)?void 0:r.body),s=Bi(i);if(o){const e=oo(s);return t.concat(s,s.visualViewport||[],Hi(i)?i:[],e&&n?io(e):[])}return t.concat(i,io(i,[],n))}function oo(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function so(e){const t=eo(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Fi(e),o=i?e.offsetWidth:n,s=i?e.offsetHeight:r,a=oi(n)!==o||oi(r)!==s;return a&&(n=o,r=s),{width:n,height:r,$:a}}function ao(e){return _i(e)?e:e.contextElement}function lo(e){const t=ao(e);if(!Fi(t))return ai(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=so(t);let s=(o?oi(n.width):n.width)/r,a=(o?oi(n.height):n.height)/i;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const co=ai(0);function ho(e){const t=Bi(e);return Ji()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:co}function uo(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),o=ao(e);let s=ai(1);t&&(r?_i(r)&&(s=lo(r)):s=lo(e));const a=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==Bi(e))&&t}(o,n,r)?ho(o):ai(0);let l=(i.left+a.x)/s.x,c=(i.top+a.y)/s.y,h=i.width/s.x,u=i.height/s.y;if(o){const e=Bi(o),t=r&&_i(r)?Bi(r):r;let n=e,i=oo(n);for(;i&&r&&t!==n;){const e=lo(i),t=i.getBoundingClientRect(),r=eo(i),o=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,s=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,c*=e.y,h*=e.x,u*=e.y,l+=o,c+=s,n=Bi(i),i=oo(n)}}return Ni({width:h,height:u,x:l,y:c})}function fo(e,t){const n=to(e).scrollLeft;return t?t.left+n:uo(Ii(e)).left+n}function po(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-fo(e,n),y:n.top+t.scrollTop}}const mo=new Set(["absolute","fixed"]);function go(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=Bi(e),r=Ii(e),i=n.visualViewport;let o=r.clientWidth,s=r.clientHeight,a=0,l=0;if(i){o=i.width,s=i.height;const e=Ji();(!e||e&&"fixed"===t)&&(a=i.offsetLeft,l=i.offsetTop)}const c=fo(r);if(c<=0){const e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i="CSS1Compat"===e.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,s=Math.abs(r.clientWidth-t.clientWidth-i);s<=25&&(o-=s)}else c<=25&&(o+=c);return{width:o,height:s,x:a,y:l}}(e,n);else if("document"===t)r=function(e){const t=Ii(e),n=to(e),r=e.ownerDocument.body,i=ii(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=ii(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+fo(e);const a=-n.scrollTop;return"rtl"===eo(r).direction&&(s+=ii(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:s,y:a}}(Ii(e));else if(_i(t))r=function(e,t){const n=uo(e,!0,"fixed"===t),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=Fi(e)?lo(e):ai(1);return{width:e.clientWidth*o.x,height:e.clientHeight*o.y,x:i*o.x,y:r*o.y}}(t,n);else{const n=ho(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Ni(r)}function vo(e,t){const n=no(e);return!(n===t||!_i(n)||Zi(n))&&("fixed"===eo(n).position||vo(n,t))}function bo(e,t,n){const r=Fi(t),i=Ii(t),o="fixed"===n,s=uo(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=ai(0);function c(){l.x=fo(i)}if(r||!r&&!o)if(("body"!==Li(t)||Hi(i))&&(a=to(t)),r){const e=uo(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else i&&c();o&&!r&&i&&c();const h=!i||r||o?ai(0):po(i,a);return{x:s.left+a.scrollLeft-l.x-h.x,y:s.top+a.scrollTop-l.y-h.y,width:s.width,height:s.height}}function yo(e){return"static"===eo(e).position}function wo(e,t){if(!Fi(e)||"fixed"===eo(e).position)return null;if(t)return t(e);let n=e.offsetParent;return Ii(e)===n&&(n=n.ownerDocument.body),n}function xo(e,t){const n=Bi(e);if($i(e))return n;if(!Fi(e)){let t=no(e);for(;t&&!Zi(t);){if(_i(t)&&!yo(t))return t;t=no(t)}return n}let r=wo(e,t);for(;r&&qi(r)&&yo(r);)r=wo(r,t);return r&&Zi(r)&&yo(r)&&!Xi(r)?n:r||function(e){let t=no(e);for(;Fi(t)&&!Zi(t);){if(Xi(t))return t;if($i(t))return null;t=no(t)}return null}(e)||n}const ko={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o="fixed"===i,s=Ii(r),a=!!t&&$i(t.floating);if(r===s||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=ai(1);const h=ai(0),u=Fi(r);if((u||!u&&!o)&&(("body"!==Li(r)||Hi(s))&&(l=to(r)),Fi(r))){const e=uo(r);c=lo(r),h.x=e.x+r.clientLeft,h.y=e.y+r.clientTop}const d=!s||u||o?ai(0):po(s,l);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+h.x+d.x,y:n.y*c.y-l.scrollTop*c.y+h.y+d.y}},getDocumentElement:Ii,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[..."clippingAncestors"===n?$i(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let r=io(e,[],!1).filter(e=>_i(e)&&"body"!==Li(e)),i=null;const o="fixed"===eo(e).position;let s=o?no(e):e;for(;_i(s)&&!Zi(s);){const t=eo(s),n=Xi(s);n||"fixed"!==t.position||(i=null),(o?!n&&!i:!n&&"static"===t.position&&i&&mo.has(i.position)||Hi(s)&&!n&&vo(e,s))?r=r.filter(e=>e!==s):i=t,s=no(s)}return t.set(e,r),r}(t,this._c):[].concat(n),r],s=o[0],a=o.reduce((e,n)=>{const r=go(t,n,i);return e.top=ii(r.top,e.top),e.right=ri(r.right,e.right),e.bottom=ri(r.bottom,e.bottom),e.left=ii(r.left,e.left),e},go(t,s,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:xo,getElementRects:async function(e){const t=this.getOffsetParent||xo,n=this.getDimensions,r=await n(e.floating);return{reference:bo(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=so(e);return{width:t,height:n}},getScale:lo,isElement:_i,isRTL:function(e){return"rtl"===eo(e).direction}};function So(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Eo(e,t,n,r){void 0===r&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:l=!1}=r,c=ao(e),h=i||o?[...c?io(c):[],...io(t)]:[];h.forEach(e=>{i&&e.addEventListener("scroll",n,{passive:!0}),o&&e.addEventListener("resize",n)});const u=c&&a?function(e,t){let n,r=null;const i=Ii(e);function o(){var e;clearTimeout(n),null==(e=r)||e.disconnect(),r=null}return function s(a,l){void 0===a&&(a=!1),void 0===l&&(l=1),o();const c=e.getBoundingClientRect(),{left:h,top:u,width:d,height:f}=c;if(a||t(),!d||!f)return;const p={rootMargin:-si(u)+"px "+-si(i.clientWidth-(h+d))+"px "+-si(i.clientHeight-(u+f))+"px "+-si(h)+"px",threshold:ii(0,ri(1,l))||1};let m=!0;function g(t){const r=t[0].intersectionRatio;if(r!==l){if(!m)return s();r?s(!1,r):n=setTimeout(()=>{s(!1,1e-7)},1e3)}1!==r||So(c,e.getBoundingClientRect())||s(),m=!1}try{r=new IntersectionObserver(g,{...p,root:i.ownerDocument})}catch(e){r=new IntersectionObserver(g,p)}r.observe(e)}(!0),o}(c,n):null;let d,f=-1,p=null;s&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;null==(e=p)||e.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let m=l?uo(e):null;return l&&function t(){const r=uo(e);m&&!So(m,r)&&n();m=r,d=requestAnimationFrame(t)}(),n(),()=>{var e;h.forEach(e=>{i&&e.removeEventListener("scroll",n),o&&e.removeEventListener("resize",n)}),null==u||u(),null==(e=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(d)}}const Co=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:s,middlewareData:a}=t,l=await async function(e,t){const{placement:n,platform:r,elements:i}=e,o=await(null==r.isRTL?void 0:r.isRTL(i.floating)),s=di(n),a=fi(n),l="y"===vi(n),c=Di.has(s)?-1:1,h=o&&l?-1:1,u=ui(t,e);let{mainAxis:d,crossAxis:f,alignmentAxis:p}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&"number"==typeof p&&(f="end"===a?-1*p:p),l?{x:f*h,y:d*c}:{x:d*c,y:f*h}}(t,e);return s===(null==(n=a.offset)?void 0:n.placement)&&null!=(r=a.arrow)&&r.alignmentOffset?{}:{x:i+l.x,y:o+l.y,data:{...l,placement:s}}}}},Oo=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:a={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=ui(e,t),c={x:n,y:r},h=await Ti(t,l),u=vi(di(i)),d=pi(u);let f=c[d],p=c[u];if(o){const e="y"===d?"bottom":"right";f=hi(f+h["y"===d?"top":"left"],f,f-h[e])}if(s){const e="y"===u?"bottom":"right";p=hi(p+h["y"===u?"top":"left"],p,p-h[e])}const m=a.fn({...t,[d]:f,[u]:p});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[d]:o,[u]:s}}}}}},No=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:o,rects:s,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:h=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=ui(e,t);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const v=di(i),b=vi(a),y=di(a)===a,w=await(null==l.isRTL?void 0:l.isRTL(c.floating)),x=d||(y||!m?[Ci(a)]:function(e){const t=Ci(e);return[yi(e),t,yi(t)]}(a)),k="none"!==p;!d&&k&&x.push(...Ei(a,m,p,w));const S=[a,...x],E=await Ti(t,g),C=[];let O=(null==(r=o.flip)?void 0:r.overflows)||[];if(h&&C.push(E[v]),u){const e=function(e,t,n){void 0===n&&(n=!1);const r=fi(e),i=bi(e),o=mi(i);let s="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=Ci(s)),[s,Ci(s)]}(i,s,w);C.push(E[e[0]],E[e[1]])}if(O=[...O,{placement:i,overflows:C}],!C.every(e=>e<=0)){var N,A;const e=((null==(N=o.flip)?void 0:N.index)||0)+1,t=S[e];if(t){if(!("alignment"===u&&b!==vi(t))||O.every(e=>vi(e.placement)!==b||e.overflows[0]>0))return{data:{index:e,overflows:O},reset:{placement:t}}}let n=null==(A=O.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:A.placement;if(!n)switch(f){case"bestFit":{var T;const e=null==(T=O.filter(e=>{if(k){const t=vi(e.placement);return t===b||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:T[0];e&&(n=e);break}case"initialPlacement":n=a}if(i!==n)return{reset:{placement:n}}}return{}}}},Ao=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:o,platform:s,elements:a}=t,{apply:l=()=>{},...c}=ui(e,t),h=await Ti(t,c),u=di(i),d=fi(i),f="y"===vi(i),{width:p,height:m}=o.floating;let g,v;"top"===u||"bottom"===u?(g=u,v=d===(await(null==s.isRTL?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(v=u,g="end"===d?"top":"bottom");const b=m-h.top-h.bottom,y=p-h.left-h.right,w=ri(m-h[g],b),x=ri(p-h[v],y),k=!t.middlewareData.shift;let S=w,E=x;if(null!=(n=t.middlewareData.shift)&&n.enabled.x&&(E=y),null!=(r=t.middlewareData.shift)&&r.enabled.y&&(S=b),k&&!d){const e=ii(h.left,0),t=ii(h.right,0),n=ii(h.top,0),r=ii(h.bottom,0);f?E=p-2*(0!==e||0!==t?e+t:ii(h.left,h.right)):S=m-2*(0!==n||0!==r?n+r:ii(h.top,h.bottom))}await l({...t,availableWidth:E,availableHeight:S});const C=await s.getDimensions(a.floating);return p!==C.width||m!==C.height?{reset:{rects:!0}}:{}}}},To=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...i}=ui(e,t);switch(r){case"referenceHidden":{const e=Mi(await Ti(t,{...i,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Ri(e)}}}case"escaped":{const e=Mi(await Ti(t,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Ri(e)}}}default:return{}}}}},Mo=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:o,platform:s,elements:a,middlewareData:l}=t,{element:c,padding:h=0}=ui(e,t)||{};if(null==c)return{};const u=Oi(h),d={x:n,y:r},f=bi(i),p=mi(f),m=await s.getDimensions(c),g="y"===f,v=g?"top":"left",b=g?"bottom":"right",y=g?"clientHeight":"clientWidth",w=o.reference[p]+o.reference[f]-d[f]-o.floating[p],x=d[f]-o.reference[f],k=await(null==s.getOffsetParent?void 0:s.getOffsetParent(c));let S=k?k[y]:0;S&&await(null==s.isElement?void 0:s.isElement(k))||(S=a.floating[y]||o.floating[p]);const E=w/2-x/2,C=S/2-m[p]/2-1,O=ri(u[v],C),N=ri(u[b],C),A=O,T=S-m[p]-N,M=S/2-m[p]/2+E,R=hi(A,M,T),D=!l.arrow&&null!=fi(i)&&M!==R&&o.reference[p]/2-(M<A?O:N)-m[p]/2<0,P=D?M<A?M-A:M-T:0;return{[f]:d[f]+P,data:{[f]:R,centerOffset:M-R-P,...D&&{alignmentOffset:P}},reset:D}}}),Ro=function(e){return void 0===e&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:o,middlewareData:s}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=ui(e,t),h={x:n,y:r},u=vi(i),d=pi(u);let f=h[d],p=h[u];const m=ui(a,t),g="number"==typeof m?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const e="y"===d?"height":"width",t=o.reference[d]-o.floating[e]+g.mainAxis,n=o.reference[d]+o.reference[e]-g.mainAxis;f<t?f=t:f>n&&(f=n)}if(c){var v,b;const e="y"===d?"width":"height",t=Di.has(di(i)),n=o.reference[u]-o.floating[e]+(t&&(null==(v=s.offset)?void 0:v[u])||0)+(t?0:g.crossAxis),r=o.reference[u]+o.reference[e]+(t?0:(null==(b=s.offset)?void 0:b[u])||0)-(t?g.crossAxis:0);p<n?p=n:p>r&&(p=r)}return{[d]:f,[u]:p}}}},Do=(e,t,n)=>{const r=new Map,i={platform:ko,...n},o={...i.platform,_c:r};return(async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:s}=n,a=o.filter(Boolean),l=await(null==s.isRTL?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:u}=Ai(c,r,l),d=r,f={},p=0;for(let n=0;n<a.length;n++){const{name:o,fn:m}=a[n],{x:g,y:v,data:b,reset:y}=await m({x:h,y:u,initialPlacement:r,placement:d,strategy:i,middlewareData:f,rects:c,platform:s,elements:{reference:e,floating:t}});h=null!=g?g:h,u=null!=v?v:u,f={...f,[o]:{...f[o],...b}},y&&p<=50&&(p++,"object"==typeof y&&(y.placement&&(d=y.placement),y.rects&&(c=!0===y.rects?await s.getElementRects({reference:e,floating:t,strategy:i}):y.rects),({x:h,y:u}=Ai(c,d,l))),n=-1)}return{x:h,y:u,placement:d,strategy:i,middlewareData:f}})(e,t,{...i,platform:o})};var Po="undefined"!=typeof document?e.useLayoutEffect:function(){};function Lo(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;0!==r--;)if(!Lo(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;0!==r--;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;0!==r--;){const n=i[r];if(("_owner"!==n||!e.$$typeof)&&!Lo(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function Bo(e){if("undefined"==typeof window)return 1;return(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Io(e,t){const n=Bo(e);return Math.round(t*n)/n}function jo(e){const t=s.useRef(e);return Po(()=>{t.current=e}),t}function _o(e){void 0===e&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:l}={},transform:c=!0,whileElementsMounted:h,open:u}=e,[d,f]=s.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=s.useState(r);Lo(p,r)||m(r);const[g,v]=s.useState(null),[b,y]=s.useState(null),w=s.useCallback(e=>{e!==E.current&&(E.current=e,v(e))},[]),x=s.useCallback(e=>{e!==C.current&&(C.current=e,y(e))},[]),k=o||g,S=l||b,E=s.useRef(null),C=s.useRef(null),O=s.useRef(d),N=null!=h,A=jo(h),T=jo(i),M=jo(u),R=s.useCallback(()=>{if(!E.current||!C.current)return;const e={placement:t,strategy:n,middleware:p};T.current&&(e.platform=T.current),Do(E.current,C.current,e).then(e=>{const t={...e,isPositioned:!1!==M.current};D.current&&!Lo(O.current,t)&&(O.current=t,a.flushSync(()=>{f(t)}))})},[p,t,n,T,M]);Po(()=>{!1===u&&O.current.isPositioned&&(O.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[u]);const D=s.useRef(!1);Po(()=>(D.current=!0,()=>{D.current=!1}),[]),Po(()=>{if(k&&(E.current=k),S&&(C.current=S),k&&S){if(A.current)return A.current(k,S,R);R()}},[k,S,R,A,N]);const P=s.useMemo(()=>({reference:E,floating:C,setReference:w,setFloating:x}),[w,x]),L=s.useMemo(()=>({reference:k,floating:S}),[k,S]),B=s.useMemo(()=>{const e={position:n,left:0,top:0};if(!L.floating)return e;const t=Io(L.floating,d.x),r=Io(L.floating,d.y);return c?{...e,transform:"translate("+t+"px, "+r+"px)",...Bo(L.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:t,top:r}},[n,c,L.floating,d.x,d.y]);return s.useMemo(()=>({...d,update:R,refs:P,elements:L,floatingStyles:B}),[d,R,P,L,B])}const Fo=e=>({name:"arrow",options:e,fn(t){const{element:n,padding:r}="function"==typeof e?e(t):e;return n&&(i=n,{}.hasOwnProperty.call(i,"current"))?null!=n.current?Mo({element:n.current,padding:r}).fn(t):{}:n?Mo({element:n,padding:r}).fn(t):{};var i}}),Wo=(e,t)=>({...Co(e),options:[e,t]}),zo=(e,t)=>({...Oo(e),options:[e,t]}),Ho=(e,t)=>({...Ro(e),options:[e,t]}),Vo=(e,t)=>({...No(e),options:[e,t]}),qo=(e,t)=>({...Ao(e),options:[e,t]}),Uo=(e,t)=>({...To(e),options:[e,t]}),$o=(e,t)=>({...Fo(e),options:[e,t]});var Ko=s.forwardRef((e,n)=>{const{children:r,width:i=10,height:o=5,...s}=e;return t.jsx(Kr.svg,{...s,ref:n,width:i,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ko.displayName="Arrow";var Yo=Ko;function Go(e){const[t,n]=s.useState(void 0);return bt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const t=new ResizeObserver(t=>{if(!Array.isArray(t))return;if(!t.length)return;const r=t[0];let i,o;if("borderBoxSize"in r){const e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,o=t.blockSize}else i=e.offsetWidth,o=e.offsetHeight;n({width:i,height:o})});return t.observe(e,{box:"border-box"}),()=>t.unobserve(e)}n(void 0)},[e]),t}var Xo="Popper",[Jo,Qo]=gt(Xo),[Zo,es]=Jo(Xo),ts=e=>{const{__scopePopper:n,children:r}=e,[i,o]=s.useState(null);return t.jsx(Zo,{scope:n,anchor:i,onAnchorChange:o,children:r})};ts.displayName=Xo;var ns="PopperAnchor",rs=s.forwardRef((e,n)=>{const{__scopePopper:r,virtualRef:i,...o}=e,a=es(ns,r),l=s.useRef(null),c=Ye(n,l),h=s.useRef(null);return s.useEffect(()=>{const e=h.current;h.current=i?.current||l.current,e!==h.current&&a.onAnchorChange(h.current)}),i?null:t.jsx(Kr.div,{...o,ref:c})});rs.displayName=ns;var is="PopperContent",[os,ss]=Jo(is),as=s.forwardRef((e,n)=>{const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:a="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:h=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...v}=e,b=es(is,r),[y,w]=s.useState(null),x=Ye(n,e=>w(e)),[k,S]=s.useState(null),E=Go(k),C=E?.width??0,O=E?.height??0,N=i+("center"!==a?"-"+a:""),A="number"==typeof d?d:{top:0,right:0,bottom:0,left:0,...d},T=Array.isArray(u)?u:[u],M=T.length>0,R={padding:A,boundary:T.filter(us),altBoundary:M},{refs:D,floatingStyles:P,placement:L,isPositioned:B,middlewareData:I}=_o({strategy:"fixed",placement:N,whileElementsMounted:(...e)=>Eo(...e,{animationFrame:"always"===m}),elements:{reference:b.anchor},middleware:[Wo({mainAxis:o+O,alignmentAxis:l}),h&&zo({mainAxis:!0,crossAxis:!1,limiter:"partial"===f?Ho():void 0,...R}),h&&Vo({...R}),qo({...R,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{const{width:i,height:o}=t.reference,s=e.floating.style;s.setProperty("--radix-popper-available-width",`${n}px`),s.setProperty("--radix-popper-available-height",`${r}px`),s.setProperty("--radix-popper-anchor-width",`${i}px`),s.setProperty("--radix-popper-anchor-height",`${o}px`)}}),k&&$o({element:k,padding:c}),ds({arrowWidth:C,arrowHeight:O}),p&&Uo({strategy:"referenceHidden",...R})]}),[j,_]=fs(L),F=Tt(g);bt(()=>{B&&F?.()},[B,F]);const W=I.arrow?.x,z=I.arrow?.y,H=0!==I.arrow?.centerOffset,[V,q]=s.useState();return bt(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),t.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...P,transform:B?P.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[I.transformOrigin?.x,I.transformOrigin?.y].join(" "),...I.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(os,{scope:r,placedSide:j,onArrowChange:S,arrowX:W,arrowY:z,shouldHideArrow:H,children:t.jsx(Kr.div,{"data-side":j,"data-align":_,...v,ref:x,style:{...v.style,animation:B?void 0:"none"}})})})});as.displayName=is;var ls="PopperArrow",cs={top:"bottom",right:"left",bottom:"top",left:"right"},hs=s.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,o=ss(ls,r),s=cs[o.placedSide];return t.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:t.jsx(Yo,{...i,ref:n,style:{...i.style,display:"block"}})})});function us(e){return null!==e}hs.displayName=ls;var ds=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:i}=t,o=0!==i.arrow?.centerOffset,s=o?0:e.arrowWidth,a=o?0:e.arrowHeight,[l,c]=fs(n),h={start:"0%",center:"50%",end:"100%"}[c],u=(i.arrow?.x??0)+s/2,d=(i.arrow?.y??0)+a/2;let f="",p="";return"bottom"===l?(f=o?h:`${u}px`,p=-a+"px"):"top"===l?(f=o?h:`${u}px`,p=`${r.floating.height+a}px`):"right"===l?(f=-a+"px",p=o?h:`${d}px`):"left"===l&&(f=`${r.floating.width+a}px`,p=o?h:`${d}px`),{data:{x:f,y:p}}}});function fs(e){const[t,n="center"]=e.split("-");return[t,n]}var ps=ts,ms=rs,gs=as,vs=hs;var bs=e=>{const{present:t,children:n}=e,r=function(e){const[t,n]=s.useState(),r=s.useRef(null),i=s.useRef(e),o=s.useRef("none"),a=e?"mounted":"unmounted",[l,c]=function(e,t){return s.useReducer((e,n)=>t[e][n]??e,e)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.useEffect(()=>{const e=ys(r.current);o.current="mounted"===l?e:"none"},[l]),bt(()=>{const t=r.current,n=i.current;if(n!==e){const r=o.current,s=ys(t);if(e)c("MOUNT");else if("none"===s||"none"===t?.display)c("UNMOUNT");else{c(n&&r!==s?"ANIMATION_OUT":"UNMOUNT")}i.current=e}},[e,c]),bt(()=>{if(t){let e;const n=t.ownerDocument.defaultView??window,s=o=>{const s=ys(r.current).includes(CSS.escape(o.animationName));if(o.target===t&&s&&(c("ANIMATION_END"),!i.current)){const r=t.style.animationFillMode;t.style.animationFillMode="forwards",e=n.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=r)})}},a=e=>{e.target===t&&(o.current=ys(r.current))};return t.addEventListener("animationstart",a),t.addEventListener("animationcancel",s),t.addEventListener("animationend",s),()=>{n.clearTimeout(e),t.removeEventListener("animationstart",a),t.removeEventListener("animationcancel",s),t.removeEventListener("animationend",s)}}c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:s.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}(t),i="function"==typeof n?n({present:r.isPresent}):s.Children.only(n),o=Ye(r.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof n||r.isPresent?s.cloneElement(i,{ref:o}):null};function ys(e){return e?.animationName||"none"}bs.displayName="Presence";var ws=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),xs=s.forwardRef((e,n)=>t.jsx(Kr.span,{...e,ref:n,style:{...ws,...e.style}}));xs.displayName="VisuallyHidden";var ks=xs,[Ss,Es]=gt("Tooltip",[Qo]),Cs=Qo(),Os="TooltipProvider",Ns=700,As="tooltip.open",[Ts,Ms]=Ss(Os),Rs=e=>{const{__scopeTooltip:n,delayDuration:r=Ns,skipDelayDuration:i=300,disableHoverableContent:o=!1,children:a}=e,l=s.useRef(!0),c=s.useRef(!1),h=s.useRef(0);return s.useEffect(()=>{const e=h.current;return()=>window.clearTimeout(e)},[]),t.jsx(Ts,{scope:n,isOpenDelayedRef:l,delayDuration:r,onOpen:s.useCallback(()=>{window.clearTimeout(h.current),l.current=!1},[]),onClose:s.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>l.current=!0,i)},[i]),isPointerInTransitRef:c,onPointerInTransitChange:s.useCallback(e=>{c.current=e},[]),disableHoverableContent:o,children:a})};Rs.displayName=Os;var Ds="Tooltip",[Ps,Ls]=Ss(Ds),Bs=e=>{const{__scopeTooltip:n,children:r,open:i,defaultOpen:o,onOpenChange:a,disableHoverableContent:l,delayDuration:c}=e,h=Ms(Ds,e.__scopeTooltip),u=Cs(n),[d,f]=s.useState(null),p=xt(),m=s.useRef(0),g=l??h.disableHoverableContent,v=c??h.delayDuration,b=s.useRef(!1),[y,w]=St({prop:i,defaultProp:o??!1,onChange:e=>{e?(h.onOpen(),document.dispatchEvent(new CustomEvent(As))):h.onClose(),a?.(e)},caller:Ds}),x=s.useMemo(()=>y?b.current?"delayed-open":"instant-open":"closed",[y]),k=s.useCallback(()=>{window.clearTimeout(m.current),m.current=0,b.current=!1,w(!0)},[w]),S=s.useCallback(()=>{window.clearTimeout(m.current),m.current=0,w(!1)},[w]),E=s.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{b.current=!0,w(!0),m.current=0},v)},[v,w]);return s.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),t.jsx(ps,{...u,children:t.jsx(Ps,{scope:n,contentId:p,open:y,stateAttribute:x,trigger:d,onTriggerChange:f,onTriggerEnter:s.useCallback(()=>{h.isOpenDelayedRef.current?E():k()},[h.isOpenDelayedRef,E,k]),onTriggerLeave:s.useCallback(()=>{g?S():(window.clearTimeout(m.current),m.current=0)},[S,g]),onOpen:k,onClose:S,disableHoverableContent:g,children:r})})};Bs.displayName=Ds;var Is="TooltipTrigger",js=s.forwardRef((e,n)=>{const{__scopeTooltip:r,...i}=e,o=Ls(Is,r),a=Ms(Is,r),l=Cs(r),c=Ye(n,s.useRef(null),o.onTriggerChange),h=s.useRef(!1),u=s.useRef(!1),d=s.useCallback(()=>h.current=!1,[]);return s.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),t.jsx(ms,{asChild:!0,...l,children:t.jsx(Kr.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...i,ref:c,onPointerMove:mt(e.onPointerMove,e=>{"touch"!==e.pointerType&&(u.current||a.isPointerInTransitRef.current||(o.onTriggerEnter(),u.current=!0))}),onPointerLeave:mt(e.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:mt(e.onPointerDown,()=>{o.open&&o.onClose(),h.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:mt(e.onFocus,()=>{h.current||o.onOpen()}),onBlur:mt(e.onBlur,o.onClose),onClick:mt(e.onClick,o.onClose)})})});js.displayName=Is;var[_s,Fs]=Ss("TooltipPortal",{forceMount:void 0}),Ws="TooltipContent",zs=s.forwardRef((e,n)=>{const r=Fs(Ws,e.__scopeTooltip),{forceMount:i=r.forceMount,side:o="top",...s}=e,a=Ls(Ws,e.__scopeTooltip);return t.jsx(bs,{present:i||a.open,children:a.disableHoverableContent?t.jsx($s,{side:o,...s,ref:n}):t.jsx(Hs,{side:o,...s,ref:n})})}),Hs=s.forwardRef((e,n)=>{const r=Ls(Ws,e.__scopeTooltip),i=Ms(Ws,e.__scopeTooltip),o=s.useRef(null),a=Ye(n,o),[l,c]=s.useState(null),{trigger:h,onClose:u}=r,d=o.current,{onPointerInTransitChange:f}=i,p=s.useCallback(()=>{c(null),f(!1)},[f]),m=s.useCallback((e,t)=>{const n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=function(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,i,o)){case o:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}(r,n.getBoundingClientRect()),o=function(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}(r,i),s=function(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}(t.getBoundingClientRect()),a=function(e){const t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),function(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const r=e[n];for(;t.length>=2;){const e=t[t.length-1],n=t[t.length-2];if(!((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x)))break;t.pop()}t.push(r)}t.pop();const n=[];for(let t=e.length-1;t>=0;t--){const r=e[t];for(;n.length>=2;){const e=n[n.length-1],t=n[n.length-2];if(!((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x)))break;n.pop()}n.push(r)}return n.pop(),1===t.length&&1===n.length&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}(t)}([...o,...s]);c(a),f(!0)},[f]);return s.useEffect(()=>()=>p(),[p]),s.useEffect(()=>{if(h&&d){const e=e=>m(e,d),t=e=>m(e,h);return h.addEventListener("pointerleave",e),d.addEventListener("pointerleave",t),()=>{h.removeEventListener("pointerleave",e),d.removeEventListener("pointerleave",t)}}},[h,d,m,p]),s.useEffect(()=>{if(l){const e=e=>{const t=e.target,n={x:e.clientX,y:e.clientY},r=h?.contains(t)||d?.contains(t),i=!function(e,t){const{x:n,y:r}=e;let i=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){const s=t[e],a=t[o],l=s.x,c=s.y,h=a.x,u=a.y;c>r!=u>r&&n<(h-l)*(r-c)/(u-c)+l&&(i=!i)}return i}(n,l);r?p():i&&(p(),u())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[h,d,l,u,p]),t.jsx($s,{...e,ref:a})}),[Vs,qs]=Ss(Ds,{isInside:!1}),Us=function(e){const n=({children:e})=>t.jsx(t.Fragment,{children:e});return n.displayName=`${e}.Slottable`,n.__radixId=Ur,n}("TooltipContent"),$s=s.forwardRef((e,n)=>{const{__scopeTooltip:r,children:i,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:l,...c}=e,h=Ls(Ws,r),u=Cs(r),{onClose:d}=h;return s.useEffect(()=>(document.addEventListener(As,d),()=>document.removeEventListener(As,d)),[d]),s.useEffect(()=>{if(h.trigger){const e=e=>{const t=e.target;t?.contains(h.trigger)&&d()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[h.trigger,d]),t.jsx(Zr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:t.jsxs(gs,{"data-state":h.stateAttribute,...u,...c,ref:n,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[t.jsx(Us,{children:i}),t.jsx(Vs,{scope:r,isInside:!0,children:t.jsx(ks,{id:h.contentId,role:"tooltip",children:o||i})})]})})});zs.displayName=Ws;var Ks="TooltipArrow";s.forwardRef((e,n)=>{const{__scopeTooltip:r,...i}=e,o=Cs(r);return qs(Ks,r).isInside?null:t.jsx(vs,{...o,...i,ref:n})}).displayName=Ks;var Ys=zs,Gs=Rs,Xs=Bs,Js=js,Qs=s.forwardRef(function(e,t){var n=e.className,r=e.sideOffset,i=void 0===r?4:r,o=G(e,["className","sideOffset"]);return s.createElement(Ys,Object.assign({ref:t,sideOffset:i,className:qe("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",n)},o))});Qs.displayName=Ys.displayName;var Zs=s.createContext(null);function ea(){var e=s.useContext(Zs);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}function ta(e){var t=e.defaultOpen,n=void 0===t||t,r=e.open,i=e.onOpenChange,o=e.className,a=e.style,l=e.children,c=G(e,["defaultOpen","open","onOpenChange","className","style","children"]),h=function(){var e=m(s.useState(void 0),2),t=e[0],n=e[1];return s.useEffect(function(){var e=window.matchMedia("(max-width: ".concat(767,"px)")),t=function(){n(window.innerWidth<768)};return e.addEventListener("change",t),n(window.innerWidth<768),function(){return e.removeEventListener("change",t)}},[]),!!t}(),u=m(s.useState(!1),2),d=u[0],f=u[1],p=m(s.useState(n),2),g=p[0],v=p[1],b=null!=r?r:g,y=s.useCallback(function(e){var t="function"==typeof e?e(b):e;i?i(t):v(t),document.cookie="".concat("sidebar_state","=").concat(t,"; path=/; max-age=").concat(604800)},[i,b]),w=s.useCallback(function(){return h?f(function(e){return!e}):y(function(e){return!e})},[h,y,f]);s.useEffect(function(){var e=function(e){"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),w())};return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}},[w]);var x=b?"expanded":"collapsed",k=s.useMemo(function(){return{state:x,open:b,setOpen:y,isMobile:h,openMobile:d,setOpenMobile:f,toggleSidebar:w}},[x,b,y,h,d,f,w]);return s.createElement(Zs.Provider,{value:k},s.createElement(Gs,{delayDuration:0},s.createElement("div",Object.assign({style:Object.assign({"--sidebar-width":"16rem","--sidebar-width-icon":"3rem"},a),className:qe("group/sidebar-wrapper flex min-h-svh w-full",o)},c),l)))}function na(e){var t=e.side,n=void 0===t?"left":t,r=e.variant,i=void 0===r?"sidebar":r,o=e.collapsible,a=void 0===o?"offcanvas":o,l=e.className,c=e.children,h=G(e,["side","variant","collapsible","className","children"]),u=ea(),d=u.isMobile,f=u.state,p=u.openMobile,m=u.setOpenMobile;return"none"===a?s.createElement("div",Object.assign({className:qe("bg-sidebar text-sidebar-foreground flex h-full w-[var(--sidebar-width)] flex-col",l)},h),c):d?s.createElement(Ir,Object.assign({open:p,onOpenChange:m},h),s.createElement(Wr,{className:"bg-sidebar text-sidebar-foreground w-[var(--sidebar-width)] p-0 [&>button]:hidden",style:{"--sidebar-width":"18rem"},side:n},s.createElement(zr,{className:"sr-only"},s.createElement(Hr,null,"Sidebar"),s.createElement(Vr,null,"Displays the mobile sidebar.")),s.createElement("div",{className:"flex h-full w-full flex-col"},c))):s.createElement("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":f,"data-collapsible":"collapsed"===f?a:"","data-variant":i,"data-side":n},s.createElement("div",{className:qe("relative w-[var(--sidebar-width)] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","floating"===i||"inset"===i?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+1rem)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]")}),s.createElement("div",Object.assign({className:qe("fixed inset-y-0 z-10 hidden h-svh w-[var(--sidebar-width)] transition-[left,right,width] duration-200 ease-linear md:flex","left"===n?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===i||"inset"===i?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+1rem+2px)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)] group-data-[side=left]:border-r group-data-[side=right]:border-l",l)},h),s.createElement("div",{className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm"},c)))}function ra(e){var t=e.className,n=e.onClick,r=G(e,["className","onClick"]),i=ea().toggleSidebar;return s.createElement(at,Object.assign({variant:"ghost",size:"icon",className:qe("h-7 w-7",t),onClick:function(e){null==n||n(e),i()}},r),s.createElement(_,null),s.createElement("span",{className:"sr-only"},"Toggle Sidebar"))}function ia(e){var t=e.className,n=G(e,["className"]);return s.createElement("main",Object.assign({className:qe("bg-background relative flex w-full flex-1 flex-col","md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",t)},n))}function oa(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("flex flex-col gap-2 p-2",t)},n))}function sa(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("flex flex-col gap-2 p-2",t)},n))}function aa(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t)},n))}function la(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("relative flex w-full min-w-0 flex-col p-2",t)},n))}function ca(e){var t=e.className,n=e.asChild,r=void 0!==n&&n,i=G(e,["className","asChild"]),o=r?Ze:"div";return s.createElement(o,Object.assign({className:qe("text-sidebar-foreground/70 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium transition-[margin,opacity] duration-200 ease-linear [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",t)},i))}function ha(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("w-full text-sm",t)},n))}function ua(e){var t=e.className,n=G(e,["className"]);return s.createElement("ul",Object.assign({className:qe("flex w-full min-w-0 flex-col gap-1",t)},n))}function da(e){var t=e.className,n=G(e,["className"]);return s.createElement("li",Object.assign({className:qe("group/menu-item relative",t)},n))}var fa=ot("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function pa(e){var t=e.asChild,n=void 0!==t&&t,r=e.isActive,i=void 0!==r&&r,o=e.variant,a=void 0===o?"default":o,l=e.size,c=void 0===l?"default":l,h=e.tooltip,u=e.className,d=G(e,["asChild","isActive","variant","size","tooltip","className"]),f=n?Ze:"button",p=ea(),m=p.isMobile,g=p.state,v=s.createElement(f,Object.assign({"data-size":c,"data-active":i,className:qe(fa({variant:a,size:c}),u)},d));return h?("string"==typeof h&&(h={children:h}),s.createElement(Xs,null,s.createElement(Js,{asChild:!0},v),s.createElement(Qs,Object.assign({side:"right",align:"center",hidden:"collapsed"!==g||m},h)))):v}var ma=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=Qe(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),ga=s.forwardRef((e,n)=>t.jsx(ma.label,{...e,ref:n,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));ga.displayName="Label";var va=ga,ba=ot("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ya=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(va,Object.assign({ref:t,className:qe(ba(),n)},r))});ya.displayName=va.displayName;var wa=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:qe("rounded-lg border bg-card text-card-foreground shadow-sm",n)},r))});wa.displayName="Card";var xa=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:qe("flex flex-col space-y-1.5 p-6",n)},r))});xa.displayName="CardHeader";var ka=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:qe("text-2xl font-semibold leading-none tracking-tight",n)},r))});ka.displayName="CardTitle";var Sa=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:qe("text-sm text-muted-foreground",n)},r))});Sa.displayName="CardDescription";var Ea=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:qe("p-6 pt-0",n)},r))});Ea.displayName="CardContent";var Ca=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:qe("flex items-center p-6 pt-0",n)},r))});Ca.displayName="CardFooter";var Oa={items:[],config:Object.assign({},{top:24,duration:3,maxCount:5})},Na=new Set;function Aa(){Na.forEach(function(e){return e(Oa.items.slice())})}function Ta(t){switch(t){case"success":return e.createElement(k,null);case"error":return e.createElement($,null);case"warning":return e.createElement(x,null);case"loading":return e.createElement(L,{className:"animate-spin"});default:return e.createElement(P,null)}}function Ma(e){var t,n,r;La();var i=Date.now(),o=null!==(t=e.key)&&void 0!==t?t:"msg_".concat(i,"_").concat(Math.random().toString(36).slice(2)),s=Oa.items.findIndex(function(e){return e.key===o}),a={key:o,content:e.content,duration:null!==(n=e.duration)&&void 0!==n?n:Oa.config.duration,type:e.type,onClose:e.onClose,icon:null!==(r=e.icon)&&void 0!==r?r:Ta(e.type),className:e.className,createdAt:i};return s>=0?Oa.items[s]=Object.assign({},Oa.items[s],a):(Oa.items.length>=Oa.config.maxCount&&Oa.items.shift(),Oa.items.push(a)),Aa(),a.duration>0&&"loading"!==a.type&&window.setTimeout(function(){Ra(o)},1e3*a.duration),{close:function(){return Ra(o)}}}function Ra(e){var t;if(void 0===e)return Oa.items.forEach(function(e){var t;return null===(t=e.onClose)||void 0===t?void 0:t.call(e)}),Oa.items=[],void Aa();var n=Oa.items.findIndex(function(t){return t.key===e});if(n>=0){var r=m(Oa.items.splice(n,1),1)[0];null===(t=null==r?void 0:r.onClose)||void 0===t||t.call(r),Aa()}}var Da=null,Pa=null;function La(){"undefined"!=typeof window&&(Pa||((Pa=document.createElement("div")).setAttribute("data-custom-message-holder",""),document.body.appendChild(Pa)),Da||(Da=r.createRoot(Pa)).render(e.createElement(Ba,null)))}function Ba(){var t=function(){var t=m(e.useState(Oa.items),2),n=t[0],r=t[1];return e.useEffect(function(){var e=r;return Na.add(e),function(){Na.delete(e)}},[]),n}(),n=Oa.config.top;return e.createElement("div",{className:"fixed left-1/2 -translate-x-1/2 z-[1000] w-80 pointer-events-none",style:{top:n}},e.createElement("div",{className:"mx-auto flex w-full max-w-xl flex-col items-center gap-2 px-4"},t.map(function(t){var n,r,i=function(e){switch(e){case"success":return{container:"border-green-200 bg-green-50/90 text-green-800 border-l-4 border-l-green-500",icon:"text-green-500",text:"text-green-800"};case"error":return{container:"border-red-200 bg-red-50/90 text-red-800 border-l-4 border-l-red-500",icon:"text-red-500",text:"text-red-800"};case"warning":return{container:"border-yellow-200 bg-yellow-50/90 text-yellow-800 border-l-4 border-l-yellow-500",icon:"text-yellow-500",text:"text-yellow-800"};default:return{container:"border-blue-200 bg-blue-50/90 text-blue-800 border-l-4 border-l-blue-500",icon:"text-blue-500",text:"text-blue-800"}}}(t.type);return e.createElement("div",{key:t.key,className:"pointer-events-auto flex w-full items-center gap-2 rounded-md border px-3 py-2 backdrop-blur ".concat(i.container," ").concat(null!==(n=t.className)&&void 0!==n?n:"")},e.createElement("span",{className:"text-[18px] leading-none ".concat(i.icon)},null!==(r=t.icon)&&void 0!==r?r:Ta(t.type)),e.createElement("div",{className:"min-w-0 flex-1 text-[14px] leading-normal ".concat(i.text)},"string"==typeof t.content?e.createElement("span",{className:"break-words align-middle"},t.content):t.content))})))}function Ia(t,n,r,i){if(e.isValidElement(n)||"string"==typeof n||"number"==typeof n)return{type:t,content:n,duration:r,onClose:i};var o=n;return Object.assign({},o,{type:t})}var ja,_a,Fa=(_a={open:function(e){var t;return Ma(Object.assign({},e,{type:null!==(t=e.type)&&void 0!==t?t:"info"}))},info:function(e,t,n){return Ma(Ia("info",e,t,n))},success:function(e,t,n){return Ma(Ia("success",e,t,n))},error:function(e,t,n){return Ma(Ia("error",e,t,n))},warning:function(e,t,n){return Ma(Ia("warning",e,t,n))},loading:function(e,t,n){return Ma(Ia("loading",e,null!=t?t:0,n))},destroy:function(e){return Ra(e)},config:function(e){return t=e,Oa.config=Object.assign({},Oa.config,t),void Aa();var t},useMessage:function(){var t=e.useMemo(function(){return"undefined"!=typeof window&&La(),e.createElement(e.Fragment,null)},[]);return[ja.current,t]}},(ja={}).current=_a,_a);function Wa(e,t){return function(){return e.apply(t,arguments)}}const{toString:za}=Object.prototype,{getPrototypeOf:Ha}=Object,{iterator:Va,toStringTag:qa}=Symbol,Ua=($a=Object.create(null),e=>{const t=za.call(e);return $a[t]||($a[t]=t.slice(8,-1).toLowerCase())});var $a;const Ka=e=>(e=e.toLowerCase(),t=>Ua(t)===e),Ya=e=>t=>typeof t===e,{isArray:Ga}=Array,Xa=Ya("undefined");function Ja(e){return null!==e&&!Xa(e)&&null!==e.constructor&&!Xa(e.constructor)&&el(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Qa=Ka("ArrayBuffer");const Za=Ya("string"),el=Ya("function"),tl=Ya("number"),nl=e=>null!==e&&"object"==typeof e,rl=e=>{if("object"!==Ua(e))return!1;const t=Ha(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||qa in e||Va in e)},il=Ka("Date"),ol=Ka("File"),sl=Ka("Blob"),al=Ka("FileList"),ll=Ka("URLSearchParams"),[cl,hl,ul,dl]=["ReadableStream","Request","Response","Headers"].map(Ka);function fl(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,i;if("object"!=typeof e&&(e=[e]),Ga(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(Ja(e))return;const i=n?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let s;for(r=0;r<o;r++)s=i[r],t.call(null,e[s],s,e)}}function pl(e,t){if(Ja(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r,i=n.length;for(;i-- >0;)if(r=n[i],t===r.toLowerCase())return r;return null}const ml="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,gl=e=>!Xa(e)&&e!==ml;const vl=(bl="undefined"!=typeof Uint8Array&&Ha(Uint8Array),e=>bl&&e instanceof bl);var bl;const yl=Ka("HTMLFormElement"),wl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),xl=Ka("RegExp"),kl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};fl(n,(n,i)=>{let o;!1!==(o=t(n,i,e))&&(r[i]=o||n)}),Object.defineProperties(e,r)};const Sl=Ka("AsyncFunction"),El=(Cl="function"==typeof setImmediate,Ol=el(ml.postMessage),Cl?setImmediate:Ol?(Nl=`axios@${Math.random()}`,Al=[],ml.addEventListener("message",({source:e,data:t})=>{e===ml&&t===Nl&&Al.length&&Al.shift()()},!1),e=>{Al.push(e),ml.postMessage(Nl,"*")}):e=>setTimeout(e));var Cl,Ol,Nl,Al;const Tl="undefined"!=typeof queueMicrotask?queueMicrotask.bind(ml):"undefined"!=typeof process&&process.nextTick||El;var Ml={isArray:Ga,isArrayBuffer:Qa,isBuffer:Ja,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||el(e.append)&&("formdata"===(t=Ua(e))||"object"===t&&el(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Qa(e.buffer),t},isString:Za,isNumber:tl,isBoolean:e=>!0===e||!1===e,isObject:nl,isPlainObject:rl,isEmptyObject:e=>{if(!nl(e)||Ja(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:cl,isRequest:hl,isResponse:ul,isHeaders:dl,isUndefined:Xa,isDate:il,isFile:ol,isBlob:sl,isRegExp:xl,isFunction:el,isStream:e=>nl(e)&&el(e.pipe),isURLSearchParams:ll,isTypedArray:vl,isFileList:al,forEach:fl,merge:function e(){const{caseless:t,skipUndefined:n}=gl(this)&&this||{},r={},i=(i,o)=>{const s=t&&pl(r,o)||o;rl(r[s])&&rl(i)?r[s]=e(r[s],i):rl(i)?r[s]=e({},i):Ga(i)?r[s]=i.slice():n&&Xa(i)||(r[s]=i)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&fl(arguments[e],i);return r},extend:(e,t,n,{allOwnKeys:r}={})=>(fl(t,(t,r)=>{n&&el(t)?e[r]=Wa(t,n):e[r]=t},{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let i,o,s;const a={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],r&&!r(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0);e=!1!==n&&Ha(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:Ua,kindOfTest:Ka,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(Ga(e))return e;let t=e.length;if(!tl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Va]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:yl,hasOwnProperty:wl,hasOwnProp:wl,reduceDescriptors:kl,freezeMethods:e=>{kl(e,(t,n)=>{if(el(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];el(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach(e=>{n[e]=!0})};return Ga(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:pl,global:ml,isContextDefined:gl,isSpecCompliantForm:function(e){return!!(e&&el(e.append)&&"FormData"===e[qa]&&e[Va])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(nl(e)){if(t.indexOf(e)>=0)return;if(Ja(e))return e;if(!("toJSON"in e)){t[r]=e;const i=Ga(e)?[]:{};return fl(e,(e,t)=>{const o=n(e,r+1);!Xa(o)&&(i[t]=o)}),t[r]=void 0,i}}return e};return n(e,0)},isAsyncFn:Sl,isThenable:e=>e&&(nl(e)||el(e))&&el(e.then)&&el(e.catch),setImmediate:El,asap:Tl,isIterable:e=>null!=e&&el(e[Va])};function Rl(e,t,n,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status?i.status:null)}Ml.inherits(Rl,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ml.toJSONObject(this.config),code:this.code,status:this.status}}});const Dl=Rl.prototype,Pl={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Pl[e]={value:e}}),Object.defineProperties(Rl,Pl),Object.defineProperty(Dl,"isAxiosError",{value:!0}),Rl.from=(e,t,n,r,i,o)=>{const s=Object.create(Dl);Ml.toFlatObject(e,s,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const a=e&&e.message?e.message:"Error",l=null==t&&e?e.code:t;return Rl.call(s,a,l,n,r,i),e&&null==s.cause&&Object.defineProperty(s,"cause",{value:e,configurable:!0}),s.name=e&&e.name||"Error",o&&Object.assign(s,o),s};function Ll(e){return Ml.isPlainObject(e)||Ml.isArray(e)}function Bl(e){return Ml.endsWith(e,"[]")?e.slice(0,-2):e}function Il(e,t,n){return e?e.concat(t).map(function(e,t){return e=Bl(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const jl=Ml.toFlatObject(Ml,{},null,function(e){return/^is[A-Z]/.test(e)});function _l(e,t,n){if(!Ml.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=Ml.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Ml.isUndefined(t[e])})).metaTokens,i=n.visitor||c,o=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Ml.isSpecCompliantForm(t);if(!Ml.isFunction(i))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Ml.isDate(e))return e.toISOString();if(Ml.isBoolean(e))return e.toString();if(!a&&Ml.isBlob(e))throw new Rl("Blob is not supported. Use a Buffer instead.");return Ml.isArrayBuffer(e)||Ml.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,n,i){let a=e;if(e&&!i&&"object"==typeof e)if(Ml.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Ml.isArray(e)&&function(e){return Ml.isArray(e)&&!e.some(Ll)}(e)||(Ml.isFileList(e)||Ml.endsWith(n,"[]"))&&(a=Ml.toArray(e)))return n=Bl(n),a.forEach(function(e,r){!Ml.isUndefined(e)&&null!==e&&t.append(!0===s?Il([n],r,o):null===s?n:n+"[]",l(e))}),!1;return!!Ll(e)||(t.append(Il(i,n,o),l(e)),!1)}const h=[],u=Object.assign(jl,{defaultVisitor:c,convertValue:l,isVisitable:Ll});if(!Ml.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Ml.isUndefined(n)){if(-1!==h.indexOf(n))throw Error("Circular reference detected in "+r.join("."));h.push(n),Ml.forEach(n,function(n,o){!0===(!(Ml.isUndefined(n)||null===n)&&i.call(t,n,Ml.isString(o)?o.trim():o,r,u))&&e(n,r?r.concat(o):[o])}),h.pop()}}(e),t}function Fl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Wl(e,t){this._pairs=[],e&&_l(e,this,t)}const zl=Wl.prototype;function Hl(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Vl(e,t,n){if(!t)return e;const r=n&&n.encode||Hl;Ml.isFunction(n)&&(n={serialize:n});const i=n&&n.serialize;let o;if(o=i?i(t,n):Ml.isURLSearchParams(t)?t.toString():new Wl(t,n).toString(r),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}zl.append=function(e,t){this._pairs.push([e,t])},zl.toString=function(e){const t=e?function(t){return e.call(this,t,Fl)}:Fl;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var ql=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Ml.forEach(this.handlers,function(t){null!==t&&e(t)})}},Ul={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},$l={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Wl,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const Kl="undefined"!=typeof window&&"undefined"!=typeof document,Yl="object"==typeof navigator&&navigator||void 0,Gl=Kl&&(!Yl||["ReactNative","NativeScript","NS"].indexOf(Yl.product)<0),Xl="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Jl=Kl&&window.location.href||"http://localhost";var Ql={...Object.freeze({__proto__:null,hasBrowserEnv:Kl,hasStandardBrowserEnv:Gl,hasStandardBrowserWebWorkerEnv:Xl,navigator:Yl,origin:Jl}),...$l};function Zl(e){function t(e,n,r,i){let o=e[i++];if("__proto__"===o)return!0;const s=Number.isFinite(+o),a=i>=e.length;if(o=!o&&Ml.isArray(r)?r.length:o,a)return Ml.hasOwnProp(r,o)?r[o]=[r[o],n]:r[o]=n,!s;r[o]&&Ml.isObject(r[o])||(r[o]=[]);return t(e,n,r[o],i)&&Ml.isArray(r[o])&&(r[o]=function(e){const t={},n=Object.keys(e);let r;const i=n.length;let o;for(r=0;r<i;r++)o=n[r],t[o]=e[o];return t}(r[o])),!s}if(Ml.isFormData(e)&&Ml.isFunction(e.entries)){const n={};return Ml.forEachEntry(e,(e,r)=>{t(function(e){return Ml.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null}const ec={transitional:Ul,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,i=Ml.isObject(e);i&&Ml.isHTMLForm(e)&&(e=new FormData(e));if(Ml.isFormData(e))return r?JSON.stringify(Zl(e)):e;if(Ml.isArrayBuffer(e)||Ml.isBuffer(e)||Ml.isStream(e)||Ml.isFile(e)||Ml.isBlob(e)||Ml.isReadableStream(e))return e;if(Ml.isArrayBufferView(e))return e.buffer;if(Ml.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return _l(e,new Ql.classes.URLSearchParams,{visitor:function(e,t,n,r){return Ql.isNode&&Ml.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((o=Ml.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return _l(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),function(e,t,n){if(Ml.isString(e))try{return(t||JSON.parse)(e),Ml.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||ec.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Ml.isResponse(e)||Ml.isReadableStream(e))return e;if(e&&Ml.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n){if("SyntaxError"===e.name)throw Rl.from(e,Rl.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ql.classes.FormData,Blob:Ql.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ml.forEach(["delete","get","head","post","put","patch"],e=>{ec.headers[e]={}});var tc=ec;const nc=Ml.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const rc=Symbol("internals");function ic(e){return e&&String(e).trim().toLowerCase()}function oc(e){return!1===e||null==e?e:Ml.isArray(e)?e.map(oc):String(e)}function sc(e,t,n,r,i){return Ml.isFunction(r)?r.call(this,t,n):(i&&(t=n),Ml.isString(t)?Ml.isString(r)?-1!==t.indexOf(r):Ml.isRegExp(r)?r.test(t):void 0:void 0)}class ac{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function i(e,t,n){const i=ic(t);if(!i)throw new Error("header name must be a non-empty string");const o=Ml.findKey(r,i);(!o||void 0===r[o]||!0===n||void 0===n&&!1!==r[o])&&(r[o||t]=oc(e))}const o=(e,t)=>Ml.forEach(e,(e,n)=>i(e,n,t));if(Ml.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(Ml.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let n,r,i;return e&&e.split("\n").forEach(function(e){i=e.indexOf(":"),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!n||t[n]&&nc[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t})(e),t);else if(Ml.isObject(e)&&Ml.isIterable(e)){let n,r,i={};for(const t of e){if(!Ml.isArray(t))throw TypeError("Object iterator must return a key-value pair");i[r=t[0]]=(n=i[r])?Ml.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}o(i,t)}else null!=e&&i(t,e,n);return this}get(e,t){if(e=ic(e)){const n=Ml.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(Ml.isFunction(t))return t.call(this,e,n);if(Ml.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ic(e)){const n=Ml.findKey(this,e);return!(!n||void 0===this[n]||t&&!sc(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function i(e){if(e=ic(e)){const i=Ml.findKey(n,e);!i||t&&!sc(0,n[i],i,t)||(delete n[i],r=!0)}}return Ml.isArray(e)?e.forEach(i):i(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const i=t[n];e&&!sc(0,this[i],i,e,!0)||(delete this[i],r=!0)}return r}normalize(e){const t=this,n={};return Ml.forEach(this,(r,i)=>{const o=Ml.findKey(n,i);if(o)return t[o]=oc(r),void delete t[i];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(i):String(i).trim();s!==i&&delete t[i],t[s]=oc(r),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Ml.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&Ml.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[rc]=this[rc]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=ic(e);t[r]||(!function(e,t){const n=Ml.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}(n,e),t[r]=!0)}return Ml.isArray(e)?e.forEach(r):r(e),this}}ac.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Ml.reduceDescriptors(ac.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),Ml.freezeMethods(ac);var lc=ac;function cc(e,t){const n=this||tc,r=t||n,i=lc.from(r.headers);let o=r.data;return Ml.forEach(e,function(e){o=e.call(n,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function hc(e){return!(!e||!e.__CANCEL__)}function uc(e,t,n){Rl.call(this,null==e?"canceled":e,Rl.ERR_CANCELED,t,n),this.name="CanceledError"}function dc(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new Rl("Request failed with status code "+n.status,[Rl.ERR_BAD_REQUEST,Rl.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}Ml.inherits(uc,Rl,{__CANCEL__:!0});const fc=(e,t,n=3)=>{let r=0;const i=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let i,o=0,s=0;return t=void 0!==t?t:1e3,function(a){const l=Date.now(),c=r[s];i||(i=l),n[o]=a,r[o]=l;let h=s,u=0;for(;h!==o;)u+=n[h++],h%=e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),l-i<t)return;const d=c&&l-c;return d?Math.round(1e3*u/d):void 0}}(50,250);return function(e,t){let n,r,i=0,o=1e3/t;const s=(t,o=Date.now())=>{i=o,n=null,r&&(clearTimeout(r),r=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-i;a>=o?s(e,t):(n=e,r||(r=setTimeout(()=>{r=null,s(n)},o-a)))},()=>n&&s(n)]}(n=>{const o=n.loaded,s=n.lengthComputable?n.total:void 0,a=o-r,l=i(a);r=o;e({loaded:o,total:s,progress:s?o/s:void 0,bytes:a,rate:l||void 0,estimated:l&&s&&o<=s?(s-o)/l:void 0,event:n,lengthComputable:null!=s,[t?"download":"upload"]:!0})},n)},pc=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},mc=e=>(...t)=>Ml.asap(()=>e(...t));var gc=Ql.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Ql.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Ql.origin),Ql.navigator&&/(msie|trident)/i.test(Ql.navigator.userAgent)):()=>!0,vc=Ql.hasStandardBrowserEnv?{write(e,t,n,r,i,o,s){if("undefined"==typeof document)return;const a=[`${e}=${encodeURIComponent(t)}`];Ml.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),Ml.isString(r)&&a.push(`path=${r}`),Ml.isString(i)&&a.push(`domain=${i}`),!0===o&&a.push("secure"),Ml.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function bc(e,t,n){let r=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(r||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const yc=e=>e instanceof lc?{...e}:e;function wc(e,t){t=t||{};const n={};function r(e,t,n,r){return Ml.isPlainObject(e)&&Ml.isPlainObject(t)?Ml.merge.call({caseless:r},e,t):Ml.isPlainObject(t)?Ml.merge({},t):Ml.isArray(t)?t.slice():t}function i(e,t,n,i){return Ml.isUndefined(t)?Ml.isUndefined(e)?void 0:r(void 0,e,0,i):r(e,t,0,i)}function o(e,t){if(!Ml.isUndefined(t))return r(void 0,t)}function s(e,t){return Ml.isUndefined(t)?Ml.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,i,o){return o in t?r(n,i):o in e?r(void 0,n):void 0}const l={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,n)=>i(yc(e),yc(t),0,!0)};return Ml.forEach(Object.keys({...e,...t}),function(r){const o=l[r]||i,s=o(e[r],t[r],r);Ml.isUndefined(s)&&o!==a||(n[r]=s)}),n}var xc=e=>{const t=wc({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;if(t.headers=s=lc.from(s),t.url=Vl(bc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Ml.isFormData(n))if(Ql.hasStandardBrowserEnv||Ql.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(Ml.isFunction(n.getHeaders)){const e=n.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&s.set(e,n)})}if(Ql.hasStandardBrowserEnv&&(r&&Ml.isFunction(r)&&(r=r(t)),r||!1!==r&&gc(t.url))){const e=i&&o&&vc.read(o);e&&s.set(i,e)}return t};var kc="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=xc(e);let i=r.data;const o=lc.from(r.headers).normalize();let s,a,l,c,h,{responseType:u,onUploadProgress:d,onDownloadProgress:f}=r;function p(){c&&c(),h&&h(),r.cancelToken&&r.cancelToken.unsubscribe(s),r.signal&&r.signal.removeEventListener("abort",s)}let m=new XMLHttpRequest;function g(){if(!m)return;const r=lc.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());dc(function(e){t(e),p()},function(e){n(e),p()},{data:u&&"text"!==u&&"json"!==u?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new Rl("Request aborted",Rl.ECONNABORTED,e,m)),m=null)},m.onerror=function(t){const r=new Rl(t&&t.message?t.message:"Network Error",Rl.ERR_NETWORK,e,m);r.event=t||null,n(r),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const i=r.transitional||Ul;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new Rl(t,i.clarifyTimeoutError?Rl.ETIMEDOUT:Rl.ECONNABORTED,e,m)),m=null},void 0===i&&o.setContentType(null),"setRequestHeader"in m&&Ml.forEach(o.toJSON(),function(e,t){m.setRequestHeader(t,e)}),Ml.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),u&&"json"!==u&&(m.responseType=r.responseType),f&&([l,h]=fc(f,!0),m.addEventListener("progress",l)),d&&m.upload&&([a,c]=fc(d),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",c)),(r.cancelToken||r.signal)&&(s=t=>{m&&(n(!t||t.type?new uc(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(s),r.signal&&(r.signal.aborted?s():r.signal.addEventListener("abort",s)));const v=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);v&&-1===Ql.protocols.indexOf(v)?n(new Rl("Unsupported protocol "+v+":",Rl.ERR_BAD_REQUEST,e)):m.send(i||null)})};var Sc=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const i=function(e){if(!n){n=!0,s();const t=e instanceof Error?e:this.reason;r.abort(t instanceof Rl?t:new uc(t instanceof Error?t.message:t))}};let o=t&&setTimeout(()=>{o=null,i(new Rl(`timeout ${t} of ms exceeded`,Rl.ETIMEDOUT))},t);const s=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)}),e=null)};e.forEach(e=>e.addEventListener("abort",i));const{signal:a}=r;return a.unsubscribe=()=>Ml.asap(s),a}};const Ec=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,i=0;for(;i<n;)r=i+t,yield e.slice(i,r),i=r},Cc=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},Oc=(e,t,n,r)=>{const i=async function*(e,t){for await(const n of Cc(e))yield*Ec(n,t)}(e,t);let o,s=0,a=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await i.next();if(t)return a(),void e.close();let o=r.byteLength;if(n){let e=s+=o;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),i.return())},{highWaterMark:2})},{isFunction:Nc}=Ml,Ac=(({Request:e,Response:t})=>({Request:e,Response:t}))(Ml.global),{ReadableStream:Tc,TextEncoder:Mc}=Ml.global,Rc=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Dc=e=>{e=Ml.merge.call({skipUndefined:!0},Ac,e);const{fetch:t,Request:n,Response:r}=e,i=t?Nc(t):"function"==typeof fetch,o=Nc(n),s=Nc(r);if(!i)return!1;const a=i&&Nc(Tc),l=i&&("function"==typeof Mc?(c=new Mc,e=>c.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer()));var c;const h=o&&a&&Rc(()=>{let e=!1;const t=new n(Ql.origin,{body:new Tc,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),u=s&&a&&Rc(()=>Ml.isReadableStream(new r("").body)),d={stream:u&&(e=>e.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!d[e]&&(d[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new Rl(`Response type '${e}' is not supported`,Rl.ERR_NOT_SUPPORT,n)})});const f=async(e,t)=>{const r=Ml.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Ml.isBlob(e))return e.size;if(Ml.isSpecCompliantForm(e)){const t=new n(Ql.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Ml.isArrayBufferView(e)||Ml.isArrayBuffer(e)?e.byteLength:(Ml.isURLSearchParams(e)&&(e+=""),Ml.isString(e)?(await l(e)).byteLength:void 0)})(t):r};return async e=>{let{url:i,method:s,data:a,signal:l,cancelToken:c,timeout:p,onDownloadProgress:m,onUploadProgress:g,responseType:v,headers:b,withCredentials:y="same-origin",fetchOptions:w}=xc(e),x=t||fetch;v=v?(v+"").toLowerCase():"text";let k=Sc([l,c&&c.toAbortSignal()],p),S=null;const E=k&&k.unsubscribe&&(()=>{k.unsubscribe()});let C;try{if(g&&h&&"get"!==s&&"head"!==s&&0!==(C=await f(b,a))){let e,t=new n(i,{method:"POST",body:a,duplex:"half"});if(Ml.isFormData(a)&&(e=t.headers.get("content-type"))&&b.setContentType(e),t.body){const[e,n]=pc(C,fc(mc(g)));a=Oc(t.body,65536,e,n)}}Ml.isString(y)||(y=y?"include":"omit");const t=o&&"credentials"in n.prototype,l={...w,signal:k,method:s.toUpperCase(),headers:b.normalize().toJSON(),body:a,duplex:"half",credentials:t?y:void 0};S=o&&new n(i,l);let c=await(o?x(S,w):x(i,l));const p=u&&("stream"===v||"response"===v);if(u&&(m||p&&E)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=c[t]});const t=Ml.toFiniteNumber(c.headers.get("content-length")),[n,i]=m&&pc(t,fc(mc(m),!0))||[];c=new r(Oc(c.body,65536,n,()=>{i&&i(),E&&E()}),e)}v=v||"text";let O=await d[Ml.findKey(d,v)||"text"](c,e);return!p&&E&&E(),await new Promise((t,n)=>{dc(t,n,{data:O,headers:lc.from(c.headers),status:c.status,statusText:c.statusText,config:e,request:S})})}catch(t){if(E&&E(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new Rl("Network Error",Rl.ERR_NETWORK,e,S),{cause:t.cause||t});throw Rl.from(t,t&&t.code,e,S)}}},Pc=new Map,Lc=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:i}=t,o=[r,i,n];let s,a,l=o.length,c=Pc;for(;l--;)s=o[l],a=c.get(s),void 0===a&&c.set(s,a=l?new Map:Dc(t)),c=a;return a};Lc();const Bc={http:null,xhr:kc,fetch:{get:Lc}};Ml.forEach(Bc,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const Ic=e=>`- ${e}`,jc=e=>Ml.isFunction(e)||null===e||!1===e;var _c={getAdapter:function(e,t){e=Ml.isArray(e)?e:[e];const{length:n}=e;let r,i;const o={};for(let s=0;s<n;s++){let n;if(r=e[s],i=r,!jc(r)&&(i=Bc[(n=String(r)).toLowerCase()],void 0===i))throw new Rl(`Unknown adapter '${n}'`);if(i&&(Ml.isFunction(i)||(i=i.get(t))))break;o[n||"#"+s]=i}if(!i){const e=Object.entries(o).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new Rl("There is no suitable adapter to dispatch the request "+(n?e.length>1?"since :\n"+e.map(Ic).join("\n"):" "+Ic(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return i},adapters:Bc};function Fc(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new uc(null,e)}function Wc(e){Fc(e),e.headers=lc.from(e.headers),e.data=cc.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return _c.getAdapter(e.adapter||tc.adapter,e)(e).then(function(t){return Fc(e),t.data=cc.call(e,e.transformResponse,t),t.headers=lc.from(t.headers),t},function(t){return hc(t)||(Fc(e),t&&t.response&&(t.response.data=cc.call(e,e.transformResponse,t.response),t.response.headers=lc.from(t.response.headers))),Promise.reject(t)})}const zc="1.13.2",Hc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Hc[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const Vc={};Hc.transitional=function(e,t,n){return(r,i,o)=>{if(!1===e)throw new Rl(function(e,t){return"[Axios v"+zc+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}(i," has been removed"+(t?" in "+t:"")),Rl.ERR_DEPRECATED);return t&&!Vc[i]&&(Vc[i]=!0),!e||e(r,i,o)}},Hc.spelling=function(e){return(e,t)=>!0};var qc={assertOptions:function(e,t,n){if("object"!=typeof e)throw new Rl("options must be an object",Rl.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let i=r.length;for(;i-- >0;){const o=r[i],s=t[o];if(s){const t=e[o],n=void 0===t||s(t,o,e);if(!0!==n)throw new Rl("option "+o+" must be "+n,Rl.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new Rl("Unknown option "+o,Rl.ERR_BAD_OPTION)}},validators:Hc};const Uc=qc.validators;class $c{constructor(e){this.defaults=e||{},this.interceptors={request:new ql,response:new ql}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=wc(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:i}=t;void 0!==n&&qc.assertOptions(n,{silentJSONParsing:Uc.transitional(Uc.boolean),forcedJSONParsing:Uc.transitional(Uc.boolean),clarifyTimeoutError:Uc.transitional(Uc.boolean)},!1),null!=r&&(Ml.isFunction(r)?t.paramsSerializer={serialize:r}:qc.assertOptions(r,{encode:Uc.function,serialize:Uc.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),qc.assertOptions(t,{baseUrl:Uc.spelling("baseURL"),withXsrfToken:Uc.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&Ml.merge(i.common,i[t.method]);i&&Ml.forEach(["delete","get","head","post","put","patch","common"],e=>{delete i[e]}),t.headers=lc.concat(o,i);const s=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const l=[];let c;this.interceptors.response.forEach(function(e){l.push(e.fulfilled,e.rejected)});let h,u=0;if(!a){const e=[Wc.bind(this),void 0];for(e.unshift(...s),e.push(...l),h=e.length,c=Promise.resolve(t);u<h;)c=c.then(e[u++],e[u++]);return c}h=s.length;let d=t;for(;u<h;){const e=s[u++],t=s[u++];try{d=e(d)}catch(e){t.call(this,e);break}}try{c=Wc.call(this,d)}catch(e){return Promise.reject(e)}for(u=0,h=l.length;u<h;)c=c.then(l[u++],l[u++]);return c}getUri(e){return Vl(bc((e=wc(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}Ml.forEach(["delete","get","head","options"],function(e){$c.prototype[e]=function(t,n){return this.request(wc(n||{},{method:e,url:t,data:(n||{}).data}))}}),Ml.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,i){return this.request(wc(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}$c.prototype[e]=t(),$c.prototype[e+"Form"]=t(!0)});var Kc=$c;class Yc{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new uc(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new Yc(function(t){e=t}),cancel:e}}}var Gc=Yc;const Xc={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Xc).forEach(([e,t])=>{Xc[t]=e});var Jc=Xc;const Qc=function e(t){const n=new Kc(t),r=Wa(Kc.prototype.request,n);return Ml.extend(r,Kc.prototype,n,{allOwnKeys:!0}),Ml.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(wc(t,n))},r}(tc);Qc.Axios=Kc,Qc.CanceledError=uc,Qc.CancelToken=Gc,Qc.isCancel=hc,Qc.VERSION=zc,Qc.toFormData=_l,Qc.AxiosError=Rl,Qc.Cancel=Qc.CanceledError,Qc.all=function(e){return Promise.all(e)},Qc.spread=function(e){return function(t){return e.apply(null,t)}},Qc.isAxiosError=function(e){return Ml.isObject(e)&&!0===e.isAxiosError},Qc.mergeConfig=wc,Qc.AxiosHeaders=lc,Qc.formToJSON=e=>Zl(Ml.isHTMLForm(e)?new FormData(e):e),Qc.getAdapter=_c.getAdapter,Qc.HttpStatusCode=Jc,Qc.default=Qc;var Zc=Qc.create({baseURL:"/api/cms",timeout:1e4,headers:{"Content-Type":"application/json"}}),eh=new Map;Zc.interceptors.request.use(function(e){e.url&&e.url.startsWith("http")&&(e.baseURL="");var t=localStorage.getItem("cms_token");t&&(e.headers.Authorization="Bearer ".concat(t));var n=localStorage.getItem("cms_session_id");return n&&(e.headers["X-Session-Id"]=n),e},function(e){return Promise.reject(e)}),Zc.interceptors.response.use(function(e){return e},function(e){var t="请求错误",n=!1;if(e.response){var r=e.response.status,i=e.response.data;401===r?"登录已过期,请重新登录"===(null==i?void 0:i.message)?(t="登录已过期,请重新登录",n=!0):"认证信息无效"===(null==i?void 0:i.message)?(t="认证信息无效,请重新登录",n=!0):(t="认证失败,请登录",n=!0):t=(null==i?void 0:i.message)||"HTTP ".concat(r,": ").concat(e.response.statusText)}else t=e.request?"网络连接失败,请检查网络状态":e.message||"请求错误";return n?(localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user"),"/login"!==window.location.pathname&&"/"!==window.location.pathname&&(Fa.error(t),setTimeout(function(){window.location.reload()},1e3))):Fa.error(t),Promise.reject(e)});var th,nh=function(e,t,n){var r=e;if(t){var i=new URLSearchParams(t).toString();r=r+(r.includes("?")?"&":"?")+i}var o="GET ".concat(r),s=eh.get(o);if(s)return s;var a=Zc.get(r,n).then(function(e){return e.data}).finally(function(){eh.delete(o)});return eh.set(o,a),a},rh=function(e,t,n){return Zc.post(e,t,n).then(function(e){return e.data})},ih=function(e,t,n){return Zc.put(e,t,n).then(function(e){return e.data})},oh=function(e,t){return Zc.delete(e,t).then(function(e){return e.data})};try{var sh=localStorage.getItem("cms_session_id")||void 0;th=sh}catch($k){}var ah=function(){return nh("/models")},lh=function(){return nh("/auth/signup/status/".concat(th?th+"_":"","cms_users"))},ch=function(e){return rh("/auth/signup/".concat(th?th+"_":"","cms_users"),e)},hh=function(e){return rh("/auth/login/".concat(th?th+"_":"","cms_users"),e)},uh=function(){return rh("/auth/verify/".concat(th?th+"_":"","cms_users"))},dh=function(){return nh("/auth/user/".concat(th?th+"_":"","cms_users"))},fh=function(){localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user")},ph=function(){return localStorage.getItem("cms_token")},mh=function(){var e=localStorage.getItem("cms_user");return e?JSON.parse(e):null},gh=function(e,t){var n=t?Object.assign({},t):void 0;return(null==n?void 0:n.filters)&&Array.isArray(n.filters)&&(n.filters=JSON.stringify(n.filters)),nh("/data/".concat(th?th+"_":"").concat(e),n)},vh=function(e,t){return nh("/relation/".concat(th?th+"_":"").concat(e,"/options"),t)},bh=function(e,t){return rh("/data/".concat(th?th+"_":"").concat(e),t)},yh=function(e,t){return ih("/data/".concat(th?th+"_":"").concat(e),t)},wh=function(e,t){return oh("/data/".concat(th?th+"_":"").concat(e,"?id=").concat(t))};function xh(t){var n=t.onLoginSuccess,r=m(e.useState(""),2),i=r[0],o=r[1],s=m(e.useState(""),2),a=s[0],l=s[1],c=m(e.useState(!1),2),u=c[0],d=c[1],p=m(e.useState("login"),2),g=p[0],v=p[1];e.useEffect(function(){var e=ph();if(e){var t=function(){var t=h(f().m(function t(){var r;return f().w(function(t){for(;;)switch(t.p=t.n){case 0:return d(!0),t.p=1,t.n=2,uh();case 2:if(t.v.success){t.n=3;break}throw new Error("token验证失败");case 3:return t.n=4,dh();case 4:if(!(r=t.v).success||!r.data){t.n=5;break}localStorage.setItem("cms_user",JSON.stringify(r.data)),null==n||n(e,r.data),t.n=6;break;case 5:throw new Error("获取用户信息失败");case 6:t.n=8;break;case 7:t.p=7,t.v,fh();case 8:return t.p=8,d(!1),t.f(8);case 9:return t.a(2)}},t,null,[[1,7,8,9]])}));return function(){return t.apply(this,arguments)}}();t()}},[n]),e.useEffect(function(){if(!ph()){var e=function(){var e=h(f().m(function e(){var t,n;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:return d(!0),e.p=1,e.n=2,lh();case 2:(n=e.v).success&&(null===(t=n.data)||void 0===t?void 0:t.allowSignup)?v("signup"):v("login"),e.n=4;break;case 3:e.p=3,e.v,v("login");case 4:return e.p=4,d(!1),e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}));return function(){return e.apply(this,arguments)}}();e()}},[]);var b=function(){var e=h(f().m(function e(t){var r,o,s,l,c;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t.preventDefault(),i&&a){e.n=1;break}return Fa.error("请完善登录信息"),e.a(2);case 1:if(d(!0),e.p=2,"signup"!==g){e.n=4;break}return e.n=3,ch({username:i,password:a});case 3:l=e.v,e.n=6;break;case 4:return e.n=5,hh({username:i,password:a});case 5:l=e.v;case 6:if((s=l).success&&(null===(r=s.data)||void 0===r?void 0:r.token)){e.n=7;break}return Fa.error(s.message||"登录失败"),"signup"===g&&(null===(o=s.message)||void 0===o?void 0:o.includes("已存在管理员"))&&v("login"),e.a(2);case 7:localStorage.setItem("cms_token",s.data.token),localStorage.setItem("cms_user",JSON.stringify(s.data.user)),null==n||n(s.data.token,s.data.user),e.n=9;break;case 8:e.p=8,c=e.v,Fa.error("登陆失败,".concat(c.message||"网络错误,请稍后重试"));case 9:return e.p=9,d(!1),e.f(9);case 10:return e.a(2)}},e,null,[[2,8,9,10]])}));return function(t){return e.apply(this,arguments)}}();return e.createElement("div",{className:"min-h-screen flex relative overflow-hidden bg-white"},e.createElement("div",{className:"pointer-events-none absolute inset-0"},e.createElement("div",{className:"absolute inset-0 bg-[linear-gradient(110deg,#ffffff_0%,#f7fbff_40%,#edf6ff_70%,#eaf3ff_100%)]"}),e.createElement("div",{className:"absolute inset-0 bg-[radial-gradient(1200px_600px_at_-10%_-10%,rgba(59,130,246,0.12),transparent),radial-gradient(900px_500px_at_110%_20%,rgba(147,51,234,0.10),transparent),radial-gradient(700px_400px_at_60%_120%,rgba(99,102,241,0.10),transparent)]"}),e.createElement("div",{className:"absolute inset-0 bg-[linear-gradient(115deg,rgba(255,255,255,0.6)_0%,rgba(255,255,255,0.15)_32%,transparent_32%,transparent_68%,rgba(255,255,255,0.15)_68%,rgba(255,255,255,0.6)_100%)]"})),e.createElement("div",{className:"flex-1 relative flex items-center justify-center"},e.createElement("div",{className:"relative z-10 max-w-4xl w-full px-16 text-left"},e.createElement("div",{className:"mb-12"},e.createElement("div",{className:"inline-flex items-center rounded-2xl px-4 py-2 bg-white/70 backdrop-blur border border-white/60"},e.createElement("span",{className:"text-2xl font-semibold tracking-tight text-gray-900"},"CMS 管理后台")),e.createElement("h1",{className:"mt-8 text-5xl md:text-6xl font-extrabold leading-tight text-gray-900"},"内容管理平台"),e.createElement("p",{className:"mt-6 text-2xl text-gray-600"},"一站式管理、协作与发布")),e.createElement("div",{className:"mt-8 flex items-center text-gray-500 gap-6"},e.createElement("span",{className:"flex items-center gap-2"},e.createElement("span",{className:"h-2 w-2 rounded-full bg-blue-500"}),"多角色权限"),e.createElement("span",{className:"flex items-center gap-2"},e.createElement("span",{className:"h-2 w-2 rounded-full bg-violet-500"}),"结构化内容"),e.createElement("span",{className:"flex items-center gap-2"},e.createElement("span",{className:"h-2 w-2 rounded-full bg-indigo-500"}),"可扩展 API")))),e.createElement("div",{className:"w-[480px] min-w-[380px] flex items-center justify-center p-8 mt-30"},e.createElement("div",{className:"w-full max-w-sm"},u?e.createElement(wa,{className:"bg-white/30 backdrop-blur-xl border border-white/50 shadow-none rounded-3xl overflow-hidden"},e.createElement(Ea,{className:"p-8"},e.createElement("div",{className:"space-y-4"},e.createElement(Ue,{className:"h-12 w-48"}),e.createElement(Ue,{className:"h-4 w-64"}),e.createElement(Ue,{className:"h-10 w-full"}),e.createElement(Ue,{className:"h-10 w-full"})))):e.createElement(wa,{className:"bg-white/30 backdrop-blur-xl border border-white/50 shadow-none rounded-3xl overflow-hidden"},e.createElement(xa,{className:"p-8 pb-6"},e.createElement(ka,{className:"text-center text-2xl mb-2 text-gray-800"},"signup"===g?"创建管理员账号":"欢迎使用 CMS 管理后台"),e.createElement(Sa,{className:"text-center text-gray-500"},"signup"===g?"首次进入需要先创建一个管理员账号":"请输入账号和密码登录")),e.createElement(Ea,{className:"p-8 pt-0"},e.createElement("form",{onSubmit:b,className:"space-y-6"},e.createElement("div",{className:"space-y-2"},e.createElement(ya,{htmlFor:"username"},"账号/邮箱"),e.createElement("div",{className:"relative"},e.createElement(U,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),e.createElement(lt,{id:"username",type:"text",placeholder:"邮箱",value:i,onChange:function(e){return o(e.target.value)},className:"pl-10 h-12 rounded-xl border-gray-200 hover:border-blue-400 focus:border-blue-500 transition-colors",required:!0,minLength:2}))),e.createElement("div",{className:"space-y-2"},e.createElement(ya,{htmlFor:"password"},"密码"),e.createElement("div",{className:"relative"},e.createElement(B,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),e.createElement(lt,{id:"password",type:"password",placeholder:"密码",value:a,onChange:function(e){return l(e.target.value)},className:"pl-10 h-12 rounded-xl border-gray-200 hover:border-blue-400 focus:border-blue-500 transition-colors",required:!0,minLength:6}))),e.createElement(at,{type:"submit",className:"w-full h-12 rounded-xl transition-all duration-200 font-semibold text-base shadow-lg hover:brightness-[1.03] active:scale-[0.99]",style:{backgroundImage:"linear-gradient(135deg, rgba(236, 248, 255, 0.78) 0%, rgba(221, 238, 255, 0.78) 100%)",color:"rgba(0, 0, 0, 0.7)",border:"none",boxShadow:"0 6px 24px rgba(37, 99, 235, 0.12)"},disabled:u},e.createElement(I,{className:"h-4 w-4 mr-2"}),u?"signup"===g?"创建中...":"登录中...":"signup"===g?"创建账号并进入":"登录"),e.createElement("div",{className:"text-center text-sm text-gray-500"},"signup"===g?e.createElement("button",{type:"button",className:"underline underline-offset-4 hover:text-gray-700",onClick:function(){return v("login")},disabled:u},"已有账号?去登录"):e.createElement("button",{type:"button",className:"underline underline-offset-4 hover:text-gray-700",onClick:function(){return v("signup")},disabled:u},"首次使用?创建管理员"))))))))}function kh(e,[t,n]){return Math.min(n,Math.max(t,e))}function Sh(e){const n=Eh(e),r=s.forwardRef((e,r)=>{const{children:i,...o}=e,a=s.Children.toArray(i),l=a.find(Oh);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}function Eh(e){const t=s.forwardRef((e,t)=>{const{children:n,...r}=e;if(s.isValidElement(n)){const e=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?Ke(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ch=Symbol("radix.slottable");function Oh(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Ch}var Nh=s.createContext(void 0);var Ah=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=Sh(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});var Th,Mh="dismissableLayer.update",Rh="dismissableLayer.pointerDownOutside",Dh="dismissableLayer.focusOutside",Ph=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Lh=s.forwardRef((e,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...h}=e,u=s.useContext(Ph),[d,f]=s.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=s.useState({}),g=Ye(n,e=>f(e)),v=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=d?v.indexOf(d):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(e,t=globalThis?.document){const n=Tt(e),r=s.useRef(!1),i=s.useRef(()=>{});return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){Ih(Rh,n,o,{discrete:!0})};const o={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",i.current),i.current=r,t.addEventListener("click",i.current,{once:!0})):r()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",e),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,n=[...u.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),l?.(e),e.defaultPrevented||c?.())},p),E=function(e,t=globalThis?.document){const n=Tt(e),r=s.useRef(!1);return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){Ih(Dh,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...u.branches].some(e=>e.contains(t))||(a?.(e),l?.(e),e.defaultPrevented||c?.())},p);return Mt(e=>{w===u.layers.size-1&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},p),s.useEffect(()=>{if(d)return r&&(0===u.layersWithOutsidePointerEventsDisabled.size&&(Th=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Bh(),()=>{r&&1===u.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=Th)}},[d,p,r,u]),s.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Bh())},[d,u]),s.useEffect(()=>{const e=()=>m({});return document.addEventListener(Mh,e),()=>document.removeEventListener(Mh,e)},[]),t.jsx(Ah.div,{...h,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...e.style},onFocusCapture:mt(e.onFocusCapture,E.onFocusCapture),onBlurCapture:mt(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:mt(e.onPointerDownCapture,S.onPointerDownCapture)})});Lh.displayName="DismissableLayer";function Bh(){const e=new CustomEvent(Mh);document.dispatchEvent(e)}function Ih(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?function(e,t){e&&a.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}s.forwardRef((e,n)=>{const r=s.useContext(Ph),i=s.useRef(null),o=Ye(n,i);return s.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),t.jsx(Ah.div,{...e,ref:o})}).displayName="DismissableLayerBranch";var jh="focusScope.autoFocusOnMount",_h="focusScope.autoFocusOnUnmount",Fh={bubbles:!1,cancelable:!0},Wh=s.forwardRef((e,n)=>{const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...l}=e,[c,h]=s.useState(null),u=Tt(o),d=Tt(a),f=s.useRef(null),p=Ye(n,e=>h(e)),m=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(i){let e=function(e){if(m.paused||!c)return;const t=e.target;c.contains(t)?f.current=t:qh(f.current,{select:!0})},t=function(e){if(m.paused||!c)return;const t=e.relatedTarget;null!==t&&(c.contains(t)||qh(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&qh(c)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[i,c,m.paused]),s.useEffect(()=>{if(c){Uh.add(m);const t=document.activeElement;if(!c.contains(t)){const n=new CustomEvent(jh,Fh);c.addEventListener(jh,u),c.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(qh(r,{select:t}),document.activeElement!==n)return}((e=zh(c),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&qh(c))}return()=>{c.removeEventListener(jh,u),setTimeout(()=>{const e=new CustomEvent(_h,Fh);c.addEventListener(_h,d),c.dispatchEvent(e),e.defaultPrevented||qh(t??document.body,{select:!0}),c.removeEventListener(_h,d),Uh.remove(m)},0)}}var e},[c,u,d,m]);const g=s.useCallback(e=>{if(!r&&!i)return;if(m.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){const t=e.currentTarget,[i,o]=function(e){const t=zh(e),n=Hh(t,e),r=Hh(t.reverse(),e);return[n,r]}(t);i&&o?e.shiftKey||n!==o?e.shiftKey&&n===i&&(e.preventDefault(),r&&qh(o,{select:!0})):(e.preventDefault(),r&&qh(i,{select:!0})):n===t&&e.preventDefault()}},[r,i,m.paused]);return t.jsx(Ah.div,{tabIndex:-1,...l,ref:p,onKeyDown:g})});function zh(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Hh(e,t){for(const n of e)if(!Vh(n,{upTo:t}))return n}function Vh(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function qh(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}Wh.displayName="FocusScope";var Uh=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=$h(e,t),e.unshift(t)},remove(t){e=$h(e,t),e[0]?.resume()}}}();function $h(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var Kh=s.forwardRef((e,n)=>{const{children:r,width:i=10,height:o=5,...s}=e;return t.jsx(Ah.svg,{...s,ref:n,width:i,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});Kh.displayName="Arrow";var Yh=Kh,Gh="Popper",[Xh,Jh]=gt(Gh),[Qh,Zh]=Xh(Gh),eu=e=>{const{__scopePopper:n,children:r}=e,[i,o]=s.useState(null);return t.jsx(Qh,{scope:n,anchor:i,onAnchorChange:o,children:r})};eu.displayName=Gh;var tu="PopperAnchor",nu=s.forwardRef((e,n)=>{const{__scopePopper:r,virtualRef:i,...o}=e,a=Zh(tu,r),l=s.useRef(null),c=Ye(n,l),h=s.useRef(null);return s.useEffect(()=>{const e=h.current;h.current=i?.current||l.current,e!==h.current&&a.onAnchorChange(h.current)}),i?null:t.jsx(Ah.div,{...o,ref:c})});nu.displayName=tu;var ru="PopperContent",[iu,ou]=Xh(ru),su=s.forwardRef((e,n)=>{const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:a="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:h=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...v}=e,b=Zh(ru,r),[y,w]=s.useState(null),x=Ye(n,e=>w(e)),[k,S]=s.useState(null),E=Go(k),C=E?.width??0,O=E?.height??0,N=i+("center"!==a?"-"+a:""),A="number"==typeof d?d:{top:0,right:0,bottom:0,left:0,...d},T=Array.isArray(u)?u:[u],M=T.length>0,R={padding:A,boundary:T.filter(hu),altBoundary:M},{refs:D,floatingStyles:P,placement:L,isPositioned:B,middlewareData:I}=_o({strategy:"fixed",placement:N,whileElementsMounted:(...e)=>Eo(...e,{animationFrame:"always"===m}),elements:{reference:b.anchor},middleware:[Wo({mainAxis:o+O,alignmentAxis:l}),h&&zo({mainAxis:!0,crossAxis:!1,limiter:"partial"===f?Ho():void 0,...R}),h&&Vo({...R}),qo({...R,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{const{width:i,height:o}=t.reference,s=e.floating.style;s.setProperty("--radix-popper-available-width",`${n}px`),s.setProperty("--radix-popper-available-height",`${r}px`),s.setProperty("--radix-popper-anchor-width",`${i}px`),s.setProperty("--radix-popper-anchor-height",`${o}px`)}}),k&&$o({element:k,padding:c}),uu({arrowWidth:C,arrowHeight:O}),p&&Uo({strategy:"referenceHidden",...R})]}),[j,_]=du(L),F=Tt(g);bt(()=>{B&&F?.()},[B,F]);const W=I.arrow?.x,z=I.arrow?.y,H=0!==I.arrow?.centerOffset,[V,q]=s.useState();return bt(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),t.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...P,transform:B?P.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[I.transformOrigin?.x,I.transformOrigin?.y].join(" "),...I.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(iu,{scope:r,placedSide:j,onArrowChange:S,arrowX:W,arrowY:z,shouldHideArrow:H,children:t.jsx(Ah.div,{"data-side":j,"data-align":_,...v,ref:x,style:{...v.style,animation:B?void 0:"none"}})})})});su.displayName=ru;var au="PopperArrow",lu={top:"bottom",right:"left",bottom:"top",left:"right"},cu=s.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,o=ou(au,r),s=lu[o.placedSide];return t.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:t.jsx(Yh,{...i,ref:n,style:{...i.style,display:"block"}})})});function hu(e){return null!==e}cu.displayName=au;var uu=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:i}=t,o=0!==i.arrow?.centerOffset,s=o?0:e.arrowWidth,a=o?0:e.arrowHeight,[l,c]=du(n),h={start:"0%",center:"50%",end:"100%"}[c],u=(i.arrow?.x??0)+s/2,d=(i.arrow?.y??0)+a/2;let f="",p="";return"bottom"===l?(f=o?h:`${u}px`,p=-a+"px"):"top"===l?(f=o?h:`${u}px`,p=`${r.floating.height+a}px`):"right"===l?(f=-a+"px",p=o?h:`${d}px`):"left"===l&&(f=`${r.floating.width+a}px`,p=o?h:`${d}px`),{data:{x:f,y:p}}}});function du(e){const[t,n="center"]=e.split("-");return[t,n]}var fu=eu,pu=nu,mu=su,gu=cu,vu=s.forwardRef((e,r)=>{const{container:i,...o}=e,[a,l]=s.useState(!1);bt(()=>l(!0),[]);const c=i||a&&globalThis?.document?.body;return c?n.createPortal(t.jsx(Ah.div,{...o,ref:r}),c):null});function bu(e){const t=s.useRef({value:e,previous:e});return s.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}vu.displayName="Portal";var yu=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"});s.forwardRef((e,n)=>t.jsx(Ah.span,{...e,ref:n,style:{...yu,...e.style}})).displayName="VisuallyHidden";var wu=[" ","Enter","ArrowUp","ArrowDown"],xu=[" ","Enter"],ku="Select",[Su,Eu,Cu]=function(n){const r=n+"CollectionProvider",[i,o]=gt(r),[s,a]=i(r,{collectionRef:{current:null},itemMap:new Map}),l=n=>{const{scope:r,children:i}=n,o=e.useRef(null),a=e.useRef(new Map).current;return t.jsx(s,{scope:r,itemMap:a,collectionRef:o,children:i})};l.displayName=r;const c=n+"CollectionSlot",h=Sh(c),u=e.forwardRef((e,n)=>{const{scope:r,children:i}=e,o=Ye(n,a(c,r).collectionRef);return t.jsx(h,{ref:o,children:i})});u.displayName=c;const d=n+"CollectionItemSlot",f="data-radix-collection-item",p=Sh(d),m=e.forwardRef((n,r)=>{const{scope:i,children:o,...s}=n,l=e.useRef(null),c=Ye(r,l),h=a(d,i);return e.useEffect(()=>(h.itemMap.set(l,{ref:l,...s}),()=>{h.itemMap.delete(l)})),t.jsx(p,{[f]:"",ref:c,children:o})});return m.displayName=d,[{Provider:l,Slot:u,ItemSlot:m},function(t){const r=a(n+"CollectionConsumer",t);return e.useCallback(()=>{const e=r.collectionRef.current;if(!e)return[];const t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(r.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[r.collectionRef,r.itemMap])},o]}(ku),[Ou,Nu]=gt(ku,[Cu,Jh]),Au=Jh(),[Tu,Mu]=Ou(ku),[Ru,Du]=Ou(ku),Pu=e=>{const{__scopeSelect:n,children:r,open:i,defaultOpen:o,onOpenChange:a,value:l,defaultValue:c,onValueChange:h,dir:u,name:d,autoComplete:f,disabled:p,required:m,form:g}=e,v=Au(n),[b,y]=s.useState(null),[w,x]=s.useState(null),[k,S]=s.useState(!1),E=function(e){const t=s.useContext(Nh);return e||t||"ltr"}(u),[C,O]=St({prop:i,defaultProp:o??!1,onChange:a,caller:ku}),[N,A]=St({prop:l,defaultProp:c,onChange:h,caller:ku}),T=s.useRef(null),M=!b||(g||!!b.closest("form")),[R,D]=s.useState(new Set),P=Array.from(R).map(e=>e.props.value).join(";");return t.jsx(fu,{...v,children:t.jsxs(Tu,{required:m,scope:n,trigger:b,onTriggerChange:y,valueNode:w,onValueNodeChange:x,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:xt(),value:N,onValueChange:A,open:C,onOpenChange:O,dir:E,triggerPointerDownPosRef:T,disabled:p,children:[t.jsx(Su.Provider,{scope:n,children:t.jsx(Ru,{scope:e.__scopeSelect,onNativeOptionAdd:s.useCallback(e=>{D(t=>new Set(t).add(e))},[]),onNativeOptionRemove:s.useCallback(e=>{D(t=>{const n=new Set(t);return n.delete(e),n})},[]),children:r})}),M?t.jsxs(yd,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:N,onChange:e=>A(e.target.value),disabled:p,form:g,children:[void 0===N?t.jsx("option",{value:""}):null,Array.from(R)]},P):null]})})};Pu.displayName=ku;var Lu="SelectTrigger",Bu=s.forwardRef((e,n)=>{const{__scopeSelect:r,disabled:i=!1,...o}=e,a=Au(r),l=Mu(Lu,r),c=l.disabled||i,h=Ye(n,l.onTriggerChange),u=Eu(r),d=s.useRef("touch"),[f,p,m]=xd(e=>{const t=u().filter(e=>!e.disabled),n=t.find(e=>e.value===l.value),r=kd(t,e,n);void 0!==r&&l.onValueChange(r.value)}),g=e=>{c||(l.onOpenChange(!0),m()),e&&(l.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return t.jsx(pu,{asChild:!0,...a,children:t.jsx(Ah.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":wd(l.value)?"":void 0,...o,ref:h,onClick:mt(o.onClick,e=>{e.currentTarget.focus(),"mouse"!==d.current&&g(e)}),onPointerDown:mt(o.onPointerDown,e=>{d.current=e.pointerType;const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(g(e),e.preventDefault())}),onKeyDown:mt(o.onKeyDown,e=>{const t=""!==f.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||p(e.key),t&&" "===e.key||wu.includes(e.key)&&(g(),e.preventDefault())})})})});Bu.displayName=Lu;var Iu="SelectValue",ju=s.forwardRef((e,n)=>{const{__scopeSelect:r,className:i,style:o,children:s,placeholder:a="",...l}=e,c=Mu(Iu,r),{onValueNodeHasChildrenChange:h}=c,u=void 0!==s,d=Ye(n,c.onValueNodeChange);return bt(()=>{h(u)},[h,u]),t.jsx(Ah.span,{...l,ref:d,style:{pointerEvents:"none"},children:wd(c.value)?t.jsx(t.Fragment,{children:a}):s})});ju.displayName=Iu;var _u=s.forwardRef((e,n)=>{const{__scopeSelect:r,children:i,...o}=e;return t.jsx(Ah.span,{"aria-hidden":!0,...o,ref:n,children:i||"▼"})});_u.displayName="SelectIcon";var Fu=e=>t.jsx(vu,{asChild:!0,...e});Fu.displayName="SelectPortal";var Wu="SelectContent",zu=s.forwardRef((e,n)=>{const r=Mu(Wu,e.__scopeSelect),[i,o]=s.useState();if(bt(()=>{o(new DocumentFragment)},[]),!r.open){const n=i;return n?a.createPortal(t.jsx(Vu,{scope:e.__scopeSelect,children:t.jsx(Su.Slot,{scope:e.__scopeSelect,children:t.jsx("div",{children:e.children})})}),n):null}return t.jsx($u,{...e,ref:n})});zu.displayName=Wu;var Hu=10,[Vu,qu]=Ou(Wu),Uu=Sh("SelectContent.RemoveScroll"),$u=s.forwardRef((e,n)=>{const{__scopeSelect:r,position:i="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:l,side:c,sideOffset:h,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:v,avoidCollisions:b,...y}=e,w=Mu(Wu,r),[x,k]=s.useState(null),[S,E]=s.useState(null),C=Ye(n,e=>k(e)),[O,N]=s.useState(null),[A,T]=s.useState(null),M=Eu(r),[R,D]=s.useState(!1),P=s.useRef(!1);s.useEffect(()=>{if(x)return Yn(x)},[x]),Zt();const L=s.useCallback(e=>{const[t,...n]=M().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(const n of e){if(n===i)return;if(n?.scrollIntoView({block:"nearest"}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i)return}},[M,S]),B=s.useCallback(()=>L([O,x]),[L,O,x]);s.useEffect(()=>{R&&B()},[R,B]);const{onOpenChange:I,triggerPointerDownPosRef:j}=w;s.useEffect(()=>{if(x){let e={x:0,y:0};const t=t=>{e={x:Math.abs(Math.round(t.pageX)-(j.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(j.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():x.contains(n.target)||I(!1),document.removeEventListener("pointermove",t),j.current=null};return null!==j.current&&(document.addEventListener("pointermove",t),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",n,{capture:!0})}}},[x,I,j]),s.useEffect(()=>{const e=()=>I(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[I]);const[_,F]=xd(e=>{const t=M().filter(e=>!e.disabled),n=t.find(e=>e.ref.current===document.activeElement),r=kd(t,e,n);r&&setTimeout(()=>r.ref.current.focus())}),W=s.useCallback((e,t,n)=>{const r=!P.current&&!n;(void 0!==w.value&&w.value===t||r)&&(N(e),r&&(P.current=!0))},[w.value]),z=s.useCallback(()=>x?.focus(),[x]),H=s.useCallback((e,t,n)=>{const r=!P.current&&!n;(void 0!==w.value&&w.value===t||r)&&T(e)},[w.value]),V="popper"===i?Yu:Ku,q=V===Yu?{side:c,sideOffset:h,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:v,avoidCollisions:b}:{};return t.jsx(Vu,{scope:r,content:x,viewport:S,onViewportChange:E,itemRefCallback:W,selectedItem:O,onItemLeave:z,itemTextRefCallback:H,focusSelectedItem:B,selectedItemText:A,position:i,isPositioned:R,searchRef:_,children:t.jsx(zn,{as:Uu,allowPinchZoom:!0,children:t.jsx(Wh,{asChild:!0,trapped:w.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:mt(o,e=>{w.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:t.jsx(Lh,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:t.jsx(V,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:e=>e.preventDefault(),...y,...q,onPlaced:()=>D(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:mt(y.onKeyDown,e=>{const t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||F(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let t=M().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(t=t.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>L(t)),e.preventDefault()}})})})})})})});$u.displayName="SelectContentImpl";var Ku=s.forwardRef((e,n)=>{const{__scopeSelect:r,onPlaced:i,...o}=e,a=Mu(Wu,r),l=qu(Wu,r),[c,h]=s.useState(null),[u,d]=s.useState(null),f=Ye(n,e=>d(e)),p=Eu(r),m=s.useRef(!1),g=s.useRef(!0),{viewport:v,selectedItem:b,selectedItemText:y,focusSelectedItem:w}=l,x=s.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&u&&v&&b&&y){const e=a.trigger.getBoundingClientRect(),t=u.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),r=y.getBoundingClientRect();if("rtl"!==a.dir){const i=r.left-t.left,o=n.left-i,s=e.left-o,a=e.width+s,l=Math.max(a,t.width),h=window.innerWidth-Hu,u=kh(o,[Hu,Math.max(Hu,h-l)]);c.style.minWidth=a+"px",c.style.left=u+"px"}else{const i=t.right-r.right,o=window.innerWidth-n.right-i,s=window.innerWidth-e.right-o,a=e.width+s,l=Math.max(a,t.width),h=window.innerWidth-Hu,u=kh(o,[Hu,Math.max(Hu,h-l)]);c.style.minWidth=a+"px",c.style.right=u+"px"}const o=p(),s=window.innerHeight-2*Hu,l=v.scrollHeight,h=window.getComputedStyle(u),d=parseInt(h.borderTopWidth,10),f=parseInt(h.paddingTop,10),g=parseInt(h.borderBottomWidth,10),w=d+f+l+parseInt(h.paddingBottom,10)+g,x=Math.min(5*b.offsetHeight,w),k=window.getComputedStyle(v),S=parseInt(k.paddingTop,10),E=parseInt(k.paddingBottom,10),C=e.top+e.height/2-Hu,O=s-C,N=b.offsetHeight/2,A=d+f+(b.offsetTop+N),T=w-A;if(A<=C){const e=o.length>0&&b===o[o.length-1].ref.current;c.style.bottom="0px";const t=u.clientHeight-v.offsetTop-v.offsetHeight,n=A+Math.max(O,N+(e?E:0)+t+g);c.style.height=n+"px"}else{const e=o.length>0&&b===o[0].ref.current;c.style.top="0px";const t=Math.max(C,d+v.offsetTop+(e?S:0)+N)+T;c.style.height=t+"px",v.scrollTop=A-C+v.offsetTop}c.style.margin=`${Hu}px 0`,c.style.minHeight=x+"px",c.style.maxHeight=s+"px",i?.(),requestAnimationFrame(()=>m.current=!0)}},[p,a.trigger,a.valueNode,c,u,v,b,y,a.dir,i]);bt(()=>x(),[x]);const[k,S]=s.useState();bt(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const E=s.useCallback(e=>{e&&!0===g.current&&(x(),w?.(),g.current=!1)},[x,w]);return t.jsx(Gu,{scope:r,contentWrapper:c,shouldExpandOnScrollRef:m,onScrollButtonChange:E,children:t.jsx("div",{ref:h,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:t.jsx(Ah.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ku.displayName="SelectItemAlignedPosition";var Yu=s.forwardRef((e,n)=>{const{__scopeSelect:r,align:i="start",collisionPadding:o=Hu,...s}=e,a=Au(r);return t.jsx(mu,{...a,...s,ref:n,align:i,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Yu.displayName="SelectPopperPosition";var[Gu,Xu]=Ou(Wu,{}),Ju="SelectViewport",Qu=s.forwardRef((e,n)=>{const{__scopeSelect:r,nonce:i,...o}=e,a=qu(Ju,r),l=Xu(Ju,r),c=Ye(n,a.onViewportChange),h=s.useRef(0);return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),t.jsx(Su.Slot,{scope:r,children:t.jsx(Ah.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:mt(o.onScroll,e=>{const t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=l;if(r?.current&&n){const e=Math.abs(h.current-t.scrollTop);if(e>0){const r=window.innerHeight-2*Hu,i=parseFloat(n.style.minHeight),o=parseFloat(n.style.height),s=Math.max(i,o);if(s<r){const i=s+e,o=Math.min(r,i),a=i-o;n.style.height=o+"px","0px"===n.style.bottom&&(t.scrollTop=a>0?a:0,n.style.justifyContent="flex-end")}}}h.current=t.scrollTop})})})]})});Qu.displayName=Ju;var Zu="SelectGroup",[ed,td]=Ou(Zu);s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e,o=xt();return t.jsx(ed,{scope:r,id:o,children:t.jsx(Ah.div,{role:"group","aria-labelledby":o,...i,ref:n})})}).displayName=Zu;var nd="SelectLabel",rd=s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e,o=td(nd,r);return t.jsx(Ah.div,{id:o.id,...i,ref:n})});rd.displayName=nd;var id="SelectItem",[od,sd]=Ou(id),ad=s.forwardRef((e,n)=>{const{__scopeSelect:r,value:i,disabled:o=!1,textValue:a,...l}=e,c=Mu(id,r),h=qu(id,r),u=c.value===i,[d,f]=s.useState(a??""),[p,m]=s.useState(!1),g=Ye(n,e=>h.itemRefCallback?.(e,i,o)),v=xt(),b=s.useRef("touch"),y=()=>{o||(c.onValueChange(i),c.onOpenChange(!1))};if(""===i)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return t.jsx(od,{scope:r,value:i,disabled:o,textId:v,isSelected:u,onItemTextChange:s.useCallback(e=>{f(t=>t||(e?.textContent??"").trim())},[]),children:t.jsx(Su.ItemSlot,{scope:r,value:i,disabled:o,textValue:d,children:t.jsx(Ah.div,{role:"option","aria-labelledby":v,"data-highlighted":p?"":void 0,"aria-selected":u&&p,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...l,ref:g,onFocus:mt(l.onFocus,()=>m(!0)),onBlur:mt(l.onBlur,()=>m(!1)),onClick:mt(l.onClick,()=>{"mouse"!==b.current&&y()}),onPointerUp:mt(l.onPointerUp,()=>{"mouse"===b.current&&y()}),onPointerDown:mt(l.onPointerDown,e=>{b.current=e.pointerType}),onPointerMove:mt(l.onPointerMove,e=>{b.current=e.pointerType,o?h.onItemLeave?.():"mouse"===b.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:mt(l.onPointerLeave,e=>{e.currentTarget===document.activeElement&&h.onItemLeave?.()}),onKeyDown:mt(l.onKeyDown,e=>{""!==h.searchRef?.current&&" "===e.key||(xu.includes(e.key)&&y()," "===e.key&&e.preventDefault())})})})})});ad.displayName=id;var ld="SelectItemText",cd=s.forwardRef((e,n)=>{const{__scopeSelect:r,className:i,style:o,...l}=e,c=Mu(ld,r),h=qu(ld,r),u=sd(ld,r),d=Du(ld,r),[f,p]=s.useState(null),m=Ye(n,e=>p(e),u.onItemTextChange,e=>h.itemTextRefCallback?.(e,u.value,u.disabled)),g=f?.textContent,v=s.useMemo(()=>t.jsx("option",{value:u.value,disabled:u.disabled,children:g},u.value),[u.disabled,u.value,g]),{onNativeOptionAdd:b,onNativeOptionRemove:y}=d;return bt(()=>(b(v),()=>y(v)),[b,y,v]),t.jsxs(t.Fragment,{children:[t.jsx(Ah.span,{id:u.textId,...l,ref:m}),u.isSelected&&c.valueNode&&!c.valueNodeHasChildren?a.createPortal(l.children,c.valueNode):null]})});cd.displayName=ld;var hd="SelectItemIndicator",ud=s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e;return sd(hd,r).isSelected?t.jsx(Ah.span,{"aria-hidden":!0,...i,ref:n}):null});ud.displayName=hd;var dd="SelectScrollUpButton",fd=s.forwardRef((e,n)=>{const r=qu(dd,e.__scopeSelect),i=Xu(dd,e.__scopeSelect),[o,a]=s.useState(!1),l=Ye(n,i.onScrollButtonChange);return bt(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollTop>0;a(e)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?t.jsx(gd,{...e,ref:l,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}}):null});fd.displayName=dd;var pd="SelectScrollDownButton",md=s.forwardRef((e,n)=>{const r=qu(pd,e.__scopeSelect),i=Xu(pd,e.__scopeSelect),[o,a]=s.useState(!1),l=Ye(n,i.onScrollButtonChange);return bt(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?t.jsx(gd,{...e,ref:l,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}}):null});md.displayName=pd;var gd=s.forwardRef((e,n)=>{const{__scopeSelect:r,onAutoScroll:i,...o}=e,a=qu("SelectScrollButton",r),l=s.useRef(null),c=Eu(r),h=s.useCallback(()=>{null!==l.current&&(window.clearInterval(l.current),l.current=null)},[]);return s.useEffect(()=>()=>h(),[h]),bt(()=>{const e=c().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[c]),t.jsx(Ah.div,{"aria-hidden":!0,...o,ref:n,style:{flexShrink:0,...o.style},onPointerDown:mt(o.onPointerDown,()=>{null===l.current&&(l.current=window.setInterval(i,50))}),onPointerMove:mt(o.onPointerMove,()=>{a.onItemLeave?.(),null===l.current&&(l.current=window.setInterval(i,50))}),onPointerLeave:mt(o.onPointerLeave,()=>{h()})})}),vd=s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e;return t.jsx(Ah.div,{"aria-hidden":!0,...i,ref:n})});vd.displayName="SelectSeparator";var bd="SelectArrow";s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e,o=Au(r),s=Mu(bd,r),a=qu(bd,r);return s.open&&"popper"===a.position?t.jsx(gu,{...o,...i,ref:n}):null}).displayName=bd;var yd=s.forwardRef(({__scopeSelect:e,value:n,...r},i)=>{const o=s.useRef(null),a=Ye(i,o),l=bu(n);return s.useEffect(()=>{const e=o.current;if(!e)return;const t=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(t,"value").set;if(l!==n&&r){const t=new Event("change",{bubbles:!0});r.call(e,n),e.dispatchEvent(t)}},[l,n]),t.jsx(Ah.select,{...r,style:{...yu,...r.style},ref:a,defaultValue:n})});function wd(e){return""===e||void 0===e}function xd(e){const t=Tt(e),n=s.useRef(""),r=s.useRef(0),i=s.useCallback(e=>{const i=n.current+e;t(i),function e(t){n.current=t,window.clearTimeout(r.current),""!==t&&(r.current=window.setTimeout(()=>e(""),1e3))}(i)},[t]),o=s.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return s.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,o]}function kd(e,t,n){const r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let o=(s=e,a=Math.max(i,0),s.map((e,t)=>s[(a+t)%s.length]));var s,a;1===r.length&&(o=o.filter(e=>e!==n));const l=o.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return l!==n?l:void 0}yd.displayName="SelectBubbleInput";var Sd=Bu,Ed=_u,Cd=Fu,Od=zu,Nd=Qu,Ad=rd,Td=ad,Md=cd,Rd=ud,Dd=fd,Pd=md,Ld=vd,Bd=Pu,Id=ju,jd=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=G(e,["className","children"]);return s.createElement(Sd,Object.assign({ref:t,className:qe("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",n)},i),r,s.createElement(Ed,{asChild:!0},s.createElement(E,{className:"h-4 w-4 opacity-50"})))});jd.displayName=Sd.displayName;var _d=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Dd,Object.assign({ref:t,className:qe("flex cursor-default items-center justify-center py-1",n)},r),s.createElement(N,{className:"h-4 w-4"}))});_d.displayName=Dd.displayName;var Fd=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Pd,Object.assign({ref:t,className:qe("flex cursor-default items-center justify-center py-1",n)},r),s.createElement(E,{className:"h-4 w-4"}))});Fd.displayName=Pd.displayName;var Wd=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=e.position,o=void 0===i?"popper":i,a=G(e,["className","children","position"]);return s.createElement(Cd,null,s.createElement(Od,Object.assign({ref:t,className:qe("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]","popper"===o&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",n),position:o},a),s.createElement(_d,null),s.createElement(Nd,{className:qe("p-1","popper"===o&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]")},r),s.createElement(Fd,null)))});Wd.displayName=Od.displayName;var zd=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Ad,Object.assign({ref:t,className:qe("py-1.5 pl-8 pr-2 text-sm font-semibold",n)},r))});zd.displayName=Ad.displayName;var Hd=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=G(e,["className","children"]);return s.createElement(Td,Object.assign({ref:t,className:qe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n)},i),s.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},s.createElement(Rd,null,s.createElement(S,{className:"h-4 w-4"}))),s.createElement(Md,null,r))});Hd.displayName=Td.displayName;var Vd=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Ld,Object.assign({ref:t,className:qe("-mx-1 my-1 h-px bg-muted",n)},r))});function qd(e){const t=s.forwardRef((e,t)=>{const{children:n,...r}=e;if(s.isValidElement(n)){const e=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?Ke(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}Vd.displayName=Ld.displayName;var Ud=Symbol("radix.slottable");function $d(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Ud}var Kd=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=function(e){const n=qd(e),r=s.forwardRef((e,r)=>{const{children:i,...o}=e,a=s.Children.toArray(i),l=a.find($d);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),Yd="Switch",[Gd,Xd]=gt(Yd),[Jd,Qd]=Gd(Yd),Zd=s.forwardRef((e,n)=>{const{__scopeSwitch:r,name:i,checked:o,defaultChecked:a,required:l,disabled:c,value:h="on",onCheckedChange:u,form:d,...f}=e,[p,m]=s.useState(null),g=Ye(n,e=>m(e)),v=s.useRef(!1),b=!p||(d||!!p.closest("form")),[y,w]=St({prop:o,defaultProp:a??!1,onChange:u,caller:Yd});return t.jsxs(Jd,{scope:r,checked:y,disabled:c,children:[t.jsx(Kd.button,{type:"button",role:"switch","aria-checked":y,"aria-required":l,"data-state":rf(y),"data-disabled":c?"":void 0,disabled:c,value:h,...f,ref:g,onClick:mt(e.onClick,e=>{w(e=>!e),b&&(v.current=e.isPropagationStopped(),v.current||e.stopPropagation())})}),b&&t.jsx(nf,{control:p,bubbles:!v.current,name:i,value:h,checked:y,required:l,disabled:c,form:d,style:{transform:"translateX(-100%)"}})]})});Zd.displayName=Yd;var ef="SwitchThumb",tf=s.forwardRef((e,n)=>{const{__scopeSwitch:r,...i}=e,o=Qd(ef,r);return t.jsx(Kd.span,{"data-state":rf(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:n})});tf.displayName=ef;var nf=s.forwardRef(({__scopeSwitch:e,control:n,checked:r,bubbles:i=!0,...o},a)=>{const l=s.useRef(null),c=Ye(l,a),h=bu(r),u=Go(n);return s.useEffect(()=>{const e=l.current;if(!e)return;const t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,"checked").set;if(h!==r&&n){const t=new Event("click",{bubbles:i});n.call(e,r),e.dispatchEvent(t)}},[h,r,i]),t.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:c,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function rf(e){return e?"checked":"unchecked"}nf.displayName="SwitchBubbleInput";var of=Zd,sf=tf,af=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(of,Object.assign({className:qe("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",n)},r,{ref:t}),s.createElement(sf,{className:qe("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")}))});af.displayName=of.displayName;var lf=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("textarea",Object.assign({className:qe("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:t},r))});lf.displayName="Textarea";var cf=Ar,hf=Tr,uf=Mr,df=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Rr,Object.assign({ref:t,className:qe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n)},r))});df.displayName=Rr.displayName;var ff=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=G(e,["className","children"]);return s.createElement(uf,null,s.createElement(df,null),s.createElement(Dr,Object.assign({ref:t,className:qe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n)},i),r,s.createElement(Br,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"},s.createElement(K,{className:"h-4 w-4"}),s.createElement("span",{className:"sr-only"},"Close"))))});ff.displayName=Dr.displayName;var pf=function(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("flex flex-col space-y-1.5 text-center sm:text-left",t)},n))};pf.displayName="DialogHeader";var mf=function(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t)},n))};mf.displayName="DialogFooter";var gf=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Pr,Object.assign({ref:t,className:qe("text-lg font-semibold leading-none tracking-tight",n)},r))});gf.displayName=Pr.displayName;var vf,bf=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Lr,Object.assign({ref:t,className:qe("text-sm text-muted-foreground",n)},r))});function yf(e,t=!1){const n=e.length;let r=0,i="",o=0,s=16,a=0,l=0,c=0,h=0,u=0;function d(t,n){let i=0,o=0;for(;i<t||!n;){let t=e.charCodeAt(r);if(t>=48&&t<=57)o=16*o+t-48;else if(t>=65&&t<=70)o=16*o+t-65+10;else{if(!(t>=97&&t<=102))break;o=16*o+t-97+10}r++,i++}return i<t&&(o=-1),o}function f(){if(i="",u=0,o=r,l=a,h=c,r>=n)return o=n,s=17;let t=e.charCodeAt(r);if(wf(t)){do{r++,i+=String.fromCharCode(t),t=e.charCodeAt(r)}while(wf(t));return s=15}if(xf(t))return r++,i+=String.fromCharCode(t),13===t&&10===e.charCodeAt(r)&&(r++,i+="\n"),a++,c=r,s=14;switch(t){case 123:return r++,s=1;case 125:return r++,s=2;case 91:return r++,s=3;case 93:return r++,s=4;case 58:return r++,s=6;case 44:return r++,s=5;case 34:return r++,i=function(){let t="",i=r;for(;;){if(r>=n){t+=e.substring(i,r),u=2;break}const o=e.charCodeAt(r);if(34===o){t+=e.substring(i,r),r++;break}if(92!==o){if(o>=0&&o<=31){if(xf(o)){t+=e.substring(i,r),u=2;break}u=6}r++}else{if(t+=e.substring(i,r),r++,r>=n){u=2;break}switch(e.charCodeAt(r++)){case 34:t+='"';break;case 92:t+="\\";break;case 47:t+="/";break;case 98:t+="\b";break;case 102:t+="\f";break;case 110:t+="\n";break;case 114:t+="\r";break;case 116:t+="\t";break;case 117:const e=d(4,!0);e>=0?t+=String.fromCharCode(e):u=4;break;default:u=5}i=r}}return t}(),s=10;case 47:const l=r-1;if(47===e.charCodeAt(r+1)){for(r+=2;r<n&&!xf(e.charCodeAt(r));)r++;return i=e.substring(l,r),s=12}if(42===e.charCodeAt(r+1)){r+=2;const t=n-1;let o=!1;for(;r<t;){const t=e.charCodeAt(r);if(42===t&&47===e.charCodeAt(r+1)){r+=2,o=!0;break}r++,xf(t)&&(13===t&&10===e.charCodeAt(r)&&r++,a++,c=r)}return o||(r++,u=1),i=e.substring(l,r),s=13}return i+=String.fromCharCode(t),r++,s=16;case 45:if(i+=String.fromCharCode(t),r++,r===n||!kf(e.charCodeAt(r)))return s=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=function(){let t=r;if(48===e.charCodeAt(r))r++;else for(r++;r<e.length&&kf(e.charCodeAt(r));)r++;if(r<e.length&&46===e.charCodeAt(r)){if(r++,!(r<e.length&&kf(e.charCodeAt(r))))return u=3,e.substring(t,r);for(r++;r<e.length&&kf(e.charCodeAt(r));)r++}let n=r;if(r<e.length&&(69===e.charCodeAt(r)||101===e.charCodeAt(r)))if(r++,(r<e.length&&43===e.charCodeAt(r)||45===e.charCodeAt(r))&&r++,r<e.length&&kf(e.charCodeAt(r))){for(r++;r<e.length&&kf(e.charCodeAt(r));)r++;n=r}else u=3;return e.substring(t,n)}(),s=11;default:for(;r<n&&p(t);)r++,t=e.charCodeAt(r);if(o!==r){switch(i=e.substring(o,r),i){case"true":return s=8;case"false":return s=9;case"null":return s=7}return s=16}return i+=String.fromCharCode(t),r++,s=16}}function p(e){if(wf(e)||xf(e))return!1;switch(e){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}return{setPosition:function(e){r=e,i="",o=0,s=16,u=0},getPosition:()=>r,scan:t?function(){let e;do{e=f()}while(e>=12&&e<=15);return e}:f,getToken:()=>s,getTokenValue:()=>i,getTokenOffset:()=>o,getTokenLength:()=>r-o,getTokenStartLine:()=>l,getTokenStartCharacter:()=>o-h,getTokenError:()=>u}}function wf(e){return 32===e||9===e}function xf(e){return 10===e||13===e}function kf(e){return e>=48&&e<=57}bf.displayName=Lr.displayName,function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"}(vf||(vf={}));const Sf=new Array(20).fill(0).map((e,t)=>" ".repeat(t)),Ef=200,Cf={" ":{"\n":new Array(Ef).fill(0).map((e,t)=>"\n"+" ".repeat(t)),"\r":new Array(Ef).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(Ef).fill(0).map((e,t)=>"\r\n"+" ".repeat(t))},"\t":{"\n":new Array(Ef).fill(0).map((e,t)=>"\n"+"\t".repeat(t)),"\r":new Array(Ef).fill(0).map((e,t)=>"\r"+"\t".repeat(t)),"\r\n":new Array(Ef).fill(0).map((e,t)=>"\r\n"+"\t".repeat(t))}},Of=["\n","\r","\r\n"];function Nf(e,t,n){let r,i,o,s,a;if(t){for(s=t.offset,a=s+t.length,o=s;o>0&&!Tf(e,o-1);)o--;let l=a;for(;l<e.length&&!Tf(e,l);)l++;i=e.substring(o,l),r=function(e,t){let n=0,r=0;const i=t.tabSize||4;for(;n<e.length;){let t=e.charAt(n);if(t===Sf[1])r++;else{if("\t"!==t)break;r+=i}n++}return Math.floor(r/i)}(i,n)}else i=e,r=0,o=0,s=0,a=e.length;const l=function(e,t){for(let e=0;e<t.length;e++){const n=t.charAt(e);if("\r"===n)return e+1<t.length&&"\n"===t.charAt(e+1)?"\r\n":"\r";if("\n"===n)return"\n"}return e&&e.eol||"\n"}(n,e),c=Of.includes(l);let h,u=0,d=0;h=n.insertSpaces?Sf[n.tabSize||4]??Af(Sf[1],n.tabSize||4):"\t";const f="\t"===h?"\t":" ";let p=yf(i,!1),m=!1;function g(){if(u>1)return Af(l,u)+Af(h,r+d);const e=h.length*(r+d);return!c||e>Cf[f][l].length?l+Af(h,r+d):e<=0?l:Cf[f][l][e]}function v(){let e=p.scan();for(u=0;15===e||14===e;)14===e&&n.keepLines?u+=1:14===e&&(u=1),e=p.scan();return m=16===e||0!==p.getTokenError(),e}const b=[];function y(n,r,i){m||t&&!(r<a&&i>s)||e.substring(r,i)===n||b.push({offset:r,length:i-r,content:n})}let w=v();if(n.keepLines&&u>0&&y(Af(l,u),0,0),17!==w){let e=p.getTokenOffset()+o;y(h.length*r<20&&n.insertSpaces?Sf[h.length*r]:Af(h,r),o,e)}for(;17!==w;){let e=p.getTokenOffset()+p.getTokenLength()+o,t=v(),r="",i=!1;for(;0===u&&(12===t||13===t);){let n=p.getTokenOffset()+o;y(Sf[1],e,n),e=p.getTokenOffset()+p.getTokenLength()+o,i=12===t,r=i?g():"",t=v()}if(2===t)1!==w&&d--,n.keepLines&&u>0||!n.keepLines&&1!==w?r=g():n.keepLines&&(r=Sf[1]);else if(4===t)3!==w&&d--,n.keepLines&&u>0||!n.keepLines&&3!==w?r=g():n.keepLines&&(r=Sf[1]);else{switch(w){case 3:case 1:d++,r=n.keepLines&&u>0||!n.keepLines?g():Sf[1];break;case 5:r=n.keepLines&&u>0||!n.keepLines?g():Sf[1];break;case 12:r=g();break;case 13:u>0?r=g():i||(r=Sf[1]);break;case 6:n.keepLines&&u>0?r=g():i||(r=Sf[1]);break;case 10:n.keepLines&&u>0?r=g():6!==t||i||(r="");break;case 7:case 8:case 9:case 11:case 2:case 4:n.keepLines&&u>0?r=g():12!==t&&13!==t||i?5!==t&&17!==t&&(m=!0):r=Sf[1];break;case 16:m=!0}u>0&&(12===t||13===t)&&(r=g())}17===t&&(r=n.keepLines&&u>0?g():n.insertFinalNewline?l:"");y(r,e,p.getTokenOffset()+o),w=t}return b}function Af(e,t){let n="";for(let r=0;r<t;r++)n+=e;return n}function Tf(e,t){return-1!=="\r\n".indexOf(e.charAt(t))}var Mf,Rf,Df;!function(e){e.DEFAULT={allowTrailingComma:!1}}(Mf||(Mf={})),function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"}(Rf||(Rf={})),function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"}(Df||(Df={}));const Pf=function(e,t=[],n=Mf.DEFAULT){let r=null,i=[];const o=[];function s(e){Array.isArray(i)?i.push(e):null!==r&&(i[r]=e)}const a={onObjectBegin:()=>{const e={};s(e),o.push(i),i=e,r=null},onObjectProperty:e=>{r=e},onObjectEnd:()=>{i=o.pop()},onArrayBegin:()=>{const e=[];s(e),o.push(i),i=e,r=null},onArrayEnd:()=>{i=o.pop()},onLiteralValue:s,onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}};return function(e,t,n=Mf.DEFAULT){const r=yf(e,!1),i=[];let o=0;function s(e){return e?()=>0===o&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function a(e){return e?t=>0===o&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function l(e){return e?t=>0===o&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function c(e){return e?()=>{if(o>0)o++;else{!1===e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())&&(o=1)}}:()=>!0}function h(e){return e?()=>{o>0&&o--,0===o&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}const u=c(t.onObjectBegin),d=l(t.onObjectProperty),f=h(t.onObjectEnd),p=c(t.onArrayBegin),m=h(t.onArrayEnd),g=l(t.onLiteralValue),v=a(t.onSeparator),b=s(t.onComment),y=a(t.onError),w=n&&n.disallowComments,x=n&&n.allowTrailingComma;function k(){for(;;){const e=r.scan();switch(r.getTokenError()){case 4:S(14);break;case 5:S(15);break;case 3:S(13);break;case 1:w||S(11);break;case 2:S(12);break;case 6:S(16)}switch(e){case 12:case 13:w?S(10):b();break;case 16:S(1);break;case 15:case 14:break;default:return e}}}function S(e,t=[],n=[]){if(y(e),t.length+n.length>0){let e=r.getToken();for(;17!==e;){if(-1!==t.indexOf(e)){k();break}if(-1!==n.indexOf(e))break;e=k()}}}function E(e){const t=r.getTokenValue();return e?g(t):(d(t),i.push(t)),k(),!0}function C(){switch(r.getToken()){case 11:const e=r.getTokenValue();let t=Number(e);isNaN(t)&&(S(2),t=0),g(t);break;case 7:g(null);break;case 8:g(!0);break;case 9:g(!1);break;default:return!1}return k(),!0}function O(){return 10!==r.getToken()?(S(3,[],[2,5]),!1):(E(!1),6===r.getToken()?(v(":"),k(),T()||S(4,[],[2,5])):S(5,[],[2,5]),i.pop(),!0)}function N(){u(),k();let e=!1;for(;2!==r.getToken()&&17!==r.getToken();){if(5===r.getToken()){if(e||S(4,[],[]),v(","),k(),2===r.getToken()&&x)break}else e&&S(6,[],[]);O()||S(4,[],[2,5]),e=!0}return f(),2!==r.getToken()?S(7,[2],[]):k(),!0}function A(){p(),k();let e=!0,t=!1;for(;4!==r.getToken()&&17!==r.getToken();){if(5===r.getToken()){if(t||S(4,[],[]),v(","),k(),4===r.getToken()&&x)break}else t&&S(6,[],[]);e?(i.push(0),e=!1):i[i.length-1]++,T()||S(4,[],[4,5]),t=!0}return m(),e||i.pop(),4!==r.getToken()?S(8,[4],[]):k(),!0}function T(){switch(r.getToken()){case 3:return A();case 1:return N();case 10:return E(!0);default:return C()}}if(k(),17===r.getToken())return!!n.allowEmptyContent||(S(4,[],[]),!1);if(!T())return S(4,[],[]),!1;17!==r.getToken()&&S(9,[],[])}(e,a,n),i[0]};var Lf;function Bf(e,t){if(!t.length)return"JSON 格式不正确";var n=t[0],r=function(e,t){for(var n=1,r=1,i=Math.max(0,Math.min(t,e.length)),o=0;o<i;o++){"\n"===e.charAt(o)?(n++,r=1):r++}return{line:n,col:r}}(e,n.offset),i=r.line,o=r.col,s=function(e){switch(e){case 1:return"InvalidSymbol";case 2:return"InvalidNumberFormat";case 3:return"PropertyNameExpected";case 4:return"ValueExpected";case 5:return"ColonExpected";case 6:return"CommaExpected";case 7:return"CloseBraceExpected";case 8:return"CloseBracketExpected";case 9:return"EndOfFileExpected";case 10:return"InvalidCommentToken";case 11:return"UnexpectedEndOfComment";case 12:return"UnexpectedEndOfString";case 13:return"UnexpectedEndOfNumber";case 14:return"InvalidUnicode";case 15:return"InvalidEscapeCharacter";case 16:return"InvalidCharacter"}return"<unknown ParseErrorCode>"}(n.error);return"JSON 格式不正确(".concat(s,",行 ").concat(i," 列 ").concat(o,")")}function If(e){if(null==e||""===e)return{ok:!0,value:null,pretty:"null",compact:"null"};try{if("string"!=typeof e)return{ok:!0,value:e,pretty:JSON.stringify(e,null,2),compact:JSON.stringify(e)};var t=e,n=[],r=Pf(t,n,{allowTrailingComma:!0,disallowComments:!1});return n.length?{ok:!1,message:Bf(t,n),pretty:t,compact:t}:{ok:!0,value:r,pretty:JSON.stringify(r,null,2),compact:JSON.stringify(r)}}catch(t){var i="string"==typeof e?e:String(e);return{ok:!1,message:"JSON 格式不正确",pretty:i,compact:i}}}function jf(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=(e||"").toString(),r=[];if(Pf(n,r,{allowTrailingComma:!0,disallowComments:!1}),r.length)return{ok:!1,message:Bf(n,r)};for(var i=function(e,t,n){return Nf(e,t,n)}(n,void 0,{insertSpaces:!0,tabSize:t}),o=n,s=i.length-1;s>=0;s--){var a=i[s];o=o.slice(0,a.offset)+a.content+o.slice(a.offset+a.length)}return{ok:!0,formatted:o}}function _f(){return _f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_f.apply(null,arguments)}!function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"}(Lf||(Lf={}));let Ff=[],Wf=[];function zf(e){if(e<768)return!1;for(let t=0,n=Ff.length;;){let r=t+n>>1;if(e<Ff[r])n=r;else{if(!(e>=Wf[r]))return!0;t=r+1}if(t==n)return!1}}function Hf(e){return e>=127462&&e<=127487}(()=>{let e="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 t=0,n=0;t<e.length;t++)(t%2?Wf:Ff).push(n+=e[t])})();function Vf(e,t,n=!0,r=!0){return(n?qf:Uf)(e,t,r)}function qf(e,t,n){if(t==e.length)return t;t&&Kf(e.charCodeAt(t))&&Yf(e.charCodeAt(t-1))&&t--;let r=$f(e,t);for(t+=Gf(r);t<e.length;){let i=$f(e,t);if(8205==r||8205==i||n&&zf(i))t+=Gf(i),r=i;else{if(!Hf(i))break;{let n=0,r=t-2;for(;r>=0&&Hf($f(e,r));)n++,r-=2;if(n%2==0)break;t+=2}}}return t}function Uf(e,t,n){for(;t>0;){let r=qf(e,t-2,n);if(r<t)return r;t--}return 0}function $f(e,t){let n=e.charCodeAt(t);if(!Yf(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return Kf(r)?r-56320+(n-55296<<10)+65536:n}function Kf(e){return e>=56320&&e<57344}function Yf(e){return e>=55296&&e<56320}function Gf(e){return e<65536?1:2}class Xf{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]=op(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Qf.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=op(this,e,t);let n=[];return this.decompose(e,t,n,0),Qf.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),r=new tp(this),i=new tp(e);for(let e=t,o=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(o+=r.value.length,r.done||o>=n)return!0}}iter(e=1){return new tp(this,e)}iterRange(e,t=this.length){return new np(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new rp(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new Jf(e):Qf.from(Jf.split(e,[])):Xf.empty}}class Jf extends Xf{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let o=this.text[i],s=r+o.length;if((t?n:s)>=e)return new ip(r,s,n,o);r=s+1,n++}}decompose(e,t,n,r){let i=e<=0&&t>=this.length?this:new Jf(ep(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&r){let e=n.pop(),t=Zf(i.text,e.text.slice(),0,i.length);if(t.length<=32)n.push(new Jf(t,e.length+i.length));else{let e=t.length>>1;n.push(new Jf(t.slice(0,e)),new Jf(t.slice(e)))}}else n.push(i)}replace(e,t,n){if(!(n instanceof Jf))return super.replace(e,t,n);[e,t]=op(this,e,t);let r=Zf(this.text,Zf(n.text,ep(this.text,0,e)),t),i=this.length+n.length-(t-e);return r.length<=32?new Jf(r,i):Qf.from(Jf.split(r,[]),i)}sliceString(e,t=this.length,n="\n"){[e,t]=op(this,e,t);let r="";for(let i=0,o=0;i<=t&&o<this.text.length;o++){let s=this.text[o],a=i+s.length;i>e&&o&&(r+=n),e<a&&t>i&&(r+=s.slice(Math.max(0,e-i),t-i)),i=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let i of e)n.push(i),r+=i.length+1,32==n.length&&(t.push(new Jf(n,r)),n=[],r=-1);return r>-1&&t.push(new Jf(n,r)),t}}class Qf extends Xf{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let o=this.children[i],s=r+o.length,a=n+o.lines-1;if((t?a:s)>=e)return o.lineInner(e,t,n,r);r=s+1,n=a+1}}decompose(e,t,n,r){for(let i=0,o=0;o<=t&&i<this.children.length;i++){let s=this.children[i],a=o+s.length;if(e<=a&&t>=o){let i=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!i?n.push(s):s.decompose(e-o,t-o,n,i)}o=a+1}}replace(e,t,n){if([e,t]=op(this,e,t),n.lines<this.lines)for(let r=0,i=0;r<this.children.length;r++){let o=this.children[r],s=i+o.length;if(e>=i&&t<=s){let a=o.replace(e-i,t-i,n),l=this.lines-o.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let i=this.children.slice();return i[r]=a,new Qf(i,this.length-(t-e)+n.length)}return super.replace(i,s,a)}i=s+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=op(this,e,t);let r="";for(let i=0,o=0;i<this.children.length&&o<=t;i++){let s=this.children[i],a=o+s.length;o>e&&i&&(r+=n),e<a&&t>o&&(r+=s.sliceString(e-o,t-o,n)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Qf))return 0;let n=0,[r,i,o,s]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,i+=t){if(r==o||i==s)return n;let a=this.children[r],l=e.children[i];if(a!=l)return n+a.scanIdentical(l,t);n+=a.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new Jf(n,t)}let r=Math.max(32,n>>5),i=r<<1,o=r>>1,s=[],a=0,l=-1,c=[];function h(e){let t;if(e.lines>i&&e instanceof Qf)for(let t of e.children)h(t);else e.lines>o&&(a>o||!a)?(u(),s.push(e)):e instanceof Jf&&a&&(t=c[c.length-1])instanceof Jf&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new Jf(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>r&&u(),a+=e.lines,l+=e.length+1,c.push(e))}function u(){0!=a&&(s.push(1==c.length?c[0]:Qf.from(c,l)),l=-1,a=c.length=0)}for(let t of e)h(t);return u(),1==s.length?s[0]:new Qf(s,t)}}function Zf(e,t,n=0,r=1e9){for(let i=0,o=0,s=!0;o<e.length&&i<=r;o++){let a=e[o],l=i+a.length;l>=n&&(l>r&&(a=a.slice(0,r-i)),i<n&&(a=a.slice(n-i)),s?(t[t.length-1]+=a,s=!1):t.push(a)),i=l+1}return t}function ep(e,t,n){return Zf(e,[""],t,n)}Xf.empty=new Jf([""],0);class tp{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 Jf?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],o=i>>1,s=r instanceof Jf?r.text.length:r.children.length;if(o==(t>0?s:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&i)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(r instanceof Jf){let i=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=0==e?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[o+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof Jf?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class np{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new tp(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:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.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 rp{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=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=r,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(Xf.prototype[Symbol.iterator]=function(){return this.iter()},tp.prototype[Symbol.iterator]=np.prototype[Symbol.iterator]=rp.prototype[Symbol.iterator]=function(){return this});class ip{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}}function op(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function sp(e,t,n=!0,r=!0){return Vf(e,t,n,r)}function ap(e,t){let n=e.charCodeAt(t);if(!(r=n,r>=55296&&r<56320&&t+1!=e.length))return n;var r;let i=e.charCodeAt(t+1);return function(e){return e>=56320&&e<57344}(i)?i-56320+(n-55296<<10)+65536:n}function lp(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}function cp(e){return e<65536?1:2}const hp=/\r\n?|\n/;var up=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(up||(up={}));class dp{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 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],o=this.sections[t++];o<0?(e(n,r,i),r+=i):r+=o,n+=i}}iterChangedRanges(e,t=!1){gp(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];r<0?e.push(n,r):e.push(r,n)}return new dp(e)}composeDesc(e){return this.empty?e:e.empty?this:bp(this,e)}mapDesc(e,t=!1){return e.empty?this:vp(this,e,t)}mapPos(e,t=-1,n=up.Simple){let r=0,i=0;for(let o=0;o<this.sections.length;){let s=this.sections[o++],a=this.sections[o++],l=r+s;if(a<0){if(l>e)return i+(e-r);i+=s}else{if(n!=up.Simple&&l>=e&&(n==up.TrackDel&&r<e&&l>e||n==up.TrackBefore&&r<e||n==up.TrackAfter&&l>e))return null;if(l>e||l==e&&t<0&&!s)return e==r||t<0?i:i+a;i+=a}r=l}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=r+this.sections[n++];if(this.sections[n++]>=0&&r<=t&&i>=e)return!(r<e&&i>t)||"cover";r=i}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+n+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeDesc");return new dp(e)}static create(e){return new dp(e)}}class fp extends dp{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 gp(this,(t,n,r,i,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return vp(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,i=0;r<t.length;r+=2){let o=t[r],s=t[r+1];if(s>=0){t[r]=s,t[r+1]=o;let a=r>>1;for(;n.length<a;)n.push(Xf.empty);n.push(o?e.slice(i,i+o):Xf.empty)}i+=o}return new fp(t,n)}compose(e){return this.empty?e:e.empty?this:bp(this,e,!0)}map(e,t=!1){return e.empty?this:vp(this,e,t,!0)}iterChanges(e,t=!1){gp(this,e,t)}get desc(){return dp.create(this.sections)}filter(e){let t=[],n=[],r=[],i=new yp(this);e:for(let o=0,s=0;;){let a=o==e.length?1e9:e[o++];for(;s<a||s==a&&0==i.len;){if(i.done)break e;let e=Math.min(i.len,a-s);pp(r,e,-1);let o=-1==i.ins?-1:0==i.off?i.ins:0;pp(t,e,o),o>0&&mp(n,t,i.text),i.forward(e),s+=e}let l=e[o++];for(;s<l;){if(i.done)break e;let e=Math.min(i.len,l-s);pp(t,e,-1),pp(r,e,-1==i.ins?-1:0==i.off?i.ins:0),i.forward(e),s+=e}}return{changes:new fp(t,n),filtered:dp.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):0==r?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let r=[],i=[],o=0,s=null;function a(e=!1){if(!e&&!r.length)return;o<t&&pp(r,t-o,-1);let n=new fp(r,i);s=s?s.compose(n.map(s)):n,r=[],i=[],o=0}return function e(l){if(Array.isArray(l))for(let t of l)e(t);else if(l instanceof fp){if(l.length!=t)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${t})`);a(),s=s?s.compose(l.map(s)):l}else{let{from:e,to:s=e,insert:c}=l;if(e>s||e<0||s>t)throw new RangeError(`Invalid change range ${e} to ${s} (in doc of length ${t})`);let h=c?"string"==typeof c?Xf.of(c.split(n||hp)):c:Xf.empty,u=h.length;if(e==s&&0==u)return;e<o&&a(),e>o&&pp(r,e-o,-1),pp(r,s-e,u),mp(i,r,h),o=s}}(e),a(!s),s}static empty(e){return new fp(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if("number"==typeof i)t.push(i,-1);else{if(!Array.isArray(i)||"number"!=typeof i[0]||i.some((e,t)=>t&&"string"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==i.length)t.push(i[0],0);else{for(;n.length<r;)n.push(Xf.empty);n[r]=Xf.of(i.slice(1)),t.push(i[0],n[r].length)}}}return new fp(t,n)}static createSet(e,t){return new fp(e,t)}}function pp(e,t,n,r=!1){if(0==t&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&0==t&&0==e[i]?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function mp(e,t,n){if(0==n.length)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(Xf.empty);e.push(n)}}function gp(e,t,n){let r=e.inserted;for(let i=0,o=0,s=0;s<e.sections.length;){let a=e.sections[s++],l=e.sections[s++];if(l<0)i+=a,o+=a;else{let c=i,h=o,u=Xf.empty;for(;c+=a,h+=l,l&&r&&(u=u.append(r[s-2>>1])),!(n||s==e.sections.length||e.sections[s+1]<0);)a=e.sections[s++],l=e.sections[s++];t(i,c,o,h,u),i=c,o=h}}}function vp(e,t,n,r=!1){let i=[],o=r?[]:null,s=new yp(e),a=new yp(t);for(let e=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(-1==s.ins&&-1==a.ins){let e=Math.min(s.len,a.len);pp(i,e,-1),s.forward(e),a.forward(e)}else if(a.ins>=0&&(s.ins<0||e==s.i||0==s.off&&(a.len<s.len||a.len==s.len&&!n))){let t=a.len;for(pp(i,a.ins,-1);t;){let n=Math.min(s.len,t);s.ins>=0&&e<s.i&&s.len<=n&&(pp(i,0,s.ins),o&&mp(o,i,s.text),e=s.i),s.forward(n),t-=n}a.next()}else{if(!(s.ins>=0)){if(s.done&&a.done)return o?fp.createSet(i,o):dp.create(i);throw new Error("Mismatched change set lengths")}{let t=0,n=s.len;for(;n;)if(-1==a.ins){let e=Math.min(n,a.len);t+=e,n-=e,a.forward(e)}else{if(!(0==a.ins&&a.len<n))break;n-=a.len,a.next()}pp(i,t,e<s.i?s.ins:0),o&&e<s.i&&mp(o,i,s.text),e=s.i,s.forward(s.len-n)}}}}function bp(e,t,n=!1){let r=[],i=n?[]:null,o=new yp(e),s=new yp(t);for(let e=!1;;){if(o.done&&s.done)return i?fp.createSet(r,i):dp.create(r);if(0==o.ins)pp(r,o.len,0,e),o.next();else if(0!=s.len||s.done){if(o.done||s.done)throw new Error("Mismatched change set lengths");{let t=Math.min(o.len2,s.len),n=r.length;if(-1==o.ins){let n=-1==s.ins?-1:s.off?0:s.ins;pp(r,t,n,e),i&&n&&mp(i,r,s.text)}else-1==s.ins?(pp(r,o.off?0:o.len,t,e),i&&mp(i,r,o.textBit(t))):(pp(r,o.off?0:o.len,s.off?0:s.ins,e),i&&!s.off&&mp(i,r,s.text));e=(o.ins>t||s.ins>=0&&s.len>t)&&(e||r.length>n),o.forward2(t),s.forward(t)}}else pp(r,0,s.ins,e),i&&mp(i,r,s.text),s.next()}}class yp{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-2==this.ins}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?Xf.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Xf.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class wp{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new wp(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return xp.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return xp.range(this.anchor,n)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||this.goalColumn!=e.goalColumn||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return xp.range(e.anchor,e.head)}static create(e,t,n){return new wp(e,t,n)}}class xp{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:xp.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 1==this.ranges.length?this:new xp([this.main],0)}addRange(e,t=!0){return xp.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,xp.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)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new xp(e.ranges.map(e=>wp.fromJSON(e)),e.main)}static single(e,t=e){return new xp([xp.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;r<e.length;r++){let i=e[r];if(i.empty?i.from<=n:i.from<n)return xp.normalized(e.slice(),t);n=i.to}return new xp(e,t)}static cursor(e,t=0,n,r){return wp.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=r?r:16777215)<<6)}static range(e,t,n,r){let i=(null!=n?n:16777215)<<6|(null==r?7:Math.min(6,r));return t<e?wp.create(t,e,48|i):wp.create(e,t,(t>e?8:0)|i)}static normalized(e,t=0){let n=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(n);for(let n=1;n<e.length;n++){let r=e[n],i=e[n-1];if(r.empty?r.from<=i.to:r.from<i.to){let o=i.from,s=Math.max(r.to,i.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?xp.range(s,o):xp.range(o,s))}}return new xp(e,t)}}function kp(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let Sp=0;class Ep{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=Sp++,this.default=e([]),this.extensions="function"==typeof i?i(this):i}get reader(){return this}static define(e={}){return new Ep(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:Cp),!!e.static,e.enables)}of(e){return new Op([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Op(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Op(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}}function Cp(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class Op{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Sp++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,i=this.id,o=e[i]>>1,s=2==this.type,a=!1,l=!1,c=[];for(let n of this.dependencies)"doc"==n?a=!0:"selection"==n?l=!0:1&(null!==(t=e[n.id])&&void 0!==t?t:1)||c.push(e[n.id]);return{create:e=>(e.values[o]=n(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||Ap(e,c)){let t=n(e);if(s?!Np(t,e.values[o],r):!r(t,e.values[o]))return e.values[o]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[i];if(null!=l){let i=Vp(t,l);if(this.dependencies.every(n=>n instanceof Ep?t.facet(n)===e.facet(n):!(n instanceof Rp)||t.field(n,!1)==e.field(n,!1))||(s?Np(a=n(e),i,r):r(a=n(e),i)))return e.values[o]=i,0}else a=n(e);return e.values[o]=a,1}}}}function Np(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function Ap(e,t){let n=!1;for(let r of t)1&Hp(e,r)&&(n=!0);return n}function Tp(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),o=r.filter(e=>!(1&e)),s=e[t.id]>>1;function a(e){let n=[];for(let t=0;t<r.length;t++){let o=Vp(e,r[t]);if(2==i[t])for(let e of o)n.push(e);else n.push(o)}return t.combine(n)}return{create(e){for(let t of r)Hp(e,t);return e.values[s]=a(e),1},update(e,n){if(!Ap(e,o))return 0;let r=a(e);return t.compare(r,e.values[s])?0:(e.values[s]=r,1)},reconfigure(e,i){let o=Ap(e,r),l=i.config.facets[t.id],c=i.facet(t);if(l&&!o&&Cp(n,l))return e.values[s]=c,0;let h=a(e);return t.compare(h,c)?(e.values[s]=c,0):(e.values[s]=h,1)}}}const Mp=Ep.define({static:!0});class Rp{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(e){let t=new Rp(Sp++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Mp).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r,i=e.facet(Mp),o=n.facet(Mp);return(r=i.find(e=>e.field==this))&&r!=o.find(e=>e.field==this)?(e.values[t]=r.create(e),1):null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,Mp.of({field:this,create:e})]}get extension(){return this}}const Dp=4,Pp=3,Lp=2,Bp=1;function Ip(e){return t=>new _p(t,e)}const jp={highest:Ip(0),high:Ip(Bp),default:Ip(Lp),low:Ip(Pp),lowest:Ip(Dp)};class _p{constructor(e,t){this.inner=e,this.prec=t}}class Fp{of(e){return new Wp(this,e)}reconfigure(e){return Fp.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Wp{constructor(e,t){this.compartment=e,this.inner=t}}class zp{constructor(e,t,n,r,i,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let r=[],i=Object.create(null),o=new Map;for(let n of function(e,t,n){let r=[[],[],[],[],[]],i=new Map;function o(e,s){let a=i.get(e);if(null!=a){if(a<=s)return;let t=r[a].indexOf(e);t>-1&&r[a].splice(t,1),e instanceof Wp&&n.delete(e.compartment)}if(i.set(e,s),Array.isArray(e))for(let t of e)o(t,s);else if(e instanceof Wp){if(n.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),o(r,s)}else if(e instanceof _p)o(e.inner,e.prec);else if(e instanceof Rp)r[s].push(e),e.provides&&o(e.provides,s);else if(e instanceof Op)r[s].push(e),e.facet.extensions&&o(e.facet.extensions,Lp);else{let t=e.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(t,s)}}return o(e,Lp),r.reduce((e,t)=>e.concat(t))}(e,t,o))n instanceof Rp?r.push(n):(i[n.facet.id]||(i[n.facet.id]=[])).push(n);let s=Object.create(null),a=[],l=[];for(let e of r)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let c=null==n?void 0:n.config.facets;for(let e in i){let t=i[e],r=t[0].facet,o=c&&c[e]||[];if(t.every(e=>0==e.type))if(s[r.id]=a.length<<1|1,Cp(o,t))a.push(n.facet(r));else{let e=r.combine(t.map(e=>e.value));a.push(n&&r.compare(e,n.facet(r))?n.facet(r):e)}else{for(let e of t)0==e.type?(s[e.id]=a.length<<1|1,a.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[r.id]=l.length<<1,l.push(e=>Tp(e,r,t))}}let h=l.map(e=>e(s));return new zp(e,o,h,s,a,i)}}function Hp(e,t){if(1&t)return 2;let n=t>>1,r=e.status[n];if(4==r)throw new Error("Cyclic dependency between fields and/or facets");if(2&r)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Vp(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const qp=Ep.define(),Up=Ep.define({combine:e=>e.some(e=>e),static:!0}),$p=Ep.define({combine:e=>e.length?e[0]:void 0,static:!0}),Kp=Ep.define(),Yp=Ep.define(),Gp=Ep.define(),Xp=Ep.define({combine:e=>!!e.length&&e[0]});class Jp{constructor(e,t){this.type=e,this.value=t}static define(){return new Qp}}class Qp{of(e){return new Jp(this,e)}}class Zp{constructor(e){this.map=e}of(e){return new em(this,e)}}class em{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new em(this.type,t)}is(e){return this.type==e}static define(e={}){return new Zp(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}}em.reconfigure=em.define(),em.appendConfig=em.define();class tm{constructor(e,t,n,r,i,o){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=i,this.scrollIntoView=o,this._doc=null,this._state=null,n&&kp(n,t.newLength),i.some(e=>e.type==tm.time)||(this.annotations=i.concat(tm.time.of(Date.now())))}static create(e,t,n,r,i,o){return new tm(e,t,n,r,i,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(tm.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function nm(e,t){let n=[];for(let r=0,i=0;;){let o,s;if(r<e.length&&(i==t.length||t[i]>=e[r]))o=e[r++],s=e[r++];else{if(!(i<t.length))return n;o=t[i++],s=t[i++]}!n.length||n[n.length-1]<o?n.push(o,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function rm(e,t,n){var r;let i,o,s;return n?(i=t.changes,o=fp.empty(t.changes.length),s=e.changes.compose(t.changes)):(i=t.changes.map(e.changes),o=e.changes.mapDesc(t.changes,!0),s=e.changes.compose(i)),{changes:s,selection:t.selection?t.selection.map(o):null===(r=e.selection)||void 0===r?void 0:r.map(i),effects:em.mapEffects(e.effects,i).concat(em.mapEffects(t.effects,o)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function im(e,t,n){let r=t.selection,i=am(t.annotations);return t.userEvent&&(i=i.concat(tm.userEvent.of(t.userEvent))),{changes:t.changes instanceof fp?t.changes:fp.of(t.changes||[],n,e.facet($p)),selection:r&&(r instanceof xp?r:xp.single(r.anchor,r.head)),effects:am(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function om(e,t,n){let r=im(e,t.length?t[0]:{},e.doc.length);t.length&&!1===t[0].filter&&(n=!1);for(let i=1;i<t.length;i++){!1===t[i].filter&&(n=!1);let o=!!t[i].sequential;r=rm(r,im(e,t[i],o?r.changes.newLength:e.doc.length),o)}let i=tm.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return function(e){let t=e.startState,n=t.facet(Gp),r=e;for(let i=n.length-1;i>=0;i--){let o=n[i](e);o&&Object.keys(o).length&&(r=rm(r,im(t,o,e.changes.newLength),!0))}return r==e?e:tm.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}(n?function(e){let t=e.startState,n=!0;for(let r of t.facet(Kp)){let t=r(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:nm(n,t))}if(!0!==n){let r,i;if(!1===n)i=e.changes.invertedDesc,r=fp.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=tm.create(t,r,e.selection&&e.selection.map(i),em.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(Yp);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof tm?i:Array.isArray(i)&&1==i.length&&i[0]instanceof tm?i[0]:om(t,am(i),!1)}return e}(i):i)}tm.time=Jp.define(),tm.userEvent=Jp.define(),tm.addToHistory=Jp.define(),tm.remote=Jp.define();const sm=[];function am(e){return null==e?sm:Array.isArray(e)?e:[e]}var lm=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(lm||(lm={}));const cm=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let hm;try{hm=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function um(e){return t=>{if(!/\S/.test(t))return lm.Space;if(function(e){if(hm)return hm.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||cm.test(n)))return!0}return!1}(t))return lm.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return lm.Word;return lm.Other}}class dm{constructor(e,t,n,r,i,o){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,o&&(o._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)Hp(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null!=n)return Hp(this,n),Vp(this,n);if(t)throw new RangeError("Field is not present in this state")}update(...e){return om(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:r,compartments:i}=n;for(let t of e.effects)t.is(Fp.reconfigure)?(n&&(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),n=null),i.set(t.value.compartment,t.value.extension)):t.is(em.reconfigure)?(n=null,r=t.value):t.is(em.appendConfig)&&(n=null,r=am(r).concat(t.value));if(n)t=e.startState.values.slice();else{n=zp.resolve(r,i,this);let e=new dm(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null);t=e.values}let o=e.startState.facet(Up)?e.newSelection:e.newSelection.asSingle();new dm(n,e.newDoc,o,t,(t,n)=>n.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:xp.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],o=am(n.effects);for(let n=1;n<t.ranges.length;n++){let s=e(t.ranges[n]),a=this.changes(s.changes),l=a.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(l);let c=r.mapDesc(a,!0);i.push(s.range.map(c)),r=r.compose(l),o=em.mapEffects(o,l).concat(em.mapEffects(am(s.effects),c))}return{changes:r,selection:xp.create(i,t.mainIndex),effects:o}}changes(e=[]){return e instanceof fp?e:fp.of(e,this.doc.length,this.facet(dm.lineSeparator))}toText(e){return Xf.of(e.split(this.facet(dm.lineSeparator)||hp))}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 null==t?e.default:(Hp(this,t),Vp(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Rp&&null!=this.config.address[r.id]&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||"string"!=typeof e.doc)throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(n)for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let i=n[t],o=e[t];r.push(i.init(e=>i.spec.fromJSON(o,e)))}return dm.create({doc:e.doc,selection:xp.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=zp.resolve(e.extensions||[],new Map),n=e.doc instanceof Xf?e.doc:Xf.of((e.doc||"").split(t.staticFacet(dm.lineSeparator)||hp)),r=e.selection?e.selection instanceof xp?e.selection:xp.single(e.selection.anchor,e.selection.head):xp.single(0);return kp(r,n.length),t.staticFacet(Up)||(r=r.asSingle()),new dm(t,n,r,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(dm.tabSize)}get lineBreak(){return this.facet(dm.lineSeparator)||"\n"}get readOnly(){return this.facet(Xp)}phrase(e,...t){for(let t of this.facet(dm.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,n)=>{if("$"==n)return"$";let r=+(n||1);return!r||r>t.length?e:t[r-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(qp))for(let o of i(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return um(t.length?t[0]:"")}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),o=e-n,s=e-n;for(;o>0;){let e=sp(t,o,!1);if(i(t.slice(e,o))!=lm.Word)break;o=e}for(;s<r;){let e=sp(t,s);if(i(t.slice(s,e))!=lm.Word)break;s=e}return o==s?null:xp.range(o+n,s+n)}}function fm(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],o=r[e];if(void 0===o)r[e]=i;else if(o===i||void 0===i);else{if(!Object.hasOwnProperty.call(n,e))throw new Error("Config merge conflict for field "+e);r[e]=n[e](o,i)}}for(let e in t)void 0===r[e]&&(r[e]=t[e]);return r}dm.allowMultipleSelections=Up,dm.tabSize=Ep.define({combine:e=>e.length?e[0]:4}),dm.lineSeparator=$p,dm.readOnly=Xp,dm.phrases=Ep.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),dm.languageData=qp,dm.changeFilter=Kp,dm.transactionFilter=Yp,dm.transactionExtender=Gp,Fp.reconfigure=em.define();class pm{eq(e){return this==e}range(e,t=e){return gm.create(e,t,this)}}function mm(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}pm.prototype.startSide=pm.prototype.endSide=0,pm.prototype.point=!1,pm.prototype.mapMode=up.TrackDel;let gm=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function vm(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class bm{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let o=r,s=i.length;;){if(o==s)return o;let r=o+s>>1,a=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==o)return a>=0?o:s;a>=0?s=r:o=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,i);i<o;i++)if(!1===r(this.from[i]+e,this.to[i]+e,this.value[i]))return!1}map(e,t){let n=[],r=[],i=[],o=-1,s=-1;for(let a=0;a<this.value.length;a++){let l,c,h=this.value[a],u=this.from[a]+e,d=this.to[a]+e;if(u==d){let e=t.mapPos(u,h.startSide,h.mapMode);if(null==e)continue;if(l=c=e,h.startSide!=h.endSide&&(c=t.mapPos(u,h.endSide),c<l))continue}else if(l=t.mapPos(u,h.startSide),c=t.mapPos(d,h.endSide),l>c||l==c&&h.startSide>0&&h.endSide<=0)continue;(c-l||h.endSide-h.startSide)<0||(o<0&&(o=l),h.point&&(s=Math.max(s,c-l)),n.push(h),r.push(l-o),i.push(c-o))}return{mapped:n.length?new bm(r,i,n,s):null,pos:o}}}class ym{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new ym(e,t,n,r)}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:r=0,filterTo:i=this.length}=e,o=e.filter;if(0==t.length&&!o)return this;if(n&&(t=t.slice().sort(vm)),this.isEmpty)return t.length?ym.of(t):this;let s=new km(this,null,-1).goto(0),a=0,l=[],c=new wm;for(;s.value||a<t.length;)if(a<t.length&&(s.from-t[a].from||s.startSide-t[a].value.startSide)>=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==s.rangeIndex&&s.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(s.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(s.chunkIndex)||i<this.chunkPos[s.chunkIndex])&&c.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||r>s.to||i<s.from||o(s.from,s.to,s.value))&&(c.addInner(s.from,s.to,s.value)||l.push(gm.create(s.from,s.to,s.value))),s.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?ym.empty:this.nextLayer.update({add:l,filter:o,filterFrom:r,filterTo:i}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],r=-1;for(let i=0;i<this.chunk.length;i++){let o=this.chunkPos[i],s=this.chunk[i],a=e.touchesRange(o,o+s.length);if(!1===a)r=Math.max(r,s.maxPoint),t.push(s),n.push(e.mapPos(o));else if(!0===a){let{mapped:i,pos:a}=s.map(o,e);i&&(r=Math.max(r,i.maxPoint),t.push(i),n.push(a))}}let i=this.nextLayer.map(e);return 0==t.length?i:new ym(n,t,i||ym.empty,r)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],o=this.chunk[r];if(t>=i&&e<=i+o.length&&!1===o.between(i,e-i,t-i,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return Sm.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Sm.from(e).goto(t)}static compare(e,t,n,r,i=-1){let o=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),a=xm(o,s,n),l=new Cm(o,a,i),c=new Cm(s,a,i);n.iterGaps((e,t,n)=>Om(l,e,c,t,n,r)),n.empty&&0==n.length&&Om(l,0,c,0,0,r)}static eq(e,t,n=0,r){null==r&&(r=999999999);let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),o=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=o.length)return!1;if(!i.length)return!0;let s=xm(i,o),a=new Cm(i,s,0).goto(n),l=new Cm(o,s,0).goto(n);for(;;){if(a.to!=l.to||!Nm(a.active,l.active)||a.point&&(!l.point||!mm(a.point,l.point)))return!1;if(a.to>r)return!0;a.next(),l.next()}}static spans(e,t,n,r,i=-1){let o=new Cm(e,null,i).goto(t),s=t,a=o.openStart;for(;;){let e=Math.min(o.to,n);if(o.point){let n=o.activeForPoint(o.to),i=o.pointFrom<t?n.length+1:o.point.startSide<0?n.length:Math.min(n.length,a);r.point(s,e,o.point,n,i,o.pointRank),a=Math.min(o.openEnd(e),n.length)}else e>s&&(r.span(s,e,o.active,a),a=o.openEnd(e));if(o.to>n)return a+(o.point&&o.to>n?1:0);s=o.to,o.next()}}static of(e,t=!1){let n=new wm;for(let r of e instanceof gm?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(vm(t,r)>0)return e.slice().sort(vm);t=r}return e}(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return ym.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=ym.empty;r=r.nextLayer)t=new ym(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}ym.empty=new ym([],[],null,-1),ym.empty.nextLayer=ym.empty;class wm{finishChunk(e){this.chunks.push(new bm(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 wm)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(r<0)&&(250==this.from.length&&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(ym.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=ym.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function xm(e,t,n){let r=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&r.set(t.chunk[e],t.chunkPos[e]);let i=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let o=r.get(e.chunk[t]);null==o||(n?n.mapPos(o):o)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(o,o+e.chunk[t].length))||i.add(e.chunk[t])}return i}class km{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}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 t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}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}{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 Sm{constructor(e){this.heap=e}static from(e,t=null,n=-1){let r=[];for(let i=0;i<e.length;i++)for(let o=e[i];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&r.push(new km(o,t,n,i));return 1==r.length?r[0]:new Sm(r)}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 e=this.heap.length>>1;e>=0;e--)Em(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)Em(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)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(),Em(this.heap,0)}}}function Em(e,t){for(let n=e[t];;){let r=1+(t<<1);if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}class Cm{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=Sm.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){Am(this.active,e),Am(this.activeTo,e),Am(this.activeRank,e),this.minActive=Mm(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;Tm(this.active,t,n),Tm(this.activeTo,t,r),Tm(this.activeRank,t,i),e&&Tm(e,t,this.cursor.from),this.minActive=Mm(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&Am(n,r)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(n),this.cursor.next()}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)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 Om(e,t,n,r,i,o){e.goto(t),n.goto(r);let s=r+i,a=r,l=r-t,c=!!o.boundChange;for(let t=!1;;){let r=e.to+l-n.to,i=r||e.endSide-n.endSide,h=i<0?e.to+l:n.to,u=Math.min(h,s);if(e.point||n.point?(e.point&&n.point&&mm(e.point,n.point)&&Nm(e.activeForPoint(e.to),n.activeForPoint(n.to))||o.comparePoint(a,u,e.point,n.point),t=!1):(t&&o.boundChange(a),u>a&&!Nm(e.active,n.active)&&o.compareRange(a,u,e.active,n.active),c&&u<s&&(r||e.openEnd(h)!=n.openEnd(h))&&(t=!0)),h>s)break;a=h,i<=0&&e.next(),i>=0&&n.next()}}function Nm(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!mm(e[n],t[n]))return!1;return!0}function Am(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function Tm(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function Mm(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}function Rm(e,t,n=e.length){let r=0;for(let i=0;i<n&&i<e.length;)9==e.charCodeAt(i)?(r+=t-r%t,i++):(r++,i=sp(e,i));return r}function Dm(e,t,n,r){for(let r=0,i=0;;){if(i>=t)return r;if(r==e.length)break;i+=9==e.charCodeAt(r)?n-i%n:1,r=sp(e,r)}return!0===r?-1:e.length}const Pm="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),Lm="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),Bm="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class Im{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,o,s){let a=[],l=/^@(\w+)\b/.exec(e[0]),c=l&&"keyframes"==l[1];if(l&&null==t)return o.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),s,o);else if(s&&"object"==typeof s){if(!l)throw new RangeError("The value of a property ("+n+") should be a primitive value.");i(r(n),s,a,c)}else null!=s&&a.push(n.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+s+";")}(a.length||c)&&o.push((!n||l||s?e:e.map(n)).join(", ")+" {"+a.join(" ")+"}")}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=Bm[Pm]||1;return Bm[Pm]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let r=e[Lm],i=n&&n.nonce;r?i&&r.setNonce(i):r=new _m(e,i),r.mount(Array.isArray(t)?t:[t],e)}}let jm=new Map;class _m{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=jm.get(n);if(t)return e[Lm]=t;this.sheet=new r.CSSStyleSheet,jm.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Lm]=this}mount(e,t){let n=this.sheet,r=0,i=0;for(let t=0;t<e.length;t++){let o=e[t],s=this.modules.indexOf(o);if(s<i&&s>-1&&(this.modules.splice(s,1),i--,s=-1),-1==s){if(this.modules.splice(i++,0,o),n)for(let e=0;e<o.rules.length;e++)n.insertRule(o.rules[e],r++)}else{for(;i<s;)r+=this.modules[i++].rules.length;r+=o.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var Fm={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:"'"},Wm={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},zm="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Hm="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Vm=0;Vm<10;Vm++)Fm[48+Vm]=Fm[96+Vm]=String(Vm);for(Vm=1;Vm<=24;Vm++)Fm[Vm+111]="F"+Vm;for(Vm=65;Vm<=90;Vm++)Fm[Vm]=String.fromCharCode(Vm+32),Wm[Vm]=String.fromCharCode(Vm);for(var qm in Fm)Wm.hasOwnProperty(qm)||(Wm[qm]=Fm[qm]);function Um(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];"string"==typeof i?e.setAttribute(r,i):null!=i&&(e[r]=i)}t++}for(;t<arguments.length;t++)$m(e,arguments[t]);return e}function $m(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var n=0;n<t.length;n++)$m(e,t[n])}}let Km="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Ym="undefined"!=typeof document?document:{documentElement:{style:{}}};const Gm=/Edge\/(\d+)/.exec(Km.userAgent),Xm=/MSIE \d/.test(Km.userAgent),Jm=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Km.userAgent),Qm=!!(Xm||Jm||Gm),Zm=!Qm&&/gecko\/(\d+)/i.test(Km.userAgent),eg=!Qm&&/Chrome\/(\d+)/.exec(Km.userAgent),tg="webkitFontSmoothing"in Ym.documentElement.style,ng=!Qm&&/Apple Computer/.test(Km.vendor),rg=ng&&(/Mobile\/\w+/.test(Km.userAgent)||Km.maxTouchPoints>2);var ig={mac:rg||/Mac/.test(Km.platform),windows:/Win/.test(Km.platform),linux:/Linux|X11/.test(Km.platform),ie:Qm,ie_version:Xm?Ym.documentMode||6:Jm?+Jm[1]:Gm?+Gm[1]:0,gecko:Zm,gecko_version:Zm?+(/Firefox\/(\d+)/.exec(Km.userAgent)||[0,0])[1]:0,chrome:!!eg,chrome_version:eg?+eg[1]:0,ios:rg,android:/Android\b/.test(Km.userAgent),webkit:tg,webkit_version:tg?+(/\bAppleWebKit\/(\d+)/.exec(Km.userAgent)||[0,0])[1]:0,safari:ng,safari_version:ng?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Km.userAgent)||[0,0])[1]:0,tabSize:null!=Ym.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function og(e,t){for(let n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}const sg=Object.create(null);function ag(e,t,n){if(e==t)return!0;e||(e=sg),t||(t=sg);let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let o of r)if(o!=n&&(-1==i.indexOf(o)||e[o]!==t[o]))return!1;return!0}function lg(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,"style"==i?e.style.cssText="":e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,"style"==i?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function cg(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}class hg{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 ug=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(ug||(ug={}));class dg extends pm{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new fg(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 mg(e,t,t,n,e.widget||null,!1)}static replace(e){let t,n,r=!!e.block;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:i,end:o}=gg(e,r);t=(i?r?-3e8:-1:5e8)-1,n=1+(o?r?2e8:1:-6e8)}return new mg(e,t,n,r,e.widget||null,!0)}static line(e){return new pg(e)}static set(e,t=!1){return ym.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}dg.none=ym.empty;class fg extends dg{constructor(e){let{start:t,end:n}=gg(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?og(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||sg}eq(e){return this==e||e instanceof fg&&this.tagName==e.tagName&&ag(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}fg.prototype.point=!1;class pg extends dg{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof pg&&this.spec.class==e.spec.class&&ag(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)}}pg.prototype.mapMode=up.TrackBefore,pg.prototype.point=!0;class mg extends dg{constructor(e,t,n,r,i,o){super(t,n,i,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?up.TrackBefore:up.TrackAfter:up.TrackDel}get type(){return this.startSide!=this.endSide?ug.WidgetRange:this.startSide<=0?ug.WidgetBefore:ug.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof mg&&(t=this.widget,n=e.widget,t==n||!!(t&&n&&t.compare(n)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide;var t,n}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)}}function gg(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return null==n&&(n=e.inclusive),null==r&&(r=e.inclusive),{start:null!=n?n:t,end:null!=r?r:t}}function vg(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}mg.prototype.point=!0;class bg extends pm{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof bg&&this.tagName==e.tagName&&ag(this.attributes,e.attributes)}static create(e){return new bg(e.tagName,e.attributes||sg)}static set(e,t=!1){return ym.of(e,t)}}function yg(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function wg(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function xg(e,t){if(!t.anchorNode)return!1;try{return wg(e,t.anchorNode)}catch(e){return!1}}function kg(e){return 3==e.nodeType?Bg(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function Sg(e,t,n,r){return!!n&&(Og(e,t,n,r,-1)||Og(e,t,n,r,1))}function Eg(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function Cg(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function Og(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Ng(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=Eg(e)+(i<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(i<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=i<0?Ng(e):0}}}function Ng(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Ag(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function Tg(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function Mg(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}bg.prototype.startSide=bg.prototype.endSide=-1;class Rg{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?Ng(t):0),n,Math.min(e.focusOffset,n?Ng(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}}let Dg,Pg=null;function Lg(e){if(e.setActive)return e.setActive();if(Pg)return e.focus(Pg);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==Pg?{get preventScroll(){return Pg={preventScroll:!0},!0}}:void 0),!Pg){Pg=!1;for(let e=0;e<t.length;){let n=t[e++],r=t[e++],i=t[e++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}}}function Bg(e,t,n=t){let r=Dg||(Dg=document.createRange());return r.setEnd(e,n),r.setStart(e,t),r}function Ig(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let o=new KeyboardEvent("keydown",i);o.synthetic=!0,e.dispatchEvent(o);let s=new KeyboardEvent("keyup",i);return s.synthetic=!0,e.dispatchEvent(s),o.defaultPrevented||s.defaultPrevented}function jg(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function _g(e,t){for(let n=e,r=t;;){if(3==n.nodeType&&r>0)return{node:n,offset:r};if(1==n.nodeType&&r>0){if("false"==n.contentEditable)return null;n=n.childNodes[r-1],r=Ng(n)}else{if(!n.parentNode||Cg(n))return null;r=Eg(n),n=n.parentNode}}}function Fg(e,t){for(let n=e,r=t;;){if(3==n.nodeType&&r<n.nodeValue.length)return{node:n,offset:r};if(1==n.nodeType&&r<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[r],r=0}else{if(!n.parentNode||Cg(n))return null;r=Eg(n)+1,n=n.parentNode}}}ig.safari&&ig.safari_version>=26&&(Pg=!1);class Wg{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new Wg(e.parentNode,Eg(e),t)}static after(e,t){return new Wg(e.parentNode,Eg(e)+1,t)}}var zg=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(zg||(zg={}));const Hg=zg.LTR,Vg=zg.RTL;function qg(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}const Ug=qg("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),$g=qg("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Kg=Object.create(null),Yg=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);Kg[t]=n,Kg[n]=-t}function Gg(e){return e<=247?Ug[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?$g[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}const Xg=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Jg{get dir(){return this.level%2?Vg:Hg}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,r){let i=-1;for(let o=0;o<e.length;o++){let s=e[o];if(s.from<=t&&s.to>=t){if(s.level==n)return o;(i<0||(0!=r?r<0?s.from<t:s.to>t:e[i].level>s.level))&&(i=o)}}if(i<0)throw new RangeError("Index out of range");return i}}function Qg(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!Qg(r.inner,i.inner))return!1}return!0}const Zg=[];function ev(e,t,n,r,i,o,s){let a=r%2?2:1;if(r%2==i%2)for(let l=t,c=0;l<n;){let t=!0,h=!1;if(c==o.length||l<o[c].from){let e=Zg[l];e!=a&&(t=!1,h=16==e)}let u=t||1!=a?null:[],d=t?r:r+1,f=l;e:for(;;)if(c<o.length&&f==o[c].from){if(h)break e;let p=o[c];if(!t)for(let e=p.to,t=c+1;;){if(e==n)break e;if(!(t<o.length&&o[t].from==e)){if(Zg[e]==a)break e;break}e=o[t++].to}if(c++,u)u.push(p);else{p.from>l&&s.push(new Jg(l,p.from,d)),tv(e,p.direction==Hg!=!(d%2)?r+1:r,i,p.inner,p.from,p.to,s),l=p.to}f=p.to}else{if(f==n||(t?Zg[f]!=a:Zg[f]==a))break;f++}u?ev(e,l,f,r+1,i,u,s):l<f&&s.push(new Jg(l,f,d)),l=f}else for(let l=n,c=o.length;l>t;){let n=!0,h=!1;if(!c||l>o[c-1].to){let e=Zg[l-1];e!=a&&(n=!1,h=16==e)}let u=n||1!=a?null:[],d=n?r:r+1,f=l;e:for(;;)if(c&&f==o[c-1].to){if(h)break e;let p=o[--c];if(!n)for(let e=p.from,n=c;;){if(e==t)break e;if(!n||o[n-1].to!=e){if(Zg[e-1]==a)break e;break}e=o[--n].from}if(u)u.push(p);else{p.to<l&&s.push(new Jg(p.to,l,d)),tv(e,p.direction==Hg!=!(d%2)?r+1:r,i,p.inner,p.from,p.to,s),l=p.from}f=p.from}else{if(f==t||(n?Zg[f-1]!=a:Zg[f-1]==a))break;f--}u?ev(e,f,l,r+1,i,u,s):f<l&&s.push(new Jg(f,l,d)),l=f}}function tv(e,t,n,r,i,o,s){let a=t%2?2:1;!function(e,t,n,r,i){for(let o=0;o<=r.length;o++){let s=o?r[o-1].to:t,a=o<r.length?r[o].from:n,l=o?256:i;for(let t=s,n=l,r=l;t<a;t++){let i=Gg(e.charCodeAt(t));512==i?i=n:8==i&&4==r&&(i=16),Zg[t]=4==i?2:i,7&i&&(r=i),n=i}for(let e=s,t=l,r=l;e<a;e++){let i=Zg[e];if(128==i)e<a-1&&t==Zg[e+1]&&24&t?i=Zg[e]=t:Zg[e]=256;else if(64==i){let i=e+1;for(;i<a&&64==Zg[i];)i++;let o=e&&8==t||i<n&&8==Zg[i]?1==r?1:8:256;for(let t=e;t<i;t++)Zg[t]=o;e=i-1}else 8==i&&1==r&&(Zg[e]=1);t=i,7&i&&(r=i)}}}(e,i,o,r,a),function(e,t,n,r,i){let o=1==i?2:1;for(let s=0,a=0,l=0;s<=r.length;s++){let c=s?r[s-1].to:t,h=s<r.length?r[s].from:n;for(let t,n,r,s=c;s<h;s++)if(n=Kg[t=e.charCodeAt(s)])if(n<0){for(let e=a-3;e>=0;e-=3)if(Yg[e+1]==-n){let t=Yg[e+2],n=2&t?i:4&t?1&t?o:i:0;n&&(Zg[s]=Zg[Yg[e]]=n),a=e;break}}else{if(189==Yg.length)break;Yg[a++]=s,Yg[a++]=t,Yg[a++]=l}else if(2==(r=Zg[s])||1==r){let e=r==i;l=e?0:1;for(let t=a-3;t>=0;t-=3){let n=Yg[t+2];if(2&n)break;if(e)Yg[t+2]|=2;else{if(4&n)break;Yg[t+2]|=4}}}}}(e,i,o,r,a),function(e,t,n,r){for(let i=0,o=r;i<=n.length;i++){let s=i?n[i-1].to:e,a=i<n.length?n[i].from:t;for(let l=s;l<a;){let s=Zg[l];if(256==s){let s=l+1;for(;;)if(s==a){if(i==n.length)break;s=n[i++].to,a=i<n.length?n[i].from:t}else{if(256!=Zg[s])break;s++}let c=1==o,h=c==(1==(s<t?Zg[s]:r))?c?1:2:r;for(let t=s,r=i,o=r?n[r-1].to:e;t>l;)t==o&&(t=n[--r].from,o=r?n[r-1].to:e),Zg[--t]=h;l=s}else o=s,l++}}}(i,o,r,a),ev(e,i,o,t,n,r,s)}function nv(e){return[new Jg(0,e,0)]}let rv="";function iv(e,t,n,r,i){var o;let s=r.head-e.from,a=Jg.find(t,s,null!==(o=r.bidiLevel)&&void 0!==o?o:-1,r.assoc),l=t[a],c=l.side(i,n);if(s==c){let e=a+=i?1:-1;if(e<0||e>=t.length)return null;l=t[a=e],s=l.side(!i,n),c=l.side(i,n)}let h=sp(e.text,s,l.forward(i,n));(h<l.from||h>l.to)&&(h=c),rv=e.text.slice(Math.min(s,h),Math.max(s,h));let u=a==(i?t.length-1:0)?null:t[a+(i?1:-1)];return u&&h==c&&u.level+(i?0:1)<l.level?xp.cursor(u.side(!i,n)+e.from,u.forward(i,n)?1:-1,u.level):xp.cursor(h+e.from,l.forward(i,n)?-1:1,l.level)}function ov(e,t,n){for(let r=t;r<n;r++){let t=Gg(e.charCodeAt(r));if(1==t)return Hg;if(2==t||4==t)return Vg}return Hg}const sv=Ep.define(),av=Ep.define(),lv=Ep.define(),cv=Ep.define(),hv=Ep.define(),uv=Ep.define(),dv=Ep.define(),fv=Ep.define(),pv=Ep.define(),mv=Ep.define({combine:e=>e.some(e=>e)}),gv=Ep.define({combine:e=>e.some(e=>e)}),vv=Ep.define();class bv{constructor(e,t="nearest",n="nearest",r=5,i=5,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=o}map(e){return e.empty?this:new bv(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 bv(xp.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const yv=em.define({map:(e,t)=>e.map(t)}),wv=em.define();function xv(e,t,n){let r=e.facet(cv);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)}const kv=Ep.define({combine:e=>!e.length||e[0]});let Sv=0;const Ev=Ep.define({combine:e=>e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})});class Cv{constructor(e,t,n,r,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(Ev.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Ev.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:r,provide:i,decorations:o}=t||{};return new Cv(Sv++,e,n,r,e=>{let t=[];return o&&t.push(Tv.of(t=>{let n=t.plugin(e);return n?o(n):dg.none})),i&&t.push(i(e)),t})}static fromClass(e,t){return Cv.define((t,n)=>new e(t,n),t)}}class Ov{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 e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(xv(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){xv(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){xv(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Nv=Ep.define(),Av=Ep.define(),Tv=Ep.define(),Mv=Ep.define(),Rv=Ep.define(),Dv=Ep.define(),Pv=Ep.define();function Lv(e,t){let n=e.state.facet(Pv);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return ym.spans(r,t.from,t.to,{point(){},span(e,n,r,o){let s=e-t.from,a=n-t.from,l=i;for(let e=r.length-1;e>=0;e--,o--){let n,i=r[e].spec.bidiIsolate;if(null==i&&(i=ov(t.text,s,a)),o>0&&l.length&&(n=l[l.length-1]).to==s&&n.direction==i)n.to=a,l=n.inner;else{let e={from:s,to:a,direction:i,inner:[]};l.push(e),l=e.inner}}}}),i}const Bv=Ep.define();function Iv(e){let t=0,n=0,r=0,i=0;for(let o of e.state.facet(Bv)){let s=o(e);s&&(null!=s.left&&(t=Math.max(t,s.left)),null!=s.right&&(n=Math.max(n,s.right)),null!=s.top&&(r=Math.max(r,s.top)),null!=s.bottom&&(i=Math.max(i,s.bottom)))}return{left:t,right:n,top:r,bottom:i}}const jv=Ep.define();class _v{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new _v(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 r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(0==t.length)return e;let n=[];for(let r=0,i=0,o=0;;){let s=r<e.length?e[r].fromB:1e9,a=i<t.length?t[i]:1e9,l=Math.min(s,a);if(1e9==l)break;let c=l+o,h=l,u=c;for(;;)if(i<t.length&&t[i]<=h){let n=t[i+1];i+=2,h=Math.max(h,n);for(let t=r;t<e.length&&e[t].fromB<=h;t++)o=e[t].toA-e[t].toB;u=Math.max(u,n+o)}else{if(!(r<e.length&&e[r].fromB<=h))break;{let t=e[r++];h=Math.max(h,t.toB),u=Math.max(u,t.toA),o=t.toA-t.toB}}n.push(new _v(c,u,l,h))}return n}}class Fv{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=fp.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let r=[];this.changes.iterChangedRanges((e,t,n,i)=>r.push(new _v(e,t,n,i))),this.changedRanges=r}static create(e,t,n){return new Fv(e,t,n)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}const Wv=[];class zv{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return Wv}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,4&this.flags){this.flags&=-5;let e=this.domAttrs;e&&function(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;null==t[r]&&e.removeAttribute(r)}for(let n in t){let r=t[n];"style"==n?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=Eg(this.dom),r=this.length?e>0:t>0;return new Wg(this.parent.dom,n+(r?1:0),0==e||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof qv)return e;return null}static get(e){return e.cmTile}}class Hv extends zv{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(2&this.flags)return;super.sync(e);let t,n=this.dom,r=null,i=(null==e?void 0:e.node)==n?e:null,o=0;for(let s of this.children){if(s.sync(e),o+=s.length+s.breakAfter,t=r?r.nextSibling:n.firstChild,i&&t!=s.dom&&(i.written=!0),s.dom.parentNode==n)for(;t&&t!=s.dom;)t=Vv(t);else n.insertBefore(s.dom,t);r=s.dom}for(t=r?r.nextSibling:n.firstChild,i&&t&&(i.written=!0);t;)t=Vv(t);this.length=o}}function Vv(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class qv extends Hv{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=zv.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let o=n.children[r++];if(o instanceof Uv)t.push(r),n=o,r=0;else{let t=i+o.length,n=e(o,i);if(void 0!==n)return n;i=t+o.breakAfter}}}resolveBlock(e,t){let n,r,i=-1,o=-1;if(this.blockTiles((s,a)=>{let l=a+s.length;if(e>=a&&e<=l){if(s.isWidget()&&t>=-1&&t<=1){if(32&s.flags)return!0;16&s.flags&&(n=void 0)}(a<e||e==l&&(t<-1?s.length:s.covers(1)))&&(!n||!s.isWidget()&&n.isWidget())&&(n=s,i=e-a),(l>e||e==a&&(t>1?s.length:s.covers(-1)))&&(!r||!s.isWidget()&&r.isWidget())&&(r=s,o=e-a)}}),!n&&!r)throw new Error("No tile at position "+e);return n&&t<0||!r?{tile:n,offset:i}:{tile:r,offset:o}}}class Uv extends Hv{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return!!this.children.length&&(e<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(e,t){let n=new Uv(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class $v extends Hv{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,n){let r=new $v(t||document.createElement("div"),e);return t&&n||(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,n){let r=null,i=-1,o=null,s=-1;!function e(a,l){for(let c=0,h=0;c<a.children.length&&h<=l;c++){let u=a.children[c],d=h+u.length;d>=l&&(u.isComposite()?e(u,l-h):(!o||o.isHidden&&(t>0||n&&Kv(o,u)))&&(d>l||32&u.flags)?(o=u,s=l-h):(h<l||16&u.flags&&!u.isHidden)&&(r=u,i=l-h)),h=d}}(this,e);let a=(t<0?r:o)||r||o;return a?{tile:a,offset:a==r?i:s}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=kg(t);return n[n.length-1]||null}(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new Wg(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,16&e.flags?1:32&e.flags?-1:t);let i=n.tile.parent,o=!1;for(let e of i.children){if(o)return new Wg(e.dom,0);e==n.tile&&(o=!0)}}return new Wg(this.dom,0)}}function Kv(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}class Yv extends Hv{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let n=new Yv(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class Gv extends zv{constructor(e,t){super(e,t.length),this.text=t}sync(e){2&this.flags||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let r=e,i=e,o=0;0==e&&t<0||e==n&&t>=0?ig.chrome||ig.gecko||(e?(r--,o=1):i<n&&(i++,o=-1)):t<0?r--:i<n&&i++;let s=Bg(this.dom,r,i).getClientRects();if(!s.length)return null;let a=s[(o?o<0:t>=0)?0:s.length-1];return ig.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(s,e=>e.width)||a),o?Ag(a,o<0):a||null}static of(e,t){let n=new Gv(t||document.createTextNode(e),e);return t||(n.flags|=2),n}}class Xv extends zv{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return!(48&this.flags)&&(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return Ag(this.dom.getBoundingClientRect(),this.length?0==e:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=!!(16&this.flags)||!(32&this.flags)&&e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?0==i:i==t.length-1||n.top<n.bottom);i+=r?-1:1);return Ag(n,!r)}}get overrideDOMText(){if(!this.length)return Xf.empty;let{root:e}=this;if(!e)return Xf.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,n,r,i){return i||(i=e.toDOM(t),e.editable||(i.contentEditable="false")),new Xv(i,n,e,r)}}class Jv extends zv{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return Xf.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class Qv{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:o,parents:s}=this;for(;e||t>0;)if(r.isComposite())if(o){if(!e)break;n&&n.break(),e--,o=!1}else if(i==r.children.length){if(!e&&!s.length)break;n&&n.leave(r),o=!!r.breakAfter,({tile:r,index:i}=s.pop()),i++}else{let a=r.children[i],l=a.breakAfter;!(t>0?a.length<=e:a.length<e)||n&&!1===n.skip(a,0,a.length)&&a.isComposite?(s.push({tile:r,index:i}),r=a,i=0,n&&a.isComposite()&&n.enter(a)):(o=!!l,i++,e-=a.length)}else if(i==r.length)o=!!r.breakAfter,({tile:r,index:i}=s.pop()),i++;else{if(!e)break;{let t=Math.min(e,r.length-i);n&&n.skip(r,i,i+t),e-=t,i+=t}}return this.tile=r,this.index=i,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Zv{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}}class eb{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){var i;this.flushBuffer();let o=this.ensureMarks(t,n),s=o.lastChild;if(!s||!s.isText()||8&s.flags)o.append(r||Gv.of(e,null===(i=this.cache.find(Gv))||void 0===i?void 0:i.dom));else{this.cache.reused.set(s,2),(o.children[o.children.length-1]=new Gv(s.dom,s.text+e)).parent=o}this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?ab(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof Yv&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(ab(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=zv.get(n.dom);e&&e.setDOM(ab(n.dom))}let e=Yv.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=zv.get(e.text);i&&this.cache.reused.set(i,2);let o=new Gv(e.text,e.text.nodeValue);o.flags|=8,r.append(o)}addInlineWidget(e,t,n){let r=this.afterWidget&&48&e.flags&&(48&this.afterWidget.flags)==(48&e.flags);r||this.flushBuffer();let i=this.ensureMarks(t,n);r||16&e.flags||i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){(this.afterWidget||this.lastBlock).length+=e,this.pos+=e}addLineStart(e,t){var n;e||(e=sb);let r=$v.start(e,t||(null===(n=this.cache.find($v))||void 0===n?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var n;let r=this.curLine;for(let i=e.length-1;i>=0;i--){let o,s=e[i];if(t>0&&(o=r.lastChild)&&o instanceof Yv&&o.mark.eq(s))r=o,t--;else{let e=Yv.of(s,null===(n=this.cache.find(Yv,e=>e.mark.eq(s)))||void 0===n?void 0:n.dom);r.append(e),r=e,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;e&&ob(this.curLine,!1)&&("BR"==e.dom.nodeName||!e.isWidget()||ig.ios&&ob(this.curLine,!0))||this.curLine.append(this.cache.findWidget(cb,0,32)||new Xv(cb.toDOM(),0,cb,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new Zv(e.from,e.to,e.value,e.rank),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-t.rank||this.wrappers[n-1].to-t.to)<0;)n--;this.wrappers.splice(n,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let n of this.wrappers){let r=t.lastChild;if(n.from<this.pos&&r instanceof Uv&&r.wrapper.eq(n.wrapper))t=r;else{let r=Uv.of(n.wrapper,null===(e=this.cache.find(Uv,e=>e.wrapper.eq(n.wrapper)))||void 0===e?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return null!=e&&!e.breakAfter&&(!e.isWidget()||(160&e.flags)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(Jv,void 0,1);return n&&(n.flags=t),n||new Jv(t)}flushBuffer(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class tb{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw new Error("Ran out of text content when drawing inline views");this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}}const nb=[Xv,$v,Gv,Yv,Jv,Uv,qv];for(let e=0;e<nb.length;e++)nb[e].bucket=e;class rb{constructor(e){this.view=e,this.buckets=nb.map(()=>[]),this.index=nb.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],o=this.index[r];for(let e=i.length-1;e>=0;e--){let s=(e+o)%i.length,a=i[s];if((!t||t(a))&&!this.reused.has(a))return i.splice(s,1),s<o&&this.index[r]--,this.reused.set(a,n),a}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,o=0;;i++){if(i==r.length){if(o)return null;o=1,i=0}let s=r[i];if(!this.reused.has(s)&&(0==o?s.widget.compare(e):s.widget.constructor==e.constructor&&e.updateDOM(s.dom,this.view)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,s.widget==e&&s.length==t&&(497&s.flags)==n?(this.reused.set(s,1),s):(this.reused.set(s,2),new Xv(s.dom,t,e,-498&s.flags|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class ib{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new rb(e),this.text=new tb(e.state.doc),this.builder=new eb(this.cache,new qv(e,e.contentDOM),ym.iter(n)),this.cache.reused.set(t,2),this.old=new Qv(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,o=0;;){let s=o<e.length?e[o++]:null,a=s?s.fromA:this.old.root.length;if(a>r){let e=a-r;this.preserve(e,!o,!s),r=a,i+=e}if(!s)break;t&&s.fromA<=t.range.fromA&&s.toA>=t.range.toA?(this.forward(s.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,s.toA),this.emit(t.range.toB,s.toB)):(this.forward(s.fromA,s.toA),this.emit(i,s.toB)),i=s.toB,r=s.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=function(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof Yv&&t.push(r.mark)}return t}(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let o=n>0||t<e.length?Xv.of(e.widget,this.view,n-t,496&e.flags,this.cache.maybeReuse(e)):this.cache.reuse(e);256&o.flags?(o.flags&=-2,this.builder.addBlockWidget(o)):(this.builder.ensureLine(null),this.builder.addInlineWidget(o,r,i),i=r.length)}else if(e.isText())this.builder.ensureLine(null),t||n!=e.length?(this.cache.add(e),this.builder.addText(e.text.slice(t,n),r,i)):this.builder.addText(e.text,r,i,this.cache.reuse(e)),i=r.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof Jv)this.cache.add(e);else{if(!(e instanceof Yv))return!1;this.builder.ensureLine(null),this.builder.addMark(e,r,i),this.cache.reused.set(e,1),i=r.length}this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof Yv&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&(r.length=i=0):e instanceof Yv&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=0,o=ym.spans(this.decorations,e,t,{point:(e,t,o,s,a,l)=>{if(o instanceof mg){if(this.disallowBlockEffectsFor[l]){if(o.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.view.state.doc.lineAt(e).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(i=s.length,a>s.length)r.continueWidget(t-e);else{let i=o.widget||(o.block?lb.block:lb.inline),l=function(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;e.block&&(t|=256);return t}(o),c=this.cache.findWidget(i,t-e,l)||Xv.of(i,this.view,t-e,l);o.block?(o.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(c)):(r.ensureLine(n),r.addInlineWidget(c,s,a))}n=null}else n=function(e,t){let n=t.spec.attributes,r=t.spec.class;if(!n&&!r)return e;e||(e={class:"cm-line"});n&&og(n,e);r&&(e.class+=" "+r);return e}(n,o);t>e&&this.text.skip(t-e)},span:(e,t,i,o)=>{for(let s=e;s<t;){let e=this.text.next(Math.min(512,t-s));null==e?(r.addLineStartIfNotCovered(n),r.addBreak(),s++):(r.ensureLine(n),r.addText(e,i,o),s+=e.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=o>i,this.openMarks=o}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=zv.get(r);if(r==this.view.contentDOM)break;e instanceof Yv?t.push(e):(null==e?void 0:e.isLine())?n=e:"DIV"!=r.nodeName||n||r==this.view.contentDOM?t.push(Yv.of(new fg({tagName:r.nodeName.toLowerCase(),attributes:cg(r)}),r)):n=new $v(r,sb)}return{line:n,marks:t}}}function ob(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}const sb={class:"cm-line"};function ab(e){let t=zv.get(e);return t&&t.setDOM(e.cloneNode()),e}class lb extends hg{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}}lb.inline=new lb("span"),lb.block=new lb("div");const cb=new class extends hg{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class hb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=dg.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.updateDeco(),this.tile=new qv(e,e.contentDOM),this.updateInner([new _v(0,0,0,e.state.doc.length)],null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>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 r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?r=this.domChanged.newSel.head:function(e,t){let n=!1;t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)});return n}(e.changes,this.hasComposition)||e.selectionSet||(r=e.state.selection.main.head));let i=r>-1?function(e,t,n){let r=db(e,n);if(!r)return null;let{node:i,from:o,to:s}=r,a=i.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(r.from,r.to)!=a)return null;let l=t.invertedDesc;return{range:new _v(l.mapPos(o),l.mapPos(s),o,s),text:i}}(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:t,to:r}=this.hasComposition;n=new _v(t,r,e.changes.mapPos(t,-1),e.changes.mapPos(r,1)).addToSet(n.slice())}this.hasComposition=i?{from:i.range.fromB,to:i.range.toB}:null,(ig.ie||ig.chrome)&&!i&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,s=this.blockWrappers;this.updateDeco();let a=function(e,t,n){let r=new fb;return ym.compare(e,t,n,r),r.changes}(o,this.decorations,e.changes);a.length&&(n=_v.extendWithRanges(n,a));let l=function(e,t,n){let r=new pb;return ym.compare(e,t,n,r),r.changes}(s,this.blockWrappers,e.changes);return l.length&&(n=_v.extendWithRanges(n,l)),i&&!n.some(e=>e.fromA<=i.range.fromA&&e.toA>=i.range.toA)&&(n=i.range.addToSet(n.slice())),!(2&this.tile.flags&&0==n.length)&&(this.updateInner(n,i),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new ib(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=r.run(e,t),ub(n,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=ig.chrome||ig.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),!r||!r.written&&n.selectionRange.focusNode==r.node&&this.tile.dom.contains(r.node)||(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof mb&&r.push(e.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(wv)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){!e&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,o=!i&&!(this.view.state.facet(kv)||n.tabIndex>-1)&&xg(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||o))return;let s=this.forceSelection;this.forceSelection=!1;let a,l,c=this.view.state.selection.main;if(c.empty?l=a=this.inlineDOMNearPos(c.anchor,c.assoc||1):(l=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),a=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),ig.gecko&&c.empty&&!this.hasComposition&&(1==(h=a).node.nodeType&&h.node.firstChild&&(0==h.offset||"false"==h.node.childNodes[h.offset-1].contentEditable)&&(h.offset==h.node.childNodes.length||"false"==h.node.childNodes[h.offset].contentEditable))){let e=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null)),a=l=new Wg(e,0),s=!0}var h;let u=this.view.observer.selectionRange;!s&&u.focusNode&&(Sg(a.node,a.offset,u.anchorNode,u.anchorOffset)&&Sg(l.node,l.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,c))||(this.view.observer.ignore(()=>{ig.android&&ig.chrome&&n.contains(u.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=yg(this.view.root);if(e)if(c.empty){if(ig.gecko){let e=function(e,t){return 1!=e.nodeType?0:(t&&"false"==e.childNodes[t-1].contentEditable?1:0)|(t<e.childNodes.length&&"false"==e.childNodes[t].contentEditable?2:0)}(a.node,a.offset);if(e&&3!=e){let t=(1==e?_g:Fg)(a.node,a.offset);t&&(a=new Wg(t.node,t.offset))}}e.collapse(a.node,a.offset),null!=c.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=c.bidiLevel)}else if(e.extend){e.collapse(a.node,a.offset);try{e.extend(l.node,l.offset)}catch(e){}}else{let t=document.createRange();c.anchor>c.head&&([a,l]=[l,a]),t.setEnd(l.node,l.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}else;o&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new Wg(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new Wg(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Sg(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=yg(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!(n&&t.empty&&t.assoc&&n.modify))return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let s=o.posAtStart;if(t.head==s||t.head==s+o.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return 2&this.tile.dom.compareDocumentPosition(e)?0:this.view.state.doc.length;let r=n.posAtStart;if(!n.isComposite())return n.isText()?e==n.dom?r+t:r+(t?n.length:0):r;{let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=0==Ng(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;0==r&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!zv.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r,i=-1,o=!1,s=-1,a=!1;return this.tile.blockTiles((t,l)=>{if(t.isWidget()){if(32&t.flags&&l>=e)return!0;16&t.flags&&(o=!0)}else{let c=l+t.length;if(l<=e&&(n=t,i=e-l,o=c<e),c>=e&&!r&&(r=t,s=e-l,a=l>e),l>e&&r)return!0}}),n||r?(o&&r?n=null:a&&n&&(r=null),n&&t<0||!r?n.domIn(i,t):r.domIn(s,t)):this.domAtPos(e,t)}coordsAt(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof mb?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;return function e(t,n){if(t.isComposite())for(let r of t.children){if(r.length>=n){let t=e(r,n);if(t)return t}if((n-=r.length)<0)break}else if(t.isText()&&n<t.length){let e=sp(t.text,n);if(e==n)return null;let r=Bg(t.dom,n,e).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,o=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,s=-1,a=this.view.textDirection==zg.LTR,l=0,c=(e,h,u)=>{for(let d=0;d<e.children.length&&!(h>r);d++){let r=e.children[d],f=h+r.length,p=r.dom.getBoundingClientRect(),{height:m}=p;if(u&&!d&&(l+=p.top-u.top),r instanceof Uv)f>n&&c(r,h,p);else if(h>=n&&(l>0&&t.push(-l),t.push(m+l),l=0,o)){let e=r.dom.lastChild,t=e?kg(e):[];if(t.length){let e=t[t.length-1],n=a?e.right-p.left:p.right-e.left;n>s&&(s=n,this.minWidth=i,this.minWidthFrom=h,this.minWidthTo=f)}}u&&d==e.children.length-1&&(l+=u.bottom-p.bottom),h=f+r.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return"rtl"==getComputedStyle(t.dom).direction?zg.RTL:zg.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t,n=0;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=kg(r.dom);if(1!=e.length)return;n+=e[0].width,t=e[0].height}if(n)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:n/e.length,textHeight:t}}});if(e)return e;let t,n,r,i=document.createElement("div");return i.className="cm-line",i.style.width="99999px",i.style.position="absolute",i.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(i);let e=kg(i.firstChild)[0];t=i.getBoundingClientRect().height,n=e&&e.width?e.width/27:7,r=e&&e.height?e.height:t,i.remove()}),{lineHeight:t,charWidth:n,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],o=i?i.from-1:this.view.state.doc.length;if(o>n){let r=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(dg.replace({widget:new mb(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!i)break;n=i.to+1}return dg.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Tv).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),n=!1,r=this.view.state.facet(Rv).map((e,t)=>{let r="function"==typeof e;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(ym.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(Mv).map(e=>"function"==typeof e?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}for(let t of this.view.state.facet(vv))try{if(t(this.view,e.range,e))return!0}catch(e){xv(this.view.state,e,"scroll handler")}let t,{range:n}=e,r=this.coordsAt(n.head,n.empty?n.assoc:n.head>n.anchor?-1:1);if(!r)return;!n.empty&&(t=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,t.left),top:Math.min(r.top,t.top),right:Math.max(r.right,t.right),bottom:Math.max(r.bottom,t.bottom)});let i=Iv(this.view),o={left:r.left-i.left,top:r.top-i.top,right:r.right+i.right,bottom:r.bottom+i.bottom},{offsetWidth:s,offsetHeight:a}=this.view.scrollDOM;!function(e,t,n,r,i,o,s,a){let l=e.ownerDocument,c=l.defaultView||window;for(let h=e,u=!1;h&&!u;)if(1==h.nodeType){let e,d=h==l.body,f=1,p=1;if(d)e=Tg(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let t=h.getBoundingClientRect();({scaleX:f,scaleY:p}=Mg(h,t)),e={left:t.left,right:t.left+h.clientWidth*f,top:t.top,bottom:t.top+h.clientHeight*p}}let m=0,g=0;if("nearest"==i)t.top<e.top?(g=t.top-(e.top+s),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+s)):t.bottom>e.bottom&&(g=t.bottom-e.bottom+s,n<0&&t.top-g<e.top&&(g=t.top-(e.top+s)));else{let r=t.bottom-t.top,o=e.bottom-e.top;g=("center"==i&&r<=o?t.top+r/2-o/2:"start"==i||"center"==i&&n<0?t.top-s:t.bottom-o+s)-e.top}if("nearest"==r?t.left<e.left?(m=t.left-(e.left+o),n>0&&t.right>e.right+m&&(m=t.right-e.right+o)):t.right>e.right&&(m=t.right-e.right+o,n<0&&t.left<e.left+m&&(m=t.left-(e.left+o))):m=("center"==r?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==r==a?t.left-o:t.right-(e.right-e.left)+o)-e.left,m||g)if(d)c.scrollBy(m,g);else{let e=0,n=0;if(g){let e=h.scrollTop;h.scrollTop+=g/p,n=(h.scrollTop-e)*p}if(m){let t=h.scrollLeft;h.scrollLeft+=m/f,e=(h.scrollLeft-t)*f}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-m)<1&&(r="nearest"),n&&Math.abs(n-g)<1&&(i="nearest")}if(d)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),h=h.assignedSlot||h.parentNode}else{if(11!=h.nodeType)break;h=h.host}}(this.view.scrollDOM,o,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,s),-s),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==zg.LTR)}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){ub(this.tile)}}function ub(e,t){let n=null==t?void 0:t.get(e);if(1!=n){null==n&&e.destroy();for(let n of e.children)ub(n,t)}}function db(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=_g(n.focusNode,n.focusOffset),i=Fg(n.focusNode,n.focusOffset),o=r||i;if(i&&r&&i.node!=r.node){let t=zv.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)o=i;else if(e.docView.lastCompositionAfterCursor){let e=zv.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(o=i)}}if(e.docView.lastCompositionAfterCursor=o!=r,!o)return null;let s=t-o.offset;return{from:s,to:s+o.node.nodeValue.length,node:o.node}}let fb=class{constructor(){this.changes=[]}compareRange(e,t){vg(e,t,this.changes)}comparePoint(e,t){vg(e,t,this.changes)}boundChange(e){vg(e,e,this.changes)}};class pb{constructor(){this.changes=[]}compareRange(e,t){vg(e,t,this.changes)}comparePoint(){}boundChange(e){vg(e,e,this.changes)}}class mb extends hg{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}}function gb(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;e&&(i.type!=ug.Text||e.type==i.type&&!(n<0?i.from<t:i.to>t))||(e=i)}}return e||r}return r}function vb(e,t,n,r){let i=e.state.doc.lineAt(t.head),o=e.bidiSpans(i),s=e.textDirectionAt(i.from);for(let a=t,l=null;;){let t=iv(i,o,s,a,n),c=rv;if(!t){if(i.number==(n?e.state.doc.lines:1))return a;c="\n",i=e.state.doc.line(i.number+(n?1:-1)),o=e.bidiSpans(i),t=e.visualLineSide(i,!n)}if(l){if(!l(c))return a}else{if(!r)return t;l=r(c)}a=t}}function bb(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(e,i,o)=>{if(t>e&&t<i){let o=r||n||(t-e<i-t?-1:1);t=o<0?e:i,r=o}});if(!r)return t}}function yb(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],o=null;if(i.empty){let t=bb(e,i.from,0);t!=i.from&&(o=xp.cursor(t,-1))}else{let t=bb(e,i.from,-1),n=bb(e,i.to,1);t==i.from&&n==i.to||(o=xp.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}o&&(n||(n=t.ranges.slice()),n[r]=o)}return n?xp.create(n,t.mainIndex):t}function wb(e,t,n){let r=bb(e.state.facet(Dv).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:xp.cursor(r,r<n.from?1:-1)}class xb{constructor(e,t){this.pos=e,this.assoc=t}}function kb(e,t,n,r){let i,o=e.contentDOM.getBoundingClientRect(),s=o.top+e.viewState.paddingTop,{x:a,y:l}=t,c=l-s;for(;;){if(c<0)return new xb(0,1);if(c>e.viewState.docHeight)return new xb(e.state.doc.length,-1);if(i=e.elementAtHeight(c),null==r)break;if(i.type==ug.Text){let t=e.docView.coordsAt(r<0?i.from:i.to,r);if(t&&(r<0?t.top<=c+s:t.bottom>=c+s))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?i.bottom+t:i.top-t}if(e.viewport.from>=i.to||e.viewport.to<=i.from){if(n)return null;if(i.type==ug.Text){let t=function(e,t,n,r,i){let o=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;o+=Math.floor((i-n.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let s=e.state.sliceDoc(n.from,n.to);return n.from+Dm(s,o,e.state.tabSize)}(e,o,i,a,l);return new xb(t,t==i.from?1:-1)}}if(i.type!=ug.Text)return c<(i.top+i.bottom)/2?new xb(i.from,1):new xb(i.to,-1);let h=e.docView.lineAt(i.from,2);return h&&h.length==i.length||(h=e.docView.lineAt(i.from,-2)),Sb(e,h,i.from,a,l)}function Sb(e,t,n,r,i){let o=-1,s=null,a=1e9,l=1e9,c=i,h=i,u=(e,t)=>{for(let n=0;n<e.length;n++){let u=e[n];if(u.top==u.bottom)continue;let d=u.left>r?u.left-r:u.right<r?r-u.right:0,f=u.top>i?u.top-i:u.bottom<i?i-u.bottom:0;u.top<=h&&u.bottom>=c&&(c=Math.min(u.top,c),h=Math.max(u.bottom,h),f=0),(o<0||(f-l||d-a)<0)&&(o>=0&&l&&a<d&&s.top<=h-2&&s.bottom>=c+2?l=0:(o=t,a=d,l=f,s=u))}};if(t.isText()){for(let e=0;e<t.length;){let n=sp(t.text,e);if(u(Bg(t.dom,e,n).getClientRects(),e),!a&&!l)break;e=n}return r>(s.left+s.right)/2==(Eb(e,o+n)==zg.LTR)?new xb(n+sp(t.text,o),-1):new xb(n+o,1)}{if(!t.length)return new xb(n,1);for(let e=0;e<t.children.length;e++){let n=t.children[e];if(!(48&n.flags)&&(u((1==n.dom.nodeType?n.dom:Bg(n.dom,0,n.length)).getClientRects(),e),!a&&!l))break}let c=t.children[o],h=t.posBefore(c,n);return c.isComposite()||c.isText()?Sb(e,c,h,Math.max(s.left,Math.min(s.right,r)),i):r>(s.left+s.right)/2==(Eb(e,o+n)==zg.LTR)?new xb(h+c.length,-1):new xb(h,1)}}function Eb(e,t){let n=e.state.doc.lineAt(t);return e.bidiSpans(n)[Jg.find(e.bidiSpans(n),t-n.from,-1,1)].dir}const Cb="￿";class Ob{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(dm.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Cb}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=zv.get(r),o=r.nextSibling;if(o==t){(null==i?void 0:i.breakAfter)&&!o&&n!=this.view.contentDOM&&this.lineBreak();break}let s=zv.get(o);(i&&s?i.breakAfter:(i?i.breakAfter:Cg(r))||Cg(o)&&("BR"!=r.nodeName||(null==i?void 0:i.isWidget()))&&this.text.length>e)&&!Ab(o,t)&&this.lineBreak(),r=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,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i,o=-1,s=1;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(i=r.exec(t))&&(o=i.index,s=i[0].length),this.append(t.slice(n,o<0?t.length:o)),o<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);n=o+s}}readNode(e){let t=zv.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&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)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(Nb(e,n.node,n.offset)?t:0))}}function Nb(e,t,n){for(;;){if(!t||n<Ng(t))return!1;if(t==e)return!0;n=Eg(t)+1,t=t.parentNode}}function Ab(e,t){let n;for(;e!=t&&e;e=e.nextSibling){let t=zv.get(e);if(!(null==t?void 0:t.isWidget()))return!1;t&&(n||(n=[])).push(t)}if(n)for(let e of n){let t=e.overrideDOMText;if(null==t?void 0:t.length)return!1}return!0}class Tb{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class Mb{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=Rb(e.docView.tile,t,n,0))){let t=i||o?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}=e.observer.selectionRange;n&&(t.push(new Tb(n,r)),i==n&&o==r||t.push(new Tb(i,o)));return t}(e),n=new Ob(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,r=2==e.length?e[1].pos:n;return n>-1&&r>-1?xp.single(n+t,r+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!wg(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=o&&o.node==t.anchorNode&&o.offset==t.anchorOffset||!wg(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((ig.ios||ig.chrome)&&e.state.selection.main.empty&&n!=r&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,r),i=Math.max(n,r),o=s.from-t,a=s.to-i;0!=o&&1!=o&&0!=t||0!=a&&-1!=a&&i!=e.state.doc.length||(n=0,r=e.state.doc.length)}e.inputState.composing>-1&&e.state.selection.ranges.length>1?this.newSel=e.state.selection.replaceRange(xp.range(r,n)):this.newSel=xp.single(r,n)}}}function Rb(e,t,n,r){if(e.isComposite()){let i=-1,o=-1,s=-1,a=-1;for(let l=0,c=r,h=r;l<e.children.length;l++){let r=e.children[l],u=c+r.length;if(c<t&&u>n)return Rb(r,t,n,c);if(u>=t&&-1==i&&(i=l,o=c),c>n&&r.dom.parentNode==e.dom){s=l,a=h;break}h=u,c=u+r.breakAfter}return{from:o,to:a<0?r+e.length:a,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:s<e.children.length&&s>=0?e.children[s].dom:null}}return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function Db(e,t){let n,{newSel:r}=t,i=e.state.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:r,to:s}=t.bounds,a=i.from,l=null;(8===o||ig.android&&t.text.length<s-r)&&(a=i.to,l="end");let c=Lb(e.state.doc.sliceString(r,s,Cb),t.text,a-r,l);c&&(ig.chrome&&13==o&&c.toB==c.from+2&&t.text.slice(c.from,c.toB)==Cb+Cb&&c.toB--,n={from:r+c.from,to:r+c.toA,insert:Xf.of(t.text.slice(c.from,c.toB).split(Cb))})}else r&&(!e.hasFocus&&e.state.facet(kv)||Bb(r,i))&&(r=null);if(!n&&!r)return!1;if(!n&&t.typeOver&&!i.empty&&r&&r.main.empty?n={from:i.from,to:i.to,insert:e.state.doc.slice(i.from,i.to)}:(ig.mac||ig.android)&&n&&n.from==n.to&&n.from==i.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(r&&2==n.insert.length&&(r=xp.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:Xf.of([n.insert.toString().replace("."," ")])}):n&&n.from>=i.from&&n.to<=i.to&&(n.from!=i.from||n.to!=i.to)&&i.to-i.from-(n.to-n.from)<=4?n={from:i.from,to:i.to,insert:e.state.doc.slice(i.from,n.from).append(n.insert).append(e.state.doc.slice(n.to,i.to))}:e.state.doc.lineAt(i.from).to<i.to&&e.docView.lineHasWidget(i.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:i.from,to:i.to,insert:e.state.toText(e.inputState.insertingText)}:ig.chrome&&n&&n.from==n.to&&n.from==i.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(r&&(r=xp.single(r.main.anchor-1,r.main.head-1)),n={from:i.from,to:i.to,insert:Xf.of([" "])}),n)return Pb(e,n,r,o);if(r&&!Bb(r,i)){let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),n=e.inputState.lastSelectionOrigin,"select.pointer"==n&&(r=yb(e.state.facet(Dv).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function Pb(e,t,n,r=-1){if(ig.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(ig.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&" "==e.state.sliceDoc(t.from,i.from))&&1==t.insert.length&&2==t.insert.lines&&Ig(e.contentDOM,"Enter",13)||(t.from==i.from-1&&t.to==i.to&&0==t.insert.length||8==r&&t.insert.length<t.to-t.from&&t.to>i.head)&&Ig(e.contentDOM,"Backspace",8)||t.from==i.from&&t.to==i.to+1&&0==t.insert.length&&Ig(e.contentDOM,"Delete",46)))return!0;let o,s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>o||(o=function(e,t,n){let r,i=e.state,o=i.selection.main,s=-1;if(t.from==t.to&&t.from<o.from||t.from>o.to){let n=t.from<o.from?-1:1,r=n<0?o.from:o.to,a=bb(i.facet(Dv).map(t=>t(e)),r,n);t.from==a&&(s=a)}if(s>-1)r={changes:t,selection:xp.cursor(t.from+t.insert.length,-1)};else if(t.from>=o.from&&t.to<=o.to&&t.to-t.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=o.from<t.from?i.sliceDoc(o.from,t.from):"",s=o.to>t.to?i.sliceDoc(t.to,o.to):"";r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+s))}else{let s=i.changes(t),a=n&&n.main.to<=s.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=o.to+10&&t.to>=o.to-10){let l,c=e.state.sliceDoc(t.from,t.to),h=n&&db(e,n.main.head);if(h){let e=t.insert.length-(t.to-t.from);l={from:h.from,to:h.to-e}}else l=e.state.doc.lineAt(o.head);let u=o.to-t.to;r=i.changeByRange(n=>{if(n.from==o.from&&n.to==o.to)return{changes:s,range:a||n.map(s)};let r=n.to-u,h=r-c.length;if(e.state.sliceDoc(h,r)!=c||r>=l.from&&h<=l.to)return{range:n};let d=i.changes({from:h,to:r,insert:t.insert}),f=n.to-o.to;return{changes:d,range:a?xp.range(Math.max(0,a.anchor+f),Math.max(0,a.head+f)):n.map(d)}})}else r={changes:s,selection:a&&i.selection.replaceRange(a)}}let a="input.type";(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,a+=".compose",e.inputState.compositionFirstChange&&(a+=".start",e.inputState.compositionFirstChange=!1));return i.update(r,{userEvent:a,scrollIntoView:!0})}(e,t,n));return e.state.facet(uv).some(n=>n(e,t.from,t.to,s,a))||e.dispatch(a()),!0}function Lb(e,t,n,r){let i=Math.min(e.length,t.length),o=0;for(;o<i&&e.charCodeAt(o)==t.charCodeAt(o);)o++;if(o==i&&e.length==t.length)return null;let s=e.length,a=t.length;for(;s>0&&a>0&&e.charCodeAt(s-1)==t.charCodeAt(a-1);)s--,a--;if("end"==r){n-=s+Math.max(0,o-Math.min(s,a))-o}if(s<o&&e.length<t.length){o-=n<=o&&n>=s?o-n:0,a=o+(a-s),s=o}else if(a<o){o-=n<=o&&n>=a?o-n:0,s=o+(s-a),a=o}return{from:o,toA:s,toB:a}}function Bb(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class Ib{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,ig.safari&&e.contentDOM.addEventListener("input",()=>null),ig.gecko&&function(e){sy.has(e)||(sy.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n,r=t.target;r!=e.contentDOM;r=r.parentNode)if(!r||11==r.nodeType||(n=zv.get(r))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?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 e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=_b(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if("scroll"!=e){let i=!t[e].handlers.length,o=n[e];o&&i!=!o.handlers.length&&(r.removeEventListener(e,this.handleEvent),o=null),o||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)"scroll"==e||t[e]||r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=e.keyCode&&zb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),ig.android&&ig.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!ig.ios||e.synthetic||e.altKey||e.metaKey||!((t=Fb.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||Wb.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0)}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&(!("Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,Ig(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0)))}ignoreDuringComposition(e){return!(!/^key/.test(e.type)||e.synthetic)&&(this.composing>0||!!(ig.safari&&!ig.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}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 jb(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){xv(n.state,e)}}}function _b(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(jb(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(jb(t.value,r))}}for(let e in qb)n(e).handlers.push(qb[e]);for(let e in Ub)n(e).observers.push(Ub[e]);return t}const Fb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Wb="dthko",zb=[16,17,18,20,91,92,224,225];function Hb(e){return.7*Math.max(0,e)+8}class Vb{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=function(e){let t,n,r=e.ownerDocument;for(let i=e.parentNode;i&&!(i==r.body||t&&n);)if(1==i.nodeType)!n&&i.scrollHeight>i.clientHeight&&(n=i),!t&&i.scrollWidth>i.clientWidth&&(t=i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}return{x:t,y:n}}(e.contentDOM),this.atoms=e.state.facet(Dv).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener("mousemove",this.move=this.move.bind(this)),i.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(dm.allowMultipleSelections)&&function(e,t){let n=e.state.facet(sv);return n.length?n[0](t):ig.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=yg(e.root);if(!r||0==r.rangeCount)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)||1!=ey(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(t=this.startEvent,n=e,Math.max(Math.abs(t.clientX-n.clientX),Math.abs(t.clientY-n.clientY))<10))return;var t,n;this.select(this.lastEvent=e);let r=0,i=0,o=0,s=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:o,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=Iv(this.view);e.clientX-c.left<=o+6?r=-Hb(o-e.clientX):e.clientX+c.right>=a-6&&(r=Hb(e.clientX-a)),e.clientY-c.top<=s+6?i=-Hb(s-e.clientY):e.clientY+c.bottom>=l-6&&(i=Hb(e.clientY-l)),this.setScrollSpeed(r,i)}up(e){null==this.dragging&&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),!1===this.dragging&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=yb(this.atoms,this.style.get(e,this.extend,this.multiple));!this.mustSelect&&n.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}const qb=Object.create(null),Ub=Object.create(null),$b=ig.ie&&ig.ie_version<15||ig.ios&&ig.webkit_version<604;function Kb(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function Yb(e,t){t=Kb(e.state,fv,t);let n,{state:r}=e,i=1,o=r.toText(t),s=o.lines==r.selection.ranges.length,a=null!=ny&&r.selection.ranges.every(e=>e.empty)&&ny==o.toString();if(a){let e=-1;n=r.changeByRange(n=>{let a=r.doc.lineAt(n.from);if(a.from==e)return{range:n};e=a.from;let l=r.toText((s?o.line(i++).text:t)+r.lineBreak);return{changes:{from:a.from,insert:l},range:xp.cursor(n.from+l.length)}})}else n=s?r.changeByRange(e=>{let t=o.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:xp.cursor(e.from+t.length)}}):r.replaceSelection(o);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function Gb(e,t,n,r){if(1==r)return xp.cursor(t,n);if(2==r)return function(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),o=t-i.from;if(0==i.length)return xp.cursor(t);0==o?n=1:o==i.length&&(n=-1);let s=o,a=o;n<0?s=sp(i.text,o,!1):a=sp(i.text,o);let l=r(i.text.slice(s,a));for(;s>0;){let e=sp(i.text,s,!1);if(r(i.text.slice(e,s))!=l)break;s=e}for(;a<i.length;){let e=sp(i.text,a);if(r(i.text.slice(a,e))!=l)break;a=e}return xp.range(s+i.from,a+i.from)}(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),o=r?r.posAtStart:i.from,s=r?r.posAtEnd:i.to;return s<e.state.doc.length&&s==i.to&&s++,xp.range(o,s)}}Ub.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},qb.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),Ub.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},Ub.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},qb.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(lv))if(n=r(e,t),n)break;if(n||0!=t.button||(n=function(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=ey(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,o,s){let a,l=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c=Gb(e,l.pos,l.assoc,r);if(n.pos!=l.pos&&!o){let t=Gb(e,n.pos,n.assoc,r),i=Math.min(t.from,c.from),o=Math.max(t.to,c.to);c=i<c.from?xp.range(i,o):xp.range(o,i)}return o?i.replaceRange(i.main.extend(c.from,c.to)):s&&1==r&&i.ranges.length>1&&(a=function(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return xp.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}(i,l.pos))?a:s?i.addRange(c):xp.create([c])}}}(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new Vb(e,t,n,r)),r&&e.observer.ignore(()=>{Lg(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),!1===i.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};const Xb=ig.ie&&ig.ie_version<=11;let Jb=null,Qb=0,Zb=0;function ey(e){if(!Xb)return e.detail;let t=Jb,n=Zb;return Jb=e,Zb=Date.now(),Qb=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(Qb+1)%3:1}function ty(e,t,n,r){if(!(n=Kb(e.state,fv,n)))return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:o}=e.inputState,s=r&&o&&function(e,t){let n=e.state.facet(av);return n.length?n[0](t):ig.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:o.from,to:o.to}:null,a={from:i,insert:n},l=e.state.changes(s?[s,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:s?"move.drop":"input.drop"}),e.inputState.draggedContent=null}qb.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=xp.range(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",Kb(e.state,pv,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},qb.dragend=e=>(e.inputState.draggedContent=null,!1),qb.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,o=()=>{++i==n.length&&ty(e,t,r.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=o,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),o()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return ty(e,t,n,!0),!0}return!1},qb.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=$b?null:t.clipboardData;return n?(Yb(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{e.focus(),n.remove(),Yb(e,n.value)},50)}(e),!1)};let ny=null;qb.copy=qb.cut=(e,t)=>{let n=yg(e.root);if(n&&!xg(e.contentDOM,n))return!1;let{text:r,ranges:i,linewise:o}=function(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let o=e.doc.lineAt(r);o.number>i&&(t.push(o.text),n.push({from:o.from,to:Math.min(e.doc.length,o.to+1)})),i=o.number}r=!0}return{text:Kb(e,pv,t.join(e.lineBreak)),ranges:n,linewise:r}}(e.state);if(!r&&!o)return!1;ny=o?r:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=$b?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",r),!0):(function(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}(e,r),!1)};const ry=Jp.define();function iy(e,t){let n=[];for(let r of e.facet(dv)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:ry.of(!0)}):null}function oy(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=iy(e.state,t);n?e.dispatch(n):e.update([])}},10)}Ub.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),oy(e)},Ub.blur=e=>{e.observer.clearSelectionRange(),oy(e)},Ub.compositionstart=Ub.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},Ub.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,ig.chrome&&ig.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},Ub.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},qb.beforeinput=(e,t)=>{var n,r;if("insertText"!=t.inputType&&"insertCompositionText"!=t.inputType||(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),"insertReplacementText"==t.inputType&&e.observer.editContext){let r=null===(n=t.dataTransfer)||void 0===n?void 0:n.getData("text/plain"),i=t.getTargetRanges();if(r&&i.length){let t=i[0],n=e.posAtDOM(t.startContainer,t.startOffset),o=e.posAtDOM(t.endContainer,t.endOffset);return Pb(e,{from:n,to:o,insert:e.state.toText(r)},null),!0}}let i;if(ig.chrome&&ig.android&&(i=Fb.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(i.key,i.keyCode),"Backspace"==i.key||"Delete"==i.key)){let t=(null===(r=window.visualViewport)||void 0===r?void 0:r.height)||0;setTimeout(()=>{var n;((null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return ig.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),ig.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>Ub.compositionend(e,t),20),!1};const sy=new Set;const ay=["pre-wrap","normal","pre-line","break-spaces"];let ly=!1;function cy(){ly=!1}class hy{constructor(e){this.lineWrapping=e,this.doc=Xf.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){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return ay.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(10*r)]||(t=!0,this.heightSamples[Math.floor(10*r)]=!0)}return t}refresh(e,t,n,r,i,o){let s=ay.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=s||Math.abs(n-this.charWidth)>.1;if(this.lineWrapping=s,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,a){this.heightSamples={};for(let e=0;e<o.length;e++){let t=o[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return a}}class uy{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class dy{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return"number"==typeof this._content?ug.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 mg?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new dy(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var fy=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(fy||(fy={}));const py=.001;class my{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>py&&(ly=!0),this.height=e)}replace(e,t,n){return my.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,o=n.doc;for(let s=r.length-1;s>=0;s--){let{fromA:a,toA:l,fromB:c,toB:h}=r[s],u=i.lineAt(a,fy.ByPosNoHeight,n.setDoc(t),0,0),d=u.to>=l?u:i.lineAt(l,fy.ByPosNoHeight,n,0,0);for(h+=d.to-l,l=d.to;s>0&&u.from<=r[s-1].toA;)a=r[s-1].fromA,c=r[s-1].fromB,s--,a<u.from&&(u=i.lineAt(a,fy.ByPosNoHeight,n,0,0));c+=u.from-a,a=u.from;let f=Sy.build(n.setDoc(o),e,c,h);i=gy(i,i.replace(a,l,f))}return i.updateHeight(n,0)}static empty(){return new yy(0,0,0)}static of(e){if(1==e.length)return e[0];let t=0,n=e.length,r=0,i=0;for(;;)if(t==n)if(r>2*i){let i=e[t-1];i.break?e.splice(--t,1,i.left,null,i.right):e.splice(--t,1,i.left,i.right),n+=1+i.break,r-=i.size}else{if(!(i>2*r))break;{let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,i-=t.size}}else if(r<i){let n=e[t++];n&&(r+=n.size)}else{let t=e[--n];t&&(i+=t.size)}let o=0;return null==e[t-1]?(o=1,t--):null==e[t]&&(o=1,n++),new xy(my.of(e.slice(0,t)),o,my.of(e.slice(n)))}}function gy(e,t){return e==t?e:(e.constructor!=t.constructor&&(ly=!0),t)}my.prototype.size=1;const vy=dg.replace({});class by extends my{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new dy(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new dy(r,0,n,this.spaceAbove,vy):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let o=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(o):o}forEachLine(e,t,n,r,i,o){e<=i+this.length&&t>=i&&o(this.lineAt(0,fy.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class yy extends by{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new dy(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,n){let r=n[0];return 1==n.length&&(r instanceof yy||r instanceof wy&&4&r.flags)&&Math.abs(this.length-r.length)<10?(r instanceof wy?r=new yy(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):my.of(n)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,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 wy extends my{constructor(e){super(e,0)}heightMetrics(e,t){let n,r=e.doc.lineAt(t).number,i=e.doc.lineAt(t+this.length).number,o=i-r+1,s=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*o);n=t/o,this.length>o+1&&(s=(this.height-t)/(this.length-o-1))}else n=this.height/o;return{firstLine:r,lastLine:i,perLine:n,perChar:s}}blockAt(e,t,n,r){let{firstLine:i,lastLine:o,perLine:s,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),o=t.doc.lineAt(i),l=s+o.length*a,c=Math.max(n,e-l/2);return new dy(o.from,o.length,c,l,0)}{let r=Math.max(0,Math.min(o-i,Math.floor((e-n)/s))),{from:a,length:l}=t.doc.line(i+r);return new dy(a,l,n+s*r,s,0)}}lineAt(e,t,n,r,i){if(t==fy.ByHeight)return this.blockAt(e,n,r,i);if(t==fy.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new dy(t,r-t,0,0,0)}let{firstLine:o,perLine:s,perChar:a}=this.heightMetrics(n,i),l=n.doc.lineAt(e),c=s+l.length*a,h=l.number-o,u=r+s*h+a*(l.from-i-h);return new dy(l.from,l.length,Math.max(r,Math.min(u,r+this.height-c)),c,0)}forEachLine(e,t,n,r,i,o){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:s,perLine:a,perChar:l}=this.heightMetrics(n,i);for(let c=e,h=r;c<=t;){let t=n.doc.lineAt(c);if(c==e){let n=t.number-s;h+=a*n+l*(e-i-n)}let r=a+l*t.length;o(new dy(t.from,t.length,h,r,0)),h+=r,c=t.to+1}}replace(e,t,n){let r=this.length-t;if(r>0){let e=n[n.length-1];e instanceof wy?n[n.length-1]=new wy(e.length+r):n.push(null,new wy(r-1))}if(e>0){let t=n[0];t instanceof wy?n[0]=new wy(e+t.length):n.unshift(new wy(e-1),null)}return my.of(n)}decomposeLeft(e,t){t.push(new wy(e-1),null)}decomposeRight(e,t){t.push(null,new wy(this.length-e-1))}updateHeight(e,t=0,n=!1,r){let i=t+this.length;if(r&&r.from<=t+this.length&&r.more){let n=[],o=Math.max(t,r.from),s=-1;for(r.from>t&&n.push(new wy(r.from-t-1).updateHeight(e,t));o<=i&&r.more;){let t=e.doc.lineAt(o).length;n.length&&n.push(null);let i=r.heights[r.index++],a=0;i<0&&(a=-i,i=r.heights[r.index++]),-1==s?s=i:Math.abs(i-s)>=py&&(s=-2);let l=new yy(t,i,a);l.outdated=!1,n.push(l),o+=t+1}o<=i&&n.push(null,new wy(i-o).updateHeight(e,o));let a=my.of(n);return(s<0||Math.abs(a.height-this.height)>=py||Math.abs(s-this.heightMetrics(e,t).perLine)>=py)&&(ly=!0),gy(this,a)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class xy extends my{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 1&this.flags}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let o=r+this.left.height,s=i+this.left.length+this.break,a=t==fy.ByHeight?e<o:e<s,l=a?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,o,s);if(this.break||(a?l.to<s:l.from>s))return l;let c=t==fy.ByPosNoHeight?fy.ByPosNoHeight:fy.ByPos;return a?l.join(this.right.lineAt(s,c,n,o,s)):this.left.lineAt(s,c,n,r,i).join(l)}forEachLine(e,t,n,r,i,o){let s=r+this.left.height,a=i+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,r,i,o),t>=a&&this.right.forEachLine(e,t,n,s,a,o);else{let l=this.lineAt(a,fy.ByPos,n,r,i);e<l.from&&this.left.forEachLine(e,l.from-1,n,r,i,o),l.to>=e&&l.from<=t&&o(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,s,a,o)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)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-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let o=i.length;for(let e of n)i.push(e);if(e>0&&ky(i,o-1),t<this.length){let e=i.length;this.decomposeRight(t,i),ky(i,e)}return my.of(i)}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,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?my.of(this.break?[e,null,t]:[e,t]):(this.left=gy(this.left,e),this.right=gy(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,r){let{left:i,right:o}=this,s=t+i.length+this.break,a=null;return r&&r.from<=t+i.length&&r.more?a=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=s+o.length&&r.more?a=o=o.updateHeight(e,s,n,r):o.updateHeight(e,s,n),a?this.balanced(i,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function ky(e,t){let n,r;null==e[t]&&(n=e[t-1])instanceof wy&&(r=e[t+1])instanceof wy&&e.splice(t-1,3,new wy(n.length+1+r.length))}class Sy{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 e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof yy?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new yy(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new by(o,r,n)):(o||i||r>=5)&&this.addLineDeco(r,i,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||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new yy(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new wy(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 yy)return e;let t=new yy(0,-1,0);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 r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof yy||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new yy(0,-1,0));let n=e;for(let e of this.nodes)e instanceof yy&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,r){let i=new Sy(n,e);return ym.spans(t,n,r,i,0),i.finish(n)}}class Ey{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&vg(e,t,this.changes,5)}}function Cy(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,o=Math.max(0,n.left),s=Math.min(i.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=r.body;)if(1==t.nodeType){let n=t,r=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=r.overflow){let r=n.getBoundingClientRect();o=Math.max(o,r.left),s=Math.min(s,r.right),a=Math.max(a,r.top),l=Math.min(t==e.parentNode?i.innerHeight:l,r.bottom)}t="absolute"==r.position||"fixed"==r.position?n.offsetParent:n.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:o-n.left,right:Math.max(o,s)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function Oy(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class Ny{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return dg.replace({widget:new Ay(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class Ay extends hg{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 Ty{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=Py,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=zg.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Av).some(e=>"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new hy(t),this.stateDeco=Ly(e),this.heightMap=my.empty().applyChanges(this.stateDeco,Xf.empty,this.heightOracle.setDoc(e.doc),[new _v(0,0,0,e.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=dg.set(this.lineGaps.map(e=>e.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new My(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Py:new By(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(Iy(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=Ly(this.state);let r=e.changedRanges,i=_v.extendWithRanges(r,function(e,t,n){let r=new Ey;return ym.compare(e,t,n,r,0),r.changes}(n,this.stateDeco,e?e.changes:fp.empty(this.state.doc.length))),o=this.heightMap.height,s=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);cy(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=o||ly)&&(e.flags|=2),s?(this.scrollAnchorPos=e.changes.mapPos(s.from,-1),this.scrollAnchorHeight=s.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=i.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 l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(l||!e.changes.empty||2&e.flags)&&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.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(gv)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?zg.RTL:zg.LTR;let o=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent,s=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=s.height;this.contentDOMHeight=s.height,this.mustMeasureContent=!1;let l=0,c=0;if(s.width&&s.height){let{scaleX:e,scaleY:n}=Mg(t,s);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,l|=16,o=a=!0)}let h=(parseInt(n.paddingTop)||0)*this.scaleY,u=(parseInt(n.paddingBottom)||0)*this.scaleY;this.paddingTop==h&&this.paddingBottom==u||(this.paddingTop=h,this.paddingBottom=u,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=jg(e.scrollDOM);let f=(this.printing?Oy:Cy)(t,this.paddingTop),p=f.top-this.pixelViewport.top,m=f.bottom-this.pixelViewport.bottom;this.pixelViewport=f;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}(e.dom))return 0;let v=s.width;if(this.contentDOMWidth==v&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=s.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(o=!0),o||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:s,textHeight:a}=e.docView.measureTextSize();o=n>0&&r.refresh(i,n,s,a,Math.max(5,v/s),t),o&&(e.docView.minWidth=0,l|=16)}p>0&&m>0?c=Math.max(p,m):p<0&&m<0&&(c=Math.min(p,m)),cy();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(o?my.empty().applyChanges(this.stateDeco,Xf.empty,this.heightOracle,[new _v(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new uy(n.from,i))}ly&&(l|=2)}let b=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}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)),r=this.heightMap,i=this.heightOracle,{visibleTop:o,visibleBottom:s}=this,a=new My(r.lineAt(o-1e3*n,fy.ByHeight,i,0,0).from,r.lineAt(s+1e3*(1-n),fy.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<a.from||e>a.to){let n,o=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=r.lineAt(e,fy.ByPos,i,0,0);n="center"==t.y?(s.top+s.bottom)/2-o/2:"start"==t.y||"nearest"==t.y&&e<a.from?s.top:s.bottom-o,a=new My(r.lineAt(n-500,fy.ByHeight,i,0,0).from,r.lineAt(n+o+500,fy.ByHeight,i,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new My(this.heightMap.lineAt(n,fy.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,fy.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,fy.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,fy.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:s}=this;return(0==e||r<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=s+Math.max(10,Math.min(n,250)))&&r>o-2e3&&i<s+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new Ny(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,o=r<<1;if(this.defaultTextDirection!=zg.LTR&&!n)return[];let s=[],a=(r,o,l,c)=>{if(o-r<i)return;let h=this.state.selection.main,u=[h.from];h.empty||u.push(h.to);for(let e of u)if(e>r&&e<o)return a(r,e-10,l,c),void a(e+10,o,l,c);let d=function(e,t){for(let n of e)if(t(n))return n;return}(e,e=>e.from>=l.from&&e.to<=l.to&&Math.abs(e.from-r)<i&&Math.abs(e.to-o)<i&&!u.some(t=>e.from<t&&e.to>t));if(!d){if(o<l.to&&t&&n&&t.visibleRanges.some(e=>e.from<=o&&e.to>=o)){let e=t.moveToLineBoundary(xp.cursor(o),!1,!0).head;e>r&&(o=e)}let e=this.gapSize(l,r,o,c);d=new Ny(r,o,e,n||e<2e6?e:2e6)}s.push(d)},l=t=>{if(t.length<o||t.type!=ug.Text)return;let i=function(e,t,n){let r=[],i=e,o=0;ym.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),o+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),o+=t-i);return{total:o,ranges:r}}(t.from,t.to,this.stateDeco);if(i.total<o)return;let s,l,c=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let e,n,o=r/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=c){let r=Dy(i,c),s=((this.visibleBottom-this.visibleTop)/2+o)/t.height;e=r-s,n=r+s}else e=(this.visibleTop-t.top-o)/t.height,n=(this.visibleBottom-t.top+o)/t.height;s=Ry(i,e),l=Ry(i,n)}else{let n=i.total*this.heightOracle.charWidth,o=r*this.heightOracle.charWidth,a=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=n.size-n.displaySize);let h,u,d=this.pixelViewport.left+a,f=this.pixelViewport.right+a;if(null!=c){let e=Dy(i,c),t=((f-d)/2+o)/n;h=e-t,u=e+t}else h=(d-o)/n,u=(f+o)/n;s=Ry(i,h),l=Ry(i,u)}s>t.from&&a(t.from,s,t,i),l<t.to&&a(l,t.to,t,i)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(l):l(e);return s}gapSize(e,t,n,r){let i=Dy(r,n)-Dy(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){Ny.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=dg.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];ym.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t<n.length&&!(8&r);t++){let i=this.visibleRanges[t],o=n[t];i.from==o.from&&i.to==o.to||(r|=4,e&&e.mapPos(i.from,-1)==o.from&&e.mapPos(i.to,1)==o.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Iy(this.heightMap.lineAt(e,fy.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)||Iy(this.heightMap.lineAt(this.scaler.fromDOM(e),fy.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 Iy(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 My{constructor(e,t){this.from=e,this.to=t}}function Ry({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],o=i-n;if(r<=o)return n+r;r-=o}}function Dy(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}const Py={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};function Ly(e){let t=e.facet(Tv).filter(e=>"function"!=typeof e),n=e.facet(Rv).filter(e=>"function"!=typeof e);return n.length&&t.push(ym.join(n)),t}class By{constructor(e,t,n){let r=0,i=0,o=0;this.viewports=n.map(({from:n,to:i})=>{let o=t.lineAt(n,fy.ByPos,e,0,0).top,s=t.lineAt(i,fy.ByPos,e,0,0).bottom;return r+=s-o,{from:n,to:i,top:o,bottom:s,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let e of this.viewports)e.domTop=o+(e.top-i)*this.scale,o=e.domBottom=e.domTop+(e.bottom-e.top),i=e.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}eq(e){return e instanceof By&&(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))}}function Iy(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new dy(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>Iy(e,t)):e._content)}const jy=Ep.define({combine:e=>e.join(" ")}),_y=Ep.define({combine:e=>e.indexOf(!0)>-1}),Fy=Im.newName(),Wy=Im.newName(),zy=Im.newName(),Hy={"&light":"."+Wy,"&dark":"."+zy};function Vy(e,t,n){return new Im(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!n||!n[t])throw new RangeError(`Unsupported selector: ${t}`);return n[t]}):e+" "+t})}const qy=Vy("."+Fy,{"&":{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"}},Hy),Uy={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},$y=ig.ie&&ig.ie_version<=11;class Ky{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Rg,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 e of t)this.queue.push(e);(ig.ie&&ig.ie_version<=11||ig.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),!window.EditContext||!ig.android||!1===e.constructor.EDIT_CONTEXT||ig.chrome&&ig.chrome_version<126||(this.editContext=new Xy(e),e.state.facet(kv)&&(e.contentDOM.editContext=this.editContext.editContext)),$y&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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(e=>{e.length>0&&e[e.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){("change"!=e.type&&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,r=this.selectionRange;if(n.state.facet(kv)?n.root.activeElement!=this.dom:!xg(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);i&&i.isWidget()&&i.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(ig.ie&&ig.ie_version<=11||ig.android&&ig.chrome)&&!n.state.selection.main.empty&&r.focusNode&&Sg(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=yg(e.root);if(!t)return!1;let n=ig.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Gy(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",r,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",r,!0),n?Gy(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=xg(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,Ng(n));;)if(r){if(1!=n.nodeType)return!1;let e=n.childNodes[r-1];"false"==e.contentEditable?r--:(n=e,r=Ng(n))}else{if(n==e)return!0;r=Eg(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(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(1==n.nodeType)!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(11!=n.nodeType)break;n=n.host}if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.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,Uy),$y&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),$y&&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 e=()=>{let e=this.delayedAndroidKey;if(e){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&Ig(this.dom,e.key,e.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(n=this.delayedAndroidKey)||void 0===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,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),-1==t?({from:t,to:n}=e):(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&xg(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new Mb(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}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,r=Db(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!Bb(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty("attributes"==e.type),"childList"==e.type){let n=Yy(t,e.previousSibling||e.target.previousSibling,-1),r=Yy(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{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(kv)!=e.state.facet(kv)&&(e.view.contentDOM.editContext=e.state.facet(kv)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(n=this.resizeScroll)||void 0===n||n.disconnect();for(let e of this.scrollTargets)e.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 Yy(e,t,n){for(;t;){let r=zv.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i!=e.dom?i:n>0?t.nextSibling:t.previousSibling}return null}function Gy(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,o=t.endOffset,s=e.docView.domAtPos(e.state.selection.main.anchor,1);return Sg(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}class Xy{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 r=e.state.selection.main,{anchor:i,head:o}=r,s=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:s,drifted:!1});let l=a-s>n.text.length;s==this.from&&i<this.from?s=i:a==this.to&&i>this.to&&(a=i);let c=Lb(e.state.sliceDoc(s,a),n.text,(l?r.from:r.to)-s,l?"end":null);if(!c){let t=xp.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));return void(Bb(t,r)||e.dispatch({selection:t,userEvent:"select"}))}let h={from:c.from+s,to:c.toA+s,insert:Xf.of(n.text.slice(c.from,c.toB).split("\n"))};if((ig.mac||ig.android)&&h.from==o-1&&/^\. ?$/.test(n.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(h={from:s,to:a,insert:Xf.of([n.text.replace("."," ")])}),this.pendingContextChange=h,!e.state.readOnly){let t=this.to-this.from+(h.to-h.from+h.insert.length);Pb(e,h,xp.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),h.from<h.to&&!h.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),o=this.toEditorPos(n.rangeEnd);t<o;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),o=this.toEditorPos(e.rangeEnd);if(i<o){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+" ":"Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":""}${/thin/i.test(r)?1:2}px`;n.push(dg.mark({attributes:{style:e}}).range(i,o))}}}e.dispatch({effects:wv.of(dg.set(n))})},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:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=yg(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,o,s,a,l)=>{if(n)return;let c=l.length-(o-i);if(r&&o>=r.to){if(r.from==i&&r.to==o&&r.insert.eq(l))return r=this.pendingContextChange=null,t+=c,void(this.to+=c);r=null,this.revertPending(e.state)}if(i+=t,(o+=t)<=this.from)this.from+=c,this.to+=c;else if(i<this.to){if(i<this.from||o>this.to||this.to-this.from+l.length>3e4)return void(n=!0);this.editContext.updateText(this.toContextPos(i),this.toContextPos(o),l.toString()),this.to+=c}t+=c}),r&&!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(e=>!e.isUserEvent("input.type")&&e.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)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(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))),r=this.toContextPos(t.head);this.editContext.selectionStart==n&&this.editContext.selectionEnd==r||this.editContext.updateSelection(n,r)}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>3e4)}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 Jy{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&&(e=>e.forEach(e=>n(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new Ty(e.state||dm.create(e)),e.scrollTo&&e.scrollTo.is(yv)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ev).map(e=>new Ov(e));for(let e of this.plugins)e.update(this);this.observer=new Ky(this),this.inputState=new Ib(this),this.inputState.ensureHandlers(this.plugins),this.docView=new hb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=!0,this.requestMeasure()})}dispatch(...e){let t=1==e.length&&e[0]instanceof tm?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,n=!1,r=!1,i=this.state;for(let t of e){if(t.startState!=i)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");i=t.state}if(this.destroyed)return void(this.viewState.state=i);let o=this.hasFocus,s=0,a=null;e.some(e=>e.annotation(ry))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=iy(i,o),a||(s=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(c=null)):this.observer.clear(),i.facet(dm.phrases)!=this.state.facet(dm.phrases))return this.setState(i);t=Fv.create(this,i,e),t.flags|=s;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(h&&(h=h.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;h=new bv(e.empty?e:xp.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(yv)&&(h=e.value.clip(this.state))}this.viewState.update(t,h),this.bidiCache=ew.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),n=this.docView.update(t),this.state.facet(jv)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(t.startState.facet(jy)!=t.state.facet(jy)&&(this.viewState.mustMeasureContent=!0),(n||r||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!t.empty)for(let e of this.state.facet(hv))try{e(t)}catch(e){xv(this.state,e,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Db(this,c)&&l.force&&Ig(this.contentDOM,l.key,l.keyCode)})}setState(e){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new Ty(e),this.plugins=e.facet(Ev).map(e=>new Ov(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new hb(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(Ev),n=e.state.facet(Ev);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new Ov(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].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(e){xv(this.state,e,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,r=n.scrollTop*this.scaleY,{scrollAnchorPos:i,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(o<0)if(jg(n))i=-1,o=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,o=e.top}this.updateState=1;let s=this.viewState.measure(this);if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5)break;let a=[];4&s||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(e=>{try{return e.read(this)}catch(e){return xv(this.state,e),Zy}}),c=Fv.create(this,this.state,[]),h=!1;c.flags|=s,t?t.flags|=s:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),h=this.docView.update(c),h&&this.docViewUpdate());for(let e=0;e<a.length;e++)if(l[e]!=Zy)try{let t=a[e];t.write&&t.write(l[e],this)}catch(e){xv(this.state,e)}if(h&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}{let e=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-o;if(e>1||e<-1){r+=e,n.scrollTop=r/this.scaleY,o=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(hv))e(t)}get themeClasses(){return Fy+" "+(this.state.facet(_y)?zy:Wy)+" "+this.state.facet(jy)}updateAttrs(){let e=tw(this,Nv,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(kv)?"true":"false",class:"cm-content",style:`${ig.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),tw(this,Av,t);let n=this.observer.ignore(()=>{let n=lg(this.contentDOM,this.contentAttrs,t),r=lg(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let e of n.effects)if(e.is(Jy.announce)){t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value}}mountStyles(){this.styleModules=this.state.facet(jv);let e=this.state.facet(Jy.cspNonce);Im.mount(this.root,this.styleModules.concat(qy).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&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(null!=e.key)for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key)return void(this.measureRequests[t]=e);this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.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 wb(this,e,vb(this,e,t,n))}moveByGroup(e,t){return wb(this,e,vb(this,e,t,t=>function(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==lm.Space&&(i=t),i==t}}(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return xp.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return function(e,t,n,r){let i=gb(e,t.head,t.assoc||-1),o=r&&i.type==ug.Text&&(e.lineWrapping||i.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head):null;if(o){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),s=e.posAtCoords({x:n==(r==zg.LTR)?t.right-1:t.left+1,y:(o.top+o.bottom)/2});if(null!=s)return xp.cursor(s,n?-1:1)}return xp.cursor(n?i.to:i.from,n?-1:1)}(this,e,t,n)}moveVertically(e,t,n){return wb(this,e,function(e,t,n,r){let i=t.head,o=n?1:-1;if(i==(n?e.state.doc.length:0))return xp.cursor(i,t.assoc);let s,a=t.goalColumn,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(i,t.assoc||-1),h=e.documentTop;if(c)null==a&&(a=c.left-l.left),s=o<0?c.top:c.bottom;else{let t=e.viewState.lineBlockAt(i);null==a&&(a=Math.min(l.right-l.left,e.defaultCharacterWidth*(i-t.from))),s=(o<0?t.top:t.bottom)+h}let u=kb(e,{x:l.left+a,y:s+(null!=r?r:e.viewState.heightOracle.textHeight>>1)*o},!1,o);return xp.cursor(u.pos,u.assoc,void 0,a)}(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=kb(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),kb(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 r=this.state.doc.lineAt(e),i=this.bidiSpans(r);return Ag(n,i[Jg.find(i,e-r.from,-1,t)].dir==zg.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(mv)||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>Qy)return nv(e.length);let t,n=this.textDirectionAt(e.from);for(let r of this.bidiCache)if(r.from==e.from&&r.dir==n&&(r.fresh||Qg(r.isolates,t=Lv(this,e))))return r.order;t||(t=Lv(this,e));let r=function(e,t,n){if(!e)return[new Jg(0,0,t==Vg?1:0)];if(t==Hg&&!n.length&&!Xg.test(e))return nv(e.length);if(n.length)for(;e.length>Zg.length;)Zg[Zg.length]=256;let r=[],i=t==Hg?0:1;return tv(e,i,i,n,0,e.length,r),r}(e.text,n,t);return this.bidiCache.push(new ew(e.from,e.to,n,t,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||ig.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Lg(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?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 yv.of(new bv("number"==typeof e?xp.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 yv.of(new bv(xp.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Cv.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Cv.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Im.newName(),r=[jy.of(n),jv.of(Vy(`.${n}`,e))];return t&&t.dark&&r.push(_y.of(!0)),r}static baseTheme(e){return jp.lowest(jv.of(Vy("."+Fy,e,Hy)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&zv.get(n)||zv.get(e);return(null===(t=null==r?void 0:r.root)||void 0===t?void 0:t.view)||null}}Jy.styleModule=jv,Jy.inputHandler=uv,Jy.clipboardInputFilter=fv,Jy.clipboardOutputFilter=pv,Jy.scrollHandler=vv,Jy.focusChangeEffect=dv,Jy.perLineTextDirection=mv,Jy.exceptionSink=cv,Jy.updateListener=hv,Jy.editable=kv,Jy.mouseSelectionStyle=lv,Jy.dragMovesSelection=av,Jy.clickAddsSelectionRange=sv,Jy.decorations=Tv,Jy.blockWrappers=Mv,Jy.outerDecorations=Rv,Jy.atomicRanges=Dv,Jy.bidiIsolatedRanges=Pv,Jy.scrollMargins=Bv,Jy.darkTheme=_y,Jy.cspNonce=Ep.define({combine:e=>e.length?e[0]:""}),Jy.contentAttributes=Av,Jy.editorAttributes=Nv,Jy.lineWrapping=Jy.contentAttributes.of({class:"cm-lineWrapping"}),Jy.announce=em.define();const Qy=4096,Zy={};class ew{constructor(e,t,n,r,i,o){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=o}static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let n=[],r=e.length?e[e.length-1].dir:zg.LTR;for(let i=Math.max(0,e.length-10);i<e.length;i++){let o=e[i];o.dir!=r||t.touchesRange(o.from,o.to)||n.push(new ew(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function tw(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],o="function"==typeof t?t(e):t;o&&og(o,n)}return n}const nw=ig.mac?"mac":ig.windows?"win":ig.linux?"linux":"key";function rw(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}const iw=jp.default(Jy.domEventHandlers({keydown:(e,t)=>uw(aw(t.state),e,t,"editor")})),ow=Ep.define({enables:iw}),sw=new WeakMap;function aw(e){let t=e.facet(ow),n=sw.get(t);return n||sw.set(t,n=function(e,t=nw){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(null==n)r[e]=t;else if(n!=t)throw new Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},o=(e,r,o,s,a)=>{var l,c;let h=n[e]||(n[e]=Object.create(null)),u=r.split(/ (?!$)/).map(e=>function(e,t){const n=e.split(/-(?!$)/);let r,i,o,s,a=n[n.length-1];"Space"==a&&(a=" ");for(let e=0;e<n.length-1;++e){const a=n[e];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else{if(!/^mod$/i.test(a))throw new Error("Unrecognized modifier name: "+a);"mac"==t?s=!0:i=!0}}return r&&(a="Alt-"+a),i&&(a="Ctrl-"+a),s&&(a="Meta-"+a),o&&(a="Shift-"+a),a}(e,t));for(let t=1;t<u.length;t++){let n=u.slice(0,t).join(" ");i(n,!0),h[n]||(h[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=lw={view:t,prefix:n,scope:e};return setTimeout(()=>{lw==r&&(lw=null)},cw),!0}]})}let d=u.join(" ");i(d,!1);let f=h[d]||(h[d]={preventDefault:!1,stopPropagation:!1,run:(null===(c=null===(l=h._any)||void 0===l?void 0:l.run)||void 0===c?void 0:c.slice())||[]});o&&f.run.push(o),s&&(f.preventDefault=!0),a&&(f.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(" "):["editor"];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,hw))}let i=r[t]||r.key;if(i)for(let t of e)o(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&o(t,"Shift-"+i,r.shift,r.preventDefault,r.stopPropagation)}return n}(t.reduce((e,t)=>e.concat(t),[]))),n}let lw=null;const cw=4e3;let hw=null;function uw(e,t,n,r){hw=t;let i=function(e){var t=!(zm&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Hm&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Wm:Fm)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(t),o=cp(ap(i,0))==i.length&&" "!=i,s="",a=!1,l=!1,c=!1;lw&&lw.view==n&&lw.scope==r&&(s=lw.prefix+" ",zb.indexOf(t.keyCode)<0&&(l=!0,lw=null));let h,u,d=new Set,f=e=>{if(e){for(let t of e.run)if(!d.has(t)&&(d.add(t),t(n)))return e.stopPropagation&&(c=!0),!0;e.preventDefault&&(e.stopPropagation&&(c=!0),l=!0)}return!1},p=e[r];return p&&(f(p[s+rw(i,t,!o)])?a=!0:!o||!(t.altKey||t.metaKey||t.ctrlKey)||ig.windows&&t.ctrlKey&&t.altKey||ig.mac&&t.altKey&&!t.ctrlKey&&!t.metaKey||!(h=Fm[t.keyCode])||h==i?o&&t.shiftKey&&f(p[s+rw(i,t,!0)])&&(a=!0):(f(p[s+rw(h,t,!0)])||t.shiftKey&&(u=Wm[t.keyCode])!=i&&u!=h&&f(p[s+rw(u,t,!1)]))&&(a=!0),!a&&f(p._any)&&(a=!0)),l&&(a=!0),a&&c&&t.stopPropagation(),hw=null,a}class dw{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(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 r=e.coordsAtPos(n.head,n.assoc||1);if(!r)return[];let i=fw(e);return[new dw(t,r.left-i.left,r.top-i.top,null,r.bottom-r.top)]}return function(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),o=e.textDirection==zg.LTR,s=e.contentDOM,a=s.getBoundingClientRect(),l=fw(e),c=s.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),d=a.right-(h?parseInt(h.paddingRight):0),f=gb(e,r,1),p=gb(e,i,-1),m=f.type==ug.Text?f:null,g=p.type==ug.Text?p:null;m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=pw(e,r,1,m));g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=pw(e,i,-1,g));if(m&&g&&m.from==g.from&&m.to==g.to)return b(y(n.from,n.to,m));{let t=m?y(n.from,null,m):w(f,!1),r=g?y(null,n.to,g):w(p,!0),i=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<r.top?i.push(v(u,t.bottom,d,r.top)):t.bottom<r.top&&e.elementAtHeight((t.bottom+r.top)/2).type==ug.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),b(t).concat(i).concat(b(r))}function v(e,n,r,i){return new dw(t,e-l.left,n-l.top,r-e,i-n)}function b({top:e,bottom:t,horizontal:n}){let r=[];for(let i=0;i<n.length;i+=2)r.push(v(n[i],e,n[i+1],t));return r}function y(t,n,r){let i=1e9,s=-1e9,a=[];function l(t,n,l,c,h){let f=e.coordsAtPos(t,t==r.to?-2:2),p=e.coordsAtPos(l,l==r.from?2:-2);f&&p&&(i=Math.min(f.top,p.top,i),s=Math.max(f.bottom,p.bottom,s),h==zg.LTR?a.push(o&&n?u:f.left,o&&c?d:p.right):a.push(!o&&c?u:p.left,!o&&n?d:f.right))}let c=null!=t?t:r.from,h=null!=n?n:r.to;for(let r of e.visibleRanges)if(r.to>c&&r.from<h)for(let i=Math.max(r.from,c),o=Math.min(r.to,h);;){let r=e.state.doc.lineAt(i);for(let s of e.bidiSpans(r)){let e=s.from+r.from,a=s.to+r.from;if(e>=o)break;a>i&&l(Math.max(e,i),null==t&&e<=c,Math.min(a,o),null==n&&a>=h,s.dir)}if(i=r.to+1,i>=o)break}return 0==a.length&&l(c,null==t,h,null==n,e.textDirection),{top:i,bottom:s,horizontal:a}}function w(e,t){let n=a.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}(e,t,n)}}function fw(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==zg.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function pw(e,t,n,r){let i=e.coordsAtPos(t,2*n);if(!i)return r;let o=e.dom.getBoundingClientRect(),s=(i.top+i.bottom)/2,a=e.posAtCoords({x:o.left+1,y:s}),l=e.posAtCoords({x:o.right-1,y:s});return null==a||null==l?r:{from:Math.max(r.from,Math.min(a,l)),to:Math.min(r.to,Math.max(a,l))}}class mw{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(gw)!=e.state.facet(gw)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){!1!==this.layer.updateOnDocViewUpdate&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(gw);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((e,t)=>{return n=e,r=this.drawn[t],!(n.constructor==r.constructor&&n.eq(r));var n,r})){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,ig.safari&&ig.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 gw=Ep.define();function vw(e){return[Cv.define(t=>new mw(t,e)),gw.of(e)]}const bw=Ep.define({combine:e=>fm(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function yw(e){return e.startState.facet(bw)!=e.state.facet(bw)}const ww=vw({above:!0,markers(e){let{state:t}=e,n=t.facet(bw),r=[];for(let i of t.selection.ranges){let o=i==t.selection.main;if(i.empty||n.drawRangeCursor){let t=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",n=i.empty?i:xp.cursor(i.head,i.head>i.anchor?-1:1);for(let i of dw.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");let n=yw(e);return n&&xw(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){xw(t.state,e)},class:"cm-cursorLayer"});function xw(e,t){t.style.animationDuration=e.facet(bw).cursorBlinkRate+"ms"}const kw=vw({above:!1,markers:e=>e.state.selection.ranges.map(t=>t.empty?[]:dw.forRange(e,"cm-selectionBackground",t)).reduce((e,t)=>e.concat(t)),update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||yw(e),class:"cm-selectionLayer"}),Sw=jp.highest(Jy.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"}}}})),Ew=em.define({map:(e,t)=>null==e?null:t.mapPos(e)}),Cw=Rp.define({create:()=>null,update:(e,t)=>(null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(Ew)?t.value:e,e))}),Ow=Cv.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(Cw);null==n?null!=this.cursor&&(null===(t=this.cursor)||void 0===t||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(Cw)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(Cw),n=null!=t&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(Cw)!=e&&this.view.dispatch({effects:Ew.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){e.target!=this.view.contentDOM&&this.view.contentDOM.contains(e.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Nw(e,t,n,r,i){t.lastIndex=0;for(let o,s=e.iterRange(n,r),a=n;!s.next().done;a+=s.value.length)if(!s.lineBreak)for(;o=t.exec(s.value);)i(a+o.index,o)}class Aw{constructor(e){const{regexp:t,decoration:n,decorate:r,boundary:i,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,r)this.addMatch=(e,t,n,i)=>r(i,n,n+e[0].length,e,t);else if("function"==typeof n)this.addMatch=(e,t,r,i)=>{let o=n(e,t,r);o&&i(r,r+e[0].length,o)};else{if(!n)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(e,t,r,i)=>i(r,r+e[0].length,n)}this.boundary=i,this.maxLength=o}createDeco(e){let t=new wm,n=t.add.bind(t);for(let{from:t,to:r}of function(e,t){let n=e.visibleRanges;if(1==n.length&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let r=[];for(let{from:i,to:o}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),o=Math.min(e.state.doc.lineAt(o).to,o+t),r.length&&r[r.length-1].to>=i?r[r.length-1].to=o:r.push({from:i,to:o});return r}(e,this.maxLength))Nw(e.state.doc,this.regexp,t,r,(t,r)=>this.addMatch(r,e,t,n));return t.finish()}updateDeco(e,t){let n=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((t,i,o,s)=>{s>=e.view.viewport.from&&o<=e.view.viewport.to&&(n=Math.min(o,n),r=Math.max(s,r))}),e.viewportMoved||r-n>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),n,r):t}updateRange(e,t,n,r){for(let i of e.visibleRanges){let o=Math.max(i.from,n),s=Math.min(i.to,r);if(s>=o){let n=e.state.doc.lineAt(o),r=n.to<s?e.state.doc.lineAt(s):n,a=Math.max(i.from,n.from),l=Math.min(i.to,r.to);if(this.boundary){for(;o>n.from;o--)if(this.boundary.test(n.text[o-1-n.from])){a=o;break}for(;s<r.to;s++)if(this.boundary.test(r.text[s-r.from])){l=s;break}}let c,h=[],u=(e,t,n)=>h.push(n.range(e,t));if(n==r)for(this.regexp.lastIndex=a-n.from;(c=this.regexp.exec(n.text))&&c.index<l-n.from;)this.addMatch(c,e,c.index+n.from,u);else Nw(e.state.doc,this.regexp,a,l,(t,n)=>this.addMatch(n,e,t,u));t=t.update({filterFrom:a,filterTo:l,filter:(e,t)=>e<a||t>l,add:h})}}return t}}const Tw=null!=/x/.unicode?"gu":"g",Mw=new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\ufeff-]",Tw),Rw={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 Dw=null;const Pw=Ep.define({combine(e){let t=fm(e,{render:null,specialChars:Mw,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==Dw&&"undefined"!=typeof document&&document.body){let t=document.body.style;Dw=null!=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)}return Dw||!1}())&&(t.specialChars=new RegExp("\t|"+t.specialChars.source,Tw)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,Tw)),t}});let Lw=null;class Bw extends hg{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=function(e){return e>=32?"•":10==e?"␤":String.fromCharCode(9216+e)}(this.code),n=e.state.phrase("Control character")+" "+(Rw[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,t);if(r)return r;let i=document.createElement("span");return i.textContent=t,i.title=n,i.setAttribute("aria-label",n),i.className="cm-specialChar",i}ignoreEvent(){return!1}}class Iw extends hg{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent="\t",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}const jw=dg.line({class:"cm-activeLine"}),_w=Cv.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(jw.range(i.from)),t=i.from)}return dg.set(n)}},{decorations:e=>e.decorations});class Fw extends hg{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild("string"==typeof this.content?document.createTextNode(this.content):"function"==typeof this.content?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?kg(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=Ag(t[0],"rtl"!=n.direction),i=parseInt(n.lineHeight);return r.bottom-r.top>1.5*i?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}}const Ww=2e3;function zw(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,o=i>Ww?-1:i==r.length?function(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}(e,t.clientX):Rm(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:o,off:i}}function Hw(e,t){let n=zw(e,t),r=e.state.selection;return n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(t,i,o){let s=zw(e,t);if(!s)return r;let a=function(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),o=[];if(t.off>Ww||n.off>Ww||t.col<0||n.col<0){let s=Math.min(t.off,n.off),a=Math.max(t.off,n.off);for(let t=r;t<=i;t++){let n=e.doc.line(t);n.length<=a&&o.push(xp.range(n.from+s,n.to+a))}}else{let s=Math.min(t.col,n.col),a=Math.max(t.col,n.col);for(let t=r;t<=i;t++){let n=e.doc.line(t),r=Dm(n.text,s,e.tabSize,!0);if(r<0)o.push(xp.cursor(n.to));else{let t=Dm(n.text,a,e.tabSize);o.push(xp.range(n.from+r,n.from+t))}}}return o}(e.state,n,s);return a.length?o?xp.create(a.concat(r.ranges)):xp.create(a):r}}:null}const Vw={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},qw={style:"cursor: crosshair"};const Uw="-10000px";class $w{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let o=[],s=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],a=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(a=e)}if(a<0)o[n]=this.createTooltipView(r,n?o[n-1]:null),s&&(s[n]=!!r.above);else{let r=o[n]=this.tooltipViews[a];s&&(s[n]=t[a]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)o.indexOf(e)<0&&(this.removeTooltipView(e),null===(n=e.destroy)||void 0===n||n.call(e));return t&&(s.forEach((e,n)=>t[n]=e),t.length=s.length),this.input=r,this.tooltips=i,this.tooltipViews=o,!0}}function Kw(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const Yw=Ep.define({combine:e=>{var t,n,r;return{position:ig.ios?"absolute":(null===(t=e.find(e=>e.position))||void 0===t?void 0:t.position)||"fixed",parent:(null===(n=e.find(e=>e.parent))||void 0===n?void 0:n.parent)||null,tooltipSpace:(null===(r=e.find(e=>e.tooltipSpace))||void 0===r?void 0:r.tooltipSpace)||Kw}}}),Gw=new WeakMap,Xw=Cv.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(Yw);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new $w(e,ex,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.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 e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(Yw);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let e=document.createElement("div");e.className="cm-tooltip-arrow",n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=Uw,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),null===(e=t.destroy)||void 0===e||e.call(t);this.parent&&this.container.remove(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(n=this.intersectionObserver)||void 0===n||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(ig.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||"absolute"==this.position)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=Iv(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(Yw).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let e of this.manager.tooltipViews)e.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:o}=e,s=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:h}=c,u=e.pos[a],d=e.size[a];if(!u||!1!==l.clip&&(u.bottom<=Math.max(n.top,r.top)||u.top>=Math.min(n.bottom,r.bottom)||u.right<Math.max(n.left,r.left)-.1||u.left>Math.min(n.right,r.right)+.1)){h.style.top=Uw;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=null!==(t=Gw.get(c))&&void 0!==t?t:d.bottom-d.top,v=c.offset||Zw,b=this.view.textDirection==zg.LTR,y=d.width>r.right-r.left?b?r.left:r.right-d.width:b?Math.max(r.left,Math.min(u.left-(f?14:0)+v.x,r.right-m)):Math.min(Math.max(r.left,u.left-m+(f?14:0)-v.x),r.right-m),w=this.above[a];!l.strictSide&&(w?u.top-g-p-v.y<r.top:u.bottom+g+p+v.y>r.bottom)&&w==r.bottom-u.bottom>u.top-r.top&&(w=this.above[a]=!w);let x=(w?u.top-r.top:r.bottom-u.bottom)-p;if(x<g&&!1!==c.resize){if(x<this.view.defaultLineHeight){h.style.top=Uw;continue}Gw.set(c,g),h.style.height=(g=x)/o+"px"}else h.style.height&&(h.style.height="");let k=w?u.top-g-p-v.y:u.bottom+p+v.y,S=y+m;if(!0!==c.overlap)for(let e of s)e.left<S&&e.right>y&&e.top<k+g&&e.bottom>k&&(k=w?e.top-g-2-p:e.bottom+p+2);if("absolute"==this.position?(h.style.top=(k-e.parent.top)/o+"px",Jw(h,(y-e.parent.left)/i)):(h.style.top=k/o+"px",Jw(h,y/i)),f){let e=u.left+(b?v.x:-v.x)-(y+14-7);f.style.left=e/i+"px"}!0!==c.overlap&&s.push({left:y,top:k,right:S,bottom:k+g}),h.classList.toggle("cm-tooltip-above",w),h.classList.toggle("cm-tooltip-below",!w),c.positioned&&c.positioned(e.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 e of this.manager.tooltipViews)e.dom.style.top=Uw}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Jw(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const Qw=Jy.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"}}}),Zw={x:0,y:0},ex=Ep.define({enables:[Xw,Qw]}),tx=Ep.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])});class nx{static create(e){return new nx(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new $w(e,tx,(e,t)=>this.createHostedView(e,t),e=>e.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)null===(e=t.destroy)||void 0===e||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(void 0!==r)if(void 0===t)t=r;else if(t!==r)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 rx=ex.compute([tx],e=>{let t=e.facet(tx);return 0===t.length?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var t;return null!==(t=e.end)&&void 0!==t?t:e.pos})),create:nx.create,above:t[0].above,arrow:t.some(e=>e.arrow)}});class ix{constructor(e,t,n,r,i){this.view=e,this.source=t,this.field=n,this.setHover=r,this.hoverTime=i,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.tile.nearest(t.target);if(!n)return;let r,i=1;if(n.isWidget())r=n.posAtStart;else{if(r=e.posAtCoords(t),null==r)return;let n=e.coordsAtPos(r);if(!n||t.y<n.top||t.y>n.bottom||t.x<n.left-e.defaultCharacterWidth||t.x>n.right+e.defaultCharacterWidth)return;let o=e.bidiSpans(e.state.doc.lineAt(r)).find(e=>e.from<=r&&e.to>=r),s=o&&o.dir==zg.RTL?-1:1;i=t.x<n.left?-s:s}let o=this.source(e,r,i);if(null==o?void 0:o.then){let t=this.pending={pos:r};o.then(n=>{this.pending==t&&(this.pending=null,!n||Array.isArray(n)&&!n.length||e.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])}))},t=>xv(e.state,t,"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(Xw),t=e?e.manager.tooltips.findIndex(e=>e.create==nx.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:r,tooltip:i}=this;if(r.length&&i&&!function(e,t){let n,{left:r,right:i,top:o,bottom:s}=e.getBoundingClientRect();if(n=e.querySelector(".cm-tooltip-arrow")){let e=n.getBoundingClientRect();o=Math.min(e.top,o),s=Math.max(e.bottom,s)}return t.clientX>=r-ox&&t.clientX<=i+ox&&t.clientY>=o-ox&&t.clientY<=s+ox}(i.dom,e)||this.pending){let{pos:i}=r[0]||this.pending,o=null!==(n=null===(t=r[0])||void 0===t?void 0:t.end)&&void 0!==n?n:i;(i==o?this.view.posAtCoords(this.lastMove)==i:function(e,t,n,r,i){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,s)<i)return!1;let a=e.posAtCoords({x:r,y:i},!1);return a>=t&&a<=n}(this.view,i,o,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:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.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),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const ox=4;function sx(e,t={}){let n=em.define(),r=Rp.define({create:()=>[],update(e,r){if(e.length&&(t.hideOnChange&&(r.docChanged||r.selection)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(r,e))),r.docChanged)){let t=[];for(let n of e){let e=r.changes.mapPos(n.pos,-1,up.TrackDel);if(null!=e){let i=Object.assign(Object.create(null),n);i.pos=e,null!=i.end&&(i.end=r.changes.mapPos(i.end)),t.push(i)}}e=t}for(let t of r.effects)t.is(n)&&(e=t.value),t.is(lx)&&(e=[]);return e},provide:e=>tx.from(e)});return{active:r,extension:[r,Cv.define(i=>new ix(i,e,r,n,t.hoverTime||300)),rx]}}function ax(e,t){let n=e.plugin(Xw);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const lx=em.define(),cx=Ep.define({combine(e){let t,n;for(let r of e)t=t||r.topContainer,n=n||r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function hx(e,t){let n=e.plugin(ux),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const ux=Cv.fromClass(class{constructor(e){this.input=e.state.facet(px),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(cx);this.top=new dx(e,!0,t.topContainer),this.bottom=new dx(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(e){let t=e.state.facet(cx);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new dx(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new dx(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(px);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],o=[],s=[];for(let n of t){let t,a=this.specs.indexOf(n);a<0?(t=n(e.view),s.push(t)):(t=this.panels[a],t.update&&t.update(e)),r.push(t),(t.top?i:o).push(t)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(o);for(let e of s)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>Jy.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class dx{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(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));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 e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=fx(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=fx(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 fx(e){let t=e.nextSibling;return e.remove(),t}const px=Ep.define({enables:ux});function mx(e,t){let n,r=new Promise(e=>n=e),i=e=>function(e,t,n){let r=t.content?t.content(e,()=>s(null)):null;if(!r){if(r=Um("form"),t.input){let e=Um("input",t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add("cm-textfield"),e.name||(e.name="input"),r.appendChild(Um("label",(t.label||"")+": ",e))}else r.appendChild(document.createTextNode(t.label||""));r.appendChild(document.createTextNode(" ")),r.appendChild(Um("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let i="FORM"==r.nodeName?[r]:r.querySelectorAll("form");for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener("keydown",e=>{27==e.keyCode?(e.preventDefault(),s(null)):13==e.keyCode&&(e.preventDefault(),s(t))}),t.addEventListener("submit",e=>{e.preventDefault(),s(t)})}let o=Um("div",r,Um("button",{onclick:()=>s(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));t.class&&(o.className=t.class);function s(t){o.contains(o.ownerDocument.activeElement)&&e.focus(),n(t)}return o.classList.add("cm-dialog"),{dom:o,top:t.top,mount:()=>{if(t.focus){let e;e="string"==typeof t.focus?r.querySelector(t.focus):r.querySelector("input")||r.querySelector("button"),e&&"select"in e?e.select():e&&"focus"in e&&e.focus()}}}}(e,t,n);e.state.field(gx,!1)?e.dispatch({effects:vx.of(i)}):e.dispatch({effects:em.appendConfig.of(gx.init(()=>[i]))});let o=bx.of(i);return{close:o,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(gx).indexOf(i)>-1&&e.dispatch({effects:o})}),t))}}const gx=Rp.define({create:()=>[],update(e,t){for(let n of t.effects)n.is(vx)?e=[n.value].concat(e):n.is(bx)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>px.computeN([e],t=>t.field(e))}),vx=em.define(),bx=em.define();class yx extends pm{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}yx.prototype.elementClass="",yx.prototype.toDOM=void 0,yx.prototype.mapMode=up.TrackBefore,yx.prototype.startSide=yx.prototype.endSide=-1,yx.prototype.point=!0;const wx=Ep.define(),xx=Ep.define(),kx={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ym.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Sx=Ep.define();function Ex(e){return[Ox(),Sx.of({...kx,...e})]}const Cx=Ep.define({combine:e=>e.some(e=>e)});function Ox(e){let t=[Nx];return e&&!1===e.fixed&&t.push(Cx.of(!0)),t}const Nx=Cv.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.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=e.state.facet(Sx).map(t=>new Rx(e,t)),this.fixed=!e.state.facet(Cx);for(let e of this.gutters)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.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(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<.8*(n.to-n.from))}if(e.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(Cx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=ym.iter(this.view.state.facet(wx),this.view.viewport.from),r=[],i=this.gutters.map(e=>new Mx(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let o of e.type)if(o.type==ug.Text&&t){Tx(n,r,o.from);for(let e of i)e.line(this.view,o,r);t=!1}else if(o.widget)for(let e of i)e.widget(this.view,o)}else if(e.type==ug.Text){Tx(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(Sx),n=e.state.facet(Sx),r=e.docChanged||e.heightChanged||e.viewportChanged||!ym.eq(e.startState.facet(wx),e.state.facet(wx),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new Rx(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>Jy.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||0==n.gutters.length||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==zg.LTR?{left:r,right:i}:{right:r,left:i}})});function Ax(e){return Array.isArray(e)?e:[e]}function Tx(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class Mx{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=ym.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let t=new Dx(e,o,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,o,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];Tx(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let o=this.gutter;(0!=r.length||o.config.renderEmptyElements)&&this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(xx)){let i=n(e,t.widget,t);i&&(r||(r=[])).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Rx{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,r=>{let i,o=r.target;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let e=o.getBoundingClientRect();i=(e.top+e.bottom)/2}else i=r.clientY;let s=e.lineBlockAtHeight(i-e.documentTop);t.domEventHandlers[n](e,s,r)&&r.preventDefault()});this.markers=Ax(t.markers(e)),t.initialSpacer&&(this.spacer=new Dx(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=Ax(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!ym.eq(this.markers,t,n.from,n.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}destroy(){for(let e of this.elements)e.destroy()}}class Dx{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),function(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n="cm-gutterElement",r=this.dom.firstChild;for(let i=0,o=0;;){let s=o,a=i<t.length?t[i++]:null,l=!1;if(a){let e=a.elementClass;e&&(n+=" "+e);for(let e=o;e<this.markers.length;e++)if(this.markers[e].compare(a)){s=e,l=!0;break}}else s=this.markers.length;for(;o<s;){let e=this.markers[o++];if(e.toDOM){e.destroy(r);let t=r.nextSibling;r.remove(),r=t}}if(!a)break;a.toDOM&&(l?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),l&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}}const Px=Ep.define(),Lx=Ep.define(),Bx=Ep.define({combine:e=>fm(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let r=n[e],i=t[e];n[e]=r?(e,t,n)=>r(e,t,n)||i(e,t,n):i}return n}})});class Ix extends yx{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function jx(e,t){return e.state.facet(Bx).formatNumber(t,e.state)}const _x=Sx.compute([Bx],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(Px),lineMarker:(e,t,n)=>n.some(e=>e.toDOM)?null:new Ix(jx(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,n)=>{for(let r of e.state.facet(Lx)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(Bx)!=e.state.facet(Bx),initialSpacer:e=>new Ix(jx(e,Fx(e.state.doc.lines))),updateSpacer(e,t){let n=jx(t.view,Fx(t.view.state.doc.lines));return n==e.number?e:new Ix(n)},domEventHandlers:e.facet(Bx).domEventHandlers,side:"before"}));function Fx(e){let t=9;for(;t<e;)t=10*t+9;return t}const Wx=new class extends yx{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},zx=wx.compute(["selection"],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(Wx.range(i)))}return ym.of(t)});const Hx=1024;let Vx=0;class qx{constructor(e,t){this.from=e,this.to=t}}class Ux{constructor(e={}){this.id=Vx++,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"function"!=typeof e&&(e=Yx.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}Ux.closedBy=new Ux({deserialize:e=>e.split(" ")}),Ux.openedBy=new Ux({deserialize:e=>e.split(" ")}),Ux.group=new Ux({deserialize:e=>e.split(" ")}),Ux.isolate=new Ux({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),Ux.contextHash=new Ux({perNode:!0}),Ux.lookAhead=new Ux({perNode:!0}),Ux.mounted=new Ux({perNode:!0});class $x{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[Ux.mounted.id]}}const Kx=Object.create(null);class Yx{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):Kx,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),r=new Yx(e.name||"",t,e.id,n);if(e.props)for(let n of e.props)if(Array.isArray(n)||(n=n(r)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}return r}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(Ux.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return e=>{for(let n=e.prop(Ux.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}}Yx.none=new Yx("",Object.create(null),0,8);class Gx{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 r=null;for(let t of e){let e=t(n);if(e){r||(r=Object.assign({},n.props));let t=e[1],i=e[0];i.combine&&i.id in r&&(t=i.combine(r[i.id],t)),r[i.id]=t}}t.push(r?new Yx(n.name,r,n.id,n.flags):n)}return new Gx(t)}}const Xx=new WeakMap,Jx=new WeakMap;var Qx;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"}(Qx||(Qx={}));class Zx{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=$x.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let n=e.toString();n&&(t&&(t+=","),t+=n)}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 dk(this.topNode,e)}cursorAt(e,t=0,n=0){let r=Xx.get(this)||this.topNode,i=new dk(r);return i.moveTo(e,t),Xx.set(this,i._tree),i}get topNode(){return new ok(this,0,0,null)}resolve(e,t=0){let n=rk(Xx.get(this)||this.topNode,e,t,!1);return Xx.set(this,n),n}resolveInner(e,t=0){let n=rk(Jx.get(this)||this.topNode,e,t,!0);return Jx.set(this,n),n}resolveStack(e,t=0){return function(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof ok?r:r.context.parent;e;e=e.parent)if(e.index<0){let o=e.parent;(i||(i=[r])).push(o.resolve(t,n)),e=o}else{let o=$x.get(e.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let s=new ok(o.tree,o.overlay[0].from+e.from,-1,e);(i||(i=[r])).push(rk(s,t,n,!1))}}return i?hk(i):r}(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,o=e.mode||0,s=(o&Qx.IncludeAnonymous)>0;for(let e=this.cursor(o|Qx.IncludeAnonymous);;){let o=!1;if(e.from<=i&&e.to>=r&&(!s&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;o=!0}for(;o&&n&&(s||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;o=!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:gk(Yx.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,n)=>new Zx(this.type,e,t,n,this.propValues),e.makeTree||((e,t,n)=>new Zx(Yx.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=Hx,reused:o=[],minRepeatType:s=r.types.length}=e,a=Array.isArray(n)?new ek(n,n.length):n,l=r.types,c=0,h=0;function u(e,t,n,b,y,w){let{id:x,start:k,end:S,size:E}=a,C=h,O=c;if(E<0){if(a.next(),-1==E){let t=o[x];return n.push(t),void b.push(k-e)}if(-3==E)return void(c=x);if(-4==E)return void(h=x);throw new RangeError(`Unrecognized record size: ${E}`)}let N,A,T=l[x],M=k-e;if(S-k<=i&&(A=g(a.pos-t,y))){let t=new Uint16Array(A.size-A.skip),n=a.pos-A.size,i=t.length;for(;a.pos>n;)i=v(A.start,t,i);N=new tk(t,S-A.start,r),M=A.start-e}else{let e=a.pos-E;a.next();let t=[],n=[],r=x>=s?x:-1,o=0,l=S;for(;a.pos>e;)r>=0&&a.id==r&&a.size>=0?(a.end<=l-i&&(p(t,n,k,o,a.end,l,r,C,O),o=t.length,l=a.end),a.next()):w>2500?d(k,e,t,n):u(k,e,t,n,r,w+1);if(r>=0&&o>0&&o<t.length&&p(t,n,k,o,k,l,r,C,O),t.reverse(),n.reverse(),r>-1&&o>0){let e=f(T,O);N=gk(T,t,n,0,t.length,0,S-k,e,e)}else N=m(T,t,n,S-k,C-S,O)}n.push(N),b.push(M)}function d(e,t,n,o){let s=[],l=0,c=-1;for(;a.pos>t;){let{id:e,start:t,end:n,size:r}=a;if(r>4)a.next();else{if(c>-1&&t<c)break;c<0&&(c=n-i),s.push(e,t,n),l++,a.next()}}if(l){let t=new Uint16Array(4*l),i=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-i,t[n++]=s[e+2]-i,t[n++]=n;n.push(new tk(t,s[2]-i,r)),o.push(i-e)}}function f(e,t){return(n,r,i)=>{let o,s,a=0,l=n.length-1;if(l>=0&&(o=n[l])instanceof Zx){if(!l&&o.type==e&&o.length==i)return o;(s=o.prop(Ux.lookAhead))&&(a=r[l]+o.length+s)}return m(e,n,r,i,a,t)}}function p(e,t,n,i,o,s,a,l,c){let h=[],u=[];for(;e.length>i;)h.push(e.pop()),u.push(t.pop()+n-o);e.push(m(r.types[a],h,u,s-o,l-s,c)),t.push(o-n)}function m(e,t,n,r,i,o,s){if(o){let e=[Ux.contextHash,o];s=s?[e].concat(s):[e]}if(i>25){let e=[Ux.lookAhead,i];s=s?[e].concat(s):[e]}return new Zx(e,t,n,r,s)}function g(e,t){let n=a.fork(),r=0,o=0,l=0,c=n.end-i,h={size:0,start:0,skip:0};e:for(let i=n.pos-e;n.pos>i;){let e=n.size;if(n.id==t&&e>=0){h.size=r,h.start=o,h.skip=l,l+=4,r+=4,n.next();continue}let a=n.pos-e;if(e<0||a<i||n.start<c)break;let u=n.id>=s?4:0,d=n.start;for(n.next();n.pos>a;){if(n.size<0){if(-3!=n.size&&-4!=n.size)break e;u+=4}else n.id>=s&&(u+=4);n.next()}o=d,r+=e,l+=u}return(t<0||r==e)&&(h.size=r,h.start=o,h.skip=l),h.size>4?h:void 0}function v(e,t,n){let{id:r,start:i,end:o,size:l}=a;if(a.next(),l>=0&&r<s){let s=n;if(l>4){let r=a.pos-(l-4);for(;a.pos>r;)n=v(e,t,n)}t[--n]=s,t[--n]=o-e,t[--n]=i-e,t[--n]=r}else-3==l?c=r:-4==l&&(h=r);return n}let b=[],y=[];for(;a.pos>0;)u(e.start||0,e.bufferStart||0,b,y,-1,0);let w=null!==(t=e.length)&&void 0!==t?t:b.length?y[0]+b[0].length:0;return new Zx(l[e.topID],b.reverse(),y.reverse(),w)}(e)}}Zx.empty=new Zx(Yx.none,[],[],0);class ek{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 ek(this.buffer,this.index)}}class tk{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Yx.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],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),n==(e+=4))return i;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return i+"("+o.join(",")+")"}findChild(e,t,n,r,i){let{buffer:o}=this,s=-1;for(let a=e;a!=t&&!(nk(i,r,o[a+1],o[a+2])&&(s=a,n>0));a=o[a+3]);return s}slice(e,t,n){let r=this.buffer,i=new Uint16Array(t-e),o=0;for(let s=e,a=0;s<t;){i[a++]=r[s++],i[a++]=r[s++]-n;let t=i[a++]=r[s++]-n;i[a++]=r[s++]-e,o=Math.max(o,t)}return new tk(i,o,this.set)}}function nk(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function rk(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof ok&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=r?0:Qx.IgnoreOverlays;if(r)for(let r=e,s=r.parent;s;r=s,s=r.parent)r instanceof ok&&r.index<0&&(null===(i=s.enter(t,n,o))||void 0===i?void 0:i.from)!=r.from&&(e=s);for(;;){let r=e.enter(t,n,o);if(!r)return e;e=r}}class ik{cursor(e=0){return new dk(this,e)}getChild(e,t=null,n=null){let r=sk(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return sk(this,e,t,n)}resolve(e,t=0){return rk(this,e,t,!1)}resolveInner(e,t=0){return rk(this,e,t,!0)}matchContext(e){return ak(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class ok extends ik{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}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,r,i=0){var o;for(let s=this;;){for(let{children:a,positions:l}=s._tree,c=t>0?a.length:-1;e!=c;e+=t){let c=a[e],h=l[e]+s.from;if(i&Qx.EnterBracketed&&c instanceof Zx&&null===(null===(o=$x.get(c))||void 0===o?void 0:o.overlay)&&(h>=n||h+c.length<=n)||nk(r,n,h,h+c.length))if(c instanceof tk){if(i&Qx.ExcludeBuffers)continue;let o=c.findChild(0,c.buffer.length,t,n-h,r);if(o>-1)return new ck(new lk(s,c,e,h),null,o)}else if(i&Qx.IncludeAnonymous||!c.type.isAnonymous||fk(c)){let o;if(!(i&Qx.IgnoreMounts)&&(o=$x.get(c))&&!o.overlay)return new ok(o.tree,h,e,s);let a=new ok(c,h,e,s);return i&Qx.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?c.children.length-1:0,t,n,r,i)}}if(i&Qx.IncludeAnonymous||!s.type.isAnonymous)return null;if(e=s.index>=0?s.index+t:t<0?-1:s._parent._tree.children.length,s=s._parent,!s)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)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let r;if(!(n&Qx.IgnoreOverlays)&&(r=$x.get(this._tree))&&r.overlay){let i=e-this.from,o=n&Qx.EnterBracketed&&r.bracketed;for(let{from:e,to:n}of r.overlay)if((t>0||o?e<=i:e<i)&&(t<0||o?n>=i:n>i))return new ok(r.tree,r.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 sk(e,t,n,r){let i=e.cursor(),o=[];if(!i.firstChild())return o;if(null!=n)for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return o;for(;;){if(null!=r&&i.type.is(r))return o;if(i.type.is(t)&&o.push(i.node),!i.nextSibling())return null==r?o:[]}}function ak(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}class lk{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class ck extends ik{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:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return i<0?null:new ck(this.context,this,i)}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)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&Qx.ExcludeBuffers)return null;let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new ck(this.context,this,i)}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 ck(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 ck(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let o=n.buffer[this.index+1];e.push(n.slice(r,i,o)),t.push(0)}return new Zx(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function hk(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof ok&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new uk(i,n)}class uk{constructor(e,t){this.heads=e,this.node=t}get next(){return hk(this.heads)}}class dk{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~Qx.EnterBracketed,e instanceof ok)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.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)}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return!!e&&(e instanceof ok?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}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:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}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&Qx.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Qx.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Qx.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));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;({index:t,_parent:n}=n))if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&Qx.IncludeAnonymous||e instanceof tk||!e.type.isAnonymous||fk(e))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 r=this.index,i=this.stack.length;i>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=i+1;break e}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new ck(this.buffer,t,this.stack[e]);return this.bufferNode=new ck(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return ak(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return ak(this._tree,e,r);let o=n[t.buffer[this.stack[i]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function fk(e){return e.children.some(e=>e instanceof tk||!e.type.isAnonymous||fk(e))}const pk=new WeakMap;function mk(e,t){if(!e.isAnonymous||t instanceof tk||t.type!=e)return 1;let n=pk.get(t);if(null==n){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof Zx)){n=1;break}n+=mk(e,r)}pk.set(t,n)}return n}function gk(e,t,n,r,i,o,s,a,l){let c=0;for(let n=r;n<i;n++)c+=mk(e,t[n]);let h=Math.ceil(1.5*c/8),u=[],d=[];return function t(n,r,i,s,a){for(let c=i;c<s;){let i=c,f=r[c],p=mk(e,n[c]);for(c++;c<s;c++){let t=mk(e,n[c]);if(p+t>=h)break;p+=t}if(c==i+1){if(p>h){let e=n[i];t(e.children,e.positions,0,e.children.length,r[i]+a);continue}u.push(n[i])}else{let t=r[c-1]+n[c-1].length-f;u.push(gk(e,n,r,i,c,f,t,null,l))}d.push(f+a-o)}}(t,n,r,i,0),(a||l)(u,d,s)}class vk{constructor(e,t,n,r,i=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(i?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let r=[new vk(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&r.push(n);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],i=1,o=e.length?e[0]:null;for(let s=0,a=0,l=0;;s++){let c=s<t.length?t[s]:null,h=c?c.fromA:1e9;if(h-a>=n)for(;o&&o.from<h;){let t=o;if(a>=t.from||h<=t.to||l){let e=Math.max(t.from,a)-l,n=Math.min(t.to,h)-l;t=e>=n?null:new vk(e,n,t.tree,t.offset+l,s>0,!!c)}if(t&&r.push(t),o.to>h)break;o=i<e.length?e[i++]:null}if(!c)break;a=c.toA,l=c.toA-c.toB}return r}}class bk{startParse(e,t,n){return"string"==typeof e&&(e=new yk(e)),n=n?n.length?n.map(e=>new qx(e.from,e.to)):[new qx(0,0)]:[new qx(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}}class yk{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 Ux({perNode:!0});let wk=0;class xk{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=wk++}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="string"==typeof e?e:"?";if(e instanceof xk&&(t=e),null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let r=new xk(n,[],null,[]);if(r.set.push(r),t)for(let e of t.set)r.set.push(e);return r}static defineModifier(e){let t=new Sk(e);return e=>e.modified.indexOf(t)>-1?e:Sk.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}}let kk=0;class Sk{constructor(e){this.name=e,this.instances=[],this.id=kk++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(n=>{return n.base==e&&(r=t,i=n.modified,r.length==i.length&&r.every((e,t)=>e==i[t]));var r,i});if(n)return n;let r=[],i=new xk(e.name,r,e,t);for(let e of t)e.instances.push(i);let o=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}(t);for(let t of e.set)if(!t.modified.length)for(let e of o)r.push(Sk.get(t,e));return i}}function Ek(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(" "))if(e){let n=[],i=2,o=e;for(let t=0;;){if("..."==o&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!r)throw new RangeError("Invalid path: "+e);if(n.push("*"==r[0]?"":'"'==r[0][0]?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){i=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);o=e.slice(t)}let s=n.length-1,a=n[s];if(!a)throw new RangeError("Invalid path: "+e);let l=new Ok(r,i,s>0?n.slice(0,s):null);t[a]=l.sort(t[a])}}return Ck.add(t)}const Ck=new Ux({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let o=new Ok(i.tags,i.mode,i.context);n?n.next=o:r=o,n=o}return r}});class Ok{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}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}}function Nk(e,t){let n=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)n[e.id]=t.class;else n[t.tag.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+" "+r:r;break}}return t},scope:r}}function Ak(e,t,n,r=0,i=e.length){let o=new Tk(r,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),r,i,"",o.highlighters),o.flush(i)}Ok.empty=new Ok([],2,null);class Tk{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,r,i){let{type:o,from:s,to:a}=e;if(s>=n||a<=t)return;o.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(o)));let l=r,c=function(e){let t=e.type.prop(Ck);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||Ok.empty,h=function(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+" "+e:e)}return n}(i,c.tags);if(h&&(l&&(l+=" "),l+=h,1==c.mode&&(r+=(r?" ":"")+h)),this.startSpan(Math.max(t,s),l),c.opaque)return;let u=e.tree&&e.tree.prop(Ux.mounted);if(u&&u.overlay){let o=e.node.enter(u.overlay[0].from+s,1),c=this.highlighters.filter(e=>!e.scope||e.scope(u.tree.type)),h=e.firstChild();for(let d=0,f=s;;d++){let p=d<u.overlay.length?u.overlay[d]:null,m=p?p.from+s:a,g=Math.max(t,f),v=Math.min(n,m);if(g<v&&h)for(;e.from<v&&(this.highlightRange(e,g,v,r,i),this.startSpan(Math.min(v,e.to),l),!(e.to>=m)&&e.nextSibling()););if(!p||m>n)break;f=p.to+s,f>t&&(this.highlightRange(o.cursor(),Math.max(t,p.from+s),Math.min(n,f),"",c),this.startSpan(Math.min(n,f),l))}h&&e.parent()}else if(e.firstChild()){u&&(r="");do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),l)}}while(e.nextSibling());e.parent()}}}const Mk=xk.define,Rk=Mk(),Dk=Mk(),Pk=Mk(Dk),Lk=Mk(Dk),Bk=Mk(),Ik=Mk(Bk),jk=Mk(Bk),_k=Mk(),Fk=Mk(_k),Wk=Mk(),zk=Mk(),Hk=Mk(),Vk=Mk(Hk),qk=Mk(),Uk={comment:Rk,lineComment:Mk(Rk),blockComment:Mk(Rk),docComment:Mk(Rk),name:Dk,variableName:Mk(Dk),typeName:Pk,tagName:Mk(Pk),propertyName:Lk,attributeName:Mk(Lk),className:Mk(Dk),labelName:Mk(Dk),namespace:Mk(Dk),macroName:Mk(Dk),literal:Bk,string:Ik,docString:Mk(Ik),character:Mk(Ik),attributeValue:Mk(Ik),number:jk,integer:Mk(jk),float:Mk(jk),bool:Mk(Bk),regexp:Mk(Bk),escape:Mk(Bk),color:Mk(Bk),url:Mk(Bk),keyword:Wk,self:Mk(Wk),null:Mk(Wk),atom:Mk(Wk),unit:Mk(Wk),modifier:Mk(Wk),operatorKeyword:Mk(Wk),controlKeyword:Mk(Wk),definitionKeyword:Mk(Wk),moduleKeyword:Mk(Wk),operator:zk,derefOperator:Mk(zk),arithmeticOperator:Mk(zk),logicOperator:Mk(zk),bitwiseOperator:Mk(zk),compareOperator:Mk(zk),updateOperator:Mk(zk),definitionOperator:Mk(zk),typeOperator:Mk(zk),controlOperator:Mk(zk),punctuation:Hk,separator:Mk(Hk),bracket:Vk,angleBracket:Mk(Vk),squareBracket:Mk(Vk),paren:Mk(Vk),brace:Mk(Vk),content:_k,heading:Fk,heading1:Mk(Fk),heading2:Mk(Fk),heading3:Mk(Fk),heading4:Mk(Fk),heading5:Mk(Fk),heading6:Mk(Fk),contentSeparator:Mk(_k),list:Mk(_k),quote:Mk(_k),emphasis:Mk(_k),strong:Mk(_k),link:Mk(_k),monospace:Mk(_k),strikethrough:Mk(_k),inserted:Mk(),deleted:Mk(),changed:Mk(),invalid:Mk(),meta:qk,documentMeta:Mk(qk),annotation:Mk(qk),processingInstruction:Mk(qk),definition:xk.defineModifier("definition"),constant:xk.defineModifier("constant"),function:xk.defineModifier("function"),standard:xk.defineModifier("standard"),local:xk.defineModifier("local"),special:xk.defineModifier("special")};for(let e in Uk){let t=Uk[e];t instanceof xk&&(t.name=e)}var $k;Nk([{tag:Uk.link,class:"tok-link"},{tag:Uk.heading,class:"tok-heading"},{tag:Uk.emphasis,class:"tok-emphasis"},{tag:Uk.strong,class:"tok-strong"},{tag:Uk.keyword,class:"tok-keyword"},{tag:Uk.atom,class:"tok-atom"},{tag:Uk.bool,class:"tok-bool"},{tag:Uk.url,class:"tok-url"},{tag:Uk.labelName,class:"tok-labelName"},{tag:Uk.inserted,class:"tok-inserted"},{tag:Uk.deleted,class:"tok-deleted"},{tag:Uk.literal,class:"tok-literal"},{tag:Uk.string,class:"tok-string"},{tag:Uk.number,class:"tok-number"},{tag:[Uk.regexp,Uk.escape,Uk.special(Uk.string)],class:"tok-string2"},{tag:Uk.variableName,class:"tok-variableName"},{tag:Uk.local(Uk.variableName),class:"tok-variableName tok-local"},{tag:Uk.definition(Uk.variableName),class:"tok-variableName tok-definition"},{tag:Uk.special(Uk.variableName),class:"tok-variableName2"},{tag:Uk.definition(Uk.propertyName),class:"tok-propertyName tok-definition"},{tag:Uk.typeName,class:"tok-typeName"},{tag:Uk.namespace,class:"tok-namespace"},{tag:Uk.className,class:"tok-className"},{tag:Uk.macroName,class:"tok-macroName"},{tag:Uk.propertyName,class:"tok-propertyName"},{tag:Uk.operator,class:"tok-operator"},{tag:Uk.comment,class:"tok-comment"},{tag:Uk.meta,class:"tok-meta"},{tag:Uk.invalid,class:"tok-invalid"},{tag:Uk.punctuation,class:"tok-punctuation"}]);const Kk=new Ux;const Yk=new Ux;class Gk{constructor(e,t,n=[],r=""){this.data=e,this.name=r,dm.prototype.hasOwnProperty("tree")||Object.defineProperty(dm.prototype,"tree",{get(){return Qk(this)}}),this.parser=t,this.extension=[aS.of(this),dm.languageData.of((e,t,n)=>{let r=Xk(e,t,n),i=r.type.prop(Kk);if(!i)return[];let o=e.facet(i),s=r.type.prop(Yk);if(s){let i=r.resolve(t-r.from,n);for(let t of s)if(t.test(i,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(o)}}return o})].concat(n)}isActiveAt(e,t,n=-1){return Xk(e,t,n).type.prop(Kk)==this.data}findRegions(e){let t=e.facet(aS);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(Kk)==this.data)return void n.push({from:t,to:t+e.length});let i=e.prop(Ux.mounted);if(i){if(i.tree.prop(Kk)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof Zx&&r(i,e.positions[n]+t)}};return r(Qk(e),0),n}get allowsNesting(){return!0}}function Xk(e,t,n){let r=e.facet(aS),i=Qk(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,Qx.ExcludeBuffers|Qx.EnterBracketed))e.type.isTop&&(i=e);return i}Gk.setState=em.define();class Jk extends Gk{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=(n=e.languageData,Ep.define({combine:n?e=>e.concat(n):void 0}));var n;return new Jk(t,e.parser.configure({props:[Kk.add(e=>e.isTop?t:void 0)]}),e.name)}configure(e,t){return new Jk(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Qk(e){let t=e.field(Gk.state,!1);return t?t.tree:Zx.empty}class Zk{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 eS=null;class tS{constructor(e,t,n=[],r,i,o,s,a){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=o,this.skipped=s,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new tS(e,t,[],Zx.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Zk(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=Zx.empty&&this.isDone(null!=t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r){if(this.fragments=this.withoutTempSkipped(vk.addTree(r,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=r,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||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(vk.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=eS;eS=this;try{return e()}finally{eS=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=nS(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:i,viewport:o,skipped:s}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,n,r,i)=>t.push({fromA:e,toA:n,fromB:r,toB:i})),n=vk.applyChanges(n,t),r=Zx.empty,i=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){s=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);n<r&&s.push({from:n,to:r})}}}return new tS(this.parser,t,n,r,i,o,s,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 t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=nS(this.fragments,n,r),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(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 bk{createParse(t,n,r){let i=r[0].from,o=r[r.length-1].to,s={parsedPos:i,advance(){let t=eS;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=o,new Zx(Yx.none,[],[],o-i)},stoppedAt:null,stopAt(){}};return s}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return eS}}function nS(e,t,n){return vk.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class rS{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 rS(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=tS.create(e.facet(aS).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new rS(n)}}Gk.state=Rp.define({create:rS.init,update(e,t){for(let e of t.effects)if(e.is(Gk.setState))return e.value;return t.startState.facet(aS)!=t.state.facet(aS)?rS.init(t.state):e.apply(t)}});let iS=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(iS=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const oS="undefined"!=typeof navigator&&(null===($k=navigator.scheduling)||void 0===$k?void 0:$k.isInputPending)?()=>navigator.scheduling.isInputPending():null,sS=Cv.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(Gk.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(Gk.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=iS(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:r}}=this.view,i=n.field(Gk.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!oS?Math.max(25,e.timeRemaining()-5):1e9),s=i.context.treeLen<r&&n.doc.length>r+1e3,a=i.context.work(()=>oS&&oS()||Date.now()>o,r+(s?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Gk.setState.of(new rS(i.context))})),this.chunkBudget>0&&(!a||s)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>xv(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),aS=Ep.define({combine:e=>e.length?e[0]:null,enables:e=>[Gk.state,sS,Jy.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class lS{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const cS=Ep.define(),hS=Ep.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function uS(e){let t=e.facet(hS);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function dS(e,t){let n="",r=e.tabSize,i=e.facet(hS)[0];if("\t"==i){for(;t>=r;)n+="\t",t-=r;i=" "}for(let e=0;e<t;e++)n+=i;return n}function fS(e,t){e instanceof dm&&(e=new pS(e));for(let n of e.state.facet(cS)){let r=n(e,t);if(void 0!==r)return r}let n=Qk(e.state);return n.length>=t?function(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return gS(r,e,n)}(e,n,t):null}class pS{constructor(e,t={}){this.state=e,this.options=t,this.unit=uS(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return null!=r&&r>=n.from&&r<=n.to?i&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(i+=o-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return Rm(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const mS=new Ux;function gS(e,t,n){for(let r=e;r;r=r.next){let e=vS(r.node);if(e)return e(yS.create(t,n,r))}return 0}function vS(e){let t=e.type.prop(mS);if(t)return t;let n,r=e.firstChild;if(r&&(n=r.type.prop(Ux.closedBy))){let t=e.lastChild,r=t&&n.indexOf(t.name)>-1;return e=>function(e,t,n,r,i){let o=e.textAfter,s=o.match(/^\s*/)[0].length,a=r&&o.slice(s,s+r.length)==r||i==e.pos+s,l=t?function(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,o=e.state.doc.lineAt(n.from),s=null==i||i<=o.from?o.to:Math.min(o.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=s)return null;let e=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}(e):null;return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}(e,!0,1,void 0,r&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?bS:null}function bS(){return 0}class yS extends pS{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 yS(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(wS(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return gS(this.context.next,this.base,this.pos)}}function wS(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function xS({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const kS=Ep.define(),SS=new Ux;function ES(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function CS(e,t,n){for(let r of e.facet(kS)){let i=r(e,t,n);if(i)return i}return function(e,t,n){let r=Qk(e);if(r.length<n)return null;let i=null;for(let o=r.resolveStack(n,1);o;o=o.next){let s=o.node;if(s.to<=n||s.from>n)continue;if(i&&s.from<t)break;let a=s.type.prop(SS);if(a&&(s.to<r.length-50||r.length==e.doc.length||!ES(s))){let r=a(s,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(i=r)}}return i}(e,t,n)}function OS(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}const NS=em.define({map:OS}),AS=em.define({map:OS});function TS(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}const MS=Rp.define({create:()=>dg.none,update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((t,n)=>e=RS(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(NS)&&!PS(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(_S),i=r?dg.replace({widget:new HS(r(t.state,n.value))}):zS;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(AS)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=RS(e,t.selection.main.head)),e},provide:e=>Jy.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid JSON for fold state");t.push(zS.range(r,i))}return dg.set(t,!0)}});function RS(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function DS(e,t,n){var r;let i=null;return null===(r=e.field(MS,!1))||void 0===r||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function PS(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function LS(e,t){return e.field(MS,!1)?t:t.concat(em.appendConfig.of(FS()))}function BS(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return Jy.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const IS=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of TS(e)){let n=CS(e.state,t.from,t.to);if(n)return e.dispatch({effects:LS(e.state,[NS.of(n),BS(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(MS,!1))return!1;let t=[];for(let n of TS(e)){let r=DS(e.state,n.from,n.to);r&&t.push(AS.of(r),BS(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),o=CS(t,i.from,i.to);o&&n.push(NS.of(o)),r=(o?e.lineBlockAt(o.to):i).to+1}return n.length&&e.dispatch({effects:LS(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(MS,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(AS.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],jS={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},_S=Ep.define({combine:e=>fm(e,jS)});function FS(e){let t=[MS,US];return e&&t.push(_S.of(e)),t}function WS(e,t){let{state:n}=e,r=n.facet(_S),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=DS(e.state,n.from,n.to);r&&e.dispatch({effects:AS.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let o=document.createElement("span");return o.textContent=r.placeholderText,o.setAttribute("aria-label",n.phrase("folded code")),o.title=n.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=i,o}const zS=dg.replace({widget:new class extends hg{toDOM(e){return WS(e,null)}}});class HS extends hg{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return WS(e,this.value)}}const VS={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class qS extends yx{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}}const US=Jy.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 $S{constructor(e,t){let n;function r(e){let t=Im.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;const i="string"==typeof t.all?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof Gk?e=>e.prop(Kk)==o.data:o?e=>e==o:void 0,this.style=Nk(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new Im(n):null,this.themeType=t.themeType}static define(e,t){return new $S(e,t||{})}}const KS=Ep.define(),YS=Ep.define({combine:e=>e.length?[e[0]]:null});function GS(e){let t=e.facet(KS);return t.length?t:e.facet(YS)}function XS(e,t){let n,r=[QS];return e instanceof $S&&(e.module&&r.push(Jy.styleModule.of(e.module)),n=e.themeType),(null==t?void 0:t.fallback)?r.push(YS.of(e)):n?r.push(KS.computeN([Jy.darkTheme],t=>t.facet(Jy.darkTheme)==("dark"==n)?[e]:[])):r.push(KS.of(e)),r}class JS{constructor(e){this.markCache=Object.create(null),this.tree=Qk(e.state),this.decorations=this.buildDeco(e,GS(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Qk(e.state),n=GS(e.state),r=n!=GS(e.startState),{viewport:i}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&o>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return dg.none;let n=new wm;for(let{from:r,to:i}of e.visibleRanges)Ak(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=dg.mark({class:r})))},r,i);return n.finish()}}const QS=jp.high(Cv.fromClass(JS,{decorations:e=>e.decorations})),ZS=$S.define([{tag:Uk.meta,color:"#404740"},{tag:Uk.link,textDecoration:"underline"},{tag:Uk.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Uk.emphasis,fontStyle:"italic"},{tag:Uk.strong,fontWeight:"bold"},{tag:Uk.strikethrough,textDecoration:"line-through"},{tag:Uk.keyword,color:"#708"},{tag:[Uk.atom,Uk.bool,Uk.url,Uk.contentSeparator,Uk.labelName],color:"#219"},{tag:[Uk.literal,Uk.inserted],color:"#164"},{tag:[Uk.string,Uk.deleted],color:"#a11"},{tag:[Uk.regexp,Uk.escape,Uk.special(Uk.string)],color:"#e40"},{tag:Uk.definition(Uk.variableName),color:"#00f"},{tag:Uk.local(Uk.variableName),color:"#30a"},{tag:[Uk.typeName,Uk.namespace],color:"#085"},{tag:Uk.className,color:"#167"},{tag:[Uk.special(Uk.variableName),Uk.macroName],color:"#256"},{tag:Uk.definition(Uk.propertyName),color:"#00c"},{tag:Uk.comment,color:"#940"},{tag:Uk.invalid,color:"#f00"}]),eE=Jy.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),tE="()[]{}",nE=Ep.define({combine:e=>fm(e,{afterCursor:!0,brackets:tE,maxScanDistance:1e4,renderMatch:oE})}),rE=dg.mark({class:"cm-matchingBracket"}),iE=dg.mark({class:"cm-nonmatchingBracket"});function oE(e){let t=[],n=e.matched?rE:iE;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const sE=Rp.define({create:()=>dg.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(nE);for(let e of t.state.selection.ranges){if(!e.empty)continue;let i=uE(t.state,e.head,-1,r)||e.head>0&&uE(t.state,e.head-1,1,r)||r.afterCursor&&(uE(t.state,e.head,1,r)||e.head<t.state.doc.length&&uE(t.state,e.head+1,-1,r));i&&(n=n.concat(r.renderMatch(i,t.state)))}return dg.set(n,!0)},provide:e=>Jy.decorations.from(e)}),aE=[sE,eE];const lE=new Ux;function cE(e,t,n){let r=e.prop(t<0?Ux.openedBy:Ux.closedBy);if(r)return r;if(1==e.name.length){let r=n.indexOf(e.name);if(r>-1&&r%2==(t<0?1:0))return[n[r+t]]}return null}function hE(e){let t=e.type.prop(lE);return t?t(e.node):e}function uE(e,t,n,r={}){let i=r.maxScanDistance||1e4,o=r.brackets||tE,s=Qk(e),a=s.resolveInner(t,n);for(let r=a;r;r=r.parent){let i=cE(r.type,n,o);if(i&&r.from<r.to){let s=hE(r);if(s&&(n>0?t>=s.from&&t<s.to:t>s.from&&t<=s.to))return dE(e,t,n,r,s,i,o)}}return function(e,t,n,r,i,o,s){let a=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=s.indexOf(a);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},h=e.doc.iterRange(t,n>0?e.doc.length:0),u=0;for(let e=0;!h.next().done&&e<=o;){let o=h.value;n<0&&(e+=o.length);let a=t+e*n;for(let e=n>0?0:o.length-1,t=n>0?o.length:-1;e!=t;e+=n){let t=s.indexOf(o[e]);if(!(t<0||r.resolveInner(a+e,1).type!=i))if(t%2==0==n>0)u++;else{if(1==u)return{start:c,end:{from:a+e,to:a+e+1},matched:t>>1==l>>1};u--}}n>0&&(e+=o.length)}return h.done?{start:c,matched:!1}:null}(e,t,n,s,a.type,i,o)}function dE(e,t,n,r,i,o,s){let a=r.parent,l={from:i.from,to:i.to},c=0,h=null==a?void 0:a.cursor();if(h&&(n<0?h.childBefore(r.from):h.childAfter(r.to)))do{if(n<0?h.to<=r.from:h.from>=r.to){if(0==c&&o.indexOf(h.type.name)>-1&&h.from<h.to){let e=hE(h);return{start:l,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(cE(h.type,n,s))c++;else if(cE(h.type,-n,s)){if(0==c){let e=hE(h);return{start:l,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}c--}}}while(n<0?h.prevSibling():h.nextSibling());return{start:l,matched:!1}}const fE=Object.create(null),pE=[Yx.none],mE=[],gE=Object.create(null),vE=Object.create(null);for(let[e,t]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"]])vE[e]=yE(fE,t);function bE(e,t){mE.indexOf(e)>-1||mE.push(e)}function yE(e,t){let n=[];for(let r of t.split(" ")){let t=[];for(let n of r.split(".")){let r=e[n]||Uk[n];r?"function"==typeof r?t.length?t=t.map(r):bE(n):t.length?bE(n):t=Array.isArray(r)?r:[r]:bE(n)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(e=>e.id),o=gE[i];if(o)return o.id;let s=gE[i]=Yx.define({id:pE.length,name:r,props:[Ek({[r]:n})]});return pE.push(s),s.id}zg.RTL,zg.LTR;function wE(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return!!i&&(r(n.update(i)),!0)}}const xE=wE(NE,0),kE=wE(OE,0),SE=wE((e,t)=>OE(e,t,function(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}(t)),0);function EE(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const CE=50;function OE(e,t,n=t.selection.ranges){let r=n.map(e=>EE(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>function(e,{open:t,close:n},r,i){let o,s,a=e.sliceDoc(r-CE,r),l=e.sliceDoc(i,i+CE),c=/\s*$/.exec(a)[0].length,h=/^\s*/.exec(l)[0].length,u=a.length-c;if(a.slice(u-t.length,u)==t&&l.slice(h,h+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:i+h,margin:h&&1}};i-r<=2*CE?o=s=e.sliceDoc(r,i):(o=e.sliceDoc(r,r+CE),s=e.sliceDoc(i-CE,i));let d=/^\s*/.exec(o)[0].length,f=/\s*$/.exec(s)[0].length,p=s.length-f-n.length;return o.slice(d,d+t.length)==t&&s.slice(p,p+n.length)==n?{open:{pos:r+d+t.length,margin:/\s/.test(o.charAt(d+t.length))?1:0},close:{pos:i-f-n.length,margin:/\s/.test(s.charAt(p-1))?1:0}}:null}(t,r[n],e.from,e.to));if(2!=e&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+" "},{from:e.to,insert:" "+r[t].close}]))};if(1!=e&&i.some(e=>e)){let e=[];for(let t,n=0;n<i.length;n++)if(t=i[n]){let i=r[n],{open:o,close:s}=t;e.push({from:o.pos-i.open.length,to:o.pos+o.margin},{from:s.pos-s.margin,to:s.pos+i.close.length})}return{changes:e}}return null}function NE(e,t,n=t.selection.ranges){let r=[],i=-1;for(let{from:e,to:o}of n){let n=r.length,s=1e9,a=EE(t,e).line;if(a){for(let n=e;n<=o;){let l=t.doc.lineAt(n);if(l.from>i&&(e==o||o>l.from)){i=l.from;let e=/^\s*/.exec(l.text)[0].length,t=e==l.length,n=l.text.slice(e,e+a.length)==a?e:-1;e<l.text.length&&e<s&&(s=e),r.push({line:l,comment:n,token:a,indent:e,empty:t,single:!1})}n=l.to+1}if(s<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=s);r.length==n+1&&(r[n].single=!0)}}if(2!=e&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:o,single:s}of r)!s&&o||e.push({from:t.from+i,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,o=r+i.length;" "==t.text[o-t.from]&&o++,e.push({from:r,to:o})}return{changes:e}}return null}const AE=Jp.define(),TE=Jp.define(),ME=Ep.define(),RE=Ep.define({combine:e=>fm(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}),DE=Rp.define({create:()=>YE.empty,update(e,t){let n=t.state.facet(RE),r=t.annotation(AE);if(r){let i=_E.fromTransaction(t,r.selection),o=r.side,s=0==o?e.undone:e.done;return s=i?FE(s,s.length,n.minDepth,i):VE(s,t.startState.selection),new YE(0==o?r.rest:s,0==o?s:r.rest)}let i=t.annotation(TE);if("full"!=i&&"before"!=i||(e=e.isolate()),!1===t.annotation(tm.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let o=_E.fromTransaction(t),s=t.annotation(tm.time),a=t.annotation(tm.userEvent);return o?e=e.addChanges(o,s,a,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,a,n.newGroupDelay)),"full"!=i&&"after"!=i||(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new YE(e.done.map(_E.fromJSON),e.undone.map(_E.fromJSON))});function PE(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(DE,!1);if(!i)return!1;let o=i.pop(e,n,t);return!!o&&(r(o),!0)}}const LE=PE(0,!1),BE=PE(1,!1),IE=PE(0,!0),jE=PE(1,!0);class _E{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(e){return new _E(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new _E(e.changes&&fp.fromJSON(e.changes),[],e.mapped&&dp.fromJSON(e.mapped),e.startSelection&&xp.fromJSON(e.startSelection),e.selectionsAfter.map(xp.fromJSON))}static fromTransaction(e,t){let n=zE;for(let t of e.startState.facet(ME)){let r=t(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new _E(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,zE)}static selection(e){return new _E(void 0,zE,void 0,void 0,e)}}function FE(e,t,n,r){let i=t+1>n+20?t-n-1:0,o=e.slice(i,t);return o.push(r),o}function WE(e,t){return e.length?t.length?e.concat(t):e:t}const zE=[],HE=200;function VE(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-HE));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),FE(e,e.length-1,1e9,n.setSelAfter(r)))}return[_E.selection([t])]}function qE(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function UE(e,t){if(!e.length)return e;let n=e.length,r=zE;for(;n;){let i=$E(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[_E.selection(r)]:zE}function $E(e,t,n){let r=WE(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):zE,n);if(!e.changes)return _E.selection(r);let i=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new _E(i,em.mapEffects(e.effects,t),s,e.startSelection.map(o),r)}const KE=/^(input\.type|delete)($|\.)/;class YE{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new YE(this.done,this.undone):this}addChanges(e,t,n,r,i){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&e.changes&&(!n||KE.test(n))&&(!s.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(i,function(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,o)=>{for(let e=0;e<n.length;){let t=n[e++],s=n[e++];o>=t&&i<=s&&(r=!0)}}),r}(s.changes,e.changes))||"input.type.compose"==n)?FE(o,o.length-1,r.minDepth,new _E(e.changes.compose(s.changes),WE(em.mapEffects(e.effects,s.changes),s.effects),s.mapped,s.startSelection,zE)):FE(o,o.length,r.minDepth,e),new YE(o,zE,t,n)}addSelection(e,t,n,r){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:zE;return i.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(o=i[i.length-1],s=e,o.ranges.length==s.ranges.length&&0===o.ranges.filter((e,t)=>e.empty!=s.ranges[t].empty).length)?this:new YE(VE(this.done,e),this.undone,t,n);var o,s}addMapping(e){return new YE(UE(this.done,e),UE(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=0==e?this.done:this.undone;if(0==r.length)return null;let i=r[r.length-1],o=i.selectionsAfter[0]||t.selection;if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:AE.of({side:e,rest:qE(r),selection:o}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let n=1==r.length?zE:r.slice(0,r.length-1);return i.mapped&&(n=UE(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:AE.of({side:e,rest:n,selection:o}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}YE.empty=new YE(zE,zE);const GE=[{key:"Mod-z",run:LE,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:BE,preventDefault:!0},{linux:"Ctrl-Shift-z",run:BE,preventDefault:!0},{key:"Mod-u",run:IE,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:jE,preventDefault:!0}];function XE(e,t){return xp.create(e.ranges.map(t),e.mainIndex)}function JE(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function QE({state:e,dispatch:t},n){let r=XE(e.selection,n);return!r.eq(e.selection,!0)&&(t(JE(e,r)),!0)}function ZE(e,t){return xp.cursor(t?e.to:e.from)}function eC(e,t){return QE(e,n=>n.empty?e.moveByChar(n,t):ZE(n,t))}function tC(e){return e.textDirectionAt(e.state.selection.main.head)==zg.LTR}const nC=e=>eC(e,!tC(e)),rC=e=>eC(e,tC(e));function iC(e,t){return QE(e,n=>n.empty?e.moveByGroup(n,t):ZE(n,t))}function oC(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function sC(e,t,n){let r,i,o=Qk(e).resolveInner(t.head),s=n?Ux.closedBy:Ux.openedBy;for(let r=t.head;;){let t=n?o.childAfter(r):o.childBefore(r);if(!t)break;oC(e,t,s)?o=t:r=n?t.to:t.from}return i=o.type.prop(s)&&(r=n?uE(e,o.from,1):uE(e,o.to,-1))&&r.matched?n?r.end.to:r.end.from:n?o.to:o.from,xp.cursor(i,n?-1:1)}function aC(e,t){return QE(e,n=>{if(!n.empty)return ZE(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const lC=e=>aC(e,!1),cC=e=>aC(e,!0);function hC(e){let t,n=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,i=0;if(n){for(let t of e.state.facet(Jy.scrollMargins)){let n=t(e);(null==n?void 0:n.top)&&(r=Math.max(null==n?void 0:n.top,r)),(null==n?void 0:n.bottom)&&(i=Math.max(null==n?void 0:n.bottom,i))}t=e.scrollDOM.clientHeight-r-i}else t=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:i,selfScroll:n,height:Math.max(e.defaultLineHeight,t-5)}}function uC(e,t){let n,r=hC(e),{state:i}=e,o=XE(i.selection,n=>n.empty?e.moveVertically(n,t,r.height):ZE(n,t));if(o.eq(i.selection))return!1;if(r.selfScroll){let t=e.coordsAtPos(i.selection.main.head),s=e.scrollDOM.getBoundingClientRect(),a=s.top+r.marginTop,l=s.bottom-r.marginBottom;t&&t.top>a&&t.bottom<l&&(n=Jy.scrollIntoView(o.main.head,{y:"start",yMargin:t.top-a}))}return e.dispatch(JE(i,o),{effects:n}),!0}const dC=e=>uC(e,!1),fC=e=>uC(e,!0);function pC(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=xp.cursor(r.from+n))}return i}function mC(e,t){let n=XE(e.state.selection,e=>{let n=t(e);return xp.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return!n.eq(e.state.selection)&&(e.dispatch(JE(e.state,n)),!0)}function gC(e,t){return mC(e,n=>e.moveByChar(n,t))}const vC=e=>gC(e,!tC(e)),bC=e=>gC(e,tC(e));function yC(e,t){return mC(e,n=>e.moveByGroup(n,t))}function wC(e,t){return mC(e,n=>e.moveVertically(n,t))}const xC=e=>wC(e,!1),kC=e=>wC(e,!0);function SC(e,t){return mC(e,n=>e.moveVertically(n,t,hC(e).height))}const EC=e=>SC(e,!1),CC=e=>SC(e,!0),OC=({state:e,dispatch:t})=>(t(JE(e,{anchor:0})),!0),NC=({state:e,dispatch:t})=>(t(JE(e,{anchor:e.doc.length})),!0),AC=({state:e,dispatch:t})=>(t(JE(e,{anchor:e.selection.main.anchor,head:0})),!0),TC=({state:e,dispatch:t})=>(t(JE(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function MC(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let o=n.doc.lineAt(r.head);if(t?o.to<e.state.doc.length:o.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<o.from||r.head>o.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(JE(n,xp.create(i,i.length-1))),!0)}function RC(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:o}=r;if(i==o){let s=t(r);s<i?(n="delete.backward",s=DC(e,s,!1)):s>i&&(n="delete.forward",s=DC(e,s,!0)),i=Math.min(i,s),o=Math.max(o,s)}else i=DC(e,i,!1),o=DC(e,o,!0);return i==o?{range:r}:{changes:{from:i,to:o},range:xp.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?Jy.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function DC(e,t,n){if(e instanceof Jy)for(let r of e.state.facet(Jy.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}const PC=(e,t,n)=>RC(e,r=>{let i,o,s=r.from,{state:a}=e,l=a.doc.lineAt(s);if(n&&!t&&s>l.from&&s<l.from+200&&!/[^ \t]/.test(i=l.text.slice(0,s-l.from))){if("\t"==i[i.length-1])return s-1;let e=Rm(i,a.tabSize)%uS(a)||uS(a);for(let t=0;t<e&&" "==i[i.length-1-t];t++)s--;o=s}else o=sp(l.text,s-l.from,t,t)+l.from,o==s&&l.number!=(t?a.doc.lines:1)?o+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(l.text.slice(o-l.from,s-l.from))&&(o=sp(l.text,o-l.from,!1,!1)+l.from);return o}),LC=e=>PC(e,!1,!0),BC=e=>PC(e,!0,!1),IC=(e,t)=>RC(e,n=>{let r=n.head,{state:i}=e,o=i.doc.lineAt(r),s=i.charCategorizer(r);for(let e=null;;){if(r==(t?o.to:o.from)){r==n.head&&o.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let a=sp(o.text,r-o.from,t)+o.from,l=o.text.slice(Math.min(r,a)-o.from,Math.max(r,a)-o.from),c=s(l);if(null!=e&&c!=e)break;" "==l&&r==n.head||(e=c),r=a}return r}),jC=e=>IC(e,!1);function _C(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(r.empty||r.to!=o.from||(o=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=o.to,e.ranges.push(r)}else t.push({from:i.from,to:o.to,ranges:[r]});n=o.number+1}return t}function FC(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of _C(e)){if(n?t.to==e.doc.length:0==t.from)continue;let o=e.doc.lineAt(n?t.to+1:t.from-1),s=o.length+1;if(n){r.push({from:t.to,to:o.to},{from:t.from,insert:o.text+e.lineBreak});for(let n of t.ranges)i.push(xp.range(Math.min(e.doc.length,n.anchor+s),Math.min(e.doc.length,n.head+s)))}else{r.push({from:o.from,to:t.from},{from:t.to,insert:e.lineBreak+o.text});for(let e of t.ranges)i.push(xp.range(e.anchor-s,e.head-s))}}return!!r.length&&(t(e.update({changes:r,scrollIntoView:!0,selection:xp.create(i,e.selection.mainIndex),userEvent:"move.line"})),!0)}function WC(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of _C(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const zC=VC(!1),HC=VC(!0);function VC(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,o=t.doc.lineAt(r),s=!e&&r==i&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,r=Qk(e).resolveInner(t),i=r.childBefore(t),o=r.childAfter(t);return i&&o&&i.to<=t&&o.from>=t&&(n=i.type.prop(Ux.closedBy))&&n.indexOf(o.name)>-1&&e.doc.lineAt(i.to).from==e.doc.lineAt(o.from).from&&!/\S/.test(e.sliceDoc(i.to,o.from))?{from:i.to,to:o.from}:null}(t,r);e&&(r=i=(i<=o.to?o:t.doc.lineAt(i)).to);let a=new pS(t,{simulateBreak:r,simulateDoubleBreak:!!s}),l=fS(a,r);for(null==l&&(l=Rm(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));i<o.to&&/\s/.test(o.text[i-o.from]);)i++;s?({from:r,to:i}=s):r>o.from&&r<o.from+100&&!/\S/.test(o.text.slice(0,r))&&(r=o.from);let c=["",dS(t,l)];return s&&c.push(dS(t,a.lineIndent(o.from,-1))),{changes:{from:r,to:i,insert:Xf.of(c)},range:xp.cursor(r+1+c[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function qC(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let o=r.from;o<=r.to;){let s=e.doc.lineAt(o);s.number>n&&(r.empty||r.to>s.from)&&(t(s,i,r),n=s.number),o=s.to+1}let o=e.changes(i);return{changes:i,range:xp.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const UC=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(qC(e,(t,n)=>{n.push({from:t.from,insert:e.facet(hS)})}),{userEvent:"input.indent"})),!0),$C=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(qC(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Rm(r,e.tabSize),o=0,s=dS(e,Math.max(0,i-uS(e)));for(;o<r.length&&o<s.length&&r.charCodeAt(o)==s.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+r.length,insert:s.slice(o)})}),{userEvent:"delete.dedent"})),!0),KC=[{key:"Ctrl-b",run:nC,shift:vC,preventDefault:!0},{key:"Ctrl-f",run:rC,shift:bC},{key:"Ctrl-p",run:lC,shift:xC},{key:"Ctrl-n",run:cC,shift:kC},{key:"Ctrl-a",run:e=>QE(e,t=>xp.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>mC(e,t=>xp.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>QE(e,t=>xp.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>mC(e,t=>xp.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:BC},{key:"Ctrl-h",run:LC},{key:"Ctrl-k",run:e=>RC(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})},{key:"Ctrl-Alt-h",run:jC},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:Xf.of(["",""])},range:xp.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:sp(r.text,n-r.from,!1)+r.from,o=n==r.to?n+1:sp(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:o,insert:e.doc.slice(n,o).append(e.doc.slice(i,n))},range:xp.cursor(o)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:fC}],YC=[{key:"ArrowLeft",run:nC,shift:vC,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>iC(e,!tC(e)),shift:e=>yC(e,!tC(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>QE(e,t=>pC(e,t,!tC(e))),shift:e=>mC(e,t=>pC(e,t,!tC(e))),preventDefault:!0},{key:"ArrowRight",run:rC,shift:bC,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>iC(e,tC(e)),shift:e=>yC(e,tC(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>QE(e,t=>pC(e,t,tC(e))),shift:e=>mC(e,t=>pC(e,t,tC(e))),preventDefault:!0},{key:"ArrowUp",run:lC,shift:xC,preventDefault:!0},{mac:"Cmd-ArrowUp",run:OC,shift:AC},{mac:"Ctrl-ArrowUp",run:dC,shift:EC},{key:"ArrowDown",run:cC,shift:kC,preventDefault:!0},{mac:"Cmd-ArrowDown",run:NC,shift:TC},{mac:"Ctrl-ArrowDown",run:fC,shift:CC},{key:"PageUp",run:dC,shift:EC},{key:"PageDown",run:fC,shift:CC},{key:"Home",run:e=>QE(e,t=>pC(e,t,!1)),shift:e=>mC(e,t=>pC(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:OC,shift:AC},{key:"End",run:e=>QE(e,t=>pC(e,t,!0)),shift:e=>mC(e,t=>pC(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:NC,shift:TC},{key:"Enter",run:zC,shift:zC},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:LC,shift:LC,preventDefault:!0},{key:"Delete",run:BC,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:jC,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>IC(e,!0),preventDefault:!0},{mac:"Mod-Backspace",run:e=>RC(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),preventDefault:!0},{mac:"Mod-Delete",run:e=>RC(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),preventDefault:!0}].concat(KC.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),GC=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>QE(e,t=>sC(e.state,t,!tC(e))),shift:e=>mC(e,t=>sC(e.state,t,!tC(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>QE(e,t=>sC(e.state,t,tC(e))),shift:e=>mC(e,t=>sC(e.state,t,tC(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>FC(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>WC(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>FC(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>WC(e,t,!0)},{key:"Mod-Alt-ArrowUp",run:e=>MC(e,!1)},{key:"Mod-Alt-ArrowDown",run:e=>MC(e,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=xp.create([n.main]):n.main.empty||(r=xp.create([xp.cursor(n.main.head)])),!!r&&(t(JE(e,r)),!0)}},{key:"Mod-Enter",run:HC},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=_C(e).map(({from:t,to:n})=>xp.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:xp.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=XE(e.selection,t=>{let n=Qk(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return xp.range(n.to,n.from)}return t});return!n.eq(e.selection)&&(t(JE(e,n)),!0)},preventDefault:!0},{key:"Mod-[",run:$C},{key:"Mod-]",run:UC},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new pS(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),i=qC(e,(t,i,o)=>{let s=fS(r,t.from);if(null==s)return;/\S/.test(t.text)||(s=0);let a=/^\s*/.exec(t.text)[0],l=dS(e,s);(a!=l||o.from<t.from+a.length)&&(n[t.from]=s,i.push({from:t.from,to:t.from+a.length,insert:l}))});return i.changes.empty||t(e.update(i,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(_C(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=XE(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>function(e,t,n){let r=!1,i=XE(e.selection,t=>{let i=uE(e,t.head,-1)||uE(e,t.head,1)||t.head>0&&uE(e,t.head-1,1)||t.head<e.doc.length&&uE(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let o=i.start.from==t.head?i.end.to:i.end.from;return n?xp.range(t.anchor,o):xp.cursor(o)});return!!r&&(t(JE(e,i)),!0)}(e,t,!1)},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=EE(e.state,n.from);return r.line?xE(e):!!r.block&&SE(e)}},{key:"Alt-A",run:kE},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat(YC),XC={key:"Tab",run:UC,shift:$C},JC="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class QC{constructor(e,t,n=0,r=e.length,i,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,r),this.bufferStart=n,this.normalize=i?e=>i(JC(e)):JC,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 ap(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=lp(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=cp(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let o=r.charCodeAt(e),s=this.match(o,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(s)return this.value=s,this;break}i==n&&e<t.length&&t.charCodeAt(e)==o&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],o=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,o=!0)),o||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}}"undefined"!=typeof Symbol&&(QC.prototype[Symbol.iterator]=function(){return this});const ZC={from:-1,to:-1,match:/.*/.exec("")},eO="gm"+(null==/x/.unicode?"":"u");class tO{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine="",this.done=!1,this.value=ZC,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new iO(e,t,n,r,i);this.re=new RegExp(t,eO+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=oO(e,r),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,r=n+t[0].length;if(this.matchPos=oO(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const nO=new WeakMap;class rO{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=nO.get(e);if(!r||r.from>=n||r.to<=t){let r=new rO(t,e.sliceString(t,n));return nO.set(e,r),r}if(r.from==t&&r.to==n)return r;let{text:i,from:o}=r;return o>t&&(i=e.sliceString(t,o)+i,o=t),r.to<n&&(i+=e.sliceString(r.to,n)),nO.set(e,new rO(o,i)),new rO(t,i.slice(t-o,n-o))}}class iO{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=ZC,this.matchPos=oO(e,r),this.re=new RegExp(t,eO+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=rO.get(e,r,this.chunkEnd(r+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 e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=oO(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=rO.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function oO(e,t){if(t>=e.length)return t;let n,r=e.lineAt(t);for(;t<r.to&&(n=r.text.charCodeAt(t-r.from))>=56320&&n<57344;)t++;return t}"undefined"!=typeof Symbol&&(tO.prototype[Symbol.iterator]=iO.prototype[Symbol.iterator]=function(){return this});const sO={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},aO=Ep.define({combine:e=>fm(e,sO,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});const lO=dg.mark({class:"cm-selectionMatch"}),cO=dg.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function hO(e,t,n,r){return!(0!=n&&e(t.sliceDoc(n-1,n))==lm.Word||r!=t.doc.length&&e(t.sliceDoc(r,r+1))==lm.Word)}const uO=Cv.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(aO),{state:n}=e,r=n.selection;if(r.ranges.length>1)return dg.none;let i,o=r.main,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return dg.none;let e=n.wordAt(o.head);if(!e)return dg.none;s=n.charCategorizer(o.head),i=n.sliceDoc(e.from,e.to)}else{let e=o.to-o.from;if(e<t.minSelectionLength||e>200)return dg.none;if(t.wholeWords){if(i=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!hO(s,n,o.from,o.to)||!function(e,t,n,r){return e(t.sliceDoc(n,n+1))==lm.Word&&e(t.sliceDoc(r-1,r))==lm.Word}(s,n,o.from,o.to))return dg.none}else if(i=n.sliceDoc(o.from,o.to),!i)return dg.none}let a=[];for(let r of e.visibleRanges){let e=new QC(n.doc,i,r.from,r.to);for(;!e.next().done;){let{from:r,to:i}=e.value;if((!s||hO(s,n,r,i))&&(o.empty&&r<=o.from&&i>=o.to?a.push(cO.range(r,i)):(r>=o.to||i<=o.from)&&a.push(lO.range(r,i)),a.length>t.maxMatches))return dg.none}}return dg.set(a)}},{decorations:e=>e.decorations}),dO=Jy.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const fO=Ep.define({combine:e=>fm(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new HO(e),scrollToMatch:e=>Jy.scrollIntoView(e)})});class pO{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||function(e){try{return new RegExp(e,eO),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new xO(this):new vO(this)}getCursor(e,t=0,n){let r=e.doc?e:dm.create({doc:e});return null==n&&(n=r.doc.length),this.regexp?bO(this,r,t,n):gO(this,r,t,n)}}class mO{constructor(e){this.spec=e}}function gO(e,t,n,r){let i;return e.wholeWord&&(i=function(e,t){return(n,r,i,o)=>((o>n||o+i.length<r)&&(o=Math.max(0,n-2),i=e.sliceString(o,Math.min(e.length,r+2))),!(t(yO(i,n-o))==lm.Word&&t(wO(i,n-o))==lm.Word||t(wO(i,r-o))==lm.Word&&t(yO(i,r-o))==lm.Word))}(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=function(e,t,n){return(r,i,o,s)=>{if(n&&!n(r,i,o,s))return!1;let a=r>=s&&i<=s+o.length?o.slice(r-s,i-s):t.doc.sliceString(r,i);return e(a,t,r,i)}}(e.test,t,i)),new QC(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}class vO extends mO{constructor(e){super(e)}nextMatch(e,t,n){let r=gO(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=gO(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=gO(this.spec,e,n,r),o=null;for(;!i.nextOverlapping().done;)o=i.value;if(o)return o;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||(r=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),!r||r.from==t&&r.to==n?null:r}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=gO(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=gO(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}function bO(e,t,n,r){let i;var o;return e.wholeWord&&(o=t.charCategorizer(t.selection.main.head),i=(e,t,n)=>!n[0].length||(o(yO(n.input,n.index))!=lm.Word||o(wO(n.input,n.index))!=lm.Word)&&(o(wO(n.input,n.index+n[0].length))!=lm.Word||o(yO(n.input,n.index+n[0].length))!=lm.Word)),e.test&&(i=function(e,t,n){return(r,i,o)=>(!n||n(r,i,o))&&e(o[0],t,r,i)}(e.test,t,i)),new tO(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function yO(e,t){return e.slice(sp(e,t,!1),t)}function wO(e,t){return e.slice(t,sp(e,t))}class xO extends mO{nextMatch(e,t,n){let r=bO(this.spec,e,n,e.doc.length).next();return r.done&&(r=bO(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-1e4*r),o=bO(this.spec,e,i,n),s=null;for(;!o.next().done;)s=o.value;if(s&&(i==t||s.from>i+10))return s;if(i==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 t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=bO(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=bO(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}const kO=em.define(),SO=em.define(),EO=Rp.define({create:e=>new CO(IO(e).create(),null),update(e,t){for(let n of t.effects)n.is(kO)?e=new CO(n.value.create(),e.panel):n.is(SO)&&(e=new CO(e.query,n.value?BO:null));return e},provide:e=>px.from(e,e=>e.panel)});class CO{constructor(e,t){this.query=e,this.panel=t}}const OO=dg.mark({class:"cm-searchMatch"}),NO=dg.mark({class:"cm-searchMatch cm-searchMatch-selected"}),AO=Cv.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(EO))}update(e){let t=e.state.field(EO);(t!=e.startState.field(EO)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return dg.none;let{view:n}=this,r=new wm;for(let t=0,i=n.visibleRanges,o=i.length;t<o;t++){let{from:s,to:a}=i[t];for(;t<o-1&&a>i[t+1].from-500;)a=i[++t].to;e.highlight(n.state,s,a,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?NO:OO)})}return r.finish()}},{decorations:e=>e.decorations});function TO(e){return t=>{let n=t.state.field(EO,!1);return n&&n.query.spec.valid?e(t,n):FO(t)}}const MO=TO((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=xp.single(r.from,r.to),o=e.state.facet(fO);return e.dispatch({selection:i,effects:[$O(e,r),o.scrollToMatch(i.main,e)],userEvent:"select.search"}),_O(e),!0}),RO=TO((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let o=xp.single(i.from,i.to),s=e.state.facet(fO);return e.dispatch({selection:o,effects:[$O(e,i),s.scrollToMatch(o.main,e)],userEvent:"select.search"}),_O(e),!0}),DO=TO((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!(!n||!n.length)&&(e.dispatch({selection:xp.create(n.map(e=>xp.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),PO=TO((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let o=t.nextMatch(n,r,r);if(!o)return!1;let s,a,l=o,c=[],h=[];l.from==r&&l.to==i&&(a=n.toText(t.getReplacement(l)),c.push({from:l.from,to:l.to,insert:a}),l=t.nextMatch(n,l.from,l.to),h.push(Jy.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+".")));let u=e.state.changes(c);return l&&(s=xp.single(l.from,l.to).map(u),h.push($O(e,l)),h.push(n.facet(fO).scrollToMatch(s.main,e))),e.dispatch({changes:u,selection:s,effects:h,userEvent:"input.replace"}),!0}),LO=TO((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:Jy.announce.of(r),userEvent:"input.replace.all"}),!0});function BO(e){return e.state.facet(fO).createPanel(e)}function IO(e,t){var n,r,i,o,s;let a=e.selection.main,l=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!l)return t;let c=e.facet(fO);return new pO({search:(null!==(n=null==t?void 0:t.literal)&&void 0!==n?n:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(r=null==t?void 0:t.caseSensitive)&&void 0!==r?r:c.caseSensitive,literal:null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:c.literal,regexp:null!==(o=null==t?void 0:t.regexp)&&void 0!==o?o:c.regexp,wholeWord:null!==(s=null==t?void 0:t.wholeWord)&&void 0!==s?s:c.wholeWord})}function jO(e){let t=hx(e,BO);return t&&t.dom.querySelector("[main-field]")}function _O(e){let t=jO(e);t&&t==e.root.activeElement&&t.select()}const FO=e=>{let t=e.state.field(EO,!1);if(t&&t.panel){let n=jO(e);if(n&&n!=e.root.activeElement){let r=IO(e.state,t.query.spec);r.valid&&e.dispatch({effects:kO.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[SO.of(!0),t?kO.of(IO(e.state,t.query.spec)):em.appendConfig.of(YO)]});return!0},WO=e=>{let t=e.state.field(EO,!1);if(!t||!t.panel)return!1;let n=hx(e,BO);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:SO.of(!1)}),!0},zO=[{key:"Mod-f",run:FO,scope:"editor search-panel"},{key:"F3",run:MO,shift:RO,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:MO,shift:RO,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:WO,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,o=[],s=0;for(let t=new QC(e.doc,e.sliceDoc(r,i));!t.next().done;){if(o.length>1e3)return!1;t.value.from==r&&(s=o.length),o.push(xp.range(t.value.from,t.value.to))}return t(e.update({selection:xp.create(o,s),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=mx(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i)return void e.dispatch({effects:r});let o=t.doc.lineAt(t.selection.main.head),[,s,a,l,c]=i,h=l?+l.slice(1):0,u=a?+a:o.number;if(a&&c){let e=u/100;s&&(e=e*("-"==s?-1:1)+o.number/t.doc.lines),u=Math.round(t.doc.lines*e)}else a&&s&&(u=u*("-"==s?-1:1)+o.number);let d=t.doc.line(Math.max(1,Math.min(t.doc.lines,u))),f=xp.cursor(d.from+Math.max(0,Math.min(h,d.length)));e.dispatch({effects:[r,Jy.scrollIntoView(f.from,{y:"center"})],selection:f})}),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return(({state:e,dispatch:t})=>{let{selection:n}=e,r=xp.create(n.ranges.map(t=>e.wordAt(t.head)||xp.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)})({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=function(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),o=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new QC(e.doc,t,r[r.length-1].to);;){if(i.next(),!i.done){if(n&&r.some(e=>e.from==i.value.from))continue;if(o){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}if(n)return null;i=new QC(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}}(e,r);return!!i&&(t(e.update({selection:e.selection.addRange(xp.range(i.from,i.to),!1),effects:Jy.scrollIntoView(i.to)})),!0)},preventDefault:!0}];class HO{constructor(e){this.view=e;let t=this.query=e.state.field(EO).query.spec;function n(e,t,n){return Um("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=Um("input",{value:t.search,placeholder:VO(e,"Find"),"aria-label":VO(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Um("input",{value:t.replace,placeholder:VO(e,"Replace"),"aria-label":VO(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Um("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Um("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Um("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=Um("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",()=>MO(e),[VO(e,"next")]),n("prev",()=>RO(e),[VO(e,"previous")]),n("select",()=>DO(e),[VO(e,"all")]),Um("label",null,[this.caseField,VO(e,"match case")]),Um("label",null,[this.reField,VO(e,"regexp")]),Um("label",null,[this.wordField,VO(e,"by word")]),...e.state.readOnly?[]:[Um("br"),this.replaceField,n("replace",()=>PO(e),[VO(e,"replace")]),n("replaceAll",()=>LO(e),[VO(e,"replace all")])],Um("button",{name:"close",onclick:()=>WO(e),"aria-label":VO(e,"close"),type:"button"},["×"])])}commit(){let e=new pO({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:kO.of(e)}))}keydown(e){var t,n,r;t=this.view,n=e,r="search-panel",uw(aw(t.state),n,t,r)?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?RO:MO)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),PO(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(kO)&&!e.value.eq(this.query)&&this.setQuery(e.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(fO).top}}function VO(e,t){return e.state.phrase(t)}const qO=30,UO=/[\s\.,:;?!]/;function $O(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,o=Math.max(r.from,t-qO),s=Math.min(i,n+qO),a=e.state.sliceDoc(o,s);if(o!=r.from)for(let e=0;e<qO;e++)if(!UO.test(a[e+1])&&UO.test(a[e])){a=a.slice(e);break}if(s!=i)for(let e=a.length-1;e>a.length-qO;e--)if(!UO.test(a[e-1])&&UO.test(a[e])){a=a.slice(0,e);break}return Jy.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${r.number}.`)}const KO=Jy.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"}}),YO=[EO,jp.low(AO),KO];class GO{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Qk(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),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(eN(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return null==this.abortListeners}addEventListener(e,t,n){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function XO(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function JO(e){let t=e.map(e=>"string"==typeof e?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=XO(t)+XO(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}class QO{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}}function ZO(e){return e.selection.main.from}function eN(e,t){var n;let{source:r}=e,i=t&&"^"!=r[0],o="$"!=r[r.length-1];return i||o?new RegExp(`${i?"^":""}(?:${r})${o?"$":""}`,null!==(n=e.flags)&&void 0!==n?n:e.ignoreCase?"i":""):e}const tN=Jp.define();function nN(e,t,n,r){let{main:i}=e.selection,o=n-i.from,s=r-i.from;return{...e.changeByRange(a=>{if(a!=i&&n!=r&&e.sliceDoc(a.from+o,a.from+s)!=e.sliceDoc(n,r))return{range:a};let l=e.toText(t);return{changes:{from:a.from+o,to:r==i.from?a.to:a.from+s,insert:l},range:xp.cursor(a.from+o+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const rN=new WeakMap;function iN(e){if(!Array.isArray(e))return e;let t=rN.get(e);return t||rN.set(e,t=JO(e)),t}const oN=em.define(),sN=em.define();class aN{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=ap(e,t),r=cp(n);this.chars.push(n);let i=e.slice(t,t+r),o=i.toUpperCase();this.folded.push(ap(o==i?i.toLowerCase():o,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:o}=this;if(1==t.length){let r=ap(e,0),i=cp(r),o=i==e.length?0:-100;if(r==t[0]);else{if(r!=n[0])return null;o+=-200}return this.ret(o,[0,i])}let s=e.indexOf(this.pattern);if(0==s)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,l=0;if(s<0){for(let i=0,o=Math.min(e.length,200);i<o&&l<a;){let o=ap(e,i);o!=t[l]&&o!=n[l]||(r[l++]=i),i+=cp(o)}if(l<a)return null}let c=0,h=0,u=!1,d=0,f=-1,p=-1,m=/[a-z]/.test(e),g=!0;for(let r=0,l=Math.min(e.length,200),v=0;r<l&&h<a;){let l=ap(e,r);s<0&&(c<a&&l==t[c]&&(i[c++]=r),d<a&&(l==t[d]||l==n[d]?(0==d&&(f=r),p=r+1,d++):d=0));let b,y=l<255?l>=48&&l<=57||l>=97&&l<=122?2:l>=65&&l<=90?1:0:(b=lp(l))!=b.toLowerCase()?1:b!=b.toUpperCase()?2:0;(!r||1==y&&m||0==v&&0!=y)&&(t[h]==l||n[h]==l&&(u=!0)?o[h++]=r:o.length&&(g=!1)),v=y,r+=cp(l)}return h==a&&0==o[0]&&g?this.result((u?-200:0)-100,o,e):d==a&&0==f?this.ret(-200-e.length+(p==e.length?0:-100),[0,p]):s>-1?this.ret(-700-e.length,[s,s+this.pattern.length]):d==a?this.ret(-900-e.length,[f,p]):h==a?this.result((u?-200:0)-100-700+(g?0:-1100),o,e):2==t.length?null:this.result((r[0]?-700:0)-200-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?cp(ap(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}}class lN{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 null==n?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const cN=Ep.define({combine:e=>fm(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:uN,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||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=>hN(e(n),t(n)),optionClass:(e,t)=>n=>hN(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function hN(e,t){return e?t?e+" "+t:e:t}function uN(e,t,n,r,i,o){let s,a,l=e.textDirection==zg.RTL,c=l,h=!1,u="top",d=t.left-i.left,f=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(c&&d<Math.min(p,f)?c=!1:!c&&f<Math.min(p,d)&&(c=!0),p<=(c?d:f))s=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,a=Math.min(400,c?d:f);else{h=!0,a=Math.min(400,(l?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=m||e>t.top?s=n.bottom-t.top:(u="bottom",s=t.bottom-n.top)}return{style:`${u}: ${s/((t.bottom-t.top)/o.offsetHeight)}px; max-width: ${a/((t.right-t.left)/o.offsetWidth)}px`,class:"cm-completionInfo-"+(h?l?"left-narrow":"right-narrow":c?"left":"right")}}function dN(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class fN{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:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:i,selected:o}=r.open,s=e.state.facet(cN);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>"cm-completionIcon-"+e)),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement("span");i.className="cm-completionLabel";let o=e.displayLabel||e.label,s=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>s&&i.appendChild(document.createTextNode(o.slice(s,t)));let a=i.appendChild(document.createElement("span"));a.appendChild(document.createTextNode(o.slice(t,n))),a.className="cm-completionMatchedText",s=n}return s<o.length&&i.appendChild(document.createTextNode(o.slice(s))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=dN(i.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",n=>{let{options:r}=e.state.field(t).open;for(let t,i=n.target;i&&i!=this.dom;i=i.parentNode)if("LI"==i.nodeName&&(t=/-(\d+)$/.exec(i.id))&&+t[1]<r.length)return this.applyCompletion(e,r[+t[1]]),void n.preventDefault()}),this.dom.addEventListener("focusout",t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(cN).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:sN.of(null)})}),this.showOptions(i,r.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),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=r){let{options:i,selected:o,disabled:s}=n.open;r.open&&r.open.options==i||(this.range=dN(i.length,o,e.state.facet(cN).maxRenderedOptions),this.showOptions(i,n.id)),this.updateSel(),s!=(null===(t=r.open)||void 0===t?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);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=dN(t.options.length,t.selected,this.view.state.facet(cN).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let o="string"==typeof i?document.createTextNode(i):i(r);if(!o)return;"then"in o?o.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>xv(this.view.state,e,"completion info")):(this.addInfoPane(o,r),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(65535*Math.random()).toString(16),null!=e.nodeType)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)"LI"==n.nodeName&&n.id?r==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby")):r--;return t&&function(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}(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(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(cN).positionInfo(this.view,t,r,n,i,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 r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",e=>{e.target==r&&e.preventDefault()});let i=null;for(let o=n.from;o<n.to;o++){let{completion:s,match:a}=e[o],{section:l}=s;if(l){let e="string"==typeof l?l:l.name;if(e!=i&&(o>n.from||0==n.from))if(i=e,"string"!=typeof l&&l.header)r.appendChild(l.header(l));else{r.appendChild(document.createElement("completion-section")).textContent=e}}const c=r.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let h=this.optionClass(s);h&&(c.className=h);for(let e of this.optionContent){let t=e(s,this.view.state,this.view,a);t&&c.appendChild(t)}}return n.from&&r.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function pN(e,t){return n=>new fN(n,e,t)}function mN(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class gN{constructor(e,t,n,r,i,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new gN(this.options,wN(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,r,i,o){if(r&&!o&&e.some(e=>e.isPending))return r.setDisabled();let s=function(e,t){let n=[],r=null,i=null,o=e=>{n.push(e);let{section:t}=e.completion;if(t){r||(r=[]);let e="string"==typeof t?t:t.name;r.some(t=>t.name==e)||r.push("string"==typeof t?{name:e}:t)}},s=t.facet(cN);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(!1===r.result.filter)for(let t of r.result.options)o(new QO(t,r.source,e?e(t):[],1e9-n.length));else{let n,a=t.sliceDoc(r.from,r.to),l=s.filterStrict?new lN(a):new aN(a);for(let t of r.result.options)if(n=l.match(t.label)){let s=t.displayLabel?e?e(t,n.matched):[]:n.matched,a=n.score+(t.boost||0);if(o(new QO(t,r.source,s,a)),"object"==typeof t.section&&"dynamic"===t.section.rank){let{name:e}=t.section;i||(i=Object.create(null)),i[e]=Math.max(a,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,o=(e,t)=>("dynamic"===e.rank&&"dynamic"===t.rank?i[t.name]-i[e.name]:0)||("number"==typeof e.rank?e.rank:1e9)-("number"==typeof t.rank?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(o))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e["string"==typeof n?n:n.name])}}let a=[],l=null,c=s.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||c(e.completion,t.completion))){let t=e.completion;!l||l.label!=t.label||l.detail!=t.detail||null!=l.type&&null!=t.type&&l.type!=t.type||l.apply!=t.apply||l.boost!=t.boost?a.push(e):mN(e.completion)>mN(l)&&(a[a.length-1]=e),l=e.completion}return a}(e,t);if(!s.length)return r&&e.some(e=>e.isPending)?r.setDisabled():null;let a=t.facet(cN).selectOnOpen?0:-1;if(r&&r.selected!=a&&-1!=r.selected){let e=r.options[r.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){a=t;break}}return new gN(s,wN(n,a),{pos:e.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:TN,above:i.aboveCursor},r?r.timestamp:Date.now(),a,!1)}map(e){return new gN(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new gN(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class vN{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new vN(xN,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(cN),r=(n.override||t.languageDataAt("autocomplete",ZO(t)).map(iN)).map(t=>(this.active.find(e=>e.source==t)||new SN(t,this.active.some(e=>0!=e.state)?1:0)).update(e,n));r.length==this.active.length&&r.every((e,t)=>e==this.active[t])&&(r=this.active);let i=this.open,o=e.effects.some(e=>e.is(CN));i&&e.docChanged&&(i=i.map(e.changes)),e.selection||r.some(t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to))||!function(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,o=r==t.length;if(i||o)return i==o;if(e[n++].result!=t[r++].result)return!1}}(r,this.active)||o?i=gN.build(r,t,this.id,i,n,o):i&&i.disabled&&!r.some(e=>e.isPending)&&(i=null),!i&&r.every(e=>!e.isPending)&&r.some(e=>e.hasResult())&&(r=r.map(e=>e.hasResult()?new SN(e.source,0):e));for(let t of e.effects)t.is(ON)&&(i=i&&i.setSelected(t.value,this.id));return r==this.active&&i==this.open?this:new vN(r,this.id,i)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?bN:yN}}const bN={"aria-autocomplete":"list"},yN={};function wN(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const xN=[];function kN(e,t){if(e.isUserEvent("input.complete")){let n=e.annotation(tN);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class SN{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return 1==this.state}update(e,t){let n=kN(e,t),r=this;(8&n||16&n&&this.touches(e))&&(r=new SN(r.source,0)),4&n&&0==r.state&&(r=new SN(this.source,1)),r=r.updateFor(e,n);for(let t of e.effects)if(t.is(oN))r=new SN(r.source,1,t.value);else if(t.is(sN))r=new SN(r.source,0);else if(t.is(CN))for(let e of t.value)e.source==r.source&&(r=e);return r}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(ZO(e.state))}}class EN extends SN{constructor(e,t,n,r,i,o){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=o}hasResult(){return!0}updateFor(e,t){var n;if(!(3&t))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let i=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),s=ZO(e.state);if(s>o||!r||2&t&&(ZO(e.startState)==this.from||s<this.limit))return new SN(this.source,4&t?1:0);let a=e.changes.mapPos(this.limit);return function(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return"function"==typeof e?e(i,n,r,t):eN(e,!0).test(i)}(r.validFor,e.state,i,o)?new EN(this.source,this.explicit,a,r,i,o):r.update&&(r=r.update(r,i,o,new GO(e.state,s,!1)))?new EN(this.source,this.explicit,a,r,r.from,null!==(n=r.to)&&void 0!==n?n:ZO(e.state)):new SN(this.source,1,this.explicit)}map(e){if(e.empty)return this;return(this.result.map?this.result.map(this.result,e):this.result)?new EN(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new SN(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}const CN=em.define({map:(e,t)=>e.map(e=>e.map(t))}),ON=em.define(),NN=Rp.define({create:()=>vN.start(),update:(e,t)=>e.update(t),provide:e=>[ex.from(e,e=>e.tooltip),Jy.contentAttributes.from(e,e=>e.attrs)]});function AN(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(NN).active.find(e=>e.source==t.source);return r instanceof EN&&("string"==typeof n?e.dispatch({...nN(e.state,n,r.from,r.to),annotations:tN.of(t.completion)}):n(e,t.completion,r.from,r.to),!0)}const TN=pN(NN,AN);function MN(e,t="option"){return n=>{let r=n.state.field(NN,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(cN).interactionDelay)return!1;let i,o=1;"page"==t&&(i=ax(n,r.open.tooltip))&&(o=Math.max(2,Math.floor(i.dom.offsetHeight/i.dom.querySelector("li").offsetHeight)-1));let{length:s}=r.open.options,a=r.open.selected>-1?r.open.selected+o*(e?1:-1):e?0:s-1;return a<0?a="page"==t?0:s-1:a>=s&&(a="page"==t?s-1:0),n.dispatch({effects:ON.of(a)}),!0}}const RN=e=>!!e.state.field(NN,!1)&&(e.dispatch({effects:oN.of(!0)}),!0);class DN{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const PN=Cv.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(NN).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(NN),n=e.state.facet(cN);if(!e.selectionSet&&!e.docChanged&&e.startState.field(NN)==t)return;let r=e.transactions.some(e=>{let t=kN(e,n);return 8&t||(e.selection||e.docChanged)&&!(3&t)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>50&&Date.now()-n.time>1e3){for(let e of n.context.abortListeners)try{e()}catch(e){xv(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(oN)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,0!=this.composing)for(let t of e.transactions)t.isUserEvent("input.type")?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(NN);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(cN).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=ZO(t),r=new GO(t,n,e.explicit,this.view),i=new DN(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(e=>{i.context.aborted||(i.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:sN.of(null)}),xv(this.view.state,e)})}scheduleAccept(){this.running.every(e=>void 0!==e.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(cN).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(cN),r=this.view.state.field(NN);for(let i=0;i<this.running.length;i++){let o=this.running[i];if(void 0===o.done)continue;if(this.running.splice(i--,1),o.done){let r=ZO(o.updates.length?o.updates[0].startState:this.view.state),i=Math.min(r,o.done.from+(o.active.explicit?0:1)),s=new EN(o.active.source,o.active.explicit,i,o.done,o.done.from,null!==(e=o.done.to)&&void 0!==e?e:r);for(let e of o.updates)s=s.update(e,n);if(s.hasResult()){t.push(s);continue}}let s=r.active.find(e=>e.source==o.active.source);if(s&&s.isPending)if(null==o.done){let e=new SN(o.active.source,0);for(let t of o.updates)e=e.update(t,n);e.isPending||t.push(e)}else this.startQuery(s)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:CN.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(NN,!1);if(t&&t.tooltip&&this.view.state.facet(cN).closeOnBlur){let n=t.open&&ax(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:sN.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:oN.of(!1)}),20),this.composing=0}}}),LN="object"==typeof navigator&&/Win/.test(navigator.platform),BN=jp.highest(Jy.domEventHandlers({keydown(e,t){let n=t.state.field(NN,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&(!LN||!e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),o=r.completion.commitCharacters||i.result.commitCharacters;return o&&o.indexOf(e.key)>-1&&AN(t,r),!1}})),IN=Jy.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"}}}),jN={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},_N=em.define({map(e,t){let n=t.mapPos(e,-1,up.TrackAfter);return null==n?void 0:n}}),FN=new class extends pm{};FN.startSide=1,FN.endSide=-1;const WN=Rp.define({create:()=>ym.empty,update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(_N)&&(e=e.update({add:[FN.range(n.value,n.value+1)]}));return e}});const zN="()[]{}<>«»»«[]{}";function HN(e){for(let t=0;t<16;t+=2)if(zN.charCodeAt(t)==e)return zN.charAt(t+1);return lp(e<128?e:e+1)}function VN(e,t){return e.languageDataAt("closeBrackets",t)[0]||jN}const qN="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),UN=Jy.inputHandler.of((e,t,n,r)=>{if((qN?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||2==r.length&&1==cp(ap(r,0))||t!=i.from||n!=i.to)return!1;let o=function(e,t){let n=VN(e,e.selection.main.head),r=n.brackets||jN.brackets;for(let i of r){let o=HN(ap(i,0));if(t==i)return o==i?JN(e,i,r.indexOf(i+i+i)>-1,n):GN(e,i,o,n.before||jN.before);if(t==o&&KN(e,e.selection.main.from))return XN(e,i,o)}return null}(e.state,r);return!!o&&(e.dispatch(o),!0)}),$N=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=VN(e,e.selection.main.head).brackets||jN.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=function(e,t){let n=e.sliceString(t-2,t);return cp(ap(n,0))==n.length?n:n.slice(1)}(e.doc,t.head);for(let i of n)if(i==r&&YN(e.doc,t.head)==HN(ap(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:xp.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:"delete.backward"})),!r}}];function KN(e,t){let n=!1;return e.field(WN).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function YN(e,t){let n=e.sliceString(t,t+2);return n.slice(0,cp(ap(n,0)))}function GN(e,t,n,r){let i=null,o=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:_N.of(o.to+t.length),range:xp.range(o.anchor+t.length,o.head+t.length)};let s=YN(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:_N.of(o.head+t.length),range:xp.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function XN(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&YN(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:xp.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function JN(e,t,n,r){let i=r.stringPrefixes||jN.stringPrefixes,o=null,s=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:_N.of(r.to+t.length),range:xp.range(r.anchor+t.length,r.head+t.length)};let s,a=r.head,l=YN(e.doc,a);if(l==t){if(QN(e,a))return{changes:{insert:t+t,from:a},effects:_N.of(a+t.length),range:xp.cursor(a+t.length)};if(KN(e,a)){let r=n&&e.sliceDoc(a,a+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:a,to:a+r.length,insert:r},range:xp.cursor(a+r.length)}}}else{if(n&&e.sliceDoc(a-2*t.length,a)==t+t&&(s=ZN(e,a-2*t.length,i))>-1&&QN(e,s))return{changes:{insert:t+t+t+t,from:a},effects:_N.of(a+t.length),range:xp.cursor(a+t.length)};if(e.charCategorizer(a)(l)!=lm.Word&&ZN(e,a,i)>-1&&!function(e,t,n,r){let i=Qk(e).resolveInner(t,-1),o=r.reduce((e,t)=>Math.max(e,t.length),0);for(let s=0;s<5;s++){let s=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+o)),a=s.indexOf(n);if(!a||a>-1&&r.indexOf(s.slice(0,a))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+a;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let l=i.to==t&&i.parent;if(!l)break;i=l}return!1}(e,a,t,i))return{changes:{insert:t+t,from:a},effects:_N.of(a+t.length),range:xp.cursor(a+t.length)}}return{range:o=r}});return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function QN(e,t){let n=Qk(e).resolveInner(t+1);return n.parent&&n.from==t}function ZN(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=lm.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=lm.Word)return n}return-1}const eA=[{key:"Ctrl-Space",run:RN},{mac:"Alt-`",run:RN},{mac:"Alt-i",run:RN},{key:"Escape",run:e=>{let t=e.state.field(NN,!1);return!(!t||!t.active.some(e=>0!=e.state))&&(e.dispatch({effects:sN.of(null)}),!0)}},{key:"ArrowDown",run:MN(!0)},{key:"ArrowUp",run:MN(!1)},{key:"PageDown",run:MN(!0,"page")},{key:"PageUp",run:MN(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(NN,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(cN).interactionDelay)&&AN(e,t.open.options[t.open.selected])}}],tA=jp.highest(ow.computeN([cN],e=>e.facet(cN).defaultKeymap?[eA]:[]));class nA{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class rA{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let r=n.facet(mA).markerFilter;r&&(e=r(e,n));let i=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new wm,s=[],a=0,l=n.doc.iter(),c=0,h=n.doc.length;for(let e=0;;){let t,n,r=e==i.length?null:i[e];if(!r&&!s.length)break;if(s.length)t=a,n=s.reduce((e,t)=>Math.min(e,t.to),r&&r.from>t?r.from:1e8);else{if(t=r.from,t>h)break;n=r.to,s.push(r),e++}for(;e<i.length;){let r=i[e];if(r.from!=t||!(r.to>r.from||r.to==t)){n=Math.min(r.from,n);break}s.push(r),e++,n=Math.min(r.to,n)}n=Math.min(n,h);let u=!1;if(s.some(e=>e.from==t&&(e.to==n||n==h))&&(u=t==n,!u&&n-t<10)){let e=t-(c+l.value.length);e>0&&(l.next(e),c=t);for(let e=t;;){if(e>=n){u=!0;break}if(!l.lineBreak&&c+l.value.length>e)break;e=c+l.value.length,c+=l.value.length,l.next()}}let d=CA(s);if(u)o.add(t,t,dg.widget({widget:new yA(d),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");o.add(t,n,dg.mark({class:"cm-lintRange cm-lintRange-"+d+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>n)}))}if(a=n,a==h)break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1)}let u=o.finish();return new rA(u,t,iA(u))}}function iA(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(r){if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new nA(r.from,n,r.diagnostic)}else r=new nA(e,n,t||i.diagnostics[0])}),r}function oA(e,t){return e.field(cA,!1)?t:t.concat(em.appendConfig.of(OA))}const sA=em.define(),aA=em.define(),lA=em.define(),cA=Rp.define({create:()=>new rA(dg.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=iA(n,e.selected.diagnostic,i)||iA(n,null,i)}!n.size&&i&&t.state.facet(mA).autoPanel&&(i=null),e=new rA(n,i,r)}for(let n of t.effects)if(n.is(sA)){let r=t.state.facet(mA).autoPanel?n.value.length?xA.open:null:e.panel;e=rA.init(n.value,r,t.state)}else n.is(aA)?e=new rA(e.diagnostics,n.value?xA.open:null,e.selected):n.is(lA)&&(e=new rA(e.diagnostics,e.panel,n.value));return e},provide:e=>[px.from(e,e=>e.panel),Jy.decorations.from(e,e=>e.diagnostics)]}),hA=dg.mark({class:"cm-lintRange cm-lintRange-active"});function uA(e,t,n){let r,{diagnostics:i}=e.state.field(cA),o=-1,s=-1;i.between(t-(n<0?1:0),t+(n>0?1:0),(e,i,{spec:a})=>{if(t>=e&&t<=i&&(e==i||(t>e||n>0)&&(t<i||n<0)))return r=a.diagnostics,o=e,s=i,!1});let a=e.state.facet(mA).tooltipFilter;return r&&a&&(r=a(r,e.state)),r?{pos:o,end:s,above:e.state.doc.lineAt(o).to<s,create:()=>({dom:dA(e,r)})}:null}function dA(e,t){return Um("ul",{class:"cm-tooltip-lint"},t.map(t=>bA(e,t,!1)))}const fA=e=>{let t=e.state.field(cA,!1);return!(!t||!t.panel)&&(e.dispatch({effects:aA.of(!1)}),!0)},pA=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(cA,!1);t&&t.panel||e.dispatch({effects:oA(e.state,[aA.of(!0)])});let n=hx(e,xA.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(cA,!1);if(!t)return!1;let n=e.state.selection.main,r=t.diagnostics.iter(n.to+1);return!(!r.value&&(r=t.diagnostics.iter(0),!r.value||r.from==n.from&&r.to==n.to))&&(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],mA=Ep.define({combine:e=>({sources:e.map(e=>e.source).filter(e=>null!=e),...fm(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:gA,tooltipFilter:gA,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})})});function gA(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function vA(e){let t=[];if(e)e:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue e}}t.push("")}return t}function bA(e,t,n){var r;let i=n?vA(t.actions):[];return Um("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},Um("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(r=t.actions)||void 0===r?void 0:r.map((n,r)=>{let o=!1,s=r=>{if(r.preventDefault(),o)return;o=!0;let i=iA(e.state.field(cA).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:a}=n,l=i[r]?a.indexOf(i[r]):-1,c=l<0?a:[a.slice(0,l),Um("u",a.slice(l,l+1)),a.slice(l+1)];return Um("button",{type:"button",class:"cm-diagnosticAction"+(n.markClass?" "+n.markClass:""),onclick:s,onmousedown:s,"aria-label":` Action: ${a}${l<0?"":` (access key "${i[r]})"`}.`},c)}),t.source&&Um("div",{class:"cm-diagnosticSource"},t.source))}class yA extends hg{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Um("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class wA{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=bA(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class xA{constructor(e){this.view=e,this.items=[];this.list=Um("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)fA(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:n}=this.items[this.selectedIndex],r=vA(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=iA(this.view.state.field(cA).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}}t.preventDefault()},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=Um("div",{class:"cm-panel-lint"},this.list,Um("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>fA(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(cA).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(cA),n=0,r=!1,i=null,o=new Set;for(e.between(0,this.view.state.doc.length,(e,s,{spec:a})=>{for(let e of a.diagnostics){if(o.has(e))continue;o.add(e);let s,a=-1;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){a=t;break}a<0?(s=new wA(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[a],a>n&&(this.items.splice(n,a-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute("aria-selected")||(s.dom.setAttribute("aria-selected","true"),i=s):s.dom.hasAttribute("aria-selected")&&s.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();0==this.items.length&&(this.items.push(new wA(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),i?(this.list.setAttribute("aria-activedescendant",i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.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=iA(this.view.state.field(cA).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:lA.of(t)})}static open(e){return new xA(e)}}function kA(e){return function(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const SA=Jy.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:kA("#d11")},".cm-lintRange-warning":{backgroundImage:kA("orange")},".cm-lintRange-info":{backgroundImage:kA("#999")},".cm-lintRange-hint":{backgroundImage:kA("#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 EA(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function CA(e){let t="hint",n=1;for(let r of e){let e=EA(r.severity);e>n&&(n=e,t=r.severity)}return t}const OA=[cA,Jy.decorations.compute([cA],e=>{let{selected:t,panel:n}=e.field(cA);return t&&n&&t.from!=t.to?dg.set([hA.range(t.from,t.to)]):dg.none}),sx(uA,{hideOn:function(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(mA).hideOn(e,n,r);if(null!=i)return i;let o=e.startState.doc.lineAt(t.pos);return!(!e.effects.some(e=>e.is(sA))&&!e.changes.touchesRange(o.from,Math.max(o.to,r)))}}),SA];var NA=function(e){void 0===e&&(e={});var{crosshairCursor:t=!1}=e,n=[];!1!==e.closeBracketsKeymap&&(n=n.concat($N)),!1!==e.defaultKeymap&&(n=n.concat(GC)),!1!==e.searchKeymap&&(n=n.concat(zO)),!1!==e.historyKeymap&&(n=n.concat(GE)),!1!==e.foldKeymap&&(n=n.concat(IS)),!1!==e.completionKeymap&&(n=n.concat(eA)),!1!==e.lintKeymap&&(n=n.concat(pA));var r=[];return!1!==e.lineNumbers&&r.push(function(e={}){return[Bx.of(e),Ox(),_x]}()),!1!==e.highlightActiveLineGutter&&r.push(zx),!1!==e.highlightSpecialChars&&r.push(function(e={}){return[Pw.of(e),Lw||(Lw=Cv.fromClass(class{constructor(e){this.view=e,this.decorations=dg.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(Pw)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new Aw({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,o=ap(t[0],0);if(9==o){let e=i.lineAt(r),t=n.state.tabSize,o=Rm(e.text,t,r-e.from);return dg.replace({widget:new Iw((t-o%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=dg.replace({widget:new Bw(e,o)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(Pw);e.startState.facet(Pw)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))]}()),!1!==e.history&&r.push(function(e={}){return[DE,RE.of(e),Jy.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?LE:"historyRedo"==e.inputType?BE:null;return!!n&&(e.preventDefault(),n(t))}})]}()),!1!==e.foldGutter&&r.push(function(e={}){let t={...VS,...e},n=new qS(t,!0),r=new qS(t,!1),i=Cv.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(aS)!=e.state.facet(aS)||e.startState.field(MS,!1)!=e.state.field(MS,!1)||Qk(e.startState)!=Qk(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new wm;for(let i of e.viewportLineBlocks){let o=DS(e.state,i.from,i.to)?r:CS(e.state,i.from,i.to)?n:null;o&&t.add(i.from,i.from,o)}return t.finish()}}),{domEventHandlers:o}=t;return[i,Ex({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(i))||void 0===t?void 0:t.markers)||ym.empty},initialSpacer:()=>new qS(t,!1),domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let r=DS(e.state,t.from,t.to);if(r)return e.dispatch({effects:AS.of(r)}),!0;let i=CS(e.state,t.from,t.to);return!!i&&(e.dispatch({effects:NS.of(i)}),!0)}}}),FS()]}()),!1!==e.drawSelection&&r.push(function(e={}){return[bw.of(e),ww,kw,Sw,gv.of(!0)]}()),!1!==e.dropCursor&&r.push([Cw,Ow]),!1!==e.allowMultipleSelections&&r.push(dm.allowMultipleSelections.of(!0)),!1!==e.indentOnInput&&r.push(dm.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+200)return e;let o=n.sliceString(i.from,r);if(!t.some(e=>e.test(o)))return e;let{state:s}=e,a=-1,l=[];for(let{head:e}of s.selection.ranges){let t=s.doc.lineAt(e);if(t.from==a)continue;a=t.from;let n=fS(s,t.from);if(null==n)continue;let r=/^\s*/.exec(t.text)[0],i=dS(s,n);r!=i&&l.push({from:t.from,to:t.from+r.length,insert:i})}return l.length?[e,{changes:l,sequential:!0}]:e})),!1!==e.syntaxHighlighting&&r.push(XS(ZS,{fallback:!0})),!1!==e.bracketMatching&&r.push(function(e={}){return[nE.of(e),aE]}()),!1!==e.closeBrackets&&r.push([UN,WN]),!1!==e.autocompletion&&r.push(function(e={}){return[BN,NN,cN.of(e),PN,tA,IN]}()),!1!==e.rectangularSelection&&r.push(function(e){let t=(null==e?void 0:e.eventFilter)||(e=>e.altKey&&0==e.button);return Jy.mouseSelectionStyle.of((e,n)=>t(n)?Hw(e,n):null)}()),!1!==t&&r.push(function(e={}){let[t,n]=Vw[e.key||"Alt"],r=Cv.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){e.keyCode!=t&&n(e)||this.set(!1)},mousemove(e){this.set(n(e))}}});return[r,Jy.contentAttributes.of(e=>{var t;return(null===(t=e.plugin(r))||void 0===t?void 0:t.isDown)?qw:null})]}()),!1!==e.highlightActiveLine&&r.push(_w),!1!==e.highlightSelectionMatches&&r.push(function(e){let t=[dO,uO];return e&&t.push(aO.of(e)),t}()),e.tabSize&&"number"==typeof e.tabSize&&r.push(hS.of(" ".repeat(e.tabSize))),r.concat([ow.of(n.flat())]).filter(Boolean)};const AA="#e06c75",TA="#abb2bf",MA="#7d8799",RA="#d19a66",DA="#2c313a",PA="#282c34",LA="#353a42",BA="#528bff",IA=[Jy.theme({"&":{color:TA,backgroundColor:PA},".cm-content":{caretColor:BA},".cm-cursor, .cm-dropCursor":{borderLeftColor:BA},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"#3E4451"},".cm-panels":{backgroundColor:"#21252b",color:TA},".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:PA,color:MA,border:"none"},".cm-activeLineGutter":{backgroundColor:DA},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:LA},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:LA,borderBottomColor:LA},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:DA,color:TA}}},{dark:!0}),XS($S.define([{tag:Uk.keyword,color:"#c678dd"},{tag:[Uk.name,Uk.deleted,Uk.character,Uk.propertyName,Uk.macroName],color:AA},{tag:[Uk.function(Uk.variableName),Uk.labelName],color:"#61afef"},{tag:[Uk.color,Uk.constant(Uk.name),Uk.standard(Uk.name)],color:RA},{tag:[Uk.definition(Uk.name),Uk.separator],color:TA},{tag:[Uk.typeName,Uk.className,Uk.number,Uk.changed,Uk.annotation,Uk.modifier,Uk.self,Uk.namespace],color:"#e5c07b"},{tag:[Uk.operator,Uk.operatorKeyword,Uk.url,Uk.escape,Uk.regexp,Uk.link,Uk.special(Uk.string)],color:"#56b6c2"},{tag:[Uk.meta,Uk.comment],color:MA},{tag:Uk.strong,fontWeight:"bold"},{tag:Uk.emphasis,fontStyle:"italic"},{tag:Uk.strikethrough,textDecoration:"line-through"},{tag:Uk.link,color:MA,textDecoration:"underline"},{tag:Uk.heading,fontWeight:"bold",color:AA},{tag:[Uk.atom,Uk.bool,Uk.special(Uk.variableName)],color:RA},{tag:[Uk.processingInstruction,Uk.string,Uk.inserted],color:"#98c379"},{tag:Uk.invalid,color:"#ffffff"}]))];var jA=Jy.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),_A=function(e){void 0===e&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:r=!1,theme:i="light",placeholder:o="",basicSetup:s=!0}=e,a=[];switch(t&&a.unshift(ow.of([XC])),s&&("boolean"==typeof s?a.unshift(NA()):a.unshift(NA(s))),o&&a.unshift(function(e){let t=Cv.fromClass(class{constructor(t){this.view=t,this.placeholder=e?dg.set([dg.widget({widget:new Fw(e),side:1}).range(0)]):dg.none}get decorations(){return this.view.state.doc.length?dg.none:this.placeholder}},{decorations:e=>e.decorations});return"string"==typeof e?[t,Jy.contentAttributes.of({"aria-placeholder":e})]:t}(o)),i){case"light":a.push(jA);break;case"dark":a.push(IA);break;case"none":break;default:a.push(i)}return!1===n&&a.push(Jy.editable.of(!1)),r&&a.push(dm.readOnly.of(!0)),[...a]};class FA{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(e=>{try{e()}catch(e){}})}}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 WA{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),0===this.latches.size&&this.stop()}start(){null===this.interval&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){null!==this.interval&&(clearInterval(this.interval),this.interval=null)}}var zA=null,HA=Jp.define(),VA=[];function qA(t){var{value:n,selection:r,onChange:i,onStatistics:o,onCreateEditor:s,onUpdate:a,extensions:l=VA,autoFocus:c,theme:h="light",height:u=null,minHeight:d=null,maxHeight:f=null,width:p=null,minWidth:m=null,maxWidth:g=null,placeholder:v="",editable:b=!0,readOnly:y=!1,indentWithTab:w=!0,basicSetup:x=!0,root:k,initialState:S}=t,[E,C]=e.useState(),[O,N]=e.useState(),[A,T]=e.useState(),M=e.useState(()=>({current:null}))[0],R=e.useState(()=>({current:null}))[0],D=Jy.theme({"&":{height:u,minHeight:d,maxHeight:f,width:p,minWidth:m,maxWidth:g},"& .cm-scroller":{height:"100% !important"}}),P=Jy.updateListener.of(e=>{if(e.docChanged&&"function"==typeof i&&!e.transactions.some(e=>e.annotation(HA))){M.current?M.current.reset():(M.current=new FA(()=>{if(R.current){var e=R.current;R.current=null,e()}M.current=null},200),("undefined"==typeof window?new WA:(zA||(zA=new WA),zA)).add(M.current));var t=e.state.doc.toString();i(t,e)}o&&o((e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)}))(e))}),L=[P,D,..._A({theme:h,editable:b,readOnly:y,placeholder:v,indentWithTab:w,basicSetup:x})];return a&&"function"==typeof a&&L.push(Jy.updateListener.of(a)),L=L.concat(l),e.useLayoutEffect(()=>{if(E&&!A){var e={doc:n,selection:r,extensions:L},t=S?dm.fromJSON(S.json,e,S.fields):dm.create(e);if(T(t),!O){var i=new Jy({state:t,parent:E,root:k});N(i),s&&s(i,t)}}return()=>{O&&(T(void 0),N(void 0))}},[E,A]),e.useEffect(()=>{t.container&&C(t.container)},[t.container]),e.useEffect(()=>()=>{O&&(O.destroy(),N(void 0)),M.current&&(M.current.cancel(),M.current=null)},[O]),e.useEffect(()=>{c&&O&&O.focus()},[c,O]),e.useEffect(()=>{O&&O.dispatch({effects:em.reconfigure.of(L)})},[h,l,u,d,f,p,m,g,v,b,y,w,x,i,a]),e.useEffect(()=>{if(void 0!==n){var e=O?O.state.doc.toString():"";if(O&&n!==e){var t=()=>{O&&n!==O.state.doc.toString()&&O.dispatch({changes:{from:0,to:O.state.doc.toString().length,insert:n||""},annotations:[HA.of(!0)]})};M.current&&!M.current.isDone?R.current=t:t()}}},[n,O]),{state:A,setState:T,view:O,setView:N,container:E,setContainer:C}}var UA=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],$A=e.forwardRef((n,r)=>{var{className:i,value:o="",selection:s,extensions:a=[],onChange:l,onStatistics:c,onCreateEditor:h,onUpdate:u,autoFocus:d,theme:f="light",height:p,minHeight:m,maxHeight:g,width:v,minWidth:b,maxWidth:y,basicSetup:w,placeholder:x,indentWithTab:k,editable:S,readOnly:E,root:C,initialState:O}=n,N=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(n,UA),A=e.useRef(null),{state:T,view:M,container:R,setContainer:D}=qA({root:C,value:o,autoFocus:d,theme:f,height:p,minHeight:m,maxHeight:g,width:v,minWidth:b,maxWidth:y,basicSetup:w,placeholder:x,indentWithTab:k,editable:S,readOnly:E,selection:s,onChange:l,onStatistics:c,onCreateEditor:h,onUpdate:u,extensions:a,initialState:O});e.useImperativeHandle(r,()=>({editor:A.current,state:T,view:M}),[A,R,T,M]);var P=e.useCallback(e=>{A.current=e,D(e)},[D]);if("string"!=typeof o)throw new Error("value must be typeof string but got "+typeof o);var L="string"==typeof f?"cm-theme-"+f:"cm-theme";return t.jsx("div",_f({ref:P,className:L+(i?" "+i:"")},N))});$A.displayName="CodeMirror";class KA{constructor(e,t,n,r,i,o,s,a,l,c=0,h){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=o,this.buffer=s,this.bufferBase=a,this.curContext=l,this.lookAhead=c,this.parent=h}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let r=e.parser.context;return new KA(e,[],t,n,n,0,[],0,r?new YA(r,r.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,r=65535&e,{parser:i}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),s=i.dynamicPrecedence(r);if(s&&(this.score+=s),0==n)return this.pushState(i.getGoto(this.state,r,!0),this.reducePos),r<i.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),void this.reduceContext(r,this.reducePos);let a=this.stack.length-3*(n-1)-(262144&e?6:0),l=a?this.stack[a-2]:this.p.ranges[0].from,c=this.reducePos-l;c>=2e3&&!(null===(t=this.p.parser.nodeSet.types[r])||void 0===t?void 0:t.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=l,this.p.lastBigReductionSize=c));let h=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-h;if(r<i.minRepeatTerm||131072&e){let e=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,l,e,u+4,!0)}if(262144&e)this.state=this.stack[a];else{let e=this.stack[a-3];this.state=i.getGoto(e,r,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(r,l)}storeNode(e,t,n,r=4,i=!1){if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this,r=this.buffer.length;if(0==r&&e.parent&&(r=e.bufferBase-e.parent.bufferBase,e=e.parent),r>0&&0==e.buffer[r-4]&&e.buffer[r-1]>-1){if(t==n)return;if(e.buffer[r-2]>=t)return void(e.buffer[r-2]=n)}}if(i&&this.pos!=n){let i=this.buffer.length;if(i>0&&(0!=this.buffer[i-4]||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}else this.buffer.push(e,t,n,r)}shift(e,t,n,r){if(131072&e)this.pushState(65535&e,this.pos);else if(262144&e)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:o}=this.p;this.pos=r;let s=o.stateFlag(i,1);!s&&(r>n||t<=o.maxNode)&&(this.reducePos=r),this.pushState(i,s?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){65536&e?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,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),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new KA(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,r,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 GA(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==n)return!1;if(!(65536&n))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 n=[];for(let r,i=0;i<t.length;i+=2)(r=t[i+1])!=this.state&&this.p.parser.hasAction(r,e)&&n.push(t[i],r);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>1&t&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(65536&t))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=65535&t,i=this.stack.length-3*n;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(null==e)return!1;t=e}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=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(393216&t);else if(65536&t){let n=(t>>19)-i;if(n>1){let r=65535&t,i=this.stack.length-3*n;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(null!=e)return e}})};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(3!=this.stack.length)return!1;let{parser:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!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||-3!=this.buffer[e])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||-4!=this.buffer[e])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new YA(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return!(e<=this.lookAhead)&&(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class YA{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class GA{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=65535&e,n=e>>19;0==n?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(n-1);let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}}class XA{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,0==this.index&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new XA(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(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,0==this.index&&this.maybeNext()}fork(){return new XA(this.stack,this.pos,this.index)}}function JA(e,t=Uint16Array){if("string"!=typeof e)return e;let n=null;for(let r=0,i=0;r<e.length;){let o=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(126==t){o=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),o+=i,n)break;o*=46}n?n[i++]=o:n=new t(o)}return n}class QA{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const ZA=new QA;class eT{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=ZA,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,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}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,n,r=this.chunkOff+e;if(r>=0&&r<this.chunk.length)t=this.pos+e,n=this.chunk.charCodeAt(r);else{let r=this.resolveOffset(e,1);if(null==r)return-1;if(t=r,t>=this.chunk2Pos&&t<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(t-this.chunk2Pos);else{let e=this.rangeIndex,r=this.range;for(;r.to<=t;)r=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=t),t+this.chunk2.length>r.to&&(this.chunk2=this.chunk2.slice(0,r.to-t)),n=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),n}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(null==n||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=ZA,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 r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}}class tT{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;!function(e,t,n,r,i,o){let s=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;0!=(a&e[s]);){let n=e[s+1];for(let r=s+3;r<n;r+=2)if((e[r+1]&a)>0){let n=e[r];if(l.allows(n)&&(-1==t.token.value||t.token.value==n||rT(n,t.token.value,i,o))){t.acceptToken(n);break}}let r=t.next,c=0,h=e[s+2];if(!(t.next<0&&h>c&&65535==e[n+3*h-3])){for(;c<h;){let i=c+h>>1,o=n+i+(i<<1),a=e[o],l=e[o+1]||65536;if(r<a)h=i;else{if(!(r>=l)){s=e[o+2],t.advance();continue e}c=i+1}}break}s=e[n+3*h-1]}}(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}function nT(e,t,n){for(let r,i=t;65535!=(r=e[i]);i++)if(r==n)return i-t;return-1}function rT(e,t,n,r){let i=nT(n,r,t);return i<0||nT(n,r,e)<i}tT.prototype.contextual=tT.prototype.fallback=tT.prototype.extend=!1,tT.prototype.fallback=tT.prototype.extend=!1;const iT="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let oT=null;function sT(e,t,n){let r=e.cursor(Qx.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}class aT{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?sT(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?sT(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],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],o=this.start[t]+n.positions[r];if(o>e)return this.nextStart=o,null;if(i instanceof Zx){if(o==e){if(o<this.safeFrom)return null;let e=o+i.length;if(e<=this.safeTo){let t=i.prop(Ux.lookAhead);if(!t||e+t<this.fragment.to)return i}}this.index[t]++,o+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+i.length}}}class lT{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new QA)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,o=r.stateSlot(e.state,3),s=e.curContext?e.curContext.hash:0,a=0;for(let r=0;r<i.length;r++){if(!(1<<r&o))continue;let l=i[r],c=this.tokens[r];if((!n||l.fallback)&&((l.contextual||c.start!=e.pos||c.mask!=o||c.context!=s)&&(this.updateCachedToken(c,l,e),c.mask=o,c.context=s),c.lookAhead>c.end+25&&(a=Math.max(c.lookAhead,a)),0!=c.value)){let r=t;if(c.extended>-1&&(t=this.addActions(e,c.extended,c.end,t)),t=this.addActions(e,c.value,c.end,t),!l.extend&&(n=c,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),n||e.pos!=this.stream.end||(n=new QA,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 QA,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){1&i?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:o}=e.p,{data:s}=o;for(let e=0;e<2;e++)for(let a=o.stateSlot(i,e?2:1);;a+=3){if(65535==s[a]){if(1!=s[a+1]){0==r&&2==s[a+1]&&(r=this.putAction(fT(s,a+2),t,n,r));break}a=fT(s,a+2)}s[a]==t&&(r=this.putAction(fT(s,a+1),t,n,r))}return r}}class cT{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,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 eT(t,r),this.tokens=new lT(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[KA.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>4*e.bufferLength?new aT(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e,t,n=this.stacks,r=this.minStackPos,i=this.stacks=[];if(this.bigReductionCount>300&&1==n.length){let[e]=n;for(;e.forceReduce()&&e.stack.length&&e.stack[e.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<n.length;o++){let s=n[o];for(;;){if(this.tokens.mainToken=null,s.pos>r)i.push(s);else{if(this.advanceStack(s,i,n))continue;{e||(e=[],t=[]),e.push(s);let n=this.tokens.getMainToken(s);t.push(n.value,n.end)}}break}}if(!i.length){let t=e&&function(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||null!=e&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}(e);if(t)return this.stackToTree(t);if(this.parser.strict)throw new SyntaxError("No parse at "+r);this.recovering||(this.recovering=5)}if(this.recovering&&e){let n=null!=this.stoppedAt&&e[0].pos>this.stoppedAt?e[0]:this.runRecovery(e,t,i);if(n)return this.stackToTree(n.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(i.length>e)for(i.sort((e,t)=>t.score-e.score);i.length>e;)i.pop();i.some(e=>e.reducePos>r)&&this.recovering--}else if(i.length>1){e:for(let e=0;e<i.length-1;e++){let t=i[e];for(let n=e+1;n<i.length;n++){let r=i[n];if(t.sameState(r)||t.buffer.length>500&&r.buffer.length>500){if(!((t.score-r.score||t.buffer.length-r.buffer.length)>0)){i.splice(e--,1);continue e}i.splice(n--,1)}}}i.length>12&&(i.sort((e,t)=>t.score-e.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let e=1;e<i.length;e++)i[e].pos<this.minStackPos&&(this.minStackPos=i[e].pos);return null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let r=e.pos,{parser:i}=this;iT&&this.stackID(e);if(null!=this.stoppedAt&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(r);o;){let r=this.parser.nodeSet.types[o.type.id]==o.type?i.getGoto(e.state,o.type.id):-1;if(r>-1&&o.length&&(!t||(o.prop(Ux.contextHash)||0)==n))return e.useNode(o,r),!0;if(!(o instanceof Zx)||0==o.children.length||o.positions[0]>0)break;let s=o.children[0];if(!(s instanceof Zx&&0==o.positions[0]))break;o=s}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let i=0;i<s.length;){let o=s[i++],a=s[i++],l=s[i++],c=i==s.length||!n,h=c?e:e.split(),u=this.tokens.mainToken;if(h.apply(o,a,u?u.start:h.pos,l),c)return!0;h.pos>r?t.push(h):n.push(h)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return hT(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=t[o<<1],l=t[1+(o<<1)],c=iT?this.stackID(s)+" -> ":"";if(s.deadEnd){if(i)continue;if(i=!0,s.restart(),this.advanceFully(s,n))continue}let h=s.split(),u=c;for(let e=0;e<10&&h.forceReduce();e++){if(this.advanceFully(h,n))break;iT&&(u=this.stackID(h)+" -> ")}for(let e of s.recoverByInsert(a))this.advanceFully(e,n);this.stream.end>s.pos?(l==s.pos&&(l++,a=0),s.recoverByDelete(a,l),hT(s,n)):(!r||r.score<h.score)&&(r=h)}return r}stackToTree(e){return e.close(),Zx.build({buffer:XA.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=(oT||(oT=new WeakMap)).get(e);return t||oT.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function hT(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e))return void(t[n].score<e.score&&(t[n]=e))}t.push(e)}class uT{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||0==this.disabled[e]}}class dT extends bk{constructor(e){if(super(),this.wrappers=[],14!=e.version)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push("");let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<t.length;e++)r.push([]);function i(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];"string"==typeof e&&(e=Ux[e]);for(let n=1;n<t.length;){let r=t[n++];if(r>=0)i(r,e,t[n++]);else{let o=t[n+-r];for(let s=-r;s>0;s--)i(t[n++],e,o);n++}}}this.nodeSet=new Gx(t.map((t,i)=>Yx.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:0==i,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Hx;let o=JA(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(pT),this.states=JA(e.states,Uint32Array),this.data=JA(e.stateData),this.goto=JA(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>"number"==typeof e?new tT(o,e):e),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 r=new cT(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],o=1&t,s=r[i++];if(o&&n)return s;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return s;if(o)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i,o=this.stateSlot(e,r?2:1);;o+=3){if(65535==(i=n[o])){if(1!=n[o+1]){if(2==n[o+1])return fT(n,o+2);break}i=n[o=fT(n,o+2)]}if(i==t||0==i)return fT(n,o+1)}return 0}stateSlot(e,t){return this.states[6*e+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);null==r;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=fT(this.data,n+2)}r=t(fT(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=fT(this.data,n+2)}if(!(1&this.data[n+2])){let e=this.data[n+1];t.some((t,n)=>1&n&&t==e)||t.push(this.data[n],e)}}return t}configure(e){let t=Object.assign(Object.create(dT.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(t=>{let n=e.tokenizers.find(e=>e.from==t);return n?n.to:t})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,r)=>{let i=e.specializers.find(e=>e.from==n.external);if(!i)return n;let o=Object.assign(Object.assign({},n),{external:i.to});return t.specializers[r]=pT(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),null!=e.strict&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),null!=e.bufferLength&&(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 null==t?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 e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n,i=this.dialects[t[e]];65535!=(n=this.data[i++]);)(r||(r=new Uint8Array(this.maxTerm+1)))[n]=1;return new uT(e,n,r)}static deserialize(e){return new dT(e)}}function fT(e,t){return e[t]|e[t+1]<<16}function pT(e){if(e.external){let t=e.extend?1:0;return(n,r)=>e.external(n,r)<<1|t}return e.get}const mT=Ek({String:Uk.string,Number:Uk.number,"True False":Uk.bool,PropertyName:Uk.propertyName,Null:Uk.null,", :":Uk.separator,"[ ]":Uk.squareBracket,"{ }":Uk.brace}),gT=dT.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:[mT],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}),vT=Jk.define({name:"json",parser:gT.configure({props:[mS.add({Object:xS({except:/^\s*\}/}),Array:xS({except:/^\s*\]/})}),SS.add({"Object Array":function(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function bT(e){return yT.apply(this,arguments)}function yT(){return yT=h(f().m(function e(t){var n,r;return f().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return e.a(2);case 1:if(!(null===(n=null===navigator||void 0===navigator?void 0:navigator.clipboard)||void 0===n?void 0:n.writeText)){e.n=3;break}return e.n=2,navigator.clipboard.writeText(t);case 2:return e.a(2);case 3:(r=document.createElement("textarea")).value=t,r.style.position="fixed",r.style.left="-9999px",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r);case 4:return e.a(2)}},e)})),yT.apply(this,arguments)}function wT(e){var t=e.value,n=e.title;if(null==t||""===t)return s.createElement("span",null,"-");var r,i=If(t),o=i.ok,a=i.pretty,l=i.compact,c=l.length>80?l.slice(0,80)+"…":l;return s.createElement(cf,null,s.createElement(hf,{asChild:!0},s.createElement("button",{type:"button",className:"max-w-xs truncate text-left font-mono text-xs text-muted-foreground hover:underline",title:"点击查看 JSON"},c)),s.createElement(ff,{className:"max-w-3xl"},s.createElement(pf,null,s.createElement(gf,null,n||"JSON")),s.createElement("div",{className:"flex items-center justify-end gap-2"},s.createElement(at,{variant:"outline",size:"sm",onClick:(r=h(f().m(function e(){return f().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,bT(a);case 1:Fa.success("已复制 JSON"),e.n=3;break;case 2:e.p=2,e.v,Fa.error("复制失败");case 3:return e.a(2)}},e,null,[[0,2]])})),function(){return r.apply(this,arguments)})},"复制")),s.createElement("pre",{className:"max-h-[60vh] overflow-auto rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap break-all"},a),!o&&s.createElement("div",{className:"text-xs text-destructive"},i.ok?"":i.message)))}function xT(e){e.id;var t=e.value;e.required;var n,r=e.disabled,i=e.onChange,o=m(s.useState(null),2),a=o[0],l=o[1];return s.createElement("div",{className:"space-y-2"},s.createElement("div",{className:"flex items-center justify-end gap-2"},s.createElement(at,{type:"button",variant:"outline",size:"sm",disabled:!!r,onClick:function(){if(!r){var e=(t||"").trim();if(e){var n=jf(e,2);n.ok?(i(n.formatted),l(null)):l(n.message)}}}},"格式化"),s.createElement(at,{type:"button",variant:"outline",size:"sm",onClick:(n=h(f().m(function e(){return f().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,bT(t||"");case 1:Fa.success("已复制"),e.n=3;break;case 2:e.p=2,e.v,Fa.error("复制失败");case 3:return e.a(2)}},e,null,[[0,2]])})),function(){return n.apply(this,arguments)})},"复制")),s.createElement("div",{className:"w-full max-w-full overflow-hidden rounded-md border bg-background"},s.createElement($A,{className:"w-full max-w-full",editable:!r,value:t||"",height:"220px",basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0},extensions:[new lS(vT),Jy.lineWrapping],onChange:function(e){r||(i(e),function(e){var t=(e||"").trim();if(!t)return l(null),!0;var n=If(t);n.ok?l(null):l(n.message)}(e))}})),a&&s.createElement("div",{className:"text-xs text-destructive"},a))}var kT=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("div",{className:"relative w-full overflow-x-auto"},s.createElement("table",Object.assign({ref:t,className:qe("w-full min-w-max caption-bottom text-sm",n)},r)))});kT.displayName="Table";var ST=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("thead",Object.assign({ref:t,className:qe("[&_tr]:border-b",n)},r))});ST.displayName="TableHeader";var ET=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("tbody",Object.assign({ref:t,className:qe("[&_tr:last-child]:border-0",n)},r))});ET.displayName="TableBody";var CT=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("tfoot",Object.assign({ref:t,className:qe("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",n)},r))});CT.displayName="TableFooter";var OT=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("tr",Object.assign({ref:t,className:qe("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",n)},r))});OT.displayName="TableRow";var NT=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("th",Object.assign({ref:t,className:qe("h-12 px-4 text-left align-middle font-medium text-muted-foreground whitespace-nowrap [&:has([role=checkbox])]:pr-0",n)},r))});NT.displayName="TableHead";var AT=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("td",Object.assign({ref:t,className:qe("p-4 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",n)},r))});AT.displayName="TableCell";var TT=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("caption",Object.assign({ref:t,className:qe("mt-4 text-sm text-muted-foreground",n)},r))});TT.displayName="TableCaption";var MT=ot("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function RT(e){var t=e.className,n=e.variant,r=G(e,["className","variant"]);return s.createElement("div",Object.assign({className:qe(MT({variant:n}),t)},r))}function DT(){return"".concat(Date.now(),"_").concat(Math.random().toString(16).slice(2))}function PT(e){return"integer"===e||"float"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"gt",label:"大于"},{value:"gte",label:"大于等于"},{value:"lt",label:"小于"},{value:"lte",label:"小于等于"},{value:"in",label:"属于(多个)"},{value:"isNull",label:"为空(NULL)"}]:"boolean"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"isNull",label:"为空(NULL)"}]:"date"===e||"datetime"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"gt",label:"晚于/大于"},{value:"gte",label:"晚于等于/大于等于"},{value:"lt",label:"早于/小于"},{value:"lte",label:"早于等于/小于等于"},{value:"isNull",label:"为空(NULL)"}]:[{value:"contains",label:"包含"},{value:"startsWith",label:"开头是"},{value:"endsWith",label:"结尾是"},{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"in",label:"属于(多个)"},{value:"isNull",label:"为空(NULL)"}]}function LT(t){var n,r,i=e.useMemo(function(){var e=[];e.push.apply(e,g([{column:"id",label:"ID",type:"id"},{column:"created_at",label:"创建时间",type:"datetime"},{column:"updated_at",label:"更新时间",type:"datetime"}]));var n,r=u(t.fields||[]);try{for(r.s();!(n=r.n()).done;){var i=n.value;if((null==i?void 0:i.name)&&("json"!==i.type&&"jsonb"!==i.type))if("relation"===i.type&&i.relation){var o=i.relation.foreignKey||"".concat(i.relation.target,"_id");e.push({column:o,label:"".concat(i.comment||i.name,"(关联)"),type:"relation"})}else e.push({column:i.name,label:i.comment||i.name,type:i.type})}}catch(e){r.e(e)}finally{r.f()}var s=new Set;return e.filter(function(e){return!s.has(e.column)&&(s.add(e.column),!0)})},[t.fields]),o=e.useMemo(function(){return new Map(i.map(function(e){return[e.column,e]}))},[i]),s=e.useMemo(function(){return new Map(i.map(function(e){return[e.column,e.type]}))},[i]),a=m(e.useState([]),2),l=a[0],c=a[1];e.useEffect(function(){c(function(e,t){return(e||[]).map(function(e){if(t.get(e.column),"is"===e.operator&&(null===e.value||"null"===e.value))return{id:DT(),column:e.column,operator:"isNull",value:""};if(("ilike"===e.operator||"like"===e.operator)&&"string"==typeof e.value){var n=e.value;if(n.startsWith("%")&&n.endsWith("%")&&n.length>=2)return{id:DT(),column:e.column,operator:"contains",value:n.slice(1,-1)};if(n.endsWith("%"))return{id:DT(),column:e.column,operator:"startsWith",value:n.slice(0,-1)};if(n.startsWith("%"))return{id:DT(),column:e.column,operator:"endsWith",value:n.slice(1)}}if("in"===e.operator){var r=Array.isArray(e.value)?e.value:[];return{id:DT(),column:e.column,operator:"in",value:r.join(",")}}return{id:DT(),column:e.column,operator:["eq","neq","gt","gte","lt","lte"].includes(e.operator)?e.operator:"eq",value:void 0===e.value||null===e.value?"":String(e.value)}})}(t.value||[],s))},[JSON.stringify(t.value),i.length]);var h=function(e,t){c(function(n){return n.map(function(n){var r,i;if(n.id!==e)return n;var s=Object.assign(Object.assign({},n),t);if(t.column&&t.column!==n.column){var a=PT((null===(r=o.get(t.column))||void 0===r?void 0:r.type)||"string");s.operator=(null===(i=a[0])||void 0===i?void 0:i.value)||"eq",s.value=""}return t.operator&&"isNull"===t.operator&&(s.value=""),s})})};return e.createElement("div",{className:"space-y-3"},e.createElement("div",{className:"flex items-center justify-between gap-3"},e.createElement(ya,{className:"text-base font-medium flex items-center gap-2"},e.createElement(R,{className:"h-4 w-4"}),"动态筛选"),e.createElement("div",{className:"flex items-center gap-2"},(null===(n=t.value)||void 0===n?void 0:n.length)>0&&e.createElement(RT,{variant:"secondary"},"已应用 ",t.value.length," 条"),e.createElement(at,{type:"button",variant:"outline",size:"sm",onClick:function(){var e=i[0];if(e){var t=PT(e.type);c(function(n){var r;return[].concat(g(n),[{id:DT(),column:e.column,operator:(null===(r=t[0])||void 0===r?void 0:r.value)||"eq",value:""}])})}}},e.createElement(F,{className:"h-4 w-4 mr-1"}),"添加条件"))),0===l.length?e.createElement("div",{className:"text-sm text-muted-foreground border rounded-lg p-3 bg-muted/20"},"暂无筛选条件(可添加条件后点击“应用”)"):e.createElement("div",{className:"space-y-2"},l.map(function(t){var n=o.get(t.column),r=(null==n?void 0:n.type)||"string",s=PT(r),a="isNull"!==t.operator;return e.createElement("div",{key:t.id,className:"grid grid-cols-12 gap-2 items-center"},e.createElement("div",{className:"col-span-5"},e.createElement(Bd,{value:t.column,onValueChange:function(e){return h(t.id,{column:e})}},e.createElement(jd,{className:"h-10"},e.createElement(Id,{placeholder:"字段"})),e.createElement(Wd,null,i.map(function(t){return e.createElement(Hd,{key:t.column,value:t.column},t.label," (",t.column,")")})))),e.createElement("div",{className:"col-span-3"},e.createElement(Bd,{value:t.operator,onValueChange:function(e){return h(t.id,{operator:e})}},e.createElement(jd,{className:"h-10"},e.createElement(Id,{placeholder:"操作符"})),e.createElement(Wd,null,s.map(function(t){return e.createElement(Hd,{key:t.value,value:t.value},t.label)})))),e.createElement("div",{className:"col-span-3"},a?"boolean"===r?e.createElement(Bd,{value:t.value,onValueChange:function(e){return h(t.id,{value:e})}},e.createElement(jd,{className:"h-10"},e.createElement(Id,{placeholder:"值"})),e.createElement(Wd,null,e.createElement(Hd,{value:"true"},"true"),e.createElement(Hd,{value:"false"},"false"))):e.createElement(lt,{className:"h-10",placeholder:"in"===t.operator?"多个值用逗号分隔":"值",type:"integer"===r||"float"===r?"number":"date"===r?"date":"datetime"===r?"datetime-local":"text",value:t.value,onChange:function(e){return h(t.id,{value:e.target.value})}}):e.createElement("div",{className:"h-10 flex items-center text-sm text-muted-foreground"},"无需填写")),e.createElement("div",{className:"col-span-1 flex justify-end"},e.createElement(at,{type:"button",variant:"ghost",size:"sm",className:"h-9 w-9 p-0",onClick:function(){return e=t.id,void c(function(t){return t.filter(function(t){return t.id!==e})});var e}},e.createElement(K,{className:"h-4 w-4"}))))})),e.createElement("div",{className:"flex items-center justify-end gap-2"},e.createElement(at,{type:"button",variant:"outline",onClick:function(){c([]),t.onChange([])},disabled:0===l.length&&0===((null===(r=t.value)||void 0===r?void 0:r.length)||0)},"清空"),e.createElement(at,{type:"button",onClick:function(){var e=function(e,t){var n,r,i=[],o=u(e);try{for(o.s();!(r=o.n()).done;){var s=r.value,a=t.get(s.column);if(a&&s.operator)if("isNull"!==s.operator){var l=null!==(n=s.value)&&void 0!==n?n:"",c=String(l).trim();if(c)if("contains"!==s.operator)if("startsWith"!==s.operator)if("endsWith"!==s.operator)if("in"!==s.operator)i.push({column:a.column,operator:s.operator,value:c});else{var h=c.split(",").map(function(e){return e.trim()}).filter(Boolean);i.push({column:a.column,operator:"in",value:h})}else i.push({column:a.column,operator:"ilike",value:"%".concat(c)});else i.push({column:a.column,operator:"ilike",value:"".concat(c,"%")});else i.push({column:a.column,operator:"ilike",value:"%".concat(c,"%")})}else i.push({column:a.column,operator:"is",value:null})}}catch(e){o.e(e)}finally{o.f()}return i}(l,o);t.onChange(e)},disabled:0===l.length},"应用")))}function BT(){var t,n=m(e.useState([]),2),r=n[0],o=n[1],s=m(e.useState(null),2),a=s[0],l=s[1],c=m(e.useState([]),2),u=c[0],p=c[1],g=m(e.useState(!1),2),v=g[0],b=g[1],y=m(e.useState(!1),2),w=y[0],x=y[1],k=m(e.useState(null),2),S=k[0],E=k[1],N=m(e.useState({}),2),A=N[0],T=N[1],M=m(e.useState(1),2),D=M[0],P=M[1],B=m(e.useState(10),2),I=B[0];B[1];var j=m(e.useState(0),2),_=j[0],z=j[1],V=m(e.useState(""),2),U=V[0],$=V[1],K=m(e.useState(!1),2),Y=K[0],G=K[1],X=m(e.useState(null),2),J=X[0],Q=X[1],Z=m(e.useState(!0),2),ee=Z[0],te=Z[1],ne=m(e.useState([]),2),re=ne[0],ie=ne[1],oe=m(e.useState(!1),2),se=oe[0],ae=oe[1],le=function(e){return Array.isArray(e)?e:Array.isArray(null==e?void 0:e.models)?e.models:Array.isArray(null==e?void 0:e.data)?e.data:Array.isArray(null==e?void 0:e.items)?e.items:[]},ce=function(e){var t;if(e&&Array.isArray(e.data)){var n="number"==typeof e.total?e.total:"number"==typeof(null===(t=e.pagination)||void 0===t?void 0:t.total)?e.pagination.total:e.data.length;return{rows:e.data,total:n}}if(e&&Array.isArray(e.rows)){var r="number"==typeof e.total?e.total:e.rows.length;return{rows:e.rows,total:r}}return Array.isArray(e)?{rows:e,total:e.length}:{rows:[],total:0}},he=function(e){return!e||!e.readOnly&&!1!==e.editable};e.useEffect(function(){ue()},[]),e.useEffect(function(){a&&de()},[a,D,I,U,re]);var ue=function(){var e=h(f().m(function e(){var t;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:return te(!0),e.p=1,e.n=2,ah();case 2:t=e.v,o(le(t.data)),e.n=4;break;case 3:e.p=3,e.v,Fa.error("加载模型列表失败");case 4:return e.p=4,te(!1),e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}));return function(){return e.apply(this,arguments)}}(),de=function(){var e=h(f().m(function e(){var t,n,r;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(a){e.n=1;break}return e.a(2);case 1:return b(!0),e.p=2,t={page:D,limit:I},U&&(t.search=U),re.length>0&&(t.filters=re),e.n=3,gh(a.table_name,t);case 3:if((n=e.v).success){e.n=4;break}return Fa.error(n.message||"加载数据失败"),p([]),z(0),e.a(2);case 4:r=ce(n.data),p(r.rows),z(r.total),e.n=6;break;case 5:e.p=5,e.v,Fa.error("加载数据失败"),p([]),z(0);case 6:return e.p=6,b(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}(),fe=function(){var e=h(f().m(function e(t){var n;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("确定要删除这条数据吗?此操作不可撤销。")){e.n=1;break}return e.a(2);case 1:return Q(t.id),e.p=2,e.n=3,wh(null==a?void 0:a.table_name,t.id);case 3:(n=e.v).success?(Fa.success("删除成功"),de()):Fa.error(n.message||"删除失败"),e.n=5;break;case 4:e.p=4,e.v,Fa.error("删除失败");case 5:return e.p=5,Q(null),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),pe=function(){var e=h(f().m(function e(){var t,n,r,i,o;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(a){e.n=1;break}return e.a(2);case 1:if(G(!0),e.p=2,t={},a.json_schema.fields.forEach(function(e){if("id"!==e.name&&he(e)){var n=A[e.name];if("date"!==e.type&&"datetime"!==e.type||(n=n?new Date(n).toISOString():null),"json"===e.type||"jsonb"===e.type){var r=(n||"").toString().trim();if(r){var i=If(r);if(!i.ok)throw new Error("字段 ".concat(e.comment||e.name,":").concat(i.message));n=i.value}else n=null}t[e.name]=n}}),!S){e.n=4;break}return e.n=3,yh(a.table_name,Object.assign(Object.assign({},t),{id:S.id}));case 3:(n=e.v).success?(Fa.success("更新成功"),x(!1),de()):Fa.error(n.message||"更新失败"),e.n=6;break;case 4:return e.n=5,bh(a.table_name,t);case 5:(r=e.v).success?(Fa.success("创建成功"),x(!1),de()):Fa.error(r.message||"创建失败");case 6:e.n=8;break;case 7:e.p=7,o=e.v,i=o instanceof Error?o.message:"操作失败",Fa.error(i);case 8:return e.p=8,G(!1),e.f(8);case 9:return e.a(2)}},e,null,[[2,7,8,9]])}));return function(){return e.apply(this,arguments)}}();return e.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},e.createElement("div",{className:"container mx-auto px-6 py-8 space-y-6"},e.createElement("div",{className:"space-y-2"},e.createElement("h1",{className:"text-3xl font-bold tracking-tight"},"数据列表"),e.createElement("p",{className:"text-muted-foreground"},"选择模型查看和管理数据")),e.createElement(wa,{className:"border-2 shadow-lg"},e.createElement(xa,{className:"bg-muted/30"},e.createElement("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4"},e.createElement("div",null,e.createElement(ka,null,"数据管理"),e.createElement(Sa,null,"选择数据模型进行查看和管理")),a&&e.createElement(at,{onClick:function(){E(null),T({}),x(!0)},className:"w-full md:w-auto"},e.createElement(F,{className:"h-4 w-4 mr-2"}),"新建数据"))),e.createElement(Ea,{className:"space-y-6 pt-6"},e.createElement("div",{className:"flex flex-col md:flex-row gap-4"},e.createElement("div",{className:"flex-1 space-y-2"},e.createElement(ya,{htmlFor:"model",className:"text-base font-medium flex items-center gap-2"},e.createElement(R,{className:"h-4 w-4"}),"选择数据模型"),e.createElement(Bd,{value:(null===(t=null==a?void 0:a.id)||void 0===t?void 0:t.toString())||"",onValueChange:function(e){var t=r.find(function(t){return t.id.toString()===e});l(t||null),P(1),$(""),ie([])},disabled:ee},e.createElement(jd,{className:"h-11"},ee?e.createElement("div",{className:"flex items-center gap-2"},e.createElement(L,{className:"h-4 w-4 animate-spin"}),e.createElement("span",null,"加载中...")):e.createElement(Id,{placeholder:"请选择模型"})),e.createElement(Wd,null,r.map(function(t){return e.createElement(Hd,{key:t.id,value:t.id.toString()},t.name," (",t.table_name,")")})))),a&&e.createElement("div",{className:"flex-1 space-y-2"},e.createElement(ya,{htmlFor:"search",className:"text-base font-medium flex items-center gap-2"},e.createElement(W,{className:"h-4 w-4"}),"搜索"),e.createElement("div",{className:"relative"},e.createElement(W,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.createElement(lt,{id:"search",placeholder:"搜索数据...",value:U,onChange:function(e){return $(e.target.value)},className:"pl-10 h-11"})))),a&&e.createElement(e.Fragment,null,e.createElement("div",{className:"flex items-center justify-end"},e.createElement(at,{type:"button",variant:"outline",className:"h-10",onClick:function(){return ae(!0)}},e.createElement(R,{className:"h-4 w-4 mr-2"}),"筛选",re.length>0?"(".concat(re.length,")"):"")),e.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},e.createElement("div",{className:"text-sm text-muted-foreground"},"共 ",e.createElement("span",{className:"font-semibold text-foreground"},_)," 条数据"),e.createElement(RT,{variant:"outline"},a.name)),e.createElement("div",{className:"rounded-lg border overflow-hidden"},e.createElement("div",{className:"overflow-x-auto"},e.createElement(kT,null,e.createElement(ST,null,e.createElement(OT,{className:"bg-muted/50"},e.createElement(NT,{className:"font-semibold w-20"},"ID"),a.json_schema.fields.map(function(t){return e.createElement(NT,{key:t.name,className:"font-semibold"},t.comment||t.name)}),e.createElement(NT,{className:"font-semibold"},"创建时间"),e.createElement(NT,{className:"font-semibold"},"更新时间"),e.createElement(NT,{className:"font-semibold w-32 text-center"},"操作"))),e.createElement(ET,null,v?Array.from({length:3}).map(function(t,n){return e.createElement(OT,{key:n},e.createElement(AT,{colSpan:a.json_schema.fields.length+4},e.createElement("div",{className:"flex items-center gap-2 py-4"},e.createElement(L,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.createElement("span",{className:"text-sm text-muted-foreground"},"加载中..."))))}):0===u.length?e.createElement(OT,null,e.createElement(AT,{colSpan:a.json_schema.fields.length+4,className:"text-center py-12"},e.createElement("div",{className:"flex flex-col items-center gap-2 text-muted-foreground"},e.createElement(W,{className:"h-8 w-8"}),e.createElement("p",null,"暂无数据")))):u.map(function(t,n){return e.createElement(OT,{key:t.id,className:n%2==0?"bg-muted/20":""},e.createElement(AT,{className:"font-mono font-medium"},t.id),a.json_schema.fields.map(function(n){return e.createElement(AT,{key:n.name},function(t,n){return"boolean"===t.type?e.createElement(RT,{variant:n?"default":"secondary"},n?"是":"否"):"date"===t.type||"datetime"===t.type?n?i(n).format("YYYY-MM-DD HH:mm:ss"):"-":"text"===t.type&&n&&n.length>50?e.createElement("span",{className:"max-w-xs truncate block",title:n},n.substring(0,50),"..."):"json"===t.type||"jsonb"===t.type?e.createElement(wT,{value:n,title:t.comment||t.name}):n||"-"}(n,t[n.name]))}),e.createElement(AT,{className:"text-sm text-muted-foreground"},i(t.created_at).format("YYYY-MM-DD HH:mm")),e.createElement(AT,{className:"text-sm text-muted-foreground"},i(t.updated_at).format("YYYY-MM-DD HH:mm")),e.createElement(AT,null,e.createElement("div",{className:"flex items-center justify-center gap-2"},e.createElement(at,{variant:"ghost",size:"sm",onClick:function(){return function(e){E(e);var t={};null==a||a.json_schema.fields.forEach(function(n){if("id"!==n.name){var r=e[n.name];"date"!==n.type&&"datetime"!==n.type||(r=r?i(r).format("YYYY-MM-DDTHH:mm"):""),"json"!==n.type&&"jsonb"!==n.type||(r=null==r||""===r?"":"string"==typeof r?r:JSON.stringify(r,null,2)),t[n.name]=r}}),T(t),x(!0)}(t)},className:"h-8 w-8 p-0"},e.createElement(H,{className:"h-4 w-4"})),e.createElement(at,{variant:"ghost",size:"sm",onClick:function(){return fe(t)},disabled:J===t.id,className:"h-8 w-8 p-0 text-destructive hover:text-destructive"},J===t.id?e.createElement(L,{className:"h-4 w-4 animate-spin"}):e.createElement(q,{className:"h-4 w-4"})))))}))))),_>I&&e.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},e.createElement("div",{className:"text-sm text-muted-foreground"},"第 ",e.createElement("span",{className:"font-semibold text-foreground"},D)," 页, 共 ",e.createElement("span",{className:"font-semibold text-foreground"},Math.ceil(_/I))," 页"),e.createElement("div",{className:"flex gap-2"},e.createElement(at,{variant:"outline",size:"sm",onClick:function(){return P(Math.max(1,D-1))},disabled:1===D||v},e.createElement(C,{className:"h-4 w-4 mr-1"}),"上一页"),e.createElement(at,{variant:"outline",size:"sm",onClick:function(){return P(Math.min(Math.ceil(_/I),D+1))},disabled:D>=Math.ceil(_/I)||v},"下一页",e.createElement(O,{className:"h-4 w-4 ml-1"}))))))),a&&e.createElement(cf,{open:se,onOpenChange:ae},e.createElement(ff,{className:"max-w-3xl"},e.createElement(pf,null,e.createElement(gf,{className:"text-xl"},"筛选"),e.createElement(bf,{className:"text-sm"},a.name," - ",a.table_name)),e.createElement("div",{className:"py-2"},e.createElement(LT,{fields:a.json_schema.fields,value:re,onChange:function(e){ie(e),P(1)}})),e.createElement(mf,{className:"gap-2"},e.createElement(at,{variant:"outline",onClick:function(){return ae(!1)}},"关闭")))),e.createElement(cf,{open:w,onOpenChange:x},e.createElement(ff,{className:"max-w-3xl max-h-[85vh] overflow-y-auto"},e.createElement(pf,null,e.createElement(gf,{className:"text-2xl"},S?"编辑数据":"新建数据"),e.createElement(bf,{className:"text-base"},null==a?void 0:a.name," - ",null==a?void 0:a.table_name)),e.createElement("div",{className:"space-y-4 py-4"},null==a?void 0:a.json_schema.fields.map(function(t){return function(t){if("id"===t.name)return null;var n=he(t);switch(t.type){case"boolean":return e.createElement("div",{key:t.name,className:"flex items-center space-x-3 p-4 rounded-lg border bg-card"},e.createElement(af,{id:t.name,checked:A[t.name]||!1,disabled:!n,onCheckedChange:function(e){return T(Object.assign(Object.assign({},A),d({},t.name,e)))}}),e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium cursor-pointer"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")));case"date":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lt,{id:t.name,type:"date",value:A[t.name]||"",disabled:!n,onChange:function(e){return T(Object.assign(Object.assign({},A),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"datetime":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lt,{id:t.name,type:"datetime-local",value:A[t.name]||"",disabled:!n,onChange:function(e){return T(Object.assign(Object.assign({},A),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"text":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lf,{id:t.name,rows:4,value:A[t.name]||"",disabled:!n,onChange:function(e){return T(Object.assign(Object.assign({},A),d({},t.name,e.target.value)))},required:t.required,className:"resize-none"}));case"json":case"jsonb":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(xT,{id:t.name,value:A[t.name]||"",required:t.required,disabled:!n,onChange:function(e){return T(Object.assign(Object.assign({},A),d({},t.name,e)))}}));case"integer":case"float":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lt,{id:t.name,type:"number",value:A[t.name]||"",disabled:!n,onChange:function(e){return T(Object.assign(Object.assign({},A),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));default:return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lt,{id:t.name,type:"email"===t.type?"email":"text",maxLength:t.maxLength,value:A[t.name]||"",disabled:!n,onChange:function(e){return T(Object.assign(Object.assign({},A),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}))}}(t)})),e.createElement(mf,{className:"gap-2"},e.createElement(at,{variant:"outline",onClick:function(){return x(!1)},disabled:Y},"取消"),e.createElement(at,{onClick:pe,disabled:Y},Y?e.createElement(e.Fragment,null,e.createElement(L,{className:"h-4 w-4 mr-2 animate-spin"}),S?"更新中...":"创建中..."):S?"更新":"创建"))))))}function IT(e){return/^https?:\/\//i.test(e)}function jT(t){var n=t.url;return e.createElement("div",{className:"flex items-center gap-2 max-w-[360px]"},e.createElement(Xs,null,e.createElement(Js,{asChild:!0},e.createElement("a",{href:n,target:"_blank",rel:"noreferrer",className:"inline-flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded border bg-muted",title:"点击打开原图"},e.createElement("img",{src:n,alt:"",className:"h-full w-full object-cover",onError:function(e){e.currentTarget.style.display="none"}}))),e.createElement(Qs,{side:"right",className:"p-2"},e.createElement("img",{src:n,alt:"",className:"max-h-64 max-w-64 rounded object-contain",onError:function(e){e.currentTarget.style.display="none"}}))),e.createElement("a",{href:n,target:"_blank",rel:"noreferrer",className:"truncate text-primary underline-offset-2 hover:underline",title:n},n))}function _T(t){var n=t.model,r=m(e.useState([]),2),o=r[0],s=r[1],a=m(e.useState(!1),2),l=a[0],c=a[1],u=m(e.useState(!1),2),p=u[0],g=u[1],v=m(e.useState(!1),2),b=v[0],y=v[1],w=m(e.useState(null),2),x=w[0],k=w[1],S=m(e.useState({}),2),E=S[0],N=S[1],A=m(e.useState(1),2),M=A[0],D=A[1],P=m(e.useState(10),2),B=P[0];P[1];var I=m(e.useState(0),2),j=I[0],_=I[1],z=m(e.useState(""),2),V=z[0],U=z[1],$=m(e.useState(!1),2),K=$[0],Y=$[1],G=m(e.useState(null),2),X=G[0],J=G[1],Q=m(e.useState({}),2),Z=Q[0],ee=Q[1],te=m(e.useState([]),2),ne=te[0],re=te[1],ie=e.useMemo(function(){return ne.length?JSON.stringify(ne):""},[ne]),oe=function(e){return!e.readOnly&&!1!==e.editable};e.useEffect(function(){n&&ae()},[null==n?void 0:n.table_name,M,B,V,ie]);var se=function(){var e=h(f().m(function e(t){var n,r,i,o,s;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if("relation"===t.type&&t.relation){e.n=1;break}return e.a(2);case 1:if(n=t.relation,r=n.target,i=n.displayField,o="".concat(r,"_").concat(i||"name"),!Z[o]){e.n=2;break}return e.a(2);case 2:return e.p=2,e.n=3,vh(r,{displayField:i||"name",limit:200});case 3:(s=e.v).success&&s.data&&ee(function(e){return Object.assign(Object.assign({},e),d({},o,s.data))}),e.n=5;break;case 4:e.p=4,e.v;case 5:return e.a(2)}},e,null,[[2,4]])}));return function(t){return e.apply(this,arguments)}}();e.useEffect(function(){p&&n&&n.json_schema.fields.filter(function(e){return"relation"===e.type&&e.relation}).forEach(function(e){return se(e)})},[p,n]);var ae=function(){var e=h(f().m(function e(){var t,r,i,o;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n){e.n=1;break}return e.a(2);case 1:return c(!0),e.p=2,i={page:M,limit:B},V&&(i.search=V),ne.length>0&&(i.filters=ne),e.n=3,gh(n.table_name,i);case 3:if((o=e.v).success){e.n=4;break}return Fa.error(o.message||"加载数据失败"),s([]),_(0),e.a(2);case 4:s((null===(t=o.data)||void 0===t?void 0:t.data)||[]),_((null===(r=o.data)||void 0===r?void 0:r.total)||0),e.n=6;break;case 5:e.p=5,e.v,Fa.error("加载数据失败"),s([]),_(0);case 6:return e.p=6,c(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}(),le=function(){var e=h(f().m(function e(t){var r;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("确定要删除这条数据吗?此操作不可撤销。")){e.n=1;break}return e.a(2);case 1:return J(t.id),e.p=2,e.n=3,wh(null==n?void 0:n.table_name,t.id);case 3:(r=e.v).success?(Fa.success("删除成功"),ae()):Fa.error(r.message||"删除失败"),e.n=5;break;case 4:e.p=4,e.v,Fa.error("删除失败");case 5:return e.p=5,J(null),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),ce=function(){var e=h(f().m(function e(){var t,r,i,o,s,a;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n){e.n=1;break}return e.a(2);case 1:if(Y(!0),e.p=2,t={},n.json_schema.fields.forEach(function(e){if("id"!==e.name&&oe(e))if("relation"===e.type&&e.relation){var n=e.relation.foreignKey||"".concat(e.relation.target,"_id");t[n]=E[n]}else{var r=E[e.name];if("date"!==e.type&&"datetime"!==e.type||(r=r?new Date(r).toISOString():null),"json"===e.type||"jsonb"===e.type){var i=(r||"").toString().trim();if(i){var o=If(i);if(!o.ok)throw new Error("字段 ".concat(e.comment||e.name,":").concat(o.message));r=o.value}else r=null}t[e.name]=r}}),!x){e.n=4;break}return r=Object.assign(Object.assign({},t),{id:x.id}),e.n=3,yh(n.table_name,r);case 3:(i=e.v).success?(Fa.success("更新成功"),g(!1),ae()):Fa.error(i.message||"更新失败"),e.n=6;break;case 4:return e.n=5,bh(n.table_name,t);case 5:(o=e.v).success?(Fa.success("创建成功"),g(!1),ae()):Fa.error(o.message||"创建失败");case 6:e.n=8;break;case 7:e.p=7,a=e.v,s=a instanceof Error?a.message:"操作失败",Fa.error(s);case 8:return e.p=8,Y(!1),e.f(8);case 9:return e.a(2)}},e,null,[[2,7,8,9]])}));return function(){return e.apply(this,arguments)}}(),he=function(t,n,r){if("string"==typeof n){var o=n.trim();if(o&&function(e){var t,n=e.trim();if(!n)return!1;if(n.startsWith("data:image/"))return!0;if(!IT(n))return!1;var r=(null===(t=n.split("#")[0])||void 0===t?void 0:t.split("?")[0])||n;return/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(r)}(o))return e.createElement(jT,{url:o});if(o&&IT(o))return e.createElement("a",{href:o,target:"_blank",rel:"noreferrer",className:"max-w-[360px] truncate text-primary underline-offset-2 hover:underline block",title:o},o)}if("boolean"===t.type)return e.createElement(RT,{variant:n?"default":"secondary"},n?"是":"否");if("date"===t.type||"datetime"===t.type)return n?i(n).format("YYYY-MM-DD HH:mm:ss"):"-";if("text"===t.type&&n&&n.length>50)return e.createElement("span",{className:"max-w-xs truncate block",title:n},n.substring(0,50),"...");if("json"===t.type||"jsonb"===t.type)return e.createElement(wT,{value:n,title:t.comment||t.name});if("relation"===t.type&&t.relation&&r){var s=t.relation.displayField,a=void 0===s?"name":s,l=r["".concat(t.name,"_data")];if(l)return e.createElement(RT,{variant:"outline"},l[a]||"ID: ".concat(l.id));var c=r[t.relation.foreignKey||"".concat(t.relation.target,"_id")];return c?"ID: ".concat(c):"-"}return n||"-"};return n?e.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},e.createElement("div",{className:"container mx-auto px-6 py-4 space-y-4"},e.createElement("div",{className:"space-y-1"},e.createElement("div",{className:"flex items-center gap-3"},e.createElement("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-lg bg-primary/10 text-primary"},e.createElement(T,{className:"h-4 w-4"})),e.createElement("div",null,e.createElement("h1",{className:"text-2xl font-bold tracking-tight leading-tight"},n.name),e.createElement("p",{className:"text-sm text-muted-foreground"},"表名: ",n.table_name)))),e.createElement(wa,{className:"border-2 shadow-lg"},e.createElement(xa,{className:"bg-muted/30"},e.createElement("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4"},e.createElement("div",null,e.createElement(ka,null,"数据管理"),e.createElement(Sa,null,"查看和管理 ",n.name," 的数据")),e.createElement(at,{onClick:function(){k(null),N({}),g(!0)},className:"w-full md:w-auto"},e.createElement(F,{className:"h-4 w-4 mr-2"}),"新建数据"))),e.createElement(Ea,{className:"space-y-4 pt-4"},e.createElement("div",{className:"flex flex-col md:flex-row md:items-center gap-3"},e.createElement("div",{className:"flex-1"},e.createElement(ya,{htmlFor:"search",className:"sr-only"},"搜索"),e.createElement("div",{className:"relative"},e.createElement(W,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.createElement(lt,{id:"search",placeholder:"搜索数据...",value:V,onChange:function(e){return U(e.target.value)},className:"pl-10 h-10"}))),e.createElement(at,{type:"button",variant:"outline",className:"h-10",onClick:function(){return y(!0)}},e.createElement(R,{className:"h-4 w-4 mr-2"}),"筛选",ne.length>0?"(".concat(ne.length,")"):"")),e.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},e.createElement("div",{className:"text-sm text-muted-foreground"},"共 ",e.createElement("span",{className:"font-semibold text-foreground"},j)," 条数据"),e.createElement(RT,{variant:"outline"},n.name)),e.createElement("div",{className:"rounded-lg border overflow-hidden"},e.createElement(kT,null,e.createElement(ST,null,e.createElement(OT,{className:"bg-muted/50"},e.createElement(NT,{className:"font-semibold w-20"},"ID"),n.json_schema.fields.map(function(t){return e.createElement(NT,{key:t.name,className:"font-semibold"},t.comment||t.name)}),e.createElement(NT,{className:"font-semibold"},"创建时间"),e.createElement(NT,{className:"font-semibold"},"更新时间"),e.createElement(NT,{className:qe("font-semibold w-32 text-center sticky right-0 z-20 bg-muted/50 border-l","shadow-[-8px_0_12px_-10px_rgba(0,0,0,0.25)]")},"操作"))),e.createElement(ET,null,l?Array.from({length:3}).map(function(t,r){return e.createElement(OT,{key:r},e.createElement(AT,{colSpan:n.json_schema.fields.length+4},e.createElement("div",{className:"flex items-center gap-2 py-4"},e.createElement(L,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.createElement("span",{className:"text-sm text-muted-foreground"},"加载中..."))))}):0===o.length?e.createElement(OT,null,e.createElement(AT,{colSpan:n.json_schema.fields.length+4,className:"text-center py-12"},e.createElement("div",{className:"flex flex-col items-center gap-2 text-muted-foreground"},e.createElement(W,{className:"h-8 w-8"}),e.createElement("p",null,"暂无数据")))):o.map(function(t,r){return e.createElement(OT,{key:t.id,className:r%2==0?"bg-muted/20":""},e.createElement(AT,{className:"font-mono font-medium"},t.id),n.json_schema.fields.map(function(n){return e.createElement(AT,{key:n.name},he(n,t[n.name],t))}),e.createElement(AT,{className:"text-sm text-muted-foreground"},i(t.created_at).format("YYYY-MM-DD HH:mm")),e.createElement(AT,{className:"text-sm text-muted-foreground"},i(t.updated_at).format("YYYY-MM-DD HH:mm")),e.createElement(AT,{className:qe("sticky right-0 z-10 border-l","shadow-[-8px_0_12px_-10px_rgba(0,0,0,0.18)]",r%2==0?"bg-muted/20":"bg-background")},e.createElement("div",{className:"flex items-center justify-center gap-2"},e.createElement(at,{variant:"ghost",size:"sm",onClick:function(){return function(e){k(e);var t={};null==n||n.json_schema.fields.forEach(function(n){if("id"!==n.name)if("relation"===n.type&&n.relation){var r=n.relation.foreignKey||"".concat(n.relation.target,"_id");t[r]=e[r]}else{var o=e[n.name];"date"!==n.type&&"datetime"!==n.type||(o=o?i(o).format("YYYY-MM-DDTHH:mm"):""),"json"!==n.type&&"jsonb"!==n.type||(o=null==o||""===o?"":"string"==typeof o?o:JSON.stringify(o,null,2)),t[n.name]=o}}),N(t),g(!0)}(t)},className:"h-8 w-8 p-0"},e.createElement(H,{className:"h-4 w-4"})),e.createElement(at,{variant:"ghost",size:"sm",onClick:function(){return le(t)},disabled:X===t.id,className:"h-8 w-8 p-0 text-destructive hover:text-destructive"},X===t.id?e.createElement(L,{className:"h-4 w-4 animate-spin"}):e.createElement(q,{className:"h-4 w-4"})))))})))),j>B&&e.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},e.createElement("div",{className:"text-sm text-muted-foreground"},"第 ",e.createElement("span",{className:"font-semibold text-foreground"},M)," 页, 共 ",e.createElement("span",{className:"font-semibold text-foreground"},Math.ceil(j/B))," 页"),e.createElement("div",{className:"flex gap-2"},e.createElement(at,{variant:"outline",size:"sm",onClick:function(){return D(Math.max(1,M-1))},disabled:1===M||l},e.createElement(C,{className:"h-4 w-4 mr-1"}),"上一页"),e.createElement(at,{variant:"outline",size:"sm",onClick:function(){return D(Math.min(Math.ceil(j/B),M+1))},disabled:M>=Math.ceil(j/B)||l},"下一页",e.createElement(O,{className:"h-4 w-4 ml-1"})))))),e.createElement(cf,{open:b,onOpenChange:y},e.createElement(ff,{className:"max-w-3xl"},e.createElement(pf,null,e.createElement(gf,{className:"text-xl"},"筛选"),e.createElement(bf,{className:"text-sm"},n.name," - ",n.table_name)),e.createElement("div",{className:"py-2"},e.createElement(LT,{fields:n.json_schema.fields,value:ne,onChange:function(e){re(e),D(1)}})),e.createElement(mf,{className:"gap-2"},e.createElement(at,{variant:"outline",onClick:function(){return y(!1)}},"关闭")))),e.createElement(cf,{open:p,onOpenChange:g},e.createElement(ff,{className:"max-w-3xl max-h-[85vh] overflow-y-auto"},e.createElement(pf,null,e.createElement(gf,{className:"text-2xl"},x?"编辑数据":"新建数据"),e.createElement(bf,{className:"text-base"},n.name," - ",n.table_name)),e.createElement("div",{className:"space-y-4 py-4"},n.json_schema.fields.map(function(t){return function(t){if("id"===t.name)return null;var n=oe(t);switch(t.type){case"boolean":return e.createElement("div",{key:t.name,className:"flex items-center space-x-3 p-4 rounded-lg border bg-card"},e.createElement(af,{id:t.name,checked:E[t.name]||!1,disabled:!n,onCheckedChange:function(e){return N(Object.assign(Object.assign({},E),d({},t.name,e)))}}),e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium cursor-pointer"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")));case"date":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lt,{id:t.name,type:"date",value:E[t.name]||"",disabled:!n,onChange:function(e){return N(Object.assign(Object.assign({},E),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"datetime":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lt,{id:t.name,type:"datetime-local",value:E[t.name]||"",disabled:!n,onChange:function(e){return N(Object.assign(Object.assign({},E),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"text":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lf,{id:t.name,rows:4,value:E[t.name]||"",disabled:!n,onChange:function(e){return N(Object.assign(Object.assign({},E),d({},t.name,e.target.value)))},required:t.required,className:"resize-none"}));case"json":case"jsonb":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(xT,{id:t.name,value:E[t.name]||"",required:t.required,disabled:!n,onChange:function(e){return N(Object.assign(Object.assign({},E),d({},t.name,e)))}}));case"integer":case"float":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lt,{id:t.name,type:"number",value:E[t.name]||"",disabled:!n,onChange:function(e){return N(Object.assign(Object.assign({},E),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"relation":if(!t.relation)return null;var r=t.relation,i=r.target,o=r.displayField,s=void 0===o?"name":o,a="".concat(i,"_").concat(s),l=Z[a]||[],c=t.relation.foreignKey||"".concat(i,"_id"),h=void 0!==E[c]&&null!==E[c]?String(E[c]):"",u=l.find(function(e){return String(e.id)===h});return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(Bd,{value:h,disabled:!n,onValueChange:function(e){var t=parseInt(e,10),n=!isNaN(t)&&String(t)===e;N(Object.assign(Object.assign({},E),d({},c,n?t:e)))}},e.createElement(jd,{className:"h-11"},e.createElement(Id,{placeholder:"请选择".concat(t.comment||t.name)},u?u.label:h?"ID: ".concat(h):"请选择".concat(t.comment||t.name))),e.createElement(Wd,null,0===l.length?e.createElement(Hd,{value:"_loading",disabled:!0},"加载中..."):l.map(function(t){return e.createElement(Hd,{key:t.id,value:String(t.id)},t.label)}))));default:return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lt,{id:t.name,type:"email"===t.type?"email":"text",maxLength:t.maxLength,value:E[t.name]||"",disabled:!n,onChange:function(e){return N(Object.assign(Object.assign({},E),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}))}}(t)})),e.createElement(mf,{className:"gap-2"},e.createElement(at,{variant:"outline",onClick:function(){return g(!1)},disabled:K},"取消"),e.createElement(at,{onClick:ce,disabled:K},K?e.createElement(e.Fragment,null,e.createElement(L,{className:"h-4 w-4 mr-2 animate-spin"}),x?"更新中...":"创建中..."):x?"更新":"创建")))))):e.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},e.createElement("div",{className:"container mx-auto px-6 py-4"},e.createElement(wa,{className:"border-2"},e.createElement(Ea,{className:"py-16 text-center"},e.createElement(T,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),e.createElement("p",{className:"text-lg text-muted-foreground"},"请选择数据模型")))))}function FT(t){var n=t.model;return e.createElement(_T,{key:n.id,model:n})}function WT(t){return t.models.map(function(t){return{path:"/data/list-".concat(t.id),name:t.name,icon:e.createElement(V),component:function(){return e.createElement(FT,{model:t})}}})}var zT=function(t){return[{path:"/login",name:"登录",icon:e.createElement(I),component:xh},{name:"数据管理",icon:e.createElement(A),path:"/data",component:BT,routes:g(WT(t))}]},HT=z,VT=U,qT=j;function UT(t){var n=t.inputModels,r=t.skipAuth,i=void 0!==r&&r,o=m(e.useState("/data"),2),s=o[0],a=o[1],l=m(e.useState([]),2);l[0],l[1];var c=m(e.useState(!1),2),d=c[0],p=c[1],g=m(e.useState(null),2),v=g[0],b=g[1],y=m(e.useState(!0),2),w=y[0],x=y[1],k=e.useMemo(function(){return zT({models:n.models})},[n.models]);e.useEffect(function(){if(i)return p(!0),b(null),x(!1),void("/login"===s&&a("/data"));var e=function(){var e=h(f().m(function e(){var t,n;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,ph()){e.n=1;break}return p(!1),a("/login"),x(!1),e.a(2);case 1:return e.p=1,e.n=2,uh();case 2:if(e.v.success){e.n=3;break}throw new Error("token验证失败");case 3:if(!(t=mh())){e.n=4;break}b(t),e.n=6;break;case 4:return e.n=5,dh();case 5:(n=e.v).success&&n.data&&(b(n.data),localStorage.setItem("cms_user",JSON.stringify(n.data)));case 6:p(!0),"/login"===s&&a("/data"),e.n=8;break;case 7:e.p=7,e.v,fh(),p(!1),b(null),a("/login");case 8:e.n=10;break;case 9:e.p=9,e.v,p(!1),b(null),a("/login");case 10:return e.p=10,x(!1),e.f(10);case 11:return e.a(2)}},e,null,[[1,7],[0,9,10,11]])}));return function(){return e.apply(this,arguments)}}();e()},[i]);var S=function(e,t){b(t),p(!0),a("/data"),Fa.success("欢迎回来,".concat(t.username,"!"))},E=function(e,t){var n,r=u(e);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(i.path===t)return i;if(i.routes){var o=E(i.routes,t);if(o)return o}}}catch(e){r.e(e)}finally{r.f()}return null};if(w)return e.createElement("div",{className:"flex min-h-screen items-center justify-center bg-background"},e.createElement("div",{className:"space-y-4"},e.createElement(Ue,{className:"h-12 w-48"}),e.createElement(Ue,{className:"h-4 w-64"})));if(!d)return e.createElement(xh,{onLoginSuccess:S});var C=k.filter(function(e){return"/login"!==e.path}),O=function(t){if(!t)return T;if(e.isValidElement(t)){var n=t.type;if(n&&"function"==typeof n){var r=n.name||"";if(r.includes("Home"))return D;if(r.includes("Table"))return V;if(r.includes("Database"))return T;if(r.includes("File"))return M}}return T},N=C.flatMap(function(e){return e.routes&&e.routes.length>0?e.routes.map(function(e){return{title:e.name,icon:O(e.icon),path:e.path}}):[{title:e.name,icon:O(e.icon),path:e.path}]});return e.createElement(ta,null,e.createElement(na,{variant:"inset"},e.createElement(oa,{className:"border-b border-sidebar-border"},e.createElement("div",{className:"flex items-center gap-2 px-2 py-1"},e.createElement("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-primary"},e.createElement(HT,{className:"w-4 h-4 text-primary-foreground"})),e.createElement("span",{className:"font-semibold text-lg"},"WE0-CMS"))),e.createElement(aa,null,e.createElement(la,null,e.createElement(ca,null,"Navigation"),e.createElement(ha,null,e.createElement(ua,null,N.map(function(t){return e.createElement(da,{key:t.path},e.createElement(pa,{onClick:function(){return a(t.path)},isActive:(n=t.path,s===n||s.startsWith(n+"/")),tooltip:t.title},e.createElement(t.icon,{className:"w-4 h-4"}),e.createElement("span",null,t.title)));var n}))))),e.createElement(sa,{className:"border-t border-sidebar-border"},e.createElement(ua,null,!i&&v&&e.createElement(e.Fragment,null,e.createElement(da,null,e.createElement(pa,{tooltip:v.username||"User"},e.createElement(VT,{className:"w-4 h-4"}),e.createElement("span",{className:"truncate"},v.username))),e.createElement(da,null,e.createElement(pa,{onClick:function(){window.confirm("确定要登出系统吗?")&&(fh(),localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user"),p(!1),b(null),a("/login"),Fa.success("已成功登出"))},tooltip:"Logout"},e.createElement(qT,{className:"w-4 h-4"}),e.createElement("span",null,"Logout"))))))),e.createElement(ia,null,e.createElement("header",{className:"flex h-14 items-center gap-4 border-b bg-background px-6"},e.createElement(ra,null),e.createElement("h1",{className:"text-lg font-semibold"},function(){if("/login"===s)return"Login";var e=E(k,s);return(null==e?void 0:e.name)||"数据管理"}())),e.createElement("main",{className:"flex-1 p-6"},function(){if(!i&&"/login"===s)return e.createElement(xh,{onLoginSuccess:S});if(i&&"/login"===s)return e.createElement(BT,null);var t=E(k,s);if(t){var n=t.component;return e.createElement(n,null)}return e.createElement(BT,null)}())))}exports.CmsLayoutShadcn=UT,exports.cmsRoutes=zT,exports.default=UT,exports.setSessionId=function(e){th=e;try{localStorage.setItem("cms_session_id",e)}catch(e){}};
15
+ */const y=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),w=(t,n)=>{const r=e.forwardRef(({color:r="currentColor",size:i=24,strokeWidth:o=2,absoluteStrokeWidth:s,className:a="",children:l,...c},h)=>e.createElement("svg",{ref:h,...b,width:i,height:i,stroke:r,strokeWidth:s?24*Number(o)/Number(i):o,className:["lucide",`lucide-${y(t)}`,a].join(" "),...c},[...n.map(([t,n])=>e.createElement(t,n)),...Array.isArray(l)?l:[l]]));return r.displayName=`${t}`,r},x=w("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),k=w("CheckCircle2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),S=w("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),E=w("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),C=w("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),O=w("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),N=w("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),A=w("Crown",[["path",{d:"m2 4 3 12h14l3-12-6 7-4-7-4 7-6-7zm3 16h14",key:"zkxr6b"}]]),T=w("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),M=w("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),R=w("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]),D=w("Home",[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]]),P=w("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),L=w("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),B=w("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]),I=w("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]),j=w("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]),_=w("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),F=w("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),W=w("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),z=w("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),H=w("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a2.121 2.121 0 1 1 3 3L12 15l-4 1 1-4Z",key:"1lpok0"}]]),V=w("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]),q=w("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),U=w("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),$=w("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),K=w("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);var Y=function(){return Y=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Y.apply(this,arguments)};function G(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function X(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=X(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function J(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=X(e))&&(r&&(r+=" "),r+=t);return r}"function"==typeof SuppressedError&&SuppressedError;const Q=e=>{const t=ne(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{const n=e.split("-");return""===n[0]&&1!==n.length&&n.shift(),Z(n,t)||te(e)},getConflictingClassGroupIds:(e,t)=>{const i=n[e]||[];return t&&r[e]?[...i,...r[e]]:i}}},Z=(e,t)=>{if(0===e.length)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?Z(e.slice(1),r):void 0;if(i)return i;if(0===t.validators.length)return;const o=e.join("-");return t.validators.find(({validator:e})=>e(o))?.classGroupId},ee=/^\[(.+)\]$/,te=e=>{if(ee.test(e)){const t=ee.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},ne=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return se(Object.entries(e.classGroups),n).forEach(([e,n])=>{re(n,r,e,t)}),r},re=(e,t,n,r)=>{e.forEach(e=>{if("string"==typeof e){return void((""===e?t:ie(t,e)).classGroupId=n)}if("function"==typeof e)return oe(e)?void re(e(r),t,n,r):void t.validators.push({validator:e,classGroupId:n});Object.entries(e).forEach(([e,i])=>{re(i,ie(t,e),n,r)})})},ie=(e,t)=>{let n=e;return t.split("-").forEach(e=>{n.nextPart.has(e)||n.nextPart.set(e,{nextPart:new Map,validators:[]}),n=n.nextPart.get(e)}),n},oe=e=>e.isThemeGetter,se=(e,t)=>t?e.map(([e,n])=>[e,n.map(e=>"string"==typeof e?t+e:"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,n])=>[t+e,n])):e)]):e,ae=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const i=(i,o)=>{n.set(i,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(e){let t=n.get(e);return void 0!==t?t:void 0!==(t=r.get(e))?(i(e,t),t):void 0},set(e,t){n.has(e)?n.set(e,t):i(e,t)}}},le=e=>{const{separator:t,experimentalParseClassName:n}=e,r=1===t.length,i=t[0],o=t.length,s=e=>{const n=[];let s,a=0,l=0;for(let c=0;c<e.length;c++){let h=e[c];if(0===a){if(h===i&&(r||e.slice(c,c+o)===t)){n.push(e.slice(l,c)),l=c+o;continue}if("/"===h){s=c;continue}}"["===h?a++:"]"===h&&a--}const c=0===n.length?e:e.substring(l),h=c.startsWith("!");return{modifiers:n,hasImportantModifier:h,baseClassName:h?c.substring(1):c,maybePostfixModifierPosition:s&&s>l?s-l:void 0}};return n?e=>n({className:e,parseClassName:s}):s},ce=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(e=>{"["===e[0]?(t.push(...n.sort(),e),n=[]):n.push(e)}),t.push(...n.sort()),t},he=/\s+/;function ue(){let e,t,n=0,r="";for(;n<arguments.length;)(e=arguments[n++])&&(t=de(e))&&(r&&(r+=" "),r+=t);return r}const de=e=>{if("string"==typeof e)return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=de(e[r]))&&(n&&(n+=" "),n+=t);return n};function fe(e,...t){let n,r,i,o=function(a){const l=t.reduce((e,t)=>t(e),e());return n=(e=>({cache:ae(e.cacheSize),parseClassName:le(e),...Q(e)}))(l),r=n.cache.get,i=n.cache.set,o=s,s(a)};function s(e){const t=r(e);if(t)return t;const o=((e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,o=[],s=e.trim().split(he);let a="";for(let e=s.length-1;e>=0;e-=1){const t=s[e],{modifiers:l,hasImportantModifier:c,baseClassName:h,maybePostfixModifierPosition:u}=n(t);let d=Boolean(u),f=r(d?h.substring(0,u):h);if(!f){if(!d){a=t+(a.length>0?" "+a:a);continue}if(f=r(h),!f){a=t+(a.length>0?" "+a:a);continue}d=!1}const p=ce(l).join(":"),m=c?p+"!":p,g=m+f;if(o.includes(g))continue;o.push(g);const v=i(f,d);for(let e=0;e<v.length;++e){const t=v[e];o.push(m+t)}a=t+(a.length>0?" "+a:a)}return a})(e,n);return i(e,o),o}return function(){return o(ue.apply(null,arguments))}}const pe=e=>{const t=t=>t[e]||[];return t.isThemeGetter=!0,t},me=/^\[(?:([a-z-]+):)?(.+)\]$/i,ge=/^\d+\/\d+$/,ve=new Set(["px","full","screen"]),be=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ye=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,we=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,xe=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ke=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Se=e=>Ce(e)||ve.has(e)||ge.test(e),Ee=e=>_e(e,"length",Fe),Ce=e=>Boolean(e)&&!Number.isNaN(Number(e)),Oe=e=>_e(e,"number",Ce),Ne=e=>Boolean(e)&&Number.isInteger(Number(e)),Ae=e=>e.endsWith("%")&&Ce(e.slice(0,-1)),Te=e=>me.test(e),Me=e=>be.test(e),Re=new Set(["length","size","percentage"]),De=e=>_e(e,Re,We),Pe=e=>_e(e,"position",We),Le=new Set(["image","url"]),Be=e=>_e(e,Le,He),Ie=e=>_e(e,"",ze),je=()=>!0,_e=(e,t,n)=>{const r=me.exec(e);return!!r&&(r[1]?"string"==typeof t?r[1]===t:t.has(r[1]):n(r[2]))},Fe=e=>ye.test(e)&&!we.test(e),We=()=>!1,ze=e=>xe.test(e),He=e=>ke.test(e),Ve=fe(()=>{const e=pe("colors"),t=pe("spacing"),n=pe("blur"),r=pe("brightness"),i=pe("borderColor"),o=pe("borderRadius"),s=pe("borderSpacing"),a=pe("borderWidth"),l=pe("contrast"),c=pe("grayscale"),h=pe("hueRotate"),u=pe("invert"),d=pe("gap"),f=pe("gradientColorStops"),p=pe("gradientColorStopPositions"),m=pe("inset"),g=pe("margin"),v=pe("opacity"),b=pe("padding"),y=pe("saturate"),w=pe("scale"),x=pe("sepia"),k=pe("skew"),S=pe("space"),E=pe("translate"),C=()=>["auto",Te,t],O=()=>[Te,t],N=()=>["",Se,Ee],A=()=>["auto",Ce,Te],T=()=>["","0",Te],M=()=>[Ce,Te];return{cacheSize:500,separator:":",theme:{colors:[je],spacing:[Se,Ee],blur:["none","",Me,Te],brightness:M(),borderColor:[e],borderRadius:["none","","full",Me,Te],borderSpacing:O(),borderWidth:N(),contrast:M(),grayscale:T(),hueRotate:M(),invert:T(),gap:O(),gradientColorStops:[e],gradientColorStopPositions:[Ae,Ee],inset:C(),margin:C(),opacity:M(),padding:O(),saturate:M(),scale:M(),sepia:T(),skew:M(),space:O(),translate:O()},classGroups:{aspect:[{aspect:["auto","square","video",Te]}],container:["container"],columns:[{columns:[Me]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",Te]}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[m]}],"inset-x":[{"inset-x":[m]}],"inset-y":[{"inset-y":[m]}],start:[{start:[m]}],end:[{end:[m]}],top:[{top:[m]}],right:[{right:[m]}],bottom:[{bottom:[m]}],left:[{left:[m]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Ne,Te]}],basis:[{basis:C()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Te]}],grow:[{grow:T()}],shrink:[{shrink:T()}],order:[{order:["first","last","none",Ne,Te]}],"grid-cols":[{"grid-cols":[je]}],"col-start-end":[{col:["auto",{span:["full",Ne,Te]},Te]}],"col-start":[{"col-start":A()}],"col-end":[{"col-end":A()}],"grid-rows":[{"grid-rows":[je]}],"row-start-end":[{row:["auto",{span:[Ne,Te]},Te]}],"row-start":[{"row-start":A()}],"row-end":[{"row-end":A()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Te]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Te]}],gap:[{gap:[d]}],"gap-x":[{"gap-x":[d]}],"gap-y":[{"gap-y":[d]}],"justify-content":[{justify:["normal","start","end","center","between","around","evenly","stretch"]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[b]}],px:[{px:[b]}],py:[{py:[b]}],ps:[{ps:[b]}],pe:[{pe:[b]}],pt:[{pt:[b]}],pr:[{pr:[b]}],pb:[{pb:[b]}],pl:[{pl:[b]}],m:[{m:[g]}],mx:[{mx:[g]}],my:[{my:[g]}],ms:[{ms:[g]}],me:[{me:[g]}],mt:[{mt:[g]}],mr:[{mr:[g]}],mb:[{mb:[g]}],ml:[{ml:[g]}],"space-x":[{"space-x":[S]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[S]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Te,t]}],"min-w":[{"min-w":[Te,t,"min","max","fit"]}],"max-w":[{"max-w":[Te,t,"none","full","min","max","fit","prose",{screen:[Me]},Me]}],h:[{h:[Te,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Te,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Te,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Te,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Me,Ee]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Oe]}],"font-family":[{font:[je]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Te]}],"line-clamp":[{"line-clamp":["none",Ce,Oe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Se,Te]}],"list-image":[{"list-image":["none",Te]}],"list-style-type":[{list:["none","disc","decimal",Te]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[v]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[v]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","none","wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Se,Ee]}],"underline-offset":[{"underline-offset":["auto",Se,Te]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:O()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Te]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Te]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[v]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",Pe]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",De]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Be]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[p]}],"gradient-via-pos":[{via:[p]}],"gradient-to-pos":[{to:[p]}],"gradient-from":[{from:[f]}],"gradient-via":[{via:[f]}],"gradient-to":[{to:[f]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[v]}],"border-style":[{border:["solid","dashed","dotted","double","none","hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[v]}],"divide-style":[{divide:["solid","dashed","dotted","double","none"]}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["","solid","dashed","dotted","double","none"]}],"outline-offset":[{"outline-offset":[Se,Te]}],"outline-w":[{outline:[Se,Ee]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:N()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[v]}],"ring-offset-w":[{"ring-offset":[Se,Ee]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Me,Ie]}],"shadow-color":[{shadow:[je]}],opacity:[{opacity:[v]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Me,Te]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[h]}],invert:[{invert:[u]}],saturate:[{saturate:[y]}],sepia:[{sepia:[x]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[h]}],"backdrop-invert":[{"backdrop-invert":[u]}],"backdrop-opacity":[{"backdrop-opacity":[v]}],"backdrop-saturate":[{"backdrop-saturate":[y]}],"backdrop-sepia":[{"backdrop-sepia":[x]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Te]}],duration:[{duration:M()}],ease:[{ease:["linear","in","out","in-out",Te]}],delay:[{delay:M()}],animate:[{animate:["none","spin","ping","pulse","bounce",Te]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[w]}],"scale-x":[{"scale-x":[w]}],"scale-y":[{"scale-y":[w]}],rotate:[{rotate:[Ne,Te]}],"translate-x":[{"translate-x":[E]}],"translate-y":[{"translate-y":[E]}],"skew-x":[{"skew-x":[k]}],"skew-y":[{"skew-y":[k]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Te]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Te]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Te]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Se,Ee,Oe]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}});function qe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Ve(J(t))}function Ue(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("animate-pulse rounded-md bg-muted",t)},n))}function $e(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Ke(...e){return t=>{let n=!1;const r=e.map(e=>{const r=$e(e,t);return n||"function"!=typeof r||(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){const n=r[t];"function"==typeof n?n():$e(e[t],null)}}}}function Ye(...e){return s.useCallback(Ke(...e),e)}var Ge=Symbol.for("react.lazy"),Xe=s[" use ".trim().toString()];function Je(e){return null!=e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===Ge&&"_payload"in e&&("object"==typeof(t=e._payload)&&null!==t&&"then"in t);var t}function Qe(e){const n=et(e),r=s.forwardRef((e,r)=>{let{children:i,...o}=e;Je(i)&&"function"==typeof Xe&&(i=Xe(i._payload));const a=s.Children.toArray(i),l=a.find(nt);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}var Ze=Qe("Slot");function et(e){const t=s.forwardRef((e,t)=>{let{children:n,...r}=e;if(Je(n)&&"function"==typeof Xe&&(n=Xe(n._payload)),s.isValidElement(n)){const e=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?Ke(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var tt=Symbol("radix.slottable");function nt(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===tt}const rt=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,it=J,ot=(e,t)=>n=>{var r;if(null==(null==t?void 0:t.variants))return it(e,null==n?void 0:n.class,null==n?void 0:n.className);const{variants:i,defaultVariants:o}=t,s=Object.keys(i).map(e=>{const t=null==n?void 0:n[e],r=null==o?void 0:o[e];if(null===t)return null;const s=rt(t)||rt(r);return i[e][s]}),a=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return void 0===r||(e[n]=r),e},{}),l=null==t||null===(r=t.compoundVariants)||void 0===r?void 0:r.reduce((e,t)=>{let{class:n,className:r,...i}=t;return Object.entries(i).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...o,...a}[t]):{...o,...a}[t]===n})?[...e,n,r]:e},[]);return it(e,s,l,null==n?void 0:n.class,null==n?void 0:n.className)};var st=ot("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),at=s.forwardRef(function(e,t){var n=e.className,r=e.variant,i=e.size,o=e.asChild,a=void 0!==o&&o,l=G(e,["className","variant","size","asChild"]),c=a?Ze:"button";return s.createElement(c,Object.assign({className:qe(st({variant:r,size:i,className:n})),ref:t},l))});at.displayName="Button";var lt=s.forwardRef(function(e,t){var n=e.className,r=e.type,i=G(e,["className","type"]);return s.createElement("input",Object.assign({type:r,className:qe("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:t},i))});lt.displayName="Input";var ct=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=Qe(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),ht="horizontal",ut=["horizontal","vertical"],dt=s.forwardRef((e,n)=>{const{decorative:r,orientation:i=ht,...o}=e,s=function(e){return ut.includes(e)}(i)?i:ht,a=r?{role:"none"}:{"aria-orientation":"vertical"===s?s:void 0,role:"separator"};return t.jsx(ct.div,{"data-orientation":s,...a,...o,ref:n})});dt.displayName="Separator";var ft=dt,pt=s.forwardRef(function(e,t){var n=e.className,r=e.orientation,i=void 0===r?"horizontal":r,o=e.decorative,a=void 0===o||o,l=G(e,["className","orientation","decorative"]);return s.createElement(ft,Object.assign({ref:t,decorative:a,orientation:i,className:qe("shrink-0 bg-border","horizontal"===i?"h-[1px] w-full":"h-full w-[1px]",n)},l))});function mt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function gt(e,n=[]){let r=[];const i=()=>{const t=r.map(e=>s.createContext(e));return function(n){const r=n?.[e]||t;return s.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[function(n,i){const o=s.createContext(i),a=r.length;r=[...r,i];const l=n=>{const{scope:r,children:i,...l}=n,c=r?.[e]?.[a]||o,h=s.useMemo(()=>l,Object.values(l));return t.jsx(c.Provider,{value:h,children:i})};return l.displayName=n+"Provider",[l,function(t,r){const l=r?.[e]?.[a]||o,c=s.useContext(l);if(c)return c;if(void 0!==i)return i;throw new Error(`\`${t}\` must be used within \`${n}\``)}]},vt(i,...n)]}function vt(...e){const t=e[0];if(1===e.length)return t;const n=()=>{const n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){const r=n.reduce((t,{useScope:n,scopeName:r})=>({...t,...n(e)[`__scope${r}`]}),{});return s.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}pt.displayName=ft.displayName;var bt=globalThis?.document?s.useLayoutEffect:()=>{},yt=s[" useId ".trim().toString()]||(()=>{}),wt=0;function xt(e){const[t,n]=s.useState(yt());return bt(()=>{e||n(e=>e??String(wt++))},[e]),e||(t?`radix-${t}`:"")}var kt=s[" useInsertionEffect ".trim().toString()]||bt;function St({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,o,a]=function({defaultProp:e,onChange:t}){const[n,r]=s.useState(e),i=s.useRef(n),o=s.useRef(t);return kt(()=>{o.current=t},[t]),s.useEffect(()=>{i.current!==n&&(o.current?.(n),i.current=n)},[n,i]),[n,r,o]}({defaultProp:t,onChange:n}),l=void 0!==e,c=l?e:i;{const t=s.useRef(void 0!==e);s.useEffect(()=>{const e=t.current;if(e!==l){}t.current=l},[l,r])}const h=s.useCallback(t=>{if(l){const n=function(e){return"function"==typeof e}(t)?t(e):t;n!==e&&a.current?.(n)}else o(t)},[l,e,o,a]);return[c,h]}function Et(e){const n=Ct(e),r=s.forwardRef((e,r)=>{const{children:i,...o}=e,a=s.Children.toArray(i),l=a.find(Nt);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}function Ct(e){const t=s.forwardRef((e,t)=>{const{children:n,...r}=e;if(s.isValidElement(n)){const e=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?Ke(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ot=Symbol("radix.slottable");function Nt(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Ot}var At=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=Et(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function Tt(e){const t=s.useRef(e);return s.useEffect(()=>{t.current=e}),s.useMemo(()=>(...e)=>t.current?.(...e),[])}function Mt(e,t=globalThis?.document){const n=Tt(e);s.useEffect(()=>{const e=e=>{"Escape"===e.key&&n(e)};return t.addEventListener("keydown",e,{capture:!0}),()=>t.removeEventListener("keydown",e,{capture:!0})},[n,t])}var Rt,Dt="dismissableLayer.update",Pt="dismissableLayer.pointerDownOutside",Lt="dismissableLayer.focusOutside",Bt=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),It=s.forwardRef((e,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...h}=e,u=s.useContext(Bt),[d,f]=s.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=s.useState({}),g=Ye(n,e=>f(e)),v=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=d?v.indexOf(d):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(e,t=globalThis?.document){const n=Tt(e),r=s.useRef(!1),i=s.useRef(()=>{});return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){_t(Pt,n,o,{discrete:!0})};const o={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",i.current),i.current=r,t.addEventListener("click",i.current,{once:!0})):r()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",e),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,n=[...u.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),l?.(e),e.defaultPrevented||c?.())},p),E=function(e,t=globalThis?.document){const n=Tt(e),r=s.useRef(!1);return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){_t(Lt,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...u.branches].some(e=>e.contains(t))||(a?.(e),l?.(e),e.defaultPrevented||c?.())},p);return Mt(e=>{w===u.layers.size-1&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},p),s.useEffect(()=>{if(d)return r&&(0===u.layersWithOutsidePointerEventsDisabled.size&&(Rt=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),jt(),()=>{r&&1===u.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=Rt)}},[d,p,r,u]),s.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),jt())},[d,u]),s.useEffect(()=>{const e=()=>m({});return document.addEventListener(Dt,e),()=>document.removeEventListener(Dt,e)},[]),t.jsx(At.div,{...h,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...e.style},onFocusCapture:mt(e.onFocusCapture,E.onFocusCapture),onBlurCapture:mt(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:mt(e.onPointerDownCapture,S.onPointerDownCapture)})});It.displayName="DismissableLayer";function jt(){const e=new CustomEvent(Dt);document.dispatchEvent(e)}function _t(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?function(e,t){e&&a.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}s.forwardRef((e,n)=>{const r=s.useContext(Bt),i=s.useRef(null),o=Ye(n,i);return s.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),t.jsx(At.div,{...e,ref:o})}).displayName="DismissableLayerBranch";var Ft="focusScope.autoFocusOnMount",Wt="focusScope.autoFocusOnUnmount",zt={bubbles:!1,cancelable:!0},Ht=s.forwardRef((e,n)=>{const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...l}=e,[c,h]=s.useState(null),u=Tt(o),d=Tt(a),f=s.useRef(null),p=Ye(n,e=>h(e)),m=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(i){let e=function(e){if(m.paused||!c)return;const t=e.target;c.contains(t)?f.current=t:$t(f.current,{select:!0})},t=function(e){if(m.paused||!c)return;const t=e.relatedTarget;null!==t&&(c.contains(t)||$t(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&$t(c)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[i,c,m.paused]),s.useEffect(()=>{if(c){Kt.add(m);const t=document.activeElement;if(!c.contains(t)){const n=new CustomEvent(Ft,zt);c.addEventListener(Ft,u),c.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if($t(r,{select:t}),document.activeElement!==n)return}((e=Vt(c),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&$t(c))}return()=>{c.removeEventListener(Ft,u),setTimeout(()=>{const e=new CustomEvent(Wt,zt);c.addEventListener(Wt,d),c.dispatchEvent(e),e.defaultPrevented||$t(t??document.body,{select:!0}),c.removeEventListener(Wt,d),Kt.remove(m)},0)}}var e},[c,u,d,m]);const g=s.useCallback(e=>{if(!r&&!i)return;if(m.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){const t=e.currentTarget,[i,o]=function(e){const t=Vt(e),n=qt(t,e),r=qt(t.reverse(),e);return[n,r]}(t);i&&o?e.shiftKey||n!==o?e.shiftKey&&n===i&&(e.preventDefault(),r&&$t(o,{select:!0})):(e.preventDefault(),r&&$t(i,{select:!0})):n===t&&e.preventDefault()}},[r,i,m.paused]);return t.jsx(At.div,{tabIndex:-1,...l,ref:p,onKeyDown:g})});function Vt(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function qt(e,t){for(const n of e)if(!Ut(n,{upTo:t}))return n}function Ut(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function $t(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}Ht.displayName="FocusScope";var Kt=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Yt(e,t),e.unshift(t)},remove(t){e=Yt(e,t),e[0]?.resume()}}}();function Yt(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var Gt=s.forwardRef((e,r)=>{const{container:i,...o}=e,[a,l]=s.useState(!1);bt(()=>l(!0),[]);const c=i||a&&globalThis?.document?.body;return c?n.createPortal(t.jsx(At.div,{...o,ref:r}),c):null});Gt.displayName="Portal";var Xt=e=>{const{present:t,children:n}=e,r=function(e){const[t,n]=s.useState(),r=s.useRef(null),i=s.useRef(e),o=s.useRef("none"),a=e?"mounted":"unmounted",[l,c]=function(e,t){return s.useReducer((e,n)=>t[e][n]??e,e)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.useEffect(()=>{const e=Jt(r.current);o.current="mounted"===l?e:"none"},[l]),bt(()=>{const t=r.current,n=i.current;if(n!==e){const r=o.current,s=Jt(t);if(e)c("MOUNT");else if("none"===s||"none"===t?.display)c("UNMOUNT");else{c(n&&r!==s?"ANIMATION_OUT":"UNMOUNT")}i.current=e}},[e,c]),bt(()=>{if(t){let e;const n=t.ownerDocument.defaultView??window,s=o=>{const s=Jt(r.current).includes(CSS.escape(o.animationName));if(o.target===t&&s&&(c("ANIMATION_END"),!i.current)){const r=t.style.animationFillMode;t.style.animationFillMode="forwards",e=n.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=r)})}},a=e=>{e.target===t&&(o.current=Jt(r.current))};return t.addEventListener("animationstart",a),t.addEventListener("animationcancel",s),t.addEventListener("animationend",s),()=>{n.clearTimeout(e),t.removeEventListener("animationstart",a),t.removeEventListener("animationcancel",s),t.removeEventListener("animationend",s)}}c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:s.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}(t),i="function"==typeof n?n({present:r.isPresent}):s.Children.only(n),o=Ye(r.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof n||r.isPresent?s.cloneElement(i,{ref:o}):null};function Jt(e){return e?.animationName||"none"}Xt.displayName="Presence";var Qt=0;function Zt(){s.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??en()),document.body.insertAdjacentElement("beforeend",e[1]??en()),Qt++,()=>{1===Qt&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Qt--}},[])}function en(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var tn="right-scroll-bar-position",nn="width-before-scroll-bar";function rn(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var on="undefined"!=typeof window?s.useLayoutEffect:s.useEffect,sn=new WeakMap;function an(t,n){var r,i,o,s=(r=n||null,i=function(e){return t.forEach(function(t){return rn(t,e)})},(o=e.useState(function(){return{value:r,callback:i,facade:{get current(){return o.value},set current(e){var t=o.value;t!==e&&(o.value=e,o.callback(e,t))}}}})[0]).callback=i,o.facade);return on(function(){var e=sn.get(s);if(e){var n=new Set(e),r=new Set(t),i=s.current;n.forEach(function(e){r.has(e)||rn(e,null)}),r.forEach(function(e){n.has(e)||rn(e,i)})}sn.set(s,t)},[t]),s}function ln(e){return e}var cn=function(e){var t=e.sideCar,n=G(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return s.createElement(r,Y({},n))};cn.isSideCarExport=!0;var hn=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=ln);var n=[],r=!1;return{read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var o=function(){var n=t;t=[],n.forEach(e)},s=function(){return Promise.resolve().then(o)};s(),n={push:function(e){t.push(e),s()},filter:function(e){return t=t.filter(e),n}}}}}(null);return t.options=Y({async:!0,ssr:!1},e),t}(),un=function(){},dn=s.forwardRef(function(e,t){var n=s.useRef(null),r=s.useState({onScrollCapture:un,onWheelCapture:un,onTouchMoveCapture:un}),i=r[0],o=r[1],a=e.forwardProps,l=e.children,c=e.className,h=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,g=e.inert,v=e.allowPinchZoom,b=e.as,y=void 0===b?"div":b,w=e.gapMode,x=G(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=f,S=an([n,t]),E=Y(Y({},x),i);return s.createElement(s.Fragment,null,u&&s.createElement(k,{sideCar:hn,removeScrollBar:h,shards:d,noRelative:p,noIsolation:m,inert:g,setCallbacks:o,allowPinchZoom:!!v,lockRef:n,gapMode:w}),a?s.cloneElement(s.Children.only(l),Y(Y({},E),{ref:S})):s.createElement(y,Y({},E,{className:c,ref:S}),l))});dn.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},dn.classNames={fullWidth:nn,zeroRight:tn};function fn(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=function(){if("undefined"!=typeof __webpack_nonce__)return __webpack_nonce__}();return t&&e.setAttribute("nonce",t),e}var pn=function(){var e=0,t=null;return{add:function(n){var r,i;0==e&&(t=fn())&&(i=n,(r=t).styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},mn=function(){var e,t=(e=pn(),function(t,n){s.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])});return function(e){var n=e.styles,r=e.dynamic;return t(n,r),null}},gn={left:0,top:0,right:0,gap:0},vn=function(e){return parseInt(e||"",10)||0},bn=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return gn;var t=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],r=t["padding"===e?"paddingTop":"marginTop"],i=t["padding"===e?"paddingRight":"marginRight"];return[vn(n),vn(r),vn(i)]}(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},yn=mn(),wn="data-scroll-locked",xn=function(e,t,n,r){var i=e.left,o=e.top,s=e.right,a=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(r,";\n padding-right: ").concat(a,"px ").concat(r,";\n }\n body[").concat(wn,"] {\n overflow: hidden ").concat(r,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(r,";"),"margin"===n&&"\n padding-left: ".concat(i,"px;\n padding-top: ").concat(o,"px;\n padding-right: ").concat(s,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(a,"px ").concat(r,";\n "),"padding"===n&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),"\n }\n \n .").concat(tn," {\n right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(nn," {\n margin-right: ").concat(a,"px ").concat(r,";\n }\n \n .").concat(tn," .").concat(tn," {\n right: 0 ").concat(r,";\n }\n \n .").concat(nn," .").concat(nn," {\n margin-right: 0 ").concat(r,";\n }\n \n body[").concat(wn,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(a,"px;\n }\n")},kn=function(){var e=parseInt(document.body.getAttribute(wn)||"0",10);return isFinite(e)?e:0},Sn=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=void 0===r?"margin":r;s.useEffect(function(){return document.body.setAttribute(wn,(kn()+1).toString()),function(){var e=kn()-1;e<=0?document.body.removeAttribute(wn):document.body.setAttribute(wn,e.toString())}},[]);var o=s.useMemo(function(){return bn(i)},[i]);return s.createElement(yn,{styles:xn(o,!t,i,n?"":"!important")})},En=!1;if("undefined"!=typeof window)try{var Cn=Object.defineProperty({},"passive",{get:function(){return En=!0,!0}});window.addEventListener("test",Cn,Cn),window.removeEventListener("test",Cn,Cn)}catch(e){En=!1}var On=!!En&&{passive:!1},Nn=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&!(n.overflowY===n.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===n[t])},An=function(e,t){var n=t.ownerDocument,r=t;do{if("undefined"!=typeof ShadowRoot&&r instanceof ShadowRoot&&(r=r.host),Tn(e,r)){var i=Mn(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Tn=function(e,t){return"v"===e?function(e){return Nn(e,"overflowY")}(t):function(e){return Nn(e,"overflowX")}(t)},Mn=function(e,t){return"v"===e?function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]}(t):function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t)},Rn=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Dn=function(e){return[e.deltaX,e.deltaY]},Pn=function(e){return e&&"current"in e?e.current:e},Ln=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},Bn=0,In=[];function jn(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var _n,Fn=(_n=function(e){var t=s.useRef([]),n=s.useRef([0,0]),r=s.useRef(),i=s.useState(Bn++)[0],o=s.useState(mn)[0],a=s.useRef(e);s.useEffect(function(){a.current=e},[e]),s.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var t=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}([e.lockRef.current],(e.shards||[]).map(Pn),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=s.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!a.current.allowPinchZoom;var i,o=Rn(e),s=n.current,l="deltaX"in e?e.deltaX:s[0]-o[0],c="deltaY"in e?e.deltaY:s[1]-o[1],h=e.target,u=Math.abs(l)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===u&&"range"===h.type)return!1;var d=window.getSelection(),f=d&&d.anchorNode;if(f&&(f===h||f.contains(h)))return!1;var p=An(u,h);if(!p)return!0;if(p?i=u:(i="v"===u?"h":"v",p=An(u,h)),!p)return!1;if(!r.current&&"changedTouches"in e&&(l||c)&&(r.current=i),!i)return!0;var m=r.current||i;return function(e,t,n,r,i){var o=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),s=o*r,a=n.target,l=t.contains(a),c=!1,h=s>0,u=0,d=0;do{if(!a)break;var f=Mn(e,a),p=f[0],m=f[1]-f[2]-o*p;(p||m)&&Tn(e,a)&&(u+=m,d+=p);var g=a.parentNode;a=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(h&&(i&&Math.abs(u)<1||!i&&s>u)||!h&&(i&&Math.abs(d)<1||!i&&-s>d))&&(c=!0),c}(m,t,e,"h"===m?l:c,!0)},[]),c=s.useCallback(function(e){var n=e;if(In.length&&In[In.length-1]===o){var r="deltaY"in n?Dn(n):Rn(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&(t=e.delta,i=r,t[0]===i[0]&&t[1]===i[1]);var t,i})[0];if(i&&i.should)n.cancelable&&n.preventDefault();else if(!i){var s=(a.current.shards||[]).map(Pn).filter(Boolean).filter(function(e){return e.contains(n.target)});(s.length>0?l(n,s[0]):!a.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),h=s.useCallback(function(e,n,r,i){var o={name:e,delta:n,target:r,should:i,shadowParent:jn(r)};t.current.push(o),setTimeout(function(){t.current=t.current.filter(function(e){return e!==o})},1)},[]),u=s.useCallback(function(e){n.current=Rn(e),r.current=void 0},[]),d=s.useCallback(function(t){h(t.type,Dn(t),t.target,l(t,e.lockRef.current))},[]),f=s.useCallback(function(t){h(t.type,Rn(t),t.target,l(t,e.lockRef.current))},[]);s.useEffect(function(){return In.push(o),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",c,On),document.addEventListener("touchmove",c,On),document.addEventListener("touchstart",u,On),function(){In=In.filter(function(e){return e!==o}),document.removeEventListener("wheel",c,On),document.removeEventListener("touchmove",c,On),document.removeEventListener("touchstart",u,On)}},[]);var p=e.removeScrollBar,m=e.inert;return s.createElement(s.Fragment,null,m?s.createElement(o,{styles:Ln(i)}):null,p?s.createElement(Sn,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},hn.useMedium(_n),cn),Wn=s.forwardRef(function(e,t){return s.createElement(dn,Y({},e,{ref:t,sideCar:Fn}))});Wn.classNames=dn.classNames;var zn=Wn,Hn=new WeakMap,Vn=new WeakMap,qn={},Un=0,$n=function(e){return e&&(e.host||$n(e.parentNode))},Kn=function(e,t,n,r){var i=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=$n(t);return n&&e.contains(n)?n:null}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);qn[n]||(qn[n]=new WeakMap);var o=qn[n],s=[],a=new Set,l=new Set(i),c=function(e){e&&!a.has(e)&&(a.add(e),c(e.parentNode))};i.forEach(c);var h=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(a.has(e))h(e);else try{var t=e.getAttribute(r),i=null!==t&&"false"!==t,l=(Hn.get(e)||0)+1,c=(o.get(e)||0)+1;Hn.set(e,l),o.set(e,c),s.push(e),1===l&&i&&Vn.set(e,!0),1===c&&e.setAttribute(n,"true"),i||e.setAttribute(r,"true")}catch(e){}})};return h(t),a.clear(),Un++,function(){s.forEach(function(e){var t=Hn.get(e)-1,i=o.get(e)-1;Hn.set(e,t),o.set(e,i),t||(Vn.has(e)||e.removeAttribute(r),Vn.delete(e)),i||e.removeAttribute(n)}),--Un||(Hn=new WeakMap,Hn=new WeakMap,Vn=new WeakMap,qn={})}},Yn=function(e,t,n){void 0===n&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=t||function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),Kn(r,i,n,"aria-hidden")):function(){return null}},Gn="Dialog",[Xn,Jn]=gt(Gn),[Qn,Zn]=Xn(Gn),er=e=>{const{__scopeDialog:n,children:r,open:i,defaultOpen:o,onOpenChange:a,modal:l=!0}=e,c=s.useRef(null),h=s.useRef(null),[u,d]=St({prop:i,defaultProp:o??!1,onChange:a,caller:Gn});return t.jsx(Qn,{scope:n,triggerRef:c,contentRef:h,contentId:xt(),titleId:xt(),descriptionId:xt(),open:u,onOpenChange:d,onOpenToggle:s.useCallback(()=>d(e=>!e),[d]),modal:l,children:r})};er.displayName=Gn;var tr="DialogTrigger",nr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=Zn(tr,r),s=Ye(n,o.triggerRef);return t.jsx(At.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":kr(o.open),...i,ref:s,onClick:mt(e.onClick,o.onOpenToggle)})});nr.displayName=tr;var rr="DialogPortal",[ir,or]=Xn(rr,{forceMount:void 0}),sr=e=>{const{__scopeDialog:n,forceMount:r,children:i,container:o}=e,a=Zn(rr,n);return t.jsx(ir,{scope:n,forceMount:r,children:s.Children.map(i,e=>t.jsx(Xt,{present:r||a.open,children:t.jsx(Gt,{asChild:!0,container:o,children:e})}))})};sr.displayName=rr;var ar="DialogOverlay",lr=s.forwardRef((e,n)=>{const r=or(ar,e.__scopeDialog),{forceMount:i=r.forceMount,...o}=e,s=Zn(ar,e.__scopeDialog);return s.modal?t.jsx(Xt,{present:i||s.open,children:t.jsx(hr,{...o,ref:n})}):null});lr.displayName=ar;var cr=Et("DialogOverlay.RemoveScroll"),hr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=Zn(ar,r);return t.jsx(zn,{as:cr,allowPinchZoom:!0,shards:[o.contentRef],children:t.jsx(At.div,{"data-state":kr(o.open),...i,ref:n,style:{pointerEvents:"auto",...i.style}})})}),ur="DialogContent",dr=s.forwardRef((e,n)=>{const r=or(ur,e.__scopeDialog),{forceMount:i=r.forceMount,...o}=e,s=Zn(ur,e.__scopeDialog);return t.jsx(Xt,{present:i||s.open,children:s.modal?t.jsx(fr,{...o,ref:n}):t.jsx(pr,{...o,ref:n})})});dr.displayName=ur;var fr=s.forwardRef((e,n)=>{const r=Zn(ur,e.__scopeDialog),i=s.useRef(null),o=Ye(n,r.contentRef,i);return s.useEffect(()=>{const e=i.current;if(e)return Yn(e)},[]),t.jsx(mr,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:mt(e.onCloseAutoFocus,e=>{e.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:mt(e.onPointerDownOutside,e=>{const t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:mt(e.onFocusOutside,e=>e.preventDefault())})}),pr=s.forwardRef((e,n)=>{const r=Zn(ur,e.__scopeDialog),i=s.useRef(!1),o=s.useRef(!1);return t.jsx(mr,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(i.current||r.triggerRef.current?.focus(),t.preventDefault()),i.current=!1,o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(i.current=!0,"pointerdown"===t.detail.originalEvent.type&&(o.current=!0));const n=t.target,s=r.triggerRef.current?.contains(n);s&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&o.current&&t.preventDefault()}})}),mr=s.forwardRef((e,n)=>{const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:a,...l}=e,c=Zn(ur,r),h=s.useRef(null),u=Ye(n,h);return Zt(),t.jsxs(t.Fragment,{children:[t.jsx(Ht,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:o,onUnmountAutoFocus:a,children:t.jsx(It,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":kr(c.open),...l,ref:u,onDismiss:()=>c.onOpenChange(!1)})}),t.jsxs(t.Fragment,{children:[t.jsx(Or,{titleId:c.titleId}),t.jsx(Nr,{contentRef:h,descriptionId:c.descriptionId})]})]})}),gr="DialogTitle",vr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=Zn(gr,r);return t.jsx(At.h2,{id:o.titleId,...i,ref:n})});vr.displayName=gr;var br="DialogDescription",yr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=Zn(br,r);return t.jsx(At.p,{id:o.descriptionId,...i,ref:n})});yr.displayName=br;var wr="DialogClose",xr=s.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,o=Zn(wr,r);return t.jsx(At.button,{type:"button",...i,ref:n,onClick:mt(e.onClick,()=>o.onOpenChange(!1))})});function kr(e){return e?"open":"closed"}xr.displayName=wr;var Sr="DialogTitleWarning",[Er,Cr]=function(e,n){const r=s.createContext(n),i=e=>{const{children:n,...i}=e,o=s.useMemo(()=>i,Object.values(i));return t.jsx(r.Provider,{value:o,children:n})};return i.displayName=e+"Provider",[i,function(t){const i=s.useContext(r);if(i)return i;if(void 0!==n)return n;throw new Error(`\`${t}\` must be used within \`${e}\``)}]}(Sr,{contentName:ur,titleName:gr,docsSlug:"dialog"}),Or=({titleId:e})=>{const t=Cr(Sr),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return s.useEffect(()=>{if(e){document.getElementById(e)}},[n,e]),null},Nr=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Cr("DialogDescriptionWarning").contentName}}.`;return s.useEffect(()=>{const n=e.current?.getAttribute("aria-describedby");if(t&&n){document.getElementById(t)}},[n,e,t]),null},Ar=er,Tr=nr,Mr=sr,Rr=lr,Dr=dr,Pr=vr,Lr=yr,Br=xr,Ir=Ar,jr=Mr,_r=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Rr,Object.assign({className:qe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n)},r,{ref:t}))});_r.displayName=Rr.displayName;var Fr=ot("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Wr=s.forwardRef(function(e,t){var n=e.side,r=void 0===n?"right":n,i=e.className,o=e.children,a=G(e,["side","className","children"]);return s.createElement(jr,null,s.createElement(_r,null),s.createElement(Dr,Object.assign({ref:t,className:qe(Fr({side:r}),i)},a),o,s.createElement(Br,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary"},s.createElement(K,{className:"h-4 w-4"}),s.createElement("span",{className:"sr-only"},"Close"))))});Wr.displayName=Dr.displayName;var zr=function(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("flex flex-col space-y-2 text-center sm:text-left",t)},n))};zr.displayName="SheetHeader";var Hr=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Pr,Object.assign({ref:t,className:qe("text-lg font-semibold text-foreground",n)},r))});Hr.displayName=Pr.displayName;var Vr=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Lr,Object.assign({ref:t,className:qe("text-sm text-muted-foreground",n)},r))});function qr(e){const t=s.forwardRef((e,t)=>{const{children:n,...r}=e;if(s.isValidElement(n)){const e=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?Ke(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}Vr.displayName=Lr.displayName;var Ur=Symbol("radix.slottable");function $r(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Ur}var Kr=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=function(e){const n=qr(e),r=s.forwardRef((e,r)=>{const{children:i,...o}=e,a=s.Children.toArray(i),l=a.find($r);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});var Yr,Gr="dismissableLayer.update",Xr="dismissableLayer.pointerDownOutside",Jr="dismissableLayer.focusOutside",Qr=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Zr=s.forwardRef((e,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...h}=e,u=s.useContext(Qr),[d,f]=s.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=s.useState({}),g=Ye(n,e=>f(e)),v=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=d?v.indexOf(d):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(e,t=globalThis?.document){const n=Tt(e),r=s.useRef(!1),i=s.useRef(()=>{});return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){ti(Xr,n,o,{discrete:!0})};const o={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",i.current),i.current=r,t.addEventListener("click",i.current,{once:!0})):r()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",e),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,n=[...u.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),l?.(e),e.defaultPrevented||c?.())},p),E=function(e,t=globalThis?.document){const n=Tt(e),r=s.useRef(!1);return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){ti(Jr,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...u.branches].some(e=>e.contains(t))||(a?.(e),l?.(e),e.defaultPrevented||c?.())},p);return Mt(e=>{w===u.layers.size-1&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},p),s.useEffect(()=>{if(d)return r&&(0===u.layersWithOutsidePointerEventsDisabled.size&&(Yr=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),ei(),()=>{r&&1===u.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=Yr)}},[d,p,r,u]),s.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),ei())},[d,u]),s.useEffect(()=>{const e=()=>m({});return document.addEventListener(Gr,e),()=>document.removeEventListener(Gr,e)},[]),t.jsx(Kr.div,{...h,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...e.style},onFocusCapture:mt(e.onFocusCapture,E.onFocusCapture),onBlurCapture:mt(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:mt(e.onPointerDownCapture,S.onPointerDownCapture)})});Zr.displayName="DismissableLayer";function ei(){const e=new CustomEvent(Gr);document.dispatchEvent(e)}function ti(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?function(e,t){e&&a.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}s.forwardRef((e,n)=>{const r=s.useContext(Qr),i=s.useRef(null),o=Ye(n,i);return s.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),t.jsx(Kr.div,{...e,ref:o})}).displayName="DismissableLayerBranch";const ni=["top","right","bottom","left"],ri=Math.min,ii=Math.max,oi=Math.round,si=Math.floor,ai=e=>({x:e,y:e}),li={left:"right",right:"left",bottom:"top",top:"bottom"},ci={start:"end",end:"start"};function hi(e,t,n){return ii(e,ri(t,n))}function ui(e,t){return"function"==typeof e?e(t):e}function di(e){return e.split("-")[0]}function fi(e){return e.split("-")[1]}function pi(e){return"x"===e?"y":"x"}function mi(e){return"y"===e?"height":"width"}const gi=new Set(["top","bottom"]);function vi(e){return gi.has(di(e))?"y":"x"}function bi(e){return pi(vi(e))}function yi(e){return e.replace(/start|end/g,e=>ci[e])}const wi=["left","right"],xi=["right","left"],ki=["top","bottom"],Si=["bottom","top"];function Ei(e,t,n,r){const i=fi(e);let o=function(e,t,n){switch(e){case"top":case"bottom":return n?t?xi:wi:t?wi:xi;case"left":case"right":return t?ki:Si;default:return[]}}(di(e),"start"===n,r);return i&&(o=o.map(e=>e+"-"+i),t&&(o=o.concat(o.map(yi)))),o}function Ci(e){return e.replace(/left|right|bottom|top/g,e=>li[e])}function Oi(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function Ni(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Ai(e,t,n){let{reference:r,floating:i}=e;const o=vi(t),s=bi(t),a=mi(s),l=di(t),c="y"===o,h=r.x+r.width/2-i.width/2,u=r.y+r.height/2-i.height/2,d=r[a]/2-i[a]/2;let f;switch(l){case"top":f={x:h,y:r.y-i.height};break;case"bottom":f={x:h,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:u};break;case"left":f={x:r.x-i.width,y:u};break;default:f={x:r.x,y:r.y}}switch(fi(t)){case"start":f[s]-=d*(n&&c?-1:1);break;case"end":f[s]+=d*(n&&c?-1:1)}return f}async function Ti(e,t){var n;void 0===t&&(t={});const{x:r,y:i,platform:o,rects:s,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:h="viewport",elementContext:u="floating",altBoundary:d=!1,padding:f=0}=ui(t,e),p=Oi(f),m=a[d?"floating"===u?"reference":"floating":u],g=Ni(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(m)))||n?m:m.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:h,strategy:l})),v="floating"===u?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,b=await(null==o.getOffsetParent?void 0:o.getOffsetParent(a.floating)),y=await(null==o.isElement?void 0:o.isElement(b))&&await(null==o.getScale?void 0:o.getScale(b))||{x:1,y:1},w=Ni(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:b,strategy:l}):v);return{top:(g.top-w.top+p.top)/y.y,bottom:(w.bottom-g.bottom+p.bottom)/y.y,left:(g.left-w.left+p.left)/y.x,right:(w.right-g.right+p.right)/y.x}}function Mi(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ri(e){return ni.some(t=>e[t]>=0)}const Di=new Set(["left","top"]);function Pi(){return"undefined"!=typeof window}function Li(e){return ji(e)?(e.nodeName||"").toLowerCase():"#document"}function Bi(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Ii(e){var t;return null==(t=(ji(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function ji(e){return!!Pi()&&(e instanceof Node||e instanceof Bi(e).Node)}function _i(e){return!!Pi()&&(e instanceof Element||e instanceof Bi(e).Element)}function Fi(e){return!!Pi()&&(e instanceof HTMLElement||e instanceof Bi(e).HTMLElement)}function Wi(e){return!(!Pi()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof Bi(e).ShadowRoot)}const zi=new Set(["inline","contents"]);function Hi(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=eo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!zi.has(i)}const Vi=new Set(["table","td","th"]);function qi(e){return Vi.has(Li(e))}const Ui=[":popover-open",":modal"];function $i(e){return Ui.some(t=>{try{return e.matches(t)}catch(e){return!1}})}const Ki=["transform","translate","scale","rotate","perspective"],Yi=["transform","translate","scale","rotate","perspective","filter"],Gi=["paint","layout","strict","content"];function Xi(e){const t=Ji(),n=_i(e)?eo(e):e;return Ki.some(e=>!!n[e]&&"none"!==n[e])||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||Yi.some(e=>(n.willChange||"").includes(e))||Gi.some(e=>(n.contain||"").includes(e))}function Ji(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const Qi=new Set(["html","body","#document"]);function Zi(e){return Qi.has(Li(e))}function eo(e){return Bi(e).getComputedStyle(e)}function to(e){return _i(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function no(e){if("html"===Li(e))return e;const t=e.assignedSlot||e.parentNode||Wi(e)&&e.host||Ii(e);return Wi(t)?t.host:t}function ro(e){const t=no(e);return Zi(t)?e.ownerDocument?e.ownerDocument.body:e.body:Fi(t)&&Hi(t)?t:ro(t)}function io(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const i=ro(e),o=i===(null==(r=e.ownerDocument)?void 0:r.body),s=Bi(i);if(o){const e=oo(s);return t.concat(s,s.visualViewport||[],Hi(i)?i:[],e&&n?io(e):[])}return t.concat(i,io(i,[],n))}function oo(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function so(e){const t=eo(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Fi(e),o=i?e.offsetWidth:n,s=i?e.offsetHeight:r,a=oi(n)!==o||oi(r)!==s;return a&&(n=o,r=s),{width:n,height:r,$:a}}function ao(e){return _i(e)?e:e.contextElement}function lo(e){const t=ao(e);if(!Fi(t))return ai(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=so(t);let s=(o?oi(n.width):n.width)/r,a=(o?oi(n.height):n.height)/i;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const co=ai(0);function ho(e){const t=Bi(e);return Ji()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:co}function uo(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),o=ao(e);let s=ai(1);t&&(r?_i(r)&&(s=lo(r)):s=lo(e));const a=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==Bi(e))&&t}(o,n,r)?ho(o):ai(0);let l=(i.left+a.x)/s.x,c=(i.top+a.y)/s.y,h=i.width/s.x,u=i.height/s.y;if(o){const e=Bi(o),t=r&&_i(r)?Bi(r):r;let n=e,i=oo(n);for(;i&&r&&t!==n;){const e=lo(i),t=i.getBoundingClientRect(),r=eo(i),o=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,s=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,c*=e.y,h*=e.x,u*=e.y,l+=o,c+=s,n=Bi(i),i=oo(n)}}return Ni({width:h,height:u,x:l,y:c})}function fo(e,t){const n=to(e).scrollLeft;return t?t.left+n:uo(Ii(e)).left+n}function po(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-fo(e,n),y:n.top+t.scrollTop}}const mo=new Set(["absolute","fixed"]);function go(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=Bi(e),r=Ii(e),i=n.visualViewport;let o=r.clientWidth,s=r.clientHeight,a=0,l=0;if(i){o=i.width,s=i.height;const e=Ji();(!e||e&&"fixed"===t)&&(a=i.offsetLeft,l=i.offsetTop)}const c=fo(r);if(c<=0){const e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i="CSS1Compat"===e.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,s=Math.abs(r.clientWidth-t.clientWidth-i);s<=25&&(o-=s)}else c<=25&&(o+=c);return{width:o,height:s,x:a,y:l}}(e,n);else if("document"===t)r=function(e){const t=Ii(e),n=to(e),r=e.ownerDocument.body,i=ii(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=ii(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+fo(e);const a=-n.scrollTop;return"rtl"===eo(r).direction&&(s+=ii(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:s,y:a}}(Ii(e));else if(_i(t))r=function(e,t){const n=uo(e,!0,"fixed"===t),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=Fi(e)?lo(e):ai(1);return{width:e.clientWidth*o.x,height:e.clientHeight*o.y,x:i*o.x,y:r*o.y}}(t,n);else{const n=ho(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Ni(r)}function vo(e,t){const n=no(e);return!(n===t||!_i(n)||Zi(n))&&("fixed"===eo(n).position||vo(n,t))}function bo(e,t,n){const r=Fi(t),i=Ii(t),o="fixed"===n,s=uo(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=ai(0);function c(){l.x=fo(i)}if(r||!r&&!o)if(("body"!==Li(t)||Hi(i))&&(a=to(t)),r){const e=uo(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else i&&c();o&&!r&&i&&c();const h=!i||r||o?ai(0):po(i,a);return{x:s.left+a.scrollLeft-l.x-h.x,y:s.top+a.scrollTop-l.y-h.y,width:s.width,height:s.height}}function yo(e){return"static"===eo(e).position}function wo(e,t){if(!Fi(e)||"fixed"===eo(e).position)return null;if(t)return t(e);let n=e.offsetParent;return Ii(e)===n&&(n=n.ownerDocument.body),n}function xo(e,t){const n=Bi(e);if($i(e))return n;if(!Fi(e)){let t=no(e);for(;t&&!Zi(t);){if(_i(t)&&!yo(t))return t;t=no(t)}return n}let r=wo(e,t);for(;r&&qi(r)&&yo(r);)r=wo(r,t);return r&&Zi(r)&&yo(r)&&!Xi(r)?n:r||function(e){let t=no(e);for(;Fi(t)&&!Zi(t);){if(Xi(t))return t;if($i(t))return null;t=no(t)}return null}(e)||n}const ko={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o="fixed"===i,s=Ii(r),a=!!t&&$i(t.floating);if(r===s||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=ai(1);const h=ai(0),u=Fi(r);if((u||!u&&!o)&&(("body"!==Li(r)||Hi(s))&&(l=to(r)),Fi(r))){const e=uo(r);c=lo(r),h.x=e.x+r.clientLeft,h.y=e.y+r.clientTop}const d=!s||u||o?ai(0):po(s,l);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+h.x+d.x,y:n.y*c.y-l.scrollTop*c.y+h.y+d.y}},getDocumentElement:Ii,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[..."clippingAncestors"===n?$i(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let r=io(e,[],!1).filter(e=>_i(e)&&"body"!==Li(e)),i=null;const o="fixed"===eo(e).position;let s=o?no(e):e;for(;_i(s)&&!Zi(s);){const t=eo(s),n=Xi(s);n||"fixed"!==t.position||(i=null),(o?!n&&!i:!n&&"static"===t.position&&i&&mo.has(i.position)||Hi(s)&&!n&&vo(e,s))?r=r.filter(e=>e!==s):i=t,s=no(s)}return t.set(e,r),r}(t,this._c):[].concat(n),r],s=o[0],a=o.reduce((e,n)=>{const r=go(t,n,i);return e.top=ii(r.top,e.top),e.right=ri(r.right,e.right),e.bottom=ri(r.bottom,e.bottom),e.left=ii(r.left,e.left),e},go(t,s,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:xo,getElementRects:async function(e){const t=this.getOffsetParent||xo,n=this.getDimensions,r=await n(e.floating);return{reference:bo(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=so(e);return{width:t,height:n}},getScale:lo,isElement:_i,isRTL:function(e){return"rtl"===eo(e).direction}};function So(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Eo(e,t,n,r){void 0===r&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:l=!1}=r,c=ao(e),h=i||o?[...c?io(c):[],...io(t)]:[];h.forEach(e=>{i&&e.addEventListener("scroll",n,{passive:!0}),o&&e.addEventListener("resize",n)});const u=c&&a?function(e,t){let n,r=null;const i=Ii(e);function o(){var e;clearTimeout(n),null==(e=r)||e.disconnect(),r=null}return function s(a,l){void 0===a&&(a=!1),void 0===l&&(l=1),o();const c=e.getBoundingClientRect(),{left:h,top:u,width:d,height:f}=c;if(a||t(),!d||!f)return;const p={rootMargin:-si(u)+"px "+-si(i.clientWidth-(h+d))+"px "+-si(i.clientHeight-(u+f))+"px "+-si(h)+"px",threshold:ii(0,ri(1,l))||1};let m=!0;function g(t){const r=t[0].intersectionRatio;if(r!==l){if(!m)return s();r?s(!1,r):n=setTimeout(()=>{s(!1,1e-7)},1e3)}1!==r||So(c,e.getBoundingClientRect())||s(),m=!1}try{r=new IntersectionObserver(g,{...p,root:i.ownerDocument})}catch(e){r=new IntersectionObserver(g,p)}r.observe(e)}(!0),o}(c,n):null;let d,f=-1,p=null;s&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;null==(e=p)||e.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let m=l?uo(e):null;return l&&function t(){const r=uo(e);m&&!So(m,r)&&n();m=r,d=requestAnimationFrame(t)}(),n(),()=>{var e;h.forEach(e=>{i&&e.removeEventListener("scroll",n),o&&e.removeEventListener("resize",n)}),null==u||u(),null==(e=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(d)}}const Co=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:s,middlewareData:a}=t,l=await async function(e,t){const{placement:n,platform:r,elements:i}=e,o=await(null==r.isRTL?void 0:r.isRTL(i.floating)),s=di(n),a=fi(n),l="y"===vi(n),c=Di.has(s)?-1:1,h=o&&l?-1:1,u=ui(t,e);let{mainAxis:d,crossAxis:f,alignmentAxis:p}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&"number"==typeof p&&(f="end"===a?-1*p:p),l?{x:f*h,y:d*c}:{x:d*c,y:f*h}}(t,e);return s===(null==(n=a.offset)?void 0:n.placement)&&null!=(r=a.arrow)&&r.alignmentOffset?{}:{x:i+l.x,y:o+l.y,data:{...l,placement:s}}}}},Oo=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:a={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=ui(e,t),c={x:n,y:r},h=await Ti(t,l),u=vi(di(i)),d=pi(u);let f=c[d],p=c[u];if(o){const e="y"===d?"bottom":"right";f=hi(f+h["y"===d?"top":"left"],f,f-h[e])}if(s){const e="y"===u?"bottom":"right";p=hi(p+h["y"===u?"top":"left"],p,p-h[e])}const m=a.fn({...t,[d]:f,[u]:p});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[d]:o,[u]:s}}}}}},No=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:o,rects:s,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:h=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=ui(e,t);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const v=di(i),b=vi(a),y=di(a)===a,w=await(null==l.isRTL?void 0:l.isRTL(c.floating)),x=d||(y||!m?[Ci(a)]:function(e){const t=Ci(e);return[yi(e),t,yi(t)]}(a)),k="none"!==p;!d&&k&&x.push(...Ei(a,m,p,w));const S=[a,...x],E=await Ti(t,g),C=[];let O=(null==(r=o.flip)?void 0:r.overflows)||[];if(h&&C.push(E[v]),u){const e=function(e,t,n){void 0===n&&(n=!1);const r=fi(e),i=bi(e),o=mi(i);let s="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=Ci(s)),[s,Ci(s)]}(i,s,w);C.push(E[e[0]],E[e[1]])}if(O=[...O,{placement:i,overflows:C}],!C.every(e=>e<=0)){var N,A;const e=((null==(N=o.flip)?void 0:N.index)||0)+1,t=S[e];if(t){if(!("alignment"===u&&b!==vi(t))||O.every(e=>vi(e.placement)!==b||e.overflows[0]>0))return{data:{index:e,overflows:O},reset:{placement:t}}}let n=null==(A=O.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:A.placement;if(!n)switch(f){case"bestFit":{var T;const e=null==(T=O.filter(e=>{if(k){const t=vi(e.placement);return t===b||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:T[0];e&&(n=e);break}case"initialPlacement":n=a}if(i!==n)return{reset:{placement:n}}}return{}}}},Ao=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:o,platform:s,elements:a}=t,{apply:l=()=>{},...c}=ui(e,t),h=await Ti(t,c),u=di(i),d=fi(i),f="y"===vi(i),{width:p,height:m}=o.floating;let g,v;"top"===u||"bottom"===u?(g=u,v=d===(await(null==s.isRTL?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(v=u,g="end"===d?"top":"bottom");const b=m-h.top-h.bottom,y=p-h.left-h.right,w=ri(m-h[g],b),x=ri(p-h[v],y),k=!t.middlewareData.shift;let S=w,E=x;if(null!=(n=t.middlewareData.shift)&&n.enabled.x&&(E=y),null!=(r=t.middlewareData.shift)&&r.enabled.y&&(S=b),k&&!d){const e=ii(h.left,0),t=ii(h.right,0),n=ii(h.top,0),r=ii(h.bottom,0);f?E=p-2*(0!==e||0!==t?e+t:ii(h.left,h.right)):S=m-2*(0!==n||0!==r?n+r:ii(h.top,h.bottom))}await l({...t,availableWidth:E,availableHeight:S});const C=await s.getDimensions(a.floating);return p!==C.width||m!==C.height?{reset:{rects:!0}}:{}}}},To=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...i}=ui(e,t);switch(r){case"referenceHidden":{const e=Mi(await Ti(t,{...i,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Ri(e)}}}case"escaped":{const e=Mi(await Ti(t,{...i,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Ri(e)}}}default:return{}}}}},Mo=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:o,platform:s,elements:a,middlewareData:l}=t,{element:c,padding:h=0}=ui(e,t)||{};if(null==c)return{};const u=Oi(h),d={x:n,y:r},f=bi(i),p=mi(f),m=await s.getDimensions(c),g="y"===f,v=g?"top":"left",b=g?"bottom":"right",y=g?"clientHeight":"clientWidth",w=o.reference[p]+o.reference[f]-d[f]-o.floating[p],x=d[f]-o.reference[f],k=await(null==s.getOffsetParent?void 0:s.getOffsetParent(c));let S=k?k[y]:0;S&&await(null==s.isElement?void 0:s.isElement(k))||(S=a.floating[y]||o.floating[p]);const E=w/2-x/2,C=S/2-m[p]/2-1,O=ri(u[v],C),N=ri(u[b],C),A=O,T=S-m[p]-N,M=S/2-m[p]/2+E,R=hi(A,M,T),D=!l.arrow&&null!=fi(i)&&M!==R&&o.reference[p]/2-(M<A?O:N)-m[p]/2<0,P=D?M<A?M-A:M-T:0;return{[f]:d[f]+P,data:{[f]:R,centerOffset:M-R-P,...D&&{alignmentOffset:P}},reset:D}}}),Ro=function(e){return void 0===e&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:o,middlewareData:s}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=ui(e,t),h={x:n,y:r},u=vi(i),d=pi(u);let f=h[d],p=h[u];const m=ui(a,t),g="number"==typeof m?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const e="y"===d?"height":"width",t=o.reference[d]-o.floating[e]+g.mainAxis,n=o.reference[d]+o.reference[e]-g.mainAxis;f<t?f=t:f>n&&(f=n)}if(c){var v,b;const e="y"===d?"width":"height",t=Di.has(di(i)),n=o.reference[u]-o.floating[e]+(t&&(null==(v=s.offset)?void 0:v[u])||0)+(t?0:g.crossAxis),r=o.reference[u]+o.reference[e]+(t?0:(null==(b=s.offset)?void 0:b[u])||0)-(t?g.crossAxis:0);p<n?p=n:p>r&&(p=r)}return{[d]:f,[u]:p}}}},Do=(e,t,n)=>{const r=new Map,i={platform:ko,...n},o={...i.platform,_c:r};return(async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:s}=n,a=o.filter(Boolean),l=await(null==s.isRTL?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:u}=Ai(c,r,l),d=r,f={},p=0;for(let n=0;n<a.length;n++){const{name:o,fn:m}=a[n],{x:g,y:v,data:b,reset:y}=await m({x:h,y:u,initialPlacement:r,placement:d,strategy:i,middlewareData:f,rects:c,platform:s,elements:{reference:e,floating:t}});h=null!=g?g:h,u=null!=v?v:u,f={...f,[o]:{...f[o],...b}},y&&p<=50&&(p++,"object"==typeof y&&(y.placement&&(d=y.placement),y.rects&&(c=!0===y.rects?await s.getElementRects({reference:e,floating:t,strategy:i}):y.rects),({x:h,y:u}=Ai(c,d,l))),n=-1)}return{x:h,y:u,placement:d,strategy:i,middlewareData:f}})(e,t,{...i,platform:o})};var Po="undefined"!=typeof document?e.useLayoutEffect:function(){};function Lo(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;0!==r--;)if(!Lo(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;0!==r--;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;0!==r--;){const n=i[r];if(("_owner"!==n||!e.$$typeof)&&!Lo(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function Bo(e){if("undefined"==typeof window)return 1;return(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Io(e,t){const n=Bo(e);return Math.round(t*n)/n}function jo(e){const t=s.useRef(e);return Po(()=>{t.current=e}),t}function _o(e){void 0===e&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:l}={},transform:c=!0,whileElementsMounted:h,open:u}=e,[d,f]=s.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=s.useState(r);Lo(p,r)||m(r);const[g,v]=s.useState(null),[b,y]=s.useState(null),w=s.useCallback(e=>{e!==E.current&&(E.current=e,v(e))},[]),x=s.useCallback(e=>{e!==C.current&&(C.current=e,y(e))},[]),k=o||g,S=l||b,E=s.useRef(null),C=s.useRef(null),O=s.useRef(d),N=null!=h,A=jo(h),T=jo(i),M=jo(u),R=s.useCallback(()=>{if(!E.current||!C.current)return;const e={placement:t,strategy:n,middleware:p};T.current&&(e.platform=T.current),Do(E.current,C.current,e).then(e=>{const t={...e,isPositioned:!1!==M.current};D.current&&!Lo(O.current,t)&&(O.current=t,a.flushSync(()=>{f(t)}))})},[p,t,n,T,M]);Po(()=>{!1===u&&O.current.isPositioned&&(O.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[u]);const D=s.useRef(!1);Po(()=>(D.current=!0,()=>{D.current=!1}),[]),Po(()=>{if(k&&(E.current=k),S&&(C.current=S),k&&S){if(A.current)return A.current(k,S,R);R()}},[k,S,R,A,N]);const P=s.useMemo(()=>({reference:E,floating:C,setReference:w,setFloating:x}),[w,x]),L=s.useMemo(()=>({reference:k,floating:S}),[k,S]),B=s.useMemo(()=>{const e={position:n,left:0,top:0};if(!L.floating)return e;const t=Io(L.floating,d.x),r=Io(L.floating,d.y);return c?{...e,transform:"translate("+t+"px, "+r+"px)",...Bo(L.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:t,top:r}},[n,c,L.floating,d.x,d.y]);return s.useMemo(()=>({...d,update:R,refs:P,elements:L,floatingStyles:B}),[d,R,P,L,B])}const Fo=e=>({name:"arrow",options:e,fn(t){const{element:n,padding:r}="function"==typeof e?e(t):e;return n&&(i=n,{}.hasOwnProperty.call(i,"current"))?null!=n.current?Mo({element:n.current,padding:r}).fn(t):{}:n?Mo({element:n,padding:r}).fn(t):{};var i}}),Wo=(e,t)=>({...Co(e),options:[e,t]}),zo=(e,t)=>({...Oo(e),options:[e,t]}),Ho=(e,t)=>({...Ro(e),options:[e,t]}),Vo=(e,t)=>({...No(e),options:[e,t]}),qo=(e,t)=>({...Ao(e),options:[e,t]}),Uo=(e,t)=>({...To(e),options:[e,t]}),$o=(e,t)=>({...Fo(e),options:[e,t]});var Ko=s.forwardRef((e,n)=>{const{children:r,width:i=10,height:o=5,...s}=e;return t.jsx(Kr.svg,{...s,ref:n,width:i,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ko.displayName="Arrow";var Yo=Ko;function Go(e){const[t,n]=s.useState(void 0);return bt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const t=new ResizeObserver(t=>{if(!Array.isArray(t))return;if(!t.length)return;const r=t[0];let i,o;if("borderBoxSize"in r){const e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,o=t.blockSize}else i=e.offsetWidth,o=e.offsetHeight;n({width:i,height:o})});return t.observe(e,{box:"border-box"}),()=>t.unobserve(e)}n(void 0)},[e]),t}var Xo="Popper",[Jo,Qo]=gt(Xo),[Zo,es]=Jo(Xo),ts=e=>{const{__scopePopper:n,children:r}=e,[i,o]=s.useState(null);return t.jsx(Zo,{scope:n,anchor:i,onAnchorChange:o,children:r})};ts.displayName=Xo;var ns="PopperAnchor",rs=s.forwardRef((e,n)=>{const{__scopePopper:r,virtualRef:i,...o}=e,a=es(ns,r),l=s.useRef(null),c=Ye(n,l),h=s.useRef(null);return s.useEffect(()=>{const e=h.current;h.current=i?.current||l.current,e!==h.current&&a.onAnchorChange(h.current)}),i?null:t.jsx(Kr.div,{...o,ref:c})});rs.displayName=ns;var is="PopperContent",[os,ss]=Jo(is),as=s.forwardRef((e,n)=>{const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:a="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:h=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...v}=e,b=es(is,r),[y,w]=s.useState(null),x=Ye(n,e=>w(e)),[k,S]=s.useState(null),E=Go(k),C=E?.width??0,O=E?.height??0,N=i+("center"!==a?"-"+a:""),A="number"==typeof d?d:{top:0,right:0,bottom:0,left:0,...d},T=Array.isArray(u)?u:[u],M=T.length>0,R={padding:A,boundary:T.filter(us),altBoundary:M},{refs:D,floatingStyles:P,placement:L,isPositioned:B,middlewareData:I}=_o({strategy:"fixed",placement:N,whileElementsMounted:(...e)=>Eo(...e,{animationFrame:"always"===m}),elements:{reference:b.anchor},middleware:[Wo({mainAxis:o+O,alignmentAxis:l}),h&&zo({mainAxis:!0,crossAxis:!1,limiter:"partial"===f?Ho():void 0,...R}),h&&Vo({...R}),qo({...R,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{const{width:i,height:o}=t.reference,s=e.floating.style;s.setProperty("--radix-popper-available-width",`${n}px`),s.setProperty("--radix-popper-available-height",`${r}px`),s.setProperty("--radix-popper-anchor-width",`${i}px`),s.setProperty("--radix-popper-anchor-height",`${o}px`)}}),k&&$o({element:k,padding:c}),ds({arrowWidth:C,arrowHeight:O}),p&&Uo({strategy:"referenceHidden",...R})]}),[j,_]=fs(L),F=Tt(g);bt(()=>{B&&F?.()},[B,F]);const W=I.arrow?.x,z=I.arrow?.y,H=0!==I.arrow?.centerOffset,[V,q]=s.useState();return bt(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),t.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...P,transform:B?P.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[I.transformOrigin?.x,I.transformOrigin?.y].join(" "),...I.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(os,{scope:r,placedSide:j,onArrowChange:S,arrowX:W,arrowY:z,shouldHideArrow:H,children:t.jsx(Kr.div,{"data-side":j,"data-align":_,...v,ref:x,style:{...v.style,animation:B?void 0:"none"}})})})});as.displayName=is;var ls="PopperArrow",cs={top:"bottom",right:"left",bottom:"top",left:"right"},hs=s.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,o=ss(ls,r),s=cs[o.placedSide];return t.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:t.jsx(Yo,{...i,ref:n,style:{...i.style,display:"block"}})})});function us(e){return null!==e}hs.displayName=ls;var ds=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:i}=t,o=0!==i.arrow?.centerOffset,s=o?0:e.arrowWidth,a=o?0:e.arrowHeight,[l,c]=fs(n),h={start:"0%",center:"50%",end:"100%"}[c],u=(i.arrow?.x??0)+s/2,d=(i.arrow?.y??0)+a/2;let f="",p="";return"bottom"===l?(f=o?h:`${u}px`,p=-a+"px"):"top"===l?(f=o?h:`${u}px`,p=`${r.floating.height+a}px`):"right"===l?(f=-a+"px",p=o?h:`${d}px`):"left"===l&&(f=`${r.floating.width+a}px`,p=o?h:`${d}px`),{data:{x:f,y:p}}}});function fs(e){const[t,n="center"]=e.split("-");return[t,n]}var ps=ts,ms=rs,gs=as,vs=hs;var bs=e=>{const{present:t,children:n}=e,r=function(e){const[t,n]=s.useState(),r=s.useRef(null),i=s.useRef(e),o=s.useRef("none"),a=e?"mounted":"unmounted",[l,c]=function(e,t){return s.useReducer((e,n)=>t[e][n]??e,e)}(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return s.useEffect(()=>{const e=ys(r.current);o.current="mounted"===l?e:"none"},[l]),bt(()=>{const t=r.current,n=i.current;if(n!==e){const r=o.current,s=ys(t);if(e)c("MOUNT");else if("none"===s||"none"===t?.display)c("UNMOUNT");else{c(n&&r!==s?"ANIMATION_OUT":"UNMOUNT")}i.current=e}},[e,c]),bt(()=>{if(t){let e;const n=t.ownerDocument.defaultView??window,s=o=>{const s=ys(r.current).includes(CSS.escape(o.animationName));if(o.target===t&&s&&(c("ANIMATION_END"),!i.current)){const r=t.style.animationFillMode;t.style.animationFillMode="forwards",e=n.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=r)})}},a=e=>{e.target===t&&(o.current=ys(r.current))};return t.addEventListener("animationstart",a),t.addEventListener("animationcancel",s),t.addEventListener("animationend",s),()=>{n.clearTimeout(e),t.removeEventListener("animationstart",a),t.removeEventListener("animationcancel",s),t.removeEventListener("animationend",s)}}c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:s.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}(t),i="function"==typeof n?n({present:r.isPresent}):s.Children.only(n),o=Ye(r.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(i));return"function"==typeof n||r.isPresent?s.cloneElement(i,{ref:o}):null};function ys(e){return e?.animationName||"none"}bs.displayName="Presence";var ws=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),xs=s.forwardRef((e,n)=>t.jsx(Kr.span,{...e,ref:n,style:{...ws,...e.style}}));xs.displayName="VisuallyHidden";var ks=xs,[Ss,Es]=gt("Tooltip",[Qo]),Cs=Qo(),Os="TooltipProvider",Ns=700,As="tooltip.open",[Ts,Ms]=Ss(Os),Rs=e=>{const{__scopeTooltip:n,delayDuration:r=Ns,skipDelayDuration:i=300,disableHoverableContent:o=!1,children:a}=e,l=s.useRef(!0),c=s.useRef(!1),h=s.useRef(0);return s.useEffect(()=>{const e=h.current;return()=>window.clearTimeout(e)},[]),t.jsx(Ts,{scope:n,isOpenDelayedRef:l,delayDuration:r,onOpen:s.useCallback(()=>{window.clearTimeout(h.current),l.current=!1},[]),onClose:s.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>l.current=!0,i)},[i]),isPointerInTransitRef:c,onPointerInTransitChange:s.useCallback(e=>{c.current=e},[]),disableHoverableContent:o,children:a})};Rs.displayName=Os;var Ds="Tooltip",[Ps,Ls]=Ss(Ds),Bs=e=>{const{__scopeTooltip:n,children:r,open:i,defaultOpen:o,onOpenChange:a,disableHoverableContent:l,delayDuration:c}=e,h=Ms(Ds,e.__scopeTooltip),u=Cs(n),[d,f]=s.useState(null),p=xt(),m=s.useRef(0),g=l??h.disableHoverableContent,v=c??h.delayDuration,b=s.useRef(!1),[y,w]=St({prop:i,defaultProp:o??!1,onChange:e=>{e?(h.onOpen(),document.dispatchEvent(new CustomEvent(As))):h.onClose(),a?.(e)},caller:Ds}),x=s.useMemo(()=>y?b.current?"delayed-open":"instant-open":"closed",[y]),k=s.useCallback(()=>{window.clearTimeout(m.current),m.current=0,b.current=!1,w(!0)},[w]),S=s.useCallback(()=>{window.clearTimeout(m.current),m.current=0,w(!1)},[w]),E=s.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{b.current=!0,w(!0),m.current=0},v)},[v,w]);return s.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),t.jsx(ps,{...u,children:t.jsx(Ps,{scope:n,contentId:p,open:y,stateAttribute:x,trigger:d,onTriggerChange:f,onTriggerEnter:s.useCallback(()=>{h.isOpenDelayedRef.current?E():k()},[h.isOpenDelayedRef,E,k]),onTriggerLeave:s.useCallback(()=>{g?S():(window.clearTimeout(m.current),m.current=0)},[S,g]),onOpen:k,onClose:S,disableHoverableContent:g,children:r})})};Bs.displayName=Ds;var Is="TooltipTrigger",js=s.forwardRef((e,n)=>{const{__scopeTooltip:r,...i}=e,o=Ls(Is,r),a=Ms(Is,r),l=Cs(r),c=Ye(n,s.useRef(null),o.onTriggerChange),h=s.useRef(!1),u=s.useRef(!1),d=s.useCallback(()=>h.current=!1,[]);return s.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),t.jsx(ms,{asChild:!0,...l,children:t.jsx(Kr.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...i,ref:c,onPointerMove:mt(e.onPointerMove,e=>{"touch"!==e.pointerType&&(u.current||a.isPointerInTransitRef.current||(o.onTriggerEnter(),u.current=!0))}),onPointerLeave:mt(e.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:mt(e.onPointerDown,()=>{o.open&&o.onClose(),h.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:mt(e.onFocus,()=>{h.current||o.onOpen()}),onBlur:mt(e.onBlur,o.onClose),onClick:mt(e.onClick,o.onClose)})})});js.displayName=Is;var[_s,Fs]=Ss("TooltipPortal",{forceMount:void 0}),Ws="TooltipContent",zs=s.forwardRef((e,n)=>{const r=Fs(Ws,e.__scopeTooltip),{forceMount:i=r.forceMount,side:o="top",...s}=e,a=Ls(Ws,e.__scopeTooltip);return t.jsx(bs,{present:i||a.open,children:a.disableHoverableContent?t.jsx($s,{side:o,...s,ref:n}):t.jsx(Hs,{side:o,...s,ref:n})})}),Hs=s.forwardRef((e,n)=>{const r=Ls(Ws,e.__scopeTooltip),i=Ms(Ws,e.__scopeTooltip),o=s.useRef(null),a=Ye(n,o),[l,c]=s.useState(null),{trigger:h,onClose:u}=r,d=o.current,{onPointerInTransitChange:f}=i,p=s.useCallback(()=>{c(null),f(!1)},[f]),m=s.useCallback((e,t)=>{const n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=function(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,i,o)){case o:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}(r,n.getBoundingClientRect()),o=function(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}(r,i),s=function(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}(t.getBoundingClientRect()),a=function(e){const t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),function(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const r=e[n];for(;t.length>=2;){const e=t[t.length-1],n=t[t.length-2];if(!((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x)))break;t.pop()}t.push(r)}t.pop();const n=[];for(let t=e.length-1;t>=0;t--){const r=e[t];for(;n.length>=2;){const e=n[n.length-1],t=n[n.length-2];if(!((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x)))break;n.pop()}n.push(r)}return n.pop(),1===t.length&&1===n.length&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}(t)}([...o,...s]);c(a),f(!0)},[f]);return s.useEffect(()=>()=>p(),[p]),s.useEffect(()=>{if(h&&d){const e=e=>m(e,d),t=e=>m(e,h);return h.addEventListener("pointerleave",e),d.addEventListener("pointerleave",t),()=>{h.removeEventListener("pointerleave",e),d.removeEventListener("pointerleave",t)}}},[h,d,m,p]),s.useEffect(()=>{if(l){const e=e=>{const t=e.target,n={x:e.clientX,y:e.clientY},r=h?.contains(t)||d?.contains(t),i=!function(e,t){const{x:n,y:r}=e;let i=!1;for(let e=0,o=t.length-1;e<t.length;o=e++){const s=t[e],a=t[o],l=s.x,c=s.y,h=a.x,u=a.y;c>r!=u>r&&n<(h-l)*(r-c)/(u-c)+l&&(i=!i)}return i}(n,l);r?p():i&&(p(),u())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[h,d,l,u,p]),t.jsx($s,{...e,ref:a})}),[Vs,qs]=Ss(Ds,{isInside:!1}),Us=function(e){const n=({children:e})=>t.jsx(t.Fragment,{children:e});return n.displayName=`${e}.Slottable`,n.__radixId=Ur,n}("TooltipContent"),$s=s.forwardRef((e,n)=>{const{__scopeTooltip:r,children:i,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:l,...c}=e,h=Ls(Ws,r),u=Cs(r),{onClose:d}=h;return s.useEffect(()=>(document.addEventListener(As,d),()=>document.removeEventListener(As,d)),[d]),s.useEffect(()=>{if(h.trigger){const e=e=>{const t=e.target;t?.contains(h.trigger)&&d()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[h.trigger,d]),t.jsx(Zr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:t.jsxs(gs,{"data-state":h.stateAttribute,...u,...c,ref:n,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[t.jsx(Us,{children:i}),t.jsx(Vs,{scope:r,isInside:!0,children:t.jsx(ks,{id:h.contentId,role:"tooltip",children:o||i})})]})})});zs.displayName=Ws;var Ks="TooltipArrow";s.forwardRef((e,n)=>{const{__scopeTooltip:r,...i}=e,o=Cs(r);return qs(Ks,r).isInside?null:t.jsx(vs,{...o,...i,ref:n})}).displayName=Ks;var Ys=zs,Gs=Rs,Xs=Bs,Js=js,Qs=s.forwardRef(function(e,t){var n=e.className,r=e.sideOffset,i=void 0===r?4:r,o=G(e,["className","sideOffset"]);return s.createElement(Ys,Object.assign({ref:t,sideOffset:i,className:qe("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",n)},o))});Qs.displayName=Ys.displayName;var Zs=s.createContext(null);function ea(){var e=s.useContext(Zs);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}function ta(e){var t=e.defaultOpen,n=void 0===t||t,r=e.open,i=e.onOpenChange,o=e.className,a=e.style,l=e.children,c=G(e,["defaultOpen","open","onOpenChange","className","style","children"]),h=function(){var e=m(s.useState(void 0),2),t=e[0],n=e[1];return s.useEffect(function(){var e=window.matchMedia("(max-width: ".concat(767,"px)")),t=function(){n(window.innerWidth<768)};return e.addEventListener("change",t),n(window.innerWidth<768),function(){return e.removeEventListener("change",t)}},[]),!!t}(),u=m(s.useState(!1),2),d=u[0],f=u[1],p=m(s.useState(n),2),g=p[0],v=p[1],b=null!=r?r:g,y=s.useCallback(function(e){var t="function"==typeof e?e(b):e;i?i(t):v(t),document.cookie="".concat("sidebar_state","=").concat(t,"; path=/; max-age=").concat(604800)},[i,b]),w=s.useCallback(function(){return h?f(function(e){return!e}):y(function(e){return!e})},[h,y,f]);s.useEffect(function(){var e=function(e){"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),w())};return window.addEventListener("keydown",e),function(){return window.removeEventListener("keydown",e)}},[w]);var x=b?"expanded":"collapsed",k=s.useMemo(function(){return{state:x,open:b,setOpen:y,isMobile:h,openMobile:d,setOpenMobile:f,toggleSidebar:w}},[x,b,y,h,d,f,w]);return s.createElement(Zs.Provider,{value:k},s.createElement(Gs,{delayDuration:0},s.createElement("div",Object.assign({style:Object.assign({"--sidebar-width":"16rem","--sidebar-width-icon":"3rem"},a),className:qe("group/sidebar-wrapper flex min-h-svh w-full",o)},c),l)))}function na(e){var t=e.side,n=void 0===t?"left":t,r=e.variant,i=void 0===r?"sidebar":r,o=e.collapsible,a=void 0===o?"offcanvas":o,l=e.className,c=e.children,h=G(e,["side","variant","collapsible","className","children"]),u=ea(),d=u.isMobile,f=u.state,p=u.openMobile,m=u.setOpenMobile;return"none"===a?s.createElement("div",Object.assign({className:qe("bg-sidebar text-sidebar-foreground flex h-full w-[var(--sidebar-width)] flex-col",l)},h),c):d?s.createElement(Ir,Object.assign({open:p,onOpenChange:m},h),s.createElement(Wr,{className:"bg-sidebar text-sidebar-foreground w-[var(--sidebar-width)] p-0 [&>button]:hidden",style:{"--sidebar-width":"18rem"},side:n},s.createElement(zr,{className:"sr-only"},s.createElement(Hr,null,"Sidebar"),s.createElement(Vr,null,"Displays the mobile sidebar.")),s.createElement("div",{className:"flex h-full w-full flex-col"},c))):s.createElement("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":f,"data-collapsible":"collapsed"===f?a:"","data-variant":i,"data-side":n},s.createElement("div",{className:qe("relative w-[var(--sidebar-width)] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","floating"===i||"inset"===i?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+1rem)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]")}),s.createElement("div",Object.assign({className:qe("fixed inset-y-0 z-10 hidden h-svh w-[var(--sidebar-width)] transition-[left,right,width] duration-200 ease-linear md:flex","left"===n?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===i||"inset"===i?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+1rem+2px)]":"group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)] group-data-[side=left]:border-r group-data-[side=right]:border-l",l)},h),s.createElement("div",{className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm"},c)))}function ra(e){var t=e.className,n=e.onClick,r=G(e,["className","onClick"]),i=ea().toggleSidebar;return s.createElement(at,Object.assign({variant:"ghost",size:"icon",className:qe("h-7 w-7",t),onClick:function(e){null==n||n(e),i()}},r),s.createElement(_,null),s.createElement("span",{className:"sr-only"},"Toggle Sidebar"))}function ia(e){var t=e.className,n=G(e,["className"]);return s.createElement("main",Object.assign({className:qe("bg-background relative flex w-full flex-1 flex-col","md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",t)},n))}function oa(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("flex flex-col gap-2 p-2",t)},n))}function sa(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("flex flex-col gap-2 p-2",t)},n))}function aa(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t)},n))}function la(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("relative flex w-full min-w-0 flex-col p-2",t)},n))}function ca(e){var t=e.className,n=e.asChild,r=void 0!==n&&n,i=G(e,["className","asChild"]),o=r?Ze:"div";return s.createElement(o,Object.assign({className:qe("text-sidebar-foreground/70 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium transition-[margin,opacity] duration-200 ease-linear [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",t)},i))}function ha(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("w-full text-sm",t)},n))}function ua(e){var t=e.className,n=G(e,["className"]);return s.createElement("ul",Object.assign({className:qe("flex w-full min-w-0 flex-col gap-1",t)},n))}function da(e){var t=e.className,n=G(e,["className"]);return s.createElement("li",Object.assign({className:qe("group/menu-item relative",t)},n))}var fa=ot("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function pa(e){var t=e.asChild,n=void 0!==t&&t,r=e.isActive,i=void 0!==r&&r,o=e.variant,a=void 0===o?"default":o,l=e.size,c=void 0===l?"default":l,h=e.tooltip,u=e.className,d=G(e,["asChild","isActive","variant","size","tooltip","className"]),f=n?Ze:"button",p=ea(),m=p.isMobile,g=p.state,v=s.createElement(f,Object.assign({"data-size":c,"data-active":i,className:qe(fa({variant:a,size:c}),u)},d));return h?("string"==typeof h&&(h={children:h}),s.createElement(Xs,null,s.createElement(Js,{asChild:!0},v),s.createElement(Qs,Object.assign({side:"right",align:"center",hidden:"collapsed"!==g||m},h)))):v}var ma=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=Qe(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),ga=s.forwardRef((e,n)=>t.jsx(ma.label,{...e,ref:n,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));ga.displayName="Label";var va=ga,ba=ot("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ya=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(va,Object.assign({ref:t,className:qe(ba(),n)},r))});ya.displayName=va.displayName;var wa=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:qe("rounded-lg border bg-card text-card-foreground shadow-sm",n)},r))});wa.displayName="Card";var xa=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:qe("flex flex-col space-y-1.5 p-6",n)},r))});xa.displayName="CardHeader";var ka=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:qe("text-2xl font-semibold leading-none tracking-tight",n)},r))});ka.displayName="CardTitle";var Sa=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:qe("text-sm text-muted-foreground",n)},r))});Sa.displayName="CardDescription";var Ea=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:qe("p-6 pt-0",n)},r))});Ea.displayName="CardContent";var Ca=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("div",Object.assign({ref:t,className:qe("flex items-center p-6 pt-0",n)},r))});Ca.displayName="CardFooter";var Oa={items:[],config:Object.assign({},{top:24,duration:3,maxCount:5})},Na=new Set;function Aa(){Na.forEach(function(e){return e(Oa.items.slice())})}function Ta(t){switch(t){case"success":return e.createElement(k,null);case"error":return e.createElement($,null);case"warning":return e.createElement(x,null);case"loading":return e.createElement(L,{className:"animate-spin"});default:return e.createElement(P,null)}}function Ma(e){var t,n,r;La();var i=Date.now(),o=null!==(t=e.key)&&void 0!==t?t:"msg_".concat(i,"_").concat(Math.random().toString(36).slice(2)),s=Oa.items.findIndex(function(e){return e.key===o}),a={key:o,content:e.content,duration:null!==(n=e.duration)&&void 0!==n?n:Oa.config.duration,type:e.type,onClose:e.onClose,icon:null!==(r=e.icon)&&void 0!==r?r:Ta(e.type),className:e.className,createdAt:i};return s>=0?Oa.items[s]=Object.assign({},Oa.items[s],a):(Oa.items.length>=Oa.config.maxCount&&Oa.items.shift(),Oa.items.push(a)),Aa(),a.duration>0&&"loading"!==a.type&&window.setTimeout(function(){Ra(o)},1e3*a.duration),{close:function(){return Ra(o)}}}function Ra(e){var t;if(void 0===e)return Oa.items.forEach(function(e){var t;return null===(t=e.onClose)||void 0===t?void 0:t.call(e)}),Oa.items=[],void Aa();var n=Oa.items.findIndex(function(t){return t.key===e});if(n>=0){var r=m(Oa.items.splice(n,1),1)[0];null===(t=null==r?void 0:r.onClose)||void 0===t||t.call(r),Aa()}}var Da=null,Pa=null;function La(){"undefined"!=typeof window&&(Pa||((Pa=document.createElement("div")).setAttribute("data-custom-message-holder",""),document.body.appendChild(Pa)),Da||(Da=r.createRoot(Pa)).render(e.createElement(Ba,null)))}function Ba(){var t=function(){var t=m(e.useState(Oa.items),2),n=t[0],r=t[1];return e.useEffect(function(){var e=r;return Na.add(e),function(){Na.delete(e)}},[]),n}(),n=Oa.config.top;return e.createElement("div",{className:"fixed left-1/2 -translate-x-1/2 z-[1000] w-80 pointer-events-none",style:{top:n}},e.createElement("div",{className:"mx-auto flex w-full max-w-xl flex-col items-center gap-2 px-4"},t.map(function(t){var n,r,i=function(e){switch(e){case"success":return{container:"border-green-200 bg-green-50/90 text-green-800 border-l-4 border-l-green-500",icon:"text-green-500",text:"text-green-800"};case"error":return{container:"border-red-200 bg-red-50/90 text-red-800 border-l-4 border-l-red-500",icon:"text-red-500",text:"text-red-800"};case"warning":return{container:"border-yellow-200 bg-yellow-50/90 text-yellow-800 border-l-4 border-l-yellow-500",icon:"text-yellow-500",text:"text-yellow-800"};default:return{container:"border-blue-200 bg-blue-50/90 text-blue-800 border-l-4 border-l-blue-500",icon:"text-blue-500",text:"text-blue-800"}}}(t.type);return e.createElement("div",{key:t.key,className:"pointer-events-auto flex w-full items-center gap-2 rounded-md border px-3 py-2 backdrop-blur ".concat(i.container," ").concat(null!==(n=t.className)&&void 0!==n?n:"")},e.createElement("span",{className:"text-[18px] leading-none ".concat(i.icon)},null!==(r=t.icon)&&void 0!==r?r:Ta(t.type)),e.createElement("div",{className:"min-w-0 flex-1 text-[14px] leading-normal ".concat(i.text)},"string"==typeof t.content?e.createElement("span",{className:"break-words align-middle"},t.content):t.content))})))}function Ia(t,n,r,i){if(e.isValidElement(n)||"string"==typeof n||"number"==typeof n)return{type:t,content:n,duration:r,onClose:i};var o=n;return Object.assign({},o,{type:t})}var ja,_a,Fa=(_a={open:function(e){var t;return Ma(Object.assign({},e,{type:null!==(t=e.type)&&void 0!==t?t:"info"}))},info:function(e,t,n){return Ma(Ia("info",e,t,n))},success:function(e,t,n){return Ma(Ia("success",e,t,n))},error:function(e,t,n){return Ma(Ia("error",e,t,n))},warning:function(e,t,n){return Ma(Ia("warning",e,t,n))},loading:function(e,t,n){return Ma(Ia("loading",e,null!=t?t:0,n))},destroy:function(e){return Ra(e)},config:function(e){return t=e,Oa.config=Object.assign({},Oa.config,t),void Aa();var t},useMessage:function(){var t=e.useMemo(function(){return"undefined"!=typeof window&&La(),e.createElement(e.Fragment,null)},[]);return[ja.current,t]}},(ja={}).current=_a,_a);function Wa(e,t){return function(){return e.apply(t,arguments)}}const{toString:za}=Object.prototype,{getPrototypeOf:Ha}=Object,{iterator:Va,toStringTag:qa}=Symbol,Ua=($a=Object.create(null),e=>{const t=za.call(e);return $a[t]||($a[t]=t.slice(8,-1).toLowerCase())});var $a;const Ka=e=>(e=e.toLowerCase(),t=>Ua(t)===e),Ya=e=>t=>typeof t===e,{isArray:Ga}=Array,Xa=Ya("undefined");function Ja(e){return null!==e&&!Xa(e)&&null!==e.constructor&&!Xa(e.constructor)&&el(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Qa=Ka("ArrayBuffer");const Za=Ya("string"),el=Ya("function"),tl=Ya("number"),nl=e=>null!==e&&"object"==typeof e,rl=e=>{if("object"!==Ua(e))return!1;const t=Ha(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||qa in e||Va in e)},il=Ka("Date"),ol=Ka("File"),sl=Ka("Blob"),al=Ka("FileList"),ll=Ka("URLSearchParams"),[cl,hl,ul,dl]=["ReadableStream","Request","Response","Headers"].map(Ka);function fl(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,i;if("object"!=typeof e&&(e=[e]),Ga(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(Ja(e))return;const i=n?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let s;for(r=0;r<o;r++)s=i[r],t.call(null,e[s],s,e)}}function pl(e,t){if(Ja(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r,i=n.length;for(;i-- >0;)if(r=n[i],t===r.toLowerCase())return r;return null}const ml="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,gl=e=>!Xa(e)&&e!==ml;const vl=(bl="undefined"!=typeof Uint8Array&&Ha(Uint8Array),e=>bl&&e instanceof bl);var bl;const yl=Ka("HTMLFormElement"),wl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),xl=Ka("RegExp"),kl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};fl(n,(n,i)=>{let o;!1!==(o=t(n,i,e))&&(r[i]=o||n)}),Object.defineProperties(e,r)};const Sl=Ka("AsyncFunction"),El=(Cl="function"==typeof setImmediate,Ol=el(ml.postMessage),Cl?setImmediate:Ol?(Nl=`axios@${Math.random()}`,Al=[],ml.addEventListener("message",({source:e,data:t})=>{e===ml&&t===Nl&&Al.length&&Al.shift()()},!1),e=>{Al.push(e),ml.postMessage(Nl,"*")}):e=>setTimeout(e));var Cl,Ol,Nl,Al;const Tl="undefined"!=typeof queueMicrotask?queueMicrotask.bind(ml):"undefined"!=typeof process&&process.nextTick||El;var Ml={isArray:Ga,isArrayBuffer:Qa,isBuffer:Ja,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||el(e.append)&&("formdata"===(t=Ua(e))||"object"===t&&el(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Qa(e.buffer),t},isString:Za,isNumber:tl,isBoolean:e=>!0===e||!1===e,isObject:nl,isPlainObject:rl,isEmptyObject:e=>{if(!nl(e)||Ja(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:cl,isRequest:hl,isResponse:ul,isHeaders:dl,isUndefined:Xa,isDate:il,isFile:ol,isBlob:sl,isRegExp:xl,isFunction:el,isStream:e=>nl(e)&&el(e.pipe),isURLSearchParams:ll,isTypedArray:vl,isFileList:al,forEach:fl,merge:function e(){const{caseless:t,skipUndefined:n}=gl(this)&&this||{},r={},i=(i,o)=>{const s=t&&pl(r,o)||o;rl(r[s])&&rl(i)?r[s]=e(r[s],i):rl(i)?r[s]=e({},i):Ga(i)?r[s]=i.slice():n&&Xa(i)||(r[s]=i)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&fl(arguments[e],i);return r},extend:(e,t,n,{allOwnKeys:r}={})=>(fl(t,(t,r)=>{n&&el(t)?e[r]=Wa(t,n):e[r]=t},{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let i,o,s;const a={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)s=i[o],r&&!r(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0);e=!1!==n&&Ha(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:Ua,kindOfTest:Ka,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(Ga(e))return e;let t=e.length;if(!tl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Va]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:yl,hasOwnProperty:wl,hasOwnProp:wl,reduceDescriptors:kl,freezeMethods:e=>{kl(e,(t,n)=>{if(el(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];el(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach(e=>{n[e]=!0})};return Ga(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:pl,global:ml,isContextDefined:gl,isSpecCompliantForm:function(e){return!!(e&&el(e.append)&&"FormData"===e[qa]&&e[Va])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(nl(e)){if(t.indexOf(e)>=0)return;if(Ja(e))return e;if(!("toJSON"in e)){t[r]=e;const i=Ga(e)?[]:{};return fl(e,(e,t)=>{const o=n(e,r+1);!Xa(o)&&(i[t]=o)}),t[r]=void 0,i}}return e};return n(e,0)},isAsyncFn:Sl,isThenable:e=>e&&(nl(e)||el(e))&&el(e.then)&&el(e.catch),setImmediate:El,asap:Tl,isIterable:e=>null!=e&&el(e[Va])};function Rl(e,t,n,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status?i.status:null)}Ml.inherits(Rl,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ml.toJSONObject(this.config),code:this.code,status:this.status}}});const Dl=Rl.prototype,Pl={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Pl[e]={value:e}}),Object.defineProperties(Rl,Pl),Object.defineProperty(Dl,"isAxiosError",{value:!0}),Rl.from=(e,t,n,r,i,o)=>{const s=Object.create(Dl);Ml.toFlatObject(e,s,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const a=e&&e.message?e.message:"Error",l=null==t&&e?e.code:t;return Rl.call(s,a,l,n,r,i),e&&null==s.cause&&Object.defineProperty(s,"cause",{value:e,configurable:!0}),s.name=e&&e.name||"Error",o&&Object.assign(s,o),s};function Ll(e){return Ml.isPlainObject(e)||Ml.isArray(e)}function Bl(e){return Ml.endsWith(e,"[]")?e.slice(0,-2):e}function Il(e,t,n){return e?e.concat(t).map(function(e,t){return e=Bl(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}const jl=Ml.toFlatObject(Ml,{},null,function(e){return/^is[A-Z]/.test(e)});function _l(e,t,n){if(!Ml.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=Ml.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Ml.isUndefined(t[e])})).metaTokens,i=n.visitor||c,o=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Ml.isSpecCompliantForm(t);if(!Ml.isFunction(i))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Ml.isDate(e))return e.toISOString();if(Ml.isBoolean(e))return e.toString();if(!a&&Ml.isBlob(e))throw new Rl("Blob is not supported. Use a Buffer instead.");return Ml.isArrayBuffer(e)||Ml.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,n,i){let a=e;if(e&&!i&&"object"==typeof e)if(Ml.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Ml.isArray(e)&&function(e){return Ml.isArray(e)&&!e.some(Ll)}(e)||(Ml.isFileList(e)||Ml.endsWith(n,"[]"))&&(a=Ml.toArray(e)))return n=Bl(n),a.forEach(function(e,r){!Ml.isUndefined(e)&&null!==e&&t.append(!0===s?Il([n],r,o):null===s?n:n+"[]",l(e))}),!1;return!!Ll(e)||(t.append(Il(i,n,o),l(e)),!1)}const h=[],u=Object.assign(jl,{defaultVisitor:c,convertValue:l,isVisitable:Ll});if(!Ml.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Ml.isUndefined(n)){if(-1!==h.indexOf(n))throw Error("Circular reference detected in "+r.join("."));h.push(n),Ml.forEach(n,function(n,o){!0===(!(Ml.isUndefined(n)||null===n)&&i.call(t,n,Ml.isString(o)?o.trim():o,r,u))&&e(n,r?r.concat(o):[o])}),h.pop()}}(e),t}function Fl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Wl(e,t){this._pairs=[],e&&_l(e,this,t)}const zl=Wl.prototype;function Hl(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Vl(e,t,n){if(!t)return e;const r=n&&n.encode||Hl;Ml.isFunction(n)&&(n={serialize:n});const i=n&&n.serialize;let o;if(o=i?i(t,n):Ml.isURLSearchParams(t)?t.toString():new Wl(t,n).toString(r),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}zl.append=function(e,t){this._pairs.push([e,t])},zl.toString=function(e){const t=e?function(t){return e.call(this,t,Fl)}:Fl;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var ql=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Ml.forEach(this.handlers,function(t){null!==t&&e(t)})}},Ul={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},$l={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Wl,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const Kl="undefined"!=typeof window&&"undefined"!=typeof document,Yl="object"==typeof navigator&&navigator||void 0,Gl=Kl&&(!Yl||["ReactNative","NativeScript","NS"].indexOf(Yl.product)<0),Xl="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Jl=Kl&&window.location.href||"http://localhost";var Ql={...Object.freeze({__proto__:null,hasBrowserEnv:Kl,hasStandardBrowserEnv:Gl,hasStandardBrowserWebWorkerEnv:Xl,navigator:Yl,origin:Jl}),...$l};function Zl(e){function t(e,n,r,i){let o=e[i++];if("__proto__"===o)return!0;const s=Number.isFinite(+o),a=i>=e.length;if(o=!o&&Ml.isArray(r)?r.length:o,a)return Ml.hasOwnProp(r,o)?r[o]=[r[o],n]:r[o]=n,!s;r[o]&&Ml.isObject(r[o])||(r[o]=[]);return t(e,n,r[o],i)&&Ml.isArray(r[o])&&(r[o]=function(e){const t={},n=Object.keys(e);let r;const i=n.length;let o;for(r=0;r<i;r++)o=n[r],t[o]=e[o];return t}(r[o])),!s}if(Ml.isFormData(e)&&Ml.isFunction(e.entries)){const n={};return Ml.forEachEntry(e,(e,r)=>{t(function(e){return Ml.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null}const ec={transitional:Ul,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,i=Ml.isObject(e);i&&Ml.isHTMLForm(e)&&(e=new FormData(e));if(Ml.isFormData(e))return r?JSON.stringify(Zl(e)):e;if(Ml.isArrayBuffer(e)||Ml.isBuffer(e)||Ml.isStream(e)||Ml.isFile(e)||Ml.isBlob(e)||Ml.isReadableStream(e))return e;if(Ml.isArrayBufferView(e))return e.buffer;if(Ml.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return _l(e,new Ql.classes.URLSearchParams,{visitor:function(e,t,n,r){return Ql.isNode&&Ml.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((o=Ml.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return _l(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),function(e,t,n){if(Ml.isString(e))try{return(t||JSON.parse)(e),Ml.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||ec.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Ml.isResponse(e)||Ml.isReadableStream(e))return e;if(e&&Ml.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n){if("SyntaxError"===e.name)throw Rl.from(e,Rl.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ql.classes.FormData,Blob:Ql.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ml.forEach(["delete","get","head","post","put","patch"],e=>{ec.headers[e]={}});var tc=ec;const nc=Ml.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const rc=Symbol("internals");function ic(e){return e&&String(e).trim().toLowerCase()}function oc(e){return!1===e||null==e?e:Ml.isArray(e)?e.map(oc):String(e)}function sc(e,t,n,r,i){return Ml.isFunction(r)?r.call(this,t,n):(i&&(t=n),Ml.isString(t)?Ml.isString(r)?-1!==t.indexOf(r):Ml.isRegExp(r)?r.test(t):void 0:void 0)}class ac{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function i(e,t,n){const i=ic(t);if(!i)throw new Error("header name must be a non-empty string");const o=Ml.findKey(r,i);(!o||void 0===r[o]||!0===n||void 0===n&&!1!==r[o])&&(r[o||t]=oc(e))}const o=(e,t)=>Ml.forEach(e,(e,n)=>i(e,n,t));if(Ml.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(Ml.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let n,r,i;return e&&e.split("\n").forEach(function(e){i=e.indexOf(":"),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!n||t[n]&&nc[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t})(e),t);else if(Ml.isObject(e)&&Ml.isIterable(e)){let n,r,i={};for(const t of e){if(!Ml.isArray(t))throw TypeError("Object iterator must return a key-value pair");i[r=t[0]]=(n=i[r])?Ml.isArray(n)?[...n,t[1]]:[n,t[1]]:t[1]}o(i,t)}else null!=e&&i(t,e,n);return this}get(e,t){if(e=ic(e)){const n=Ml.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(Ml.isFunction(t))return t.call(this,e,n);if(Ml.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ic(e)){const n=Ml.findKey(this,e);return!(!n||void 0===this[n]||t&&!sc(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function i(e){if(e=ic(e)){const i=Ml.findKey(n,e);!i||t&&!sc(0,n[i],i,t)||(delete n[i],r=!0)}}return Ml.isArray(e)?e.forEach(i):i(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const i=t[n];e&&!sc(0,this[i],i,e,!0)||(delete this[i],r=!0)}return r}normalize(e){const t=this,n={};return Ml.forEach(this,(r,i)=>{const o=Ml.findKey(n,i);if(o)return t[o]=oc(r),void delete t[i];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(i):String(i).trim();s!==i&&delete t[i],t[s]=oc(r),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Ml.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&Ml.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[rc]=this[rc]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=ic(e);t[r]||(!function(e,t){const n=Ml.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}(n,e),t[r]=!0)}return Ml.isArray(e)?e.forEach(r):r(e),this}}ac.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Ml.reduceDescriptors(ac.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),Ml.freezeMethods(ac);var lc=ac;function cc(e,t){const n=this||tc,r=t||n,i=lc.from(r.headers);let o=r.data;return Ml.forEach(e,function(e){o=e.call(n,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function hc(e){return!(!e||!e.__CANCEL__)}function uc(e,t,n){Rl.call(this,null==e?"canceled":e,Rl.ERR_CANCELED,t,n),this.name="CanceledError"}function dc(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new Rl("Request failed with status code "+n.status,[Rl.ERR_BAD_REQUEST,Rl.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}Ml.inherits(uc,Rl,{__CANCEL__:!0});const fc=(e,t,n=3)=>{let r=0;const i=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let i,o=0,s=0;return t=void 0!==t?t:1e3,function(a){const l=Date.now(),c=r[s];i||(i=l),n[o]=a,r[o]=l;let h=s,u=0;for(;h!==o;)u+=n[h++],h%=e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),l-i<t)return;const d=c&&l-c;return d?Math.round(1e3*u/d):void 0}}(50,250);return function(e,t){let n,r,i=0,o=1e3/t;const s=(t,o=Date.now())=>{i=o,n=null,r&&(clearTimeout(r),r=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-i;a>=o?s(e,t):(n=e,r||(r=setTimeout(()=>{r=null,s(n)},o-a)))},()=>n&&s(n)]}(n=>{const o=n.loaded,s=n.lengthComputable?n.total:void 0,a=o-r,l=i(a);r=o;e({loaded:o,total:s,progress:s?o/s:void 0,bytes:a,rate:l||void 0,estimated:l&&s&&o<=s?(s-o)/l:void 0,event:n,lengthComputable:null!=s,[t?"download":"upload"]:!0})},n)},pc=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},mc=e=>(...t)=>Ml.asap(()=>e(...t));var gc=Ql.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Ql.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Ql.origin),Ql.navigator&&/(msie|trident)/i.test(Ql.navigator.userAgent)):()=>!0,vc=Ql.hasStandardBrowserEnv?{write(e,t,n,r,i,o,s){if("undefined"==typeof document)return;const a=[`${e}=${encodeURIComponent(t)}`];Ml.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),Ml.isString(r)&&a.push(`path=${r}`),Ml.isString(i)&&a.push(`domain=${i}`),!0===o&&a.push("secure"),Ml.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}};function bc(e,t,n){let r=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(r||0==n)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const yc=e=>e instanceof lc?{...e}:e;function wc(e,t){t=t||{};const n={};function r(e,t,n,r){return Ml.isPlainObject(e)&&Ml.isPlainObject(t)?Ml.merge.call({caseless:r},e,t):Ml.isPlainObject(t)?Ml.merge({},t):Ml.isArray(t)?t.slice():t}function i(e,t,n,i){return Ml.isUndefined(t)?Ml.isUndefined(e)?void 0:r(void 0,e,0,i):r(e,t,0,i)}function o(e,t){if(!Ml.isUndefined(t))return r(void 0,t)}function s(e,t){return Ml.isUndefined(t)?Ml.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,i,o){return o in t?r(n,i):o in e?r(void 0,n):void 0}const l={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,n)=>i(yc(e),yc(t),0,!0)};return Ml.forEach(Object.keys({...e,...t}),function(r){const o=l[r]||i,s=o(e[r],t[r],r);Ml.isUndefined(s)&&o!==a||(n[r]=s)}),n}var xc=e=>{const t=wc({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;if(t.headers=s=lc.from(s),t.url=Vl(bc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Ml.isFormData(n))if(Ql.hasStandardBrowserEnv||Ql.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(Ml.isFunction(n.getHeaders)){const e=n.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&s.set(e,n)})}if(Ql.hasStandardBrowserEnv&&(r&&Ml.isFunction(r)&&(r=r(t)),r||!1!==r&&gc(t.url))){const e=i&&o&&vc.read(o);e&&s.set(i,e)}return t};var kc="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=xc(e);let i=r.data;const o=lc.from(r.headers).normalize();let s,a,l,c,h,{responseType:u,onUploadProgress:d,onDownloadProgress:f}=r;function p(){c&&c(),h&&h(),r.cancelToken&&r.cancelToken.unsubscribe(s),r.signal&&r.signal.removeEventListener("abort",s)}let m=new XMLHttpRequest;function g(){if(!m)return;const r=lc.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());dc(function(e){t(e),p()},function(e){n(e),p()},{data:u&&"text"!==u&&"json"!==u?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new Rl("Request aborted",Rl.ECONNABORTED,e,m)),m=null)},m.onerror=function(t){const r=new Rl(t&&t.message?t.message:"Network Error",Rl.ERR_NETWORK,e,m);r.event=t||null,n(r),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const i=r.transitional||Ul;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new Rl(t,i.clarifyTimeoutError?Rl.ETIMEDOUT:Rl.ECONNABORTED,e,m)),m=null},void 0===i&&o.setContentType(null),"setRequestHeader"in m&&Ml.forEach(o.toJSON(),function(e,t){m.setRequestHeader(t,e)}),Ml.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),u&&"json"!==u&&(m.responseType=r.responseType),f&&([l,h]=fc(f,!0),m.addEventListener("progress",l)),d&&m.upload&&([a,c]=fc(d),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",c)),(r.cancelToken||r.signal)&&(s=t=>{m&&(n(!t||t.type?new uc(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(s),r.signal&&(r.signal.aborted?s():r.signal.addEventListener("abort",s)));const v=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);v&&-1===Ql.protocols.indexOf(v)?n(new Rl("Unsupported protocol "+v+":",Rl.ERR_BAD_REQUEST,e)):m.send(i||null)})};var Sc=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const i=function(e){if(!n){n=!0,s();const t=e instanceof Error?e:this.reason;r.abort(t instanceof Rl?t:new uc(t instanceof Error?t.message:t))}};let o=t&&setTimeout(()=>{o=null,i(new Rl(`timeout ${t} of ms exceeded`,Rl.ETIMEDOUT))},t);const s=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)}),e=null)};e.forEach(e=>e.addEventListener("abort",i));const{signal:a}=r;return a.unsubscribe=()=>Ml.asap(s),a}};const Ec=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,i=0;for(;i<n;)r=i+t,yield e.slice(i,r),i=r},Cc=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},Oc=(e,t,n,r)=>{const i=async function*(e,t){for await(const n of Cc(e))yield*Ec(n,t)}(e,t);let o,s=0,a=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await i.next();if(t)return a(),void e.close();let o=r.byteLength;if(n){let e=s+=o;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),i.return())},{highWaterMark:2})},{isFunction:Nc}=Ml,Ac=(({Request:e,Response:t})=>({Request:e,Response:t}))(Ml.global),{ReadableStream:Tc,TextEncoder:Mc}=Ml.global,Rc=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Dc=e=>{e=Ml.merge.call({skipUndefined:!0},Ac,e);const{fetch:t,Request:n,Response:r}=e,i=t?Nc(t):"function"==typeof fetch,o=Nc(n),s=Nc(r);if(!i)return!1;const a=i&&Nc(Tc),l=i&&("function"==typeof Mc?(c=new Mc,e=>c.encode(e)):async e=>new Uint8Array(await new n(e).arrayBuffer()));var c;const h=o&&a&&Rc(()=>{let e=!1;const t=new n(Ql.origin,{body:new Tc,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),u=s&&a&&Rc(()=>Ml.isReadableStream(new r("").body)),d={stream:u&&(e=>e.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!d[e]&&(d[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new Rl(`Response type '${e}' is not supported`,Rl.ERR_NOT_SUPPORT,n)})});const f=async(e,t)=>{const r=Ml.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Ml.isBlob(e))return e.size;if(Ml.isSpecCompliantForm(e)){const t=new n(Ql.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Ml.isArrayBufferView(e)||Ml.isArrayBuffer(e)?e.byteLength:(Ml.isURLSearchParams(e)&&(e+=""),Ml.isString(e)?(await l(e)).byteLength:void 0)})(t):r};return async e=>{let{url:i,method:s,data:a,signal:l,cancelToken:c,timeout:p,onDownloadProgress:m,onUploadProgress:g,responseType:v,headers:b,withCredentials:y="same-origin",fetchOptions:w}=xc(e),x=t||fetch;v=v?(v+"").toLowerCase():"text";let k=Sc([l,c&&c.toAbortSignal()],p),S=null;const E=k&&k.unsubscribe&&(()=>{k.unsubscribe()});let C;try{if(g&&h&&"get"!==s&&"head"!==s&&0!==(C=await f(b,a))){let e,t=new n(i,{method:"POST",body:a,duplex:"half"});if(Ml.isFormData(a)&&(e=t.headers.get("content-type"))&&b.setContentType(e),t.body){const[e,n]=pc(C,fc(mc(g)));a=Oc(t.body,65536,e,n)}}Ml.isString(y)||(y=y?"include":"omit");const t=o&&"credentials"in n.prototype,l={...w,signal:k,method:s.toUpperCase(),headers:b.normalize().toJSON(),body:a,duplex:"half",credentials:t?y:void 0};S=o&&new n(i,l);let c=await(o?x(S,w):x(i,l));const p=u&&("stream"===v||"response"===v);if(u&&(m||p&&E)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=c[t]});const t=Ml.toFiniteNumber(c.headers.get("content-length")),[n,i]=m&&pc(t,fc(mc(m),!0))||[];c=new r(Oc(c.body,65536,n,()=>{i&&i(),E&&E()}),e)}v=v||"text";let O=await d[Ml.findKey(d,v)||"text"](c,e);return!p&&E&&E(),await new Promise((t,n)=>{dc(t,n,{data:O,headers:lc.from(c.headers),status:c.status,statusText:c.statusText,config:e,request:S})})}catch(t){if(E&&E(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new Rl("Network Error",Rl.ERR_NETWORK,e,S),{cause:t.cause||t});throw Rl.from(t,t&&t.code,e,S)}}},Pc=new Map,Lc=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:i}=t,o=[r,i,n];let s,a,l=o.length,c=Pc;for(;l--;)s=o[l],a=c.get(s),void 0===a&&c.set(s,a=l?new Map:Dc(t)),c=a;return a};Lc();const Bc={http:null,xhr:kc,fetch:{get:Lc}};Ml.forEach(Bc,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const Ic=e=>`- ${e}`,jc=e=>Ml.isFunction(e)||null===e||!1===e;var _c={getAdapter:function(e,t){e=Ml.isArray(e)?e:[e];const{length:n}=e;let r,i;const o={};for(let s=0;s<n;s++){let n;if(r=e[s],i=r,!jc(r)&&(i=Bc[(n=String(r)).toLowerCase()],void 0===i))throw new Rl(`Unknown adapter '${n}'`);if(i&&(Ml.isFunction(i)||(i=i.get(t))))break;o[n||"#"+s]=i}if(!i){const e=Object.entries(o).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new Rl("There is no suitable adapter to dispatch the request "+(n?e.length>1?"since :\n"+e.map(Ic).join("\n"):" "+Ic(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return i},adapters:Bc};function Fc(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new uc(null,e)}function Wc(e){Fc(e),e.headers=lc.from(e.headers),e.data=cc.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return _c.getAdapter(e.adapter||tc.adapter,e)(e).then(function(t){return Fc(e),t.data=cc.call(e,e.transformResponse,t),t.headers=lc.from(t.headers),t},function(t){return hc(t)||(Fc(e),t&&t.response&&(t.response.data=cc.call(e,e.transformResponse,t.response),t.response.headers=lc.from(t.response.headers))),Promise.reject(t)})}const zc="1.13.2",Hc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Hc[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const Vc={};Hc.transitional=function(e,t,n){return(r,i,o)=>{if(!1===e)throw new Rl(function(e,t){return"[Axios v"+zc+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}(i," has been removed"+(t?" in "+t:"")),Rl.ERR_DEPRECATED);return t&&!Vc[i]&&(Vc[i]=!0),!e||e(r,i,o)}},Hc.spelling=function(e){return(e,t)=>!0};var qc={assertOptions:function(e,t,n){if("object"!=typeof e)throw new Rl("options must be an object",Rl.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let i=r.length;for(;i-- >0;){const o=r[i],s=t[o];if(s){const t=e[o],n=void 0===t||s(t,o,e);if(!0!==n)throw new Rl("option "+o+" must be "+n,Rl.ERR_BAD_OPTION_VALUE);continue}if(!0!==n)throw new Rl("Unknown option "+o,Rl.ERR_BAD_OPTION)}},validators:Hc};const Uc=qc.validators;class $c{constructor(e){this.defaults=e||{},this.interceptors={request:new ql,response:new ql}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=wc(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:i}=t;void 0!==n&&qc.assertOptions(n,{silentJSONParsing:Uc.transitional(Uc.boolean),forcedJSONParsing:Uc.transitional(Uc.boolean),clarifyTimeoutError:Uc.transitional(Uc.boolean)},!1),null!=r&&(Ml.isFunction(r)?t.paramsSerializer={serialize:r}:qc.assertOptions(r,{encode:Uc.function,serialize:Uc.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),qc.assertOptions(t,{baseUrl:Uc.spelling("baseURL"),withXsrfToken:Uc.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&Ml.merge(i.common,i[t.method]);i&&Ml.forEach(["delete","get","head","post","put","patch","common"],e=>{delete i[e]}),t.headers=lc.concat(o,i);const s=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const l=[];let c;this.interceptors.response.forEach(function(e){l.push(e.fulfilled,e.rejected)});let h,u=0;if(!a){const e=[Wc.bind(this),void 0];for(e.unshift(...s),e.push(...l),h=e.length,c=Promise.resolve(t);u<h;)c=c.then(e[u++],e[u++]);return c}h=s.length;let d=t;for(;u<h;){const e=s[u++],t=s[u++];try{d=e(d)}catch(e){t.call(this,e);break}}try{c=Wc.call(this,d)}catch(e){return Promise.reject(e)}for(u=0,h=l.length;u<h;)c=c.then(l[u++],l[u++]);return c}getUri(e){return Vl(bc((e=wc(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}Ml.forEach(["delete","get","head","options"],function(e){$c.prototype[e]=function(t,n){return this.request(wc(n||{},{method:e,url:t,data:(n||{}).data}))}}),Ml.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,i){return this.request(wc(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}$c.prototype[e]=t(),$c.prototype[e+"Form"]=t(!0)});var Kc=$c;class Yc{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new uc(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new Yc(function(t){e=t}),cancel:e}}}var Gc=Yc;const Xc={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Xc).forEach(([e,t])=>{Xc[t]=e});var Jc=Xc;const Qc=function e(t){const n=new Kc(t),r=Wa(Kc.prototype.request,n);return Ml.extend(r,Kc.prototype,n,{allOwnKeys:!0}),Ml.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(wc(t,n))},r}(tc);Qc.Axios=Kc,Qc.CanceledError=uc,Qc.CancelToken=Gc,Qc.isCancel=hc,Qc.VERSION=zc,Qc.toFormData=_l,Qc.AxiosError=Rl,Qc.Cancel=Qc.CanceledError,Qc.all=function(e){return Promise.all(e)},Qc.spread=function(e){return function(t){return e.apply(null,t)}},Qc.isAxiosError=function(e){return Ml.isObject(e)&&!0===e.isAxiosError},Qc.mergeConfig=wc,Qc.AxiosHeaders=lc,Qc.formToJSON=e=>Zl(Ml.isHTMLForm(e)?new FormData(e):e),Qc.getAdapter=_c.getAdapter,Qc.HttpStatusCode=Jc,Qc.default=Qc;var Zc=Qc.create({baseURL:"/api/cms",timeout:1e4,headers:{"Content-Type":"application/json"}}),eh=new Map;Zc.interceptors.request.use(function(e){e.url&&e.url.startsWith("http")&&(e.baseURL="");var t=localStorage.getItem("cms_token");t&&(e.headers.Authorization="Bearer ".concat(t));var n=localStorage.getItem("cms_session_id");return n&&(e.headers["X-Session-Id"]=n),e},function(e){return Promise.reject(e)}),Zc.interceptors.response.use(function(e){return e},function(e){var t="请求错误",n=!1;if(e.response){var r=e.response.status,i=e.response.data;401===r?"登录已过期,请重新登录"===(null==i?void 0:i.message)?(t="登录已过期,请重新登录",n=!0):"认证信息无效"===(null==i?void 0:i.message)?(t="认证信息无效,请重新登录",n=!0):(t="认证失败,请登录",n=!0):t=(null==i?void 0:i.message)||"HTTP ".concat(r,": ").concat(e.response.statusText)}else t=e.request?"网络连接失败,请检查网络状态":e.message||"请求错误";return n?(localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user"),"/login"!==window.location.pathname&&"/"!==window.location.pathname&&(Fa.error(t),setTimeout(function(){window.location.reload()},1e3))):Fa.error(t),Promise.reject(e)});var th,nh=function(e,t,n){var r=e;if(t){var i=new URLSearchParams(t).toString();r=r+(r.includes("?")?"&":"?")+i}var o="GET ".concat(r),s=eh.get(o);if(s)return s;var a=Zc.get(r,n).then(function(e){return e.data}).finally(function(){eh.delete(o)});return eh.set(o,a),a},rh=function(e,t,n){return Zc.post(e,t,n).then(function(e){return e.data})},ih=function(e,t,n){return Zc.put(e,t,n).then(function(e){return e.data})},oh=function(e,t){return Zc.delete(e,t).then(function(e){return e.data})};try{var sh=localStorage.getItem("cms_session_id")||void 0;th=sh}catch($k){}var ah=function(){return nh("/models")},lh=function(){return nh("/auth/signup/status/".concat(th?th+"_":"","cms_users"))},ch=function(e){return rh("/auth/signup/".concat(th?th+"_":"","cms_users"),e)},hh=function(e){return rh("/auth/login/".concat(th?th+"_":"","cms_users"),e)},uh=function(){return rh("/auth/verify/".concat(th?th+"_":"","cms_users"))},dh=function(){return nh("/auth/user/".concat(th?th+"_":"","cms_users"))},fh=function(){localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user")},ph=function(){return localStorage.getItem("cms_token")},mh=function(){var e=localStorage.getItem("cms_user");return e?JSON.parse(e):null},gh=function(e,t){var n=t?Object.assign({},t):void 0;return(null==n?void 0:n.filters)&&Array.isArray(n.filters)&&(n.filters=JSON.stringify(n.filters)),nh("/data/".concat(th?th+"_":"").concat(e),n)},vh=function(e,t){return nh("/relation/".concat(th?th+"_":"").concat(e,"/options"),t)},bh=function(e,t){return rh("/data/".concat(th?th+"_":"").concat(e),t)},yh=function(e,t){return ih("/data/".concat(th?th+"_":"").concat(e),t)},wh=function(e,t){return oh("/data/".concat(th?th+"_":"").concat(e,"?id=").concat(t))};function xh(t){var n=t.onLoginSuccess,r=m(e.useState(""),2),i=r[0],o=r[1],s=m(e.useState(""),2),a=s[0],l=s[1],c=m(e.useState(!1),2),u=c[0],d=c[1],p=m(e.useState("login"),2),g=p[0],v=p[1];e.useEffect(function(){var e=ph();if(e){var t=function(){var t=h(f().m(function t(){var r;return f().w(function(t){for(;;)switch(t.p=t.n){case 0:return d(!0),t.p=1,t.n=2,uh();case 2:if(t.v.success){t.n=3;break}throw new Error("token验证失败");case 3:return t.n=4,dh();case 4:if(!(r=t.v).success||!r.data){t.n=5;break}localStorage.setItem("cms_user",JSON.stringify(r.data)),null==n||n(e,r.data),t.n=6;break;case 5:throw new Error("获取用户信息失败");case 6:t.n=8;break;case 7:t.p=7,t.v,fh();case 8:return t.p=8,d(!1),t.f(8);case 9:return t.a(2)}},t,null,[[1,7,8,9]])}));return function(){return t.apply(this,arguments)}}();t()}},[n]),e.useEffect(function(){if(!ph()){var e=function(){var e=h(f().m(function e(){var t,n;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:return d(!0),e.p=1,e.n=2,lh();case 2:(n=e.v).success&&(null===(t=n.data)||void 0===t?void 0:t.allowSignup)?v("signup"):v("login"),e.n=4;break;case 3:e.p=3,e.v,v("login");case 4:return e.p=4,d(!1),e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}));return function(){return e.apply(this,arguments)}}();e()}},[]);var b=function(){var e=h(f().m(function e(t){var r,o,s,l,c;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t.preventDefault(),i&&a){e.n=1;break}return Fa.error("请完善登录信息"),e.a(2);case 1:if(d(!0),e.p=2,"signup"!==g){e.n=4;break}return e.n=3,ch({username:i,password:a});case 3:l=e.v,e.n=6;break;case 4:return e.n=5,hh({username:i,password:a});case 5:l=e.v;case 6:if((s=l).success&&(null===(r=s.data)||void 0===r?void 0:r.token)){e.n=7;break}return Fa.error(s.message||"登录失败"),"signup"===g&&(null===(o=s.message)||void 0===o?void 0:o.includes("已存在管理员"))&&v("login"),e.a(2);case 7:localStorage.setItem("cms_token",s.data.token),localStorage.setItem("cms_user",JSON.stringify(s.data.user)),null==n||n(s.data.token,s.data.user),e.n=9;break;case 8:e.p=8,c=e.v,Fa.error("登陆失败,".concat(c.message||"网络错误,请稍后重试"));case 9:return e.p=9,d(!1),e.f(9);case 10:return e.a(2)}},e,null,[[2,8,9,10]])}));return function(t){return e.apply(this,arguments)}}();return e.createElement("div",{className:"min-h-screen flex relative overflow-hidden bg-white"},e.createElement("div",{className:"pointer-events-none absolute inset-0"},e.createElement("div",{className:"absolute inset-0 bg-[linear-gradient(110deg,#ffffff_0%,#f7fbff_40%,#edf6ff_70%,#eaf3ff_100%)]"}),e.createElement("div",{className:"absolute inset-0 bg-[radial-gradient(1200px_600px_at_-10%_-10%,rgba(59,130,246,0.12),transparent),radial-gradient(900px_500px_at_110%_20%,rgba(147,51,234,0.10),transparent),radial-gradient(700px_400px_at_60%_120%,rgba(99,102,241,0.10),transparent)]"}),e.createElement("div",{className:"absolute inset-0 bg-[linear-gradient(115deg,rgba(255,255,255,0.6)_0%,rgba(255,255,255,0.15)_32%,transparent_32%,transparent_68%,rgba(255,255,255,0.15)_68%,rgba(255,255,255,0.6)_100%)]"})),e.createElement("div",{className:"flex-1 relative flex items-center justify-center"},e.createElement("div",{className:"relative z-10 max-w-4xl w-full px-16 text-left"},e.createElement("div",{className:"mb-12"},e.createElement("div",{className:"inline-flex items-center rounded-2xl px-4 py-2 bg-white/70 backdrop-blur border border-white/60"},e.createElement("span",{className:"text-2xl font-semibold tracking-tight text-gray-900"},"CMS 管理后台")),e.createElement("h1",{className:"mt-8 text-5xl md:text-6xl font-extrabold leading-tight text-gray-900"},"内容管理平台"),e.createElement("p",{className:"mt-6 text-2xl text-gray-600"},"一站式管理、协作与发布")),e.createElement("div",{className:"mt-8 flex items-center text-gray-500 gap-6"},e.createElement("span",{className:"flex items-center gap-2"},e.createElement("span",{className:"h-2 w-2 rounded-full bg-blue-500"}),"多角色权限"),e.createElement("span",{className:"flex items-center gap-2"},e.createElement("span",{className:"h-2 w-2 rounded-full bg-violet-500"}),"结构化内容"),e.createElement("span",{className:"flex items-center gap-2"},e.createElement("span",{className:"h-2 w-2 rounded-full bg-indigo-500"}),"可扩展 API")))),e.createElement("div",{className:"w-[480px] min-w-[380px] flex items-center justify-center p-8 mt-30"},e.createElement("div",{className:"w-full max-w-sm"},u?e.createElement(wa,{className:"bg-white/30 backdrop-blur-xl border border-white/50 shadow-none rounded-3xl overflow-hidden"},e.createElement(Ea,{className:"p-8"},e.createElement("div",{className:"space-y-4"},e.createElement(Ue,{className:"h-12 w-48"}),e.createElement(Ue,{className:"h-4 w-64"}),e.createElement(Ue,{className:"h-10 w-full"}),e.createElement(Ue,{className:"h-10 w-full"})))):e.createElement(wa,{className:"bg-white/30 backdrop-blur-xl border border-white/50 shadow-none rounded-3xl overflow-hidden"},e.createElement(xa,{className:"p-8 pb-6"},e.createElement(ka,{className:"text-center text-2xl mb-2 text-gray-800"},"signup"===g?"创建管理员账号":"欢迎使用 CMS 管理后台"),e.createElement(Sa,{className:"text-center text-gray-500"},"signup"===g?"首次进入需要先创建一个管理员账号":"请输入账号和密码登录")),e.createElement(Ea,{className:"p-8 pt-0"},e.createElement("form",{onSubmit:b,className:"space-y-6"},e.createElement("div",{className:"space-y-2"},e.createElement(ya,{htmlFor:"username"},"账号/邮箱"),e.createElement("div",{className:"relative"},e.createElement(U,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),e.createElement(lt,{id:"username",type:"text",placeholder:"邮箱",value:i,onChange:function(e){return o(e.target.value)},className:"pl-10 h-12 rounded-xl border-gray-200 hover:border-blue-400 focus:border-blue-500 transition-colors",required:!0,minLength:2}))),e.createElement("div",{className:"space-y-2"},e.createElement(ya,{htmlFor:"password"},"密码"),e.createElement("div",{className:"relative"},e.createElement(B,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),e.createElement(lt,{id:"password",type:"password",placeholder:"密码",value:a,onChange:function(e){return l(e.target.value)},className:"pl-10 h-12 rounded-xl border-gray-200 hover:border-blue-400 focus:border-blue-500 transition-colors",required:!0,minLength:6}))),e.createElement(at,{type:"submit",className:"w-full h-12 rounded-xl transition-all duration-200 font-semibold text-base shadow-lg hover:brightness-[1.03] active:scale-[0.99]",style:{backgroundImage:"linear-gradient(135deg, rgba(236, 248, 255, 0.78) 0%, rgba(221, 238, 255, 0.78) 100%)",color:"rgba(0, 0, 0, 0.7)",border:"none",boxShadow:"0 6px 24px rgba(37, 99, 235, 0.12)"},disabled:u},e.createElement(I,{className:"h-4 w-4 mr-2"}),u?"signup"===g?"创建中...":"登录中...":"signup"===g?"创建账号并进入":"登录"),e.createElement("div",{className:"text-center text-sm text-gray-500"},"signup"===g?e.createElement("button",{type:"button",className:"underline underline-offset-4 hover:text-gray-700",onClick:function(){return v("login")},disabled:u},"已有账号?去登录"):e.createElement("button",{type:"button",className:"underline underline-offset-4 hover:text-gray-700",onClick:function(){return v("signup")},disabled:u},"首次使用?创建管理员"))))))))}function kh(e,[t,n]){return Math.min(n,Math.max(t,e))}function Sh(e){const n=Eh(e),r=s.forwardRef((e,r)=>{const{children:i,...o}=e,a=s.Children.toArray(i),l=a.find(Oh);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}function Eh(e){const t=s.forwardRef((e,t)=>{const{children:n,...r}=e;if(s.isValidElement(n)){const e=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?Ke(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ch=Symbol("radix.slottable");function Oh(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Ch}var Nh=s.createContext(void 0);var Ah=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=Sh(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});var Th,Mh="dismissableLayer.update",Rh="dismissableLayer.pointerDownOutside",Dh="dismissableLayer.focusOutside",Ph=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Lh=s.forwardRef((e,n)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...h}=e,u=s.useContext(Ph),[d,f]=s.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=s.useState({}),g=Ye(n,e=>f(e)),v=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=v.indexOf(b),w=d?v.indexOf(d):-1,x=u.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,S=function(e,t=globalThis?.document){const n=Tt(e),r=s.useRef(!1),i=s.useRef(()=>{});return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){let r=function(){Ih(Rh,n,o,{discrete:!0})};const o={originalEvent:e};"touch"===e.pointerType?(t.removeEventListener("click",i.current),i.current=r,t.addEventListener("click",i.current,{once:!0})):r()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",e),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}(e=>{const t=e.target,n=[...u.branches].some(e=>e.contains(t));k&&!n&&(o?.(e),l?.(e),e.defaultPrevented||c?.())},p),E=function(e,t=globalThis?.document){const n=Tt(e),r=s.useRef(!1);return s.useEffect(()=>{const e=e=>{if(e.target&&!r.current){Ih(Dh,n,{originalEvent:e},{discrete:!1})}};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{const t=e.target;[...u.branches].some(e=>e.contains(t))||(a?.(e),l?.(e),e.defaultPrevented||c?.())},p);return Mt(e=>{w===u.layers.size-1&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))},p),s.useEffect(()=>{if(d)return r&&(0===u.layersWithOutsidePointerEventsDisabled.size&&(Th=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Bh(),()=>{r&&1===u.layersWithOutsidePointerEventsDisabled.size&&(p.body.style.pointerEvents=Th)}},[d,p,r,u]),s.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Bh())},[d,u]),s.useEffect(()=>{const e=()=>m({});return document.addEventListener(Mh,e),()=>document.removeEventListener(Mh,e)},[]),t.jsx(Ah.div,{...h,ref:g,style:{pointerEvents:x?k?"auto":"none":void 0,...e.style},onFocusCapture:mt(e.onFocusCapture,E.onFocusCapture),onBlurCapture:mt(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:mt(e.onPointerDownCapture,S.onPointerDownCapture)})});Lh.displayName="DismissableLayer";function Bh(){const e=new CustomEvent(Mh);document.dispatchEvent(e)}function Ih(e,t,n,{discrete:r}){const i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?function(e,t){e&&a.flushSync(()=>e.dispatchEvent(t))}(i,o):i.dispatchEvent(o)}s.forwardRef((e,n)=>{const r=s.useContext(Ph),i=s.useRef(null),o=Ye(n,i);return s.useEffect(()=>{const e=i.current;if(e)return r.branches.add(e),()=>{r.branches.delete(e)}},[r.branches]),t.jsx(Ah.div,{...e,ref:o})}).displayName="DismissableLayerBranch";var jh="focusScope.autoFocusOnMount",_h="focusScope.autoFocusOnUnmount",Fh={bubbles:!1,cancelable:!0},Wh=s.forwardRef((e,n)=>{const{loop:r=!1,trapped:i=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...l}=e,[c,h]=s.useState(null),u=Tt(o),d=Tt(a),f=s.useRef(null),p=Ye(n,e=>h(e)),m=s.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;s.useEffect(()=>{if(i){let e=function(e){if(m.paused||!c)return;const t=e.target;c.contains(t)?f.current=t:qh(f.current,{select:!0})},t=function(e){if(m.paused||!c)return;const t=e.relatedTarget;null!==t&&(c.contains(t)||qh(f.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&qh(c)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const r=new MutationObserver(n);return c&&r.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),r.disconnect()}}},[i,c,m.paused]),s.useEffect(()=>{if(c){Uh.add(m);const t=document.activeElement;if(!c.contains(t)){const n=new CustomEvent(jh,Fh);c.addEventListener(jh,u),c.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(qh(r,{select:t}),document.activeElement!==n)return}((e=zh(c),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&qh(c))}return()=>{c.removeEventListener(jh,u),setTimeout(()=>{const e=new CustomEvent(_h,Fh);c.addEventListener(_h,d),c.dispatchEvent(e),e.defaultPrevented||qh(t??document.body,{select:!0}),c.removeEventListener(_h,d),Uh.remove(m)},0)}}var e},[c,u,d,m]);const g=s.useCallback(e=>{if(!r&&!i)return;if(m.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){const t=e.currentTarget,[i,o]=function(e){const t=zh(e),n=Hh(t,e),r=Hh(t.reverse(),e);return[n,r]}(t);i&&o?e.shiftKey||n!==o?e.shiftKey&&n===i&&(e.preventDefault(),r&&qh(o,{select:!0})):(e.preventDefault(),r&&qh(i,{select:!0})):n===t&&e.preventDefault()}},[r,i,m.paused]);return t.jsx(Ah.div,{tabIndex:-1,...l,ref:p,onKeyDown:g})});function zh(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Hh(e,t){for(const n of e)if(!Vh(n,{upTo:t}))return n}function Vh(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function qh(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}Wh.displayName="FocusScope";var Uh=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=$h(e,t),e.unshift(t)},remove(t){e=$h(e,t),e[0]?.resume()}}}();function $h(e,t){const n=[...e],r=n.indexOf(t);return-1!==r&&n.splice(r,1),n}var Kh=s.forwardRef((e,n)=>{const{children:r,width:i=10,height:o=5,...s}=e;return t.jsx(Ah.svg,{...s,ref:n,width:i,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});Kh.displayName="Arrow";var Yh=Kh,Gh="Popper",[Xh,Jh]=gt(Gh),[Qh,Zh]=Xh(Gh),eu=e=>{const{__scopePopper:n,children:r}=e,[i,o]=s.useState(null);return t.jsx(Qh,{scope:n,anchor:i,onAnchorChange:o,children:r})};eu.displayName=Gh;var tu="PopperAnchor",nu=s.forwardRef((e,n)=>{const{__scopePopper:r,virtualRef:i,...o}=e,a=Zh(tu,r),l=s.useRef(null),c=Ye(n,l),h=s.useRef(null);return s.useEffect(()=>{const e=h.current;h.current=i?.current||l.current,e!==h.current&&a.onAnchorChange(h.current)}),i?null:t.jsx(Ah.div,{...o,ref:c})});nu.displayName=tu;var ru="PopperContent",[iu,ou]=Xh(ru),su=s.forwardRef((e,n)=>{const{__scopePopper:r,side:i="bottom",sideOffset:o=0,align:a="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:h=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:g,...v}=e,b=Zh(ru,r),[y,w]=s.useState(null),x=Ye(n,e=>w(e)),[k,S]=s.useState(null),E=Go(k),C=E?.width??0,O=E?.height??0,N=i+("center"!==a?"-"+a:""),A="number"==typeof d?d:{top:0,right:0,bottom:0,left:0,...d},T=Array.isArray(u)?u:[u],M=T.length>0,R={padding:A,boundary:T.filter(hu),altBoundary:M},{refs:D,floatingStyles:P,placement:L,isPositioned:B,middlewareData:I}=_o({strategy:"fixed",placement:N,whileElementsMounted:(...e)=>Eo(...e,{animationFrame:"always"===m}),elements:{reference:b.anchor},middleware:[Wo({mainAxis:o+O,alignmentAxis:l}),h&&zo({mainAxis:!0,crossAxis:!1,limiter:"partial"===f?Ho():void 0,...R}),h&&Vo({...R}),qo({...R,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{const{width:i,height:o}=t.reference,s=e.floating.style;s.setProperty("--radix-popper-available-width",`${n}px`),s.setProperty("--radix-popper-available-height",`${r}px`),s.setProperty("--radix-popper-anchor-width",`${i}px`),s.setProperty("--radix-popper-anchor-height",`${o}px`)}}),k&&$o({element:k,padding:c}),uu({arrowWidth:C,arrowHeight:O}),p&&Uo({strategy:"referenceHidden",...R})]}),[j,_]=du(L),F=Tt(g);bt(()=>{B&&F?.()},[B,F]);const W=I.arrow?.x,z=I.arrow?.y,H=0!==I.arrow?.centerOffset,[V,q]=s.useState();return bt(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),t.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...P,transform:B?P.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[I.transformOrigin?.x,I.transformOrigin?.y].join(" "),...I.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(iu,{scope:r,placedSide:j,onArrowChange:S,arrowX:W,arrowY:z,shouldHideArrow:H,children:t.jsx(Ah.div,{"data-side":j,"data-align":_,...v,ref:x,style:{...v.style,animation:B?void 0:"none"}})})})});su.displayName=ru;var au="PopperArrow",lu={top:"bottom",right:"left",bottom:"top",left:"right"},cu=s.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,o=ou(au,r),s=lu[o.placedSide];return t.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:t.jsx(Yh,{...i,ref:n,style:{...i.style,display:"block"}})})});function hu(e){return null!==e}cu.displayName=au;var uu=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:i}=t,o=0!==i.arrow?.centerOffset,s=o?0:e.arrowWidth,a=o?0:e.arrowHeight,[l,c]=du(n),h={start:"0%",center:"50%",end:"100%"}[c],u=(i.arrow?.x??0)+s/2,d=(i.arrow?.y??0)+a/2;let f="",p="";return"bottom"===l?(f=o?h:`${u}px`,p=-a+"px"):"top"===l?(f=o?h:`${u}px`,p=`${r.floating.height+a}px`):"right"===l?(f=-a+"px",p=o?h:`${d}px`):"left"===l&&(f=`${r.floating.width+a}px`,p=o?h:`${d}px`),{data:{x:f,y:p}}}});function du(e){const[t,n="center"]=e.split("-");return[t,n]}var fu=eu,pu=nu,mu=su,gu=cu,vu=s.forwardRef((e,r)=>{const{container:i,...o}=e,[a,l]=s.useState(!1);bt(()=>l(!0),[]);const c=i||a&&globalThis?.document?.body;return c?n.createPortal(t.jsx(Ah.div,{...o,ref:r}),c):null});function bu(e){const t=s.useRef({value:e,previous:e});return s.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}vu.displayName="Portal";var yu=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"});s.forwardRef((e,n)=>t.jsx(Ah.span,{...e,ref:n,style:{...yu,...e.style}})).displayName="VisuallyHidden";var wu=[" ","Enter","ArrowUp","ArrowDown"],xu=[" ","Enter"],ku="Select",[Su,Eu,Cu]=function(n){const r=n+"CollectionProvider",[i,o]=gt(r),[s,a]=i(r,{collectionRef:{current:null},itemMap:new Map}),l=n=>{const{scope:r,children:i}=n,o=e.useRef(null),a=e.useRef(new Map).current;return t.jsx(s,{scope:r,itemMap:a,collectionRef:o,children:i})};l.displayName=r;const c=n+"CollectionSlot",h=Sh(c),u=e.forwardRef((e,n)=>{const{scope:r,children:i}=e,o=Ye(n,a(c,r).collectionRef);return t.jsx(h,{ref:o,children:i})});u.displayName=c;const d=n+"CollectionItemSlot",f="data-radix-collection-item",p=Sh(d),m=e.forwardRef((n,r)=>{const{scope:i,children:o,...s}=n,l=e.useRef(null),c=Ye(r,l),h=a(d,i);return e.useEffect(()=>(h.itemMap.set(l,{ref:l,...s}),()=>{h.itemMap.delete(l)})),t.jsx(p,{[f]:"",ref:c,children:o})});return m.displayName=d,[{Provider:l,Slot:u,ItemSlot:m},function(t){const r=a(n+"CollectionConsumer",t);return e.useCallback(()=>{const e=r.collectionRef.current;if(!e)return[];const t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(r.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[r.collectionRef,r.itemMap])},o]}(ku),[Ou,Nu]=gt(ku,[Cu,Jh]),Au=Jh(),[Tu,Mu]=Ou(ku),[Ru,Du]=Ou(ku),Pu=e=>{const{__scopeSelect:n,children:r,open:i,defaultOpen:o,onOpenChange:a,value:l,defaultValue:c,onValueChange:h,dir:u,name:d,autoComplete:f,disabled:p,required:m,form:g}=e,v=Au(n),[b,y]=s.useState(null),[w,x]=s.useState(null),[k,S]=s.useState(!1),E=function(e){const t=s.useContext(Nh);return e||t||"ltr"}(u),[C,O]=St({prop:i,defaultProp:o??!1,onChange:a,caller:ku}),[N,A]=St({prop:l,defaultProp:c,onChange:h,caller:ku}),T=s.useRef(null),M=!b||(g||!!b.closest("form")),[R,D]=s.useState(new Set),P=Array.from(R).map(e=>e.props.value).join(";");return t.jsx(fu,{...v,children:t.jsxs(Tu,{required:m,scope:n,trigger:b,onTriggerChange:y,valueNode:w,onValueNodeChange:x,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:xt(),value:N,onValueChange:A,open:C,onOpenChange:O,dir:E,triggerPointerDownPosRef:T,disabled:p,children:[t.jsx(Su.Provider,{scope:n,children:t.jsx(Ru,{scope:e.__scopeSelect,onNativeOptionAdd:s.useCallback(e=>{D(t=>new Set(t).add(e))},[]),onNativeOptionRemove:s.useCallback(e=>{D(t=>{const n=new Set(t);return n.delete(e),n})},[]),children:r})}),M?t.jsxs(yd,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:N,onChange:e=>A(e.target.value),disabled:p,form:g,children:[void 0===N?t.jsx("option",{value:""}):null,Array.from(R)]},P):null]})})};Pu.displayName=ku;var Lu="SelectTrigger",Bu=s.forwardRef((e,n)=>{const{__scopeSelect:r,disabled:i=!1,...o}=e,a=Au(r),l=Mu(Lu,r),c=l.disabled||i,h=Ye(n,l.onTriggerChange),u=Eu(r),d=s.useRef("touch"),[f,p,m]=xd(e=>{const t=u().filter(e=>!e.disabled),n=t.find(e=>e.value===l.value),r=kd(t,e,n);void 0!==r&&l.onValueChange(r.value)}),g=e=>{c||(l.onOpenChange(!0),m()),e&&(l.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return t.jsx(pu,{asChild:!0,...a,children:t.jsx(Ah.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":wd(l.value)?"":void 0,...o,ref:h,onClick:mt(o.onClick,e=>{e.currentTarget.focus(),"mouse"!==d.current&&g(e)}),onPointerDown:mt(o.onPointerDown,e=>{d.current=e.pointerType;const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(g(e),e.preventDefault())}),onKeyDown:mt(o.onKeyDown,e=>{const t=""!==f.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||p(e.key),t&&" "===e.key||wu.includes(e.key)&&(g(),e.preventDefault())})})})});Bu.displayName=Lu;var Iu="SelectValue",ju=s.forwardRef((e,n)=>{const{__scopeSelect:r,className:i,style:o,children:s,placeholder:a="",...l}=e,c=Mu(Iu,r),{onValueNodeHasChildrenChange:h}=c,u=void 0!==s,d=Ye(n,c.onValueNodeChange);return bt(()=>{h(u)},[h,u]),t.jsx(Ah.span,{...l,ref:d,style:{pointerEvents:"none"},children:wd(c.value)?t.jsx(t.Fragment,{children:a}):s})});ju.displayName=Iu;var _u=s.forwardRef((e,n)=>{const{__scopeSelect:r,children:i,...o}=e;return t.jsx(Ah.span,{"aria-hidden":!0,...o,ref:n,children:i||"▼"})});_u.displayName="SelectIcon";var Fu=e=>t.jsx(vu,{asChild:!0,...e});Fu.displayName="SelectPortal";var Wu="SelectContent",zu=s.forwardRef((e,n)=>{const r=Mu(Wu,e.__scopeSelect),[i,o]=s.useState();if(bt(()=>{o(new DocumentFragment)},[]),!r.open){const n=i;return n?a.createPortal(t.jsx(Vu,{scope:e.__scopeSelect,children:t.jsx(Su.Slot,{scope:e.__scopeSelect,children:t.jsx("div",{children:e.children})})}),n):null}return t.jsx($u,{...e,ref:n})});zu.displayName=Wu;var Hu=10,[Vu,qu]=Ou(Wu),Uu=Sh("SelectContent.RemoveScroll"),$u=s.forwardRef((e,n)=>{const{__scopeSelect:r,position:i="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:l,side:c,sideOffset:h,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:v,avoidCollisions:b,...y}=e,w=Mu(Wu,r),[x,k]=s.useState(null),[S,E]=s.useState(null),C=Ye(n,e=>k(e)),[O,N]=s.useState(null),[A,T]=s.useState(null),M=Eu(r),[R,D]=s.useState(!1),P=s.useRef(!1);s.useEffect(()=>{if(x)return Yn(x)},[x]),Zt();const L=s.useCallback(e=>{const[t,...n]=M().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(const n of e){if(n===i)return;if(n?.scrollIntoView({block:"nearest"}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i)return}},[M,S]),B=s.useCallback(()=>L([O,x]),[L,O,x]);s.useEffect(()=>{R&&B()},[R,B]);const{onOpenChange:I,triggerPointerDownPosRef:j}=w;s.useEffect(()=>{if(x){let e={x:0,y:0};const t=t=>{e={x:Math.abs(Math.round(t.pageX)-(j.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(j.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():x.contains(n.target)||I(!1),document.removeEventListener("pointermove",t),j.current=null};return null!==j.current&&(document.addEventListener("pointermove",t),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",n,{capture:!0})}}},[x,I,j]),s.useEffect(()=>{const e=()=>I(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[I]);const[_,F]=xd(e=>{const t=M().filter(e=>!e.disabled),n=t.find(e=>e.ref.current===document.activeElement),r=kd(t,e,n);r&&setTimeout(()=>r.ref.current.focus())}),W=s.useCallback((e,t,n)=>{const r=!P.current&&!n;(void 0!==w.value&&w.value===t||r)&&(N(e),r&&(P.current=!0))},[w.value]),z=s.useCallback(()=>x?.focus(),[x]),H=s.useCallback((e,t,n)=>{const r=!P.current&&!n;(void 0!==w.value&&w.value===t||r)&&T(e)},[w.value]),V="popper"===i?Yu:Ku,q=V===Yu?{side:c,sideOffset:h,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:g,hideWhenDetached:v,avoidCollisions:b}:{};return t.jsx(Vu,{scope:r,content:x,viewport:S,onViewportChange:E,itemRefCallback:W,selectedItem:O,onItemLeave:z,itemTextRefCallback:H,focusSelectedItem:B,selectedItemText:A,position:i,isPositioned:R,searchRef:_,children:t.jsx(zn,{as:Uu,allowPinchZoom:!0,children:t.jsx(Wh,{asChild:!0,trapped:w.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:mt(o,e=>{w.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:t.jsx(Lh,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:t.jsx(V,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:e=>e.preventDefault(),...y,...q,onPlaced:()=>D(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:mt(y.onKeyDown,e=>{const t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||F(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let t=M().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(t=t.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>L(t)),e.preventDefault()}})})})})})})});$u.displayName="SelectContentImpl";var Ku=s.forwardRef((e,n)=>{const{__scopeSelect:r,onPlaced:i,...o}=e,a=Mu(Wu,r),l=qu(Wu,r),[c,h]=s.useState(null),[u,d]=s.useState(null),f=Ye(n,e=>d(e)),p=Eu(r),m=s.useRef(!1),g=s.useRef(!0),{viewport:v,selectedItem:b,selectedItemText:y,focusSelectedItem:w}=l,x=s.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&u&&v&&b&&y){const e=a.trigger.getBoundingClientRect(),t=u.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),r=y.getBoundingClientRect();if("rtl"!==a.dir){const i=r.left-t.left,o=n.left-i,s=e.left-o,a=e.width+s,l=Math.max(a,t.width),h=window.innerWidth-Hu,u=kh(o,[Hu,Math.max(Hu,h-l)]);c.style.minWidth=a+"px",c.style.left=u+"px"}else{const i=t.right-r.right,o=window.innerWidth-n.right-i,s=window.innerWidth-e.right-o,a=e.width+s,l=Math.max(a,t.width),h=window.innerWidth-Hu,u=kh(o,[Hu,Math.max(Hu,h-l)]);c.style.minWidth=a+"px",c.style.right=u+"px"}const o=p(),s=window.innerHeight-2*Hu,l=v.scrollHeight,h=window.getComputedStyle(u),d=parseInt(h.borderTopWidth,10),f=parseInt(h.paddingTop,10),g=parseInt(h.borderBottomWidth,10),w=d+f+l+parseInt(h.paddingBottom,10)+g,x=Math.min(5*b.offsetHeight,w),k=window.getComputedStyle(v),S=parseInt(k.paddingTop,10),E=parseInt(k.paddingBottom,10),C=e.top+e.height/2-Hu,O=s-C,N=b.offsetHeight/2,A=d+f+(b.offsetTop+N),T=w-A;if(A<=C){const e=o.length>0&&b===o[o.length-1].ref.current;c.style.bottom="0px";const t=u.clientHeight-v.offsetTop-v.offsetHeight,n=A+Math.max(O,N+(e?E:0)+t+g);c.style.height=n+"px"}else{const e=o.length>0&&b===o[0].ref.current;c.style.top="0px";const t=Math.max(C,d+v.offsetTop+(e?S:0)+N)+T;c.style.height=t+"px",v.scrollTop=A-C+v.offsetTop}c.style.margin=`${Hu}px 0`,c.style.minHeight=x+"px",c.style.maxHeight=s+"px",i?.(),requestAnimationFrame(()=>m.current=!0)}},[p,a.trigger,a.valueNode,c,u,v,b,y,a.dir,i]);bt(()=>x(),[x]);const[k,S]=s.useState();bt(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const E=s.useCallback(e=>{e&&!0===g.current&&(x(),w?.(),g.current=!1)},[x,w]);return t.jsx(Gu,{scope:r,contentWrapper:c,shouldExpandOnScrollRef:m,onScrollButtonChange:E,children:t.jsx("div",{ref:h,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:t.jsx(Ah.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ku.displayName="SelectItemAlignedPosition";var Yu=s.forwardRef((e,n)=>{const{__scopeSelect:r,align:i="start",collisionPadding:o=Hu,...s}=e,a=Au(r);return t.jsx(mu,{...a,...s,ref:n,align:i,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Yu.displayName="SelectPopperPosition";var[Gu,Xu]=Ou(Wu,{}),Ju="SelectViewport",Qu=s.forwardRef((e,n)=>{const{__scopeSelect:r,nonce:i,...o}=e,a=qu(Ju,r),l=Xu(Ju,r),c=Ye(n,a.onViewportChange),h=s.useRef(0);return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),t.jsx(Su.Slot,{scope:r,children:t.jsx(Ah.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:mt(o.onScroll,e=>{const t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=l;if(r?.current&&n){const e=Math.abs(h.current-t.scrollTop);if(e>0){const r=window.innerHeight-2*Hu,i=parseFloat(n.style.minHeight),o=parseFloat(n.style.height),s=Math.max(i,o);if(s<r){const i=s+e,o=Math.min(r,i),a=i-o;n.style.height=o+"px","0px"===n.style.bottom&&(t.scrollTop=a>0?a:0,n.style.justifyContent="flex-end")}}}h.current=t.scrollTop})})})]})});Qu.displayName=Ju;var Zu="SelectGroup",[ed,td]=Ou(Zu);s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e,o=xt();return t.jsx(ed,{scope:r,id:o,children:t.jsx(Ah.div,{role:"group","aria-labelledby":o,...i,ref:n})})}).displayName=Zu;var nd="SelectLabel",rd=s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e,o=td(nd,r);return t.jsx(Ah.div,{id:o.id,...i,ref:n})});rd.displayName=nd;var id="SelectItem",[od,sd]=Ou(id),ad=s.forwardRef((e,n)=>{const{__scopeSelect:r,value:i,disabled:o=!1,textValue:a,...l}=e,c=Mu(id,r),h=qu(id,r),u=c.value===i,[d,f]=s.useState(a??""),[p,m]=s.useState(!1),g=Ye(n,e=>h.itemRefCallback?.(e,i,o)),v=xt(),b=s.useRef("touch"),y=()=>{o||(c.onValueChange(i),c.onOpenChange(!1))};if(""===i)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return t.jsx(od,{scope:r,value:i,disabled:o,textId:v,isSelected:u,onItemTextChange:s.useCallback(e=>{f(t=>t||(e?.textContent??"").trim())},[]),children:t.jsx(Su.ItemSlot,{scope:r,value:i,disabled:o,textValue:d,children:t.jsx(Ah.div,{role:"option","aria-labelledby":v,"data-highlighted":p?"":void 0,"aria-selected":u&&p,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...l,ref:g,onFocus:mt(l.onFocus,()=>m(!0)),onBlur:mt(l.onBlur,()=>m(!1)),onClick:mt(l.onClick,()=>{"mouse"!==b.current&&y()}),onPointerUp:mt(l.onPointerUp,()=>{"mouse"===b.current&&y()}),onPointerDown:mt(l.onPointerDown,e=>{b.current=e.pointerType}),onPointerMove:mt(l.onPointerMove,e=>{b.current=e.pointerType,o?h.onItemLeave?.():"mouse"===b.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:mt(l.onPointerLeave,e=>{e.currentTarget===document.activeElement&&h.onItemLeave?.()}),onKeyDown:mt(l.onKeyDown,e=>{""!==h.searchRef?.current&&" "===e.key||(xu.includes(e.key)&&y()," "===e.key&&e.preventDefault())})})})})});ad.displayName=id;var ld="SelectItemText",cd=s.forwardRef((e,n)=>{const{__scopeSelect:r,className:i,style:o,...l}=e,c=Mu(ld,r),h=qu(ld,r),u=sd(ld,r),d=Du(ld,r),[f,p]=s.useState(null),m=Ye(n,e=>p(e),u.onItemTextChange,e=>h.itemTextRefCallback?.(e,u.value,u.disabled)),g=f?.textContent,v=s.useMemo(()=>t.jsx("option",{value:u.value,disabled:u.disabled,children:g},u.value),[u.disabled,u.value,g]),{onNativeOptionAdd:b,onNativeOptionRemove:y}=d;return bt(()=>(b(v),()=>y(v)),[b,y,v]),t.jsxs(t.Fragment,{children:[t.jsx(Ah.span,{id:u.textId,...l,ref:m}),u.isSelected&&c.valueNode&&!c.valueNodeHasChildren?a.createPortal(l.children,c.valueNode):null]})});cd.displayName=ld;var hd="SelectItemIndicator",ud=s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e;return sd(hd,r).isSelected?t.jsx(Ah.span,{"aria-hidden":!0,...i,ref:n}):null});ud.displayName=hd;var dd="SelectScrollUpButton",fd=s.forwardRef((e,n)=>{const r=qu(dd,e.__scopeSelect),i=Xu(dd,e.__scopeSelect),[o,a]=s.useState(!1),l=Ye(n,i.onScrollButtonChange);return bt(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollTop>0;a(e)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?t.jsx(gd,{...e,ref:l,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}}):null});fd.displayName=dd;var pd="SelectScrollDownButton",md=s.forwardRef((e,n)=>{const r=qu(pd,e.__scopeSelect),i=Xu(pd,e.__scopeSelect),[o,a]=s.useState(!1),l=Ye(n,i.onScrollButtonChange);return bt(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),o?t.jsx(gd,{...e,ref:l,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}}):null});md.displayName=pd;var gd=s.forwardRef((e,n)=>{const{__scopeSelect:r,onAutoScroll:i,...o}=e,a=qu("SelectScrollButton",r),l=s.useRef(null),c=Eu(r),h=s.useCallback(()=>{null!==l.current&&(window.clearInterval(l.current),l.current=null)},[]);return s.useEffect(()=>()=>h(),[h]),bt(()=>{const e=c().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[c]),t.jsx(Ah.div,{"aria-hidden":!0,...o,ref:n,style:{flexShrink:0,...o.style},onPointerDown:mt(o.onPointerDown,()=>{null===l.current&&(l.current=window.setInterval(i,50))}),onPointerMove:mt(o.onPointerMove,()=>{a.onItemLeave?.(),null===l.current&&(l.current=window.setInterval(i,50))}),onPointerLeave:mt(o.onPointerLeave,()=>{h()})})}),vd=s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e;return t.jsx(Ah.div,{"aria-hidden":!0,...i,ref:n})});vd.displayName="SelectSeparator";var bd="SelectArrow";s.forwardRef((e,n)=>{const{__scopeSelect:r,...i}=e,o=Au(r),s=Mu(bd,r),a=qu(bd,r);return s.open&&"popper"===a.position?t.jsx(gu,{...o,...i,ref:n}):null}).displayName=bd;var yd=s.forwardRef(({__scopeSelect:e,value:n,...r},i)=>{const o=s.useRef(null),a=Ye(i,o),l=bu(n);return s.useEffect(()=>{const e=o.current;if(!e)return;const t=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(t,"value").set;if(l!==n&&r){const t=new Event("change",{bubbles:!0});r.call(e,n),e.dispatchEvent(t)}},[l,n]),t.jsx(Ah.select,{...r,style:{...yu,...r.style},ref:a,defaultValue:n})});function wd(e){return""===e||void 0===e}function xd(e){const t=Tt(e),n=s.useRef(""),r=s.useRef(0),i=s.useCallback(e=>{const i=n.current+e;t(i),function e(t){n.current=t,window.clearTimeout(r.current),""!==t&&(r.current=window.setTimeout(()=>e(""),1e3))}(i)},[t]),o=s.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return s.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,o]}function kd(e,t,n){const r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let o=(s=e,a=Math.max(i,0),s.map((e,t)=>s[(a+t)%s.length]));var s,a;1===r.length&&(o=o.filter(e=>e!==n));const l=o.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return l!==n?l:void 0}yd.displayName="SelectBubbleInput";var Sd=Bu,Ed=_u,Cd=Fu,Od=zu,Nd=Qu,Ad=rd,Td=ad,Md=cd,Rd=ud,Dd=fd,Pd=md,Ld=vd,Bd=Pu,Id=ju,jd=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=G(e,["className","children"]);return s.createElement(Sd,Object.assign({ref:t,className:qe("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",n)},i),r,s.createElement(Ed,{asChild:!0},s.createElement(E,{className:"h-4 w-4 opacity-50"})))});jd.displayName=Sd.displayName;var _d=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Dd,Object.assign({ref:t,className:qe("flex cursor-default items-center justify-center py-1",n)},r),s.createElement(N,{className:"h-4 w-4"}))});_d.displayName=Dd.displayName;var Fd=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Pd,Object.assign({ref:t,className:qe("flex cursor-default items-center justify-center py-1",n)},r),s.createElement(E,{className:"h-4 w-4"}))});Fd.displayName=Pd.displayName;var Wd=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=e.position,o=void 0===i?"popper":i,a=G(e,["className","children","position"]);return s.createElement(Cd,null,s.createElement(Od,Object.assign({ref:t,className:qe("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]","popper"===o&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",n),position:o},a),s.createElement(_d,null),s.createElement(Nd,{className:qe("p-1","popper"===o&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]")},r),s.createElement(Fd,null)))});Wd.displayName=Od.displayName;var zd=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Ad,Object.assign({ref:t,className:qe("py-1.5 pl-8 pr-2 text-sm font-semibold",n)},r))});zd.displayName=Ad.displayName;var Hd=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=G(e,["className","children"]);return s.createElement(Td,Object.assign({ref:t,className:qe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n)},i),s.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},s.createElement(Rd,null,s.createElement(S,{className:"h-4 w-4"}))),s.createElement(Md,null,r))});Hd.displayName=Td.displayName;var Vd=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Ld,Object.assign({ref:t,className:qe("-mx-1 my-1 h-px bg-muted",n)},r))});function qd(e){const t=s.forwardRef((e,t)=>{const{children:n,...r}=e;if(s.isValidElement(n)){const e=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),i=function(e,t){const n={...t};for(const r in t){const i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...e)=>{const t=o(...e);return i(...e),t}:i&&(n[r]=i):"style"===r?n[r]={...i,...o}:"className"===r&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==s.Fragment&&(i.ref=t?Ke(t,e):e),s.cloneElement(n,i)}return s.Children.count(n)>1?s.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}Vd.displayName=Ld.displayName;var Ud=Symbol("radix.slottable");function $d(e){return s.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Ud}var Kd=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,n)=>{const r=function(e){const n=qd(e),r=s.forwardRef((e,r)=>{const{children:i,...o}=e,a=s.Children.toArray(i),l=a.find($d);if(l){const e=l.props.children,i=a.map(t=>t===l?s.Children.count(e)>1?s.Children.only(null):s.isValidElement(e)?e.props.children:null:t);return t.jsx(n,{...o,ref:r,children:s.isValidElement(e)?s.cloneElement(e,void 0,i):null})}return t.jsx(n,{...o,ref:r,children:i})});return r.displayName=`${e}.Slot`,r}(`Primitive.${n}`),i=s.forwardRef((e,i)=>{const{asChild:o,...s}=e,a=o?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),t.jsx(a,{...s,ref:i})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),Yd="Switch",[Gd,Xd]=gt(Yd),[Jd,Qd]=Gd(Yd),Zd=s.forwardRef((e,n)=>{const{__scopeSwitch:r,name:i,checked:o,defaultChecked:a,required:l,disabled:c,value:h="on",onCheckedChange:u,form:d,...f}=e,[p,m]=s.useState(null),g=Ye(n,e=>m(e)),v=s.useRef(!1),b=!p||(d||!!p.closest("form")),[y,w]=St({prop:o,defaultProp:a??!1,onChange:u,caller:Yd});return t.jsxs(Jd,{scope:r,checked:y,disabled:c,children:[t.jsx(Kd.button,{type:"button",role:"switch","aria-checked":y,"aria-required":l,"data-state":rf(y),"data-disabled":c?"":void 0,disabled:c,value:h,...f,ref:g,onClick:mt(e.onClick,e=>{w(e=>!e),b&&(v.current=e.isPropagationStopped(),v.current||e.stopPropagation())})}),b&&t.jsx(nf,{control:p,bubbles:!v.current,name:i,value:h,checked:y,required:l,disabled:c,form:d,style:{transform:"translateX(-100%)"}})]})});Zd.displayName=Yd;var ef="SwitchThumb",tf=s.forwardRef((e,n)=>{const{__scopeSwitch:r,...i}=e,o=Qd(ef,r);return t.jsx(Kd.span,{"data-state":rf(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:n})});tf.displayName=ef;var nf=s.forwardRef(({__scopeSwitch:e,control:n,checked:r,bubbles:i=!0,...o},a)=>{const l=s.useRef(null),c=Ye(l,a),h=bu(r),u=Go(n);return s.useEffect(()=>{const e=l.current;if(!e)return;const t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,"checked").set;if(h!==r&&n){const t=new Event("click",{bubbles:i});n.call(e,r),e.dispatchEvent(t)}},[h,r,i]),t.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:c,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function rf(e){return e?"checked":"unchecked"}nf.displayName="SwitchBubbleInput";var of=Zd,sf=tf,af=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(of,Object.assign({className:qe("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",n)},r,{ref:t}),s.createElement(sf,{className:qe("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")}))});af.displayName=of.displayName;var lf=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("textarea",Object.assign({className:qe("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:t},r))});lf.displayName="Textarea";var cf=Ar,hf=Tr,uf=Mr,df=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Rr,Object.assign({ref:t,className:qe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n)},r))});df.displayName=Rr.displayName;var ff=s.forwardRef(function(e,t){var n=e.className,r=e.children,i=G(e,["className","children"]);return s.createElement(uf,null,s.createElement(df,null),s.createElement(Dr,Object.assign({ref:t,className:qe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n)},i),r,s.createElement(Br,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"},s.createElement(K,{className:"h-4 w-4"}),s.createElement("span",{className:"sr-only"},"Close"))))});ff.displayName=Dr.displayName;var pf=function(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("flex flex-col space-y-1.5 text-center sm:text-left",t)},n))};pf.displayName="DialogHeader";var mf=function(e){var t=e.className,n=G(e,["className"]);return s.createElement("div",Object.assign({className:qe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t)},n))};mf.displayName="DialogFooter";var gf=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Pr,Object.assign({ref:t,className:qe("text-lg font-semibold leading-none tracking-tight",n)},r))});gf.displayName=Pr.displayName;var vf,bf=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement(Lr,Object.assign({ref:t,className:qe("text-sm text-muted-foreground",n)},r))});function yf(e,t=!1){const n=e.length;let r=0,i="",o=0,s=16,a=0,l=0,c=0,h=0,u=0;function d(t,n){let i=0,o=0;for(;i<t||!n;){let t=e.charCodeAt(r);if(t>=48&&t<=57)o=16*o+t-48;else if(t>=65&&t<=70)o=16*o+t-65+10;else{if(!(t>=97&&t<=102))break;o=16*o+t-97+10}r++,i++}return i<t&&(o=-1),o}function f(){if(i="",u=0,o=r,l=a,h=c,r>=n)return o=n,s=17;let t=e.charCodeAt(r);if(wf(t)){do{r++,i+=String.fromCharCode(t),t=e.charCodeAt(r)}while(wf(t));return s=15}if(xf(t))return r++,i+=String.fromCharCode(t),13===t&&10===e.charCodeAt(r)&&(r++,i+="\n"),a++,c=r,s=14;switch(t){case 123:return r++,s=1;case 125:return r++,s=2;case 91:return r++,s=3;case 93:return r++,s=4;case 58:return r++,s=6;case 44:return r++,s=5;case 34:return r++,i=function(){let t="",i=r;for(;;){if(r>=n){t+=e.substring(i,r),u=2;break}const o=e.charCodeAt(r);if(34===o){t+=e.substring(i,r),r++;break}if(92!==o){if(o>=0&&o<=31){if(xf(o)){t+=e.substring(i,r),u=2;break}u=6}r++}else{if(t+=e.substring(i,r),r++,r>=n){u=2;break}switch(e.charCodeAt(r++)){case 34:t+='"';break;case 92:t+="\\";break;case 47:t+="/";break;case 98:t+="\b";break;case 102:t+="\f";break;case 110:t+="\n";break;case 114:t+="\r";break;case 116:t+="\t";break;case 117:const e=d(4,!0);e>=0?t+=String.fromCharCode(e):u=4;break;default:u=5}i=r}}return t}(),s=10;case 47:const l=r-1;if(47===e.charCodeAt(r+1)){for(r+=2;r<n&&!xf(e.charCodeAt(r));)r++;return i=e.substring(l,r),s=12}if(42===e.charCodeAt(r+1)){r+=2;const t=n-1;let o=!1;for(;r<t;){const t=e.charCodeAt(r);if(42===t&&47===e.charCodeAt(r+1)){r+=2,o=!0;break}r++,xf(t)&&(13===t&&10===e.charCodeAt(r)&&r++,a++,c=r)}return o||(r++,u=1),i=e.substring(l,r),s=13}return i+=String.fromCharCode(t),r++,s=16;case 45:if(i+=String.fromCharCode(t),r++,r===n||!kf(e.charCodeAt(r)))return s=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=function(){let t=r;if(48===e.charCodeAt(r))r++;else for(r++;r<e.length&&kf(e.charCodeAt(r));)r++;if(r<e.length&&46===e.charCodeAt(r)){if(r++,!(r<e.length&&kf(e.charCodeAt(r))))return u=3,e.substring(t,r);for(r++;r<e.length&&kf(e.charCodeAt(r));)r++}let n=r;if(r<e.length&&(69===e.charCodeAt(r)||101===e.charCodeAt(r)))if(r++,(r<e.length&&43===e.charCodeAt(r)||45===e.charCodeAt(r))&&r++,r<e.length&&kf(e.charCodeAt(r))){for(r++;r<e.length&&kf(e.charCodeAt(r));)r++;n=r}else u=3;return e.substring(t,n)}(),s=11;default:for(;r<n&&p(t);)r++,t=e.charCodeAt(r);if(o!==r){switch(i=e.substring(o,r),i){case"true":return s=8;case"false":return s=9;case"null":return s=7}return s=16}return i+=String.fromCharCode(t),r++,s=16}}function p(e){if(wf(e)||xf(e))return!1;switch(e){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}return{setPosition:function(e){r=e,i="",o=0,s=16,u=0},getPosition:()=>r,scan:t?function(){let e;do{e=f()}while(e>=12&&e<=15);return e}:f,getToken:()=>s,getTokenValue:()=>i,getTokenOffset:()=>o,getTokenLength:()=>r-o,getTokenStartLine:()=>l,getTokenStartCharacter:()=>o-h,getTokenError:()=>u}}function wf(e){return 32===e||9===e}function xf(e){return 10===e||13===e}function kf(e){return e>=48&&e<=57}bf.displayName=Lr.displayName,function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"}(vf||(vf={}));const Sf=new Array(20).fill(0).map((e,t)=>" ".repeat(t)),Ef=200,Cf={" ":{"\n":new Array(Ef).fill(0).map((e,t)=>"\n"+" ".repeat(t)),"\r":new Array(Ef).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(Ef).fill(0).map((e,t)=>"\r\n"+" ".repeat(t))},"\t":{"\n":new Array(Ef).fill(0).map((e,t)=>"\n"+"\t".repeat(t)),"\r":new Array(Ef).fill(0).map((e,t)=>"\r"+"\t".repeat(t)),"\r\n":new Array(Ef).fill(0).map((e,t)=>"\r\n"+"\t".repeat(t))}},Of=["\n","\r","\r\n"];function Nf(e,t,n){let r,i,o,s,a;if(t){for(s=t.offset,a=s+t.length,o=s;o>0&&!Tf(e,o-1);)o--;let l=a;for(;l<e.length&&!Tf(e,l);)l++;i=e.substring(o,l),r=function(e,t){let n=0,r=0;const i=t.tabSize||4;for(;n<e.length;){let t=e.charAt(n);if(t===Sf[1])r++;else{if("\t"!==t)break;r+=i}n++}return Math.floor(r/i)}(i,n)}else i=e,r=0,o=0,s=0,a=e.length;const l=function(e,t){for(let e=0;e<t.length;e++){const n=t.charAt(e);if("\r"===n)return e+1<t.length&&"\n"===t.charAt(e+1)?"\r\n":"\r";if("\n"===n)return"\n"}return e&&e.eol||"\n"}(n,e),c=Of.includes(l);let h,u=0,d=0;h=n.insertSpaces?Sf[n.tabSize||4]??Af(Sf[1],n.tabSize||4):"\t";const f="\t"===h?"\t":" ";let p=yf(i,!1),m=!1;function g(){if(u>1)return Af(l,u)+Af(h,r+d);const e=h.length*(r+d);return!c||e>Cf[f][l].length?l+Af(h,r+d):e<=0?l:Cf[f][l][e]}function v(){let e=p.scan();for(u=0;15===e||14===e;)14===e&&n.keepLines?u+=1:14===e&&(u=1),e=p.scan();return m=16===e||0!==p.getTokenError(),e}const b=[];function y(n,r,i){m||t&&!(r<a&&i>s)||e.substring(r,i)===n||b.push({offset:r,length:i-r,content:n})}let w=v();if(n.keepLines&&u>0&&y(Af(l,u),0,0),17!==w){let e=p.getTokenOffset()+o;y(h.length*r<20&&n.insertSpaces?Sf[h.length*r]:Af(h,r),o,e)}for(;17!==w;){let e=p.getTokenOffset()+p.getTokenLength()+o,t=v(),r="",i=!1;for(;0===u&&(12===t||13===t);){let n=p.getTokenOffset()+o;y(Sf[1],e,n),e=p.getTokenOffset()+p.getTokenLength()+o,i=12===t,r=i?g():"",t=v()}if(2===t)1!==w&&d--,n.keepLines&&u>0||!n.keepLines&&1!==w?r=g():n.keepLines&&(r=Sf[1]);else if(4===t)3!==w&&d--,n.keepLines&&u>0||!n.keepLines&&3!==w?r=g():n.keepLines&&(r=Sf[1]);else{switch(w){case 3:case 1:d++,r=n.keepLines&&u>0||!n.keepLines?g():Sf[1];break;case 5:r=n.keepLines&&u>0||!n.keepLines?g():Sf[1];break;case 12:r=g();break;case 13:u>0?r=g():i||(r=Sf[1]);break;case 6:n.keepLines&&u>0?r=g():i||(r=Sf[1]);break;case 10:n.keepLines&&u>0?r=g():6!==t||i||(r="");break;case 7:case 8:case 9:case 11:case 2:case 4:n.keepLines&&u>0?r=g():12!==t&&13!==t||i?5!==t&&17!==t&&(m=!0):r=Sf[1];break;case 16:m=!0}u>0&&(12===t||13===t)&&(r=g())}17===t&&(r=n.keepLines&&u>0?g():n.insertFinalNewline?l:"");y(r,e,p.getTokenOffset()+o),w=t}return b}function Af(e,t){let n="";for(let r=0;r<t;r++)n+=e;return n}function Tf(e,t){return-1!=="\r\n".indexOf(e.charAt(t))}var Mf,Rf,Df;!function(e){e.DEFAULT={allowTrailingComma:!1}}(Mf||(Mf={})),function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"}(Rf||(Rf={})),function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"}(Df||(Df={}));const Pf=function(e,t=[],n=Mf.DEFAULT){let r=null,i=[];const o=[];function s(e){Array.isArray(i)?i.push(e):null!==r&&(i[r]=e)}const a={onObjectBegin:()=>{const e={};s(e),o.push(i),i=e,r=null},onObjectProperty:e=>{r=e},onObjectEnd:()=>{i=o.pop()},onArrayBegin:()=>{const e=[];s(e),o.push(i),i=e,r=null},onArrayEnd:()=>{i=o.pop()},onLiteralValue:s,onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}};return function(e,t,n=Mf.DEFAULT){const r=yf(e,!1),i=[];let o=0;function s(e){return e?()=>0===o&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function a(e){return e?t=>0===o&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function l(e){return e?t=>0===o&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function c(e){return e?()=>{if(o>0)o++;else{!1===e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())&&(o=1)}}:()=>!0}function h(e){return e?()=>{o>0&&o--,0===o&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}const u=c(t.onObjectBegin),d=l(t.onObjectProperty),f=h(t.onObjectEnd),p=c(t.onArrayBegin),m=h(t.onArrayEnd),g=l(t.onLiteralValue),v=a(t.onSeparator),b=s(t.onComment),y=a(t.onError),w=n&&n.disallowComments,x=n&&n.allowTrailingComma;function k(){for(;;){const e=r.scan();switch(r.getTokenError()){case 4:S(14);break;case 5:S(15);break;case 3:S(13);break;case 1:w||S(11);break;case 2:S(12);break;case 6:S(16)}switch(e){case 12:case 13:w?S(10):b();break;case 16:S(1);break;case 15:case 14:break;default:return e}}}function S(e,t=[],n=[]){if(y(e),t.length+n.length>0){let e=r.getToken();for(;17!==e;){if(-1!==t.indexOf(e)){k();break}if(-1!==n.indexOf(e))break;e=k()}}}function E(e){const t=r.getTokenValue();return e?g(t):(d(t),i.push(t)),k(),!0}function C(){switch(r.getToken()){case 11:const e=r.getTokenValue();let t=Number(e);isNaN(t)&&(S(2),t=0),g(t);break;case 7:g(null);break;case 8:g(!0);break;case 9:g(!1);break;default:return!1}return k(),!0}function O(){return 10!==r.getToken()?(S(3,[],[2,5]),!1):(E(!1),6===r.getToken()?(v(":"),k(),T()||S(4,[],[2,5])):S(5,[],[2,5]),i.pop(),!0)}function N(){u(),k();let e=!1;for(;2!==r.getToken()&&17!==r.getToken();){if(5===r.getToken()){if(e||S(4,[],[]),v(","),k(),2===r.getToken()&&x)break}else e&&S(6,[],[]);O()||S(4,[],[2,5]),e=!0}return f(),2!==r.getToken()?S(7,[2],[]):k(),!0}function A(){p(),k();let e=!0,t=!1;for(;4!==r.getToken()&&17!==r.getToken();){if(5===r.getToken()){if(t||S(4,[],[]),v(","),k(),4===r.getToken()&&x)break}else t&&S(6,[],[]);e?(i.push(0),e=!1):i[i.length-1]++,T()||S(4,[],[4,5]),t=!0}return m(),e||i.pop(),4!==r.getToken()?S(8,[4],[]):k(),!0}function T(){switch(r.getToken()){case 3:return A();case 1:return N();case 10:return E(!0);default:return C()}}if(k(),17===r.getToken())return!!n.allowEmptyContent||(S(4,[],[]),!1);if(!T())return S(4,[],[]),!1;17!==r.getToken()&&S(9,[],[])}(e,a,n),i[0]};var Lf;function Bf(e,t){if(!t.length)return"JSON 格式不正确";var n=t[0],r=function(e,t){for(var n=1,r=1,i=Math.max(0,Math.min(t,e.length)),o=0;o<i;o++){"\n"===e.charAt(o)?(n++,r=1):r++}return{line:n,col:r}}(e,n.offset),i=r.line,o=r.col,s=function(e){switch(e){case 1:return"InvalidSymbol";case 2:return"InvalidNumberFormat";case 3:return"PropertyNameExpected";case 4:return"ValueExpected";case 5:return"ColonExpected";case 6:return"CommaExpected";case 7:return"CloseBraceExpected";case 8:return"CloseBracketExpected";case 9:return"EndOfFileExpected";case 10:return"InvalidCommentToken";case 11:return"UnexpectedEndOfComment";case 12:return"UnexpectedEndOfString";case 13:return"UnexpectedEndOfNumber";case 14:return"InvalidUnicode";case 15:return"InvalidEscapeCharacter";case 16:return"InvalidCharacter"}return"<unknown ParseErrorCode>"}(n.error);return"JSON 格式不正确(".concat(s,",行 ").concat(i," 列 ").concat(o,")")}function If(e){if(null==e||""===e)return{ok:!0,value:null,pretty:"null",compact:"null"};try{if("string"!=typeof e)return{ok:!0,value:e,pretty:JSON.stringify(e,null,2),compact:JSON.stringify(e)};var t=e,n=[],r=Pf(t,n,{allowTrailingComma:!0,disallowComments:!1});return n.length?{ok:!1,message:Bf(t,n),pretty:t,compact:t}:{ok:!0,value:r,pretty:JSON.stringify(r,null,2),compact:JSON.stringify(r)}}catch(t){var i="string"==typeof e?e:String(e);return{ok:!1,message:"JSON 格式不正确",pretty:i,compact:i}}}function jf(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=(e||"").toString(),r=[];if(Pf(n,r,{allowTrailingComma:!0,disallowComments:!1}),r.length)return{ok:!1,message:Bf(n,r)};for(var i=function(e,t,n){return Nf(e,t,n)}(n,void 0,{insertSpaces:!0,tabSize:t}),o=n,s=i.length-1;s>=0;s--){var a=i[s];o=o.slice(0,a.offset)+a.content+o.slice(a.offset+a.length)}return{ok:!0,formatted:o}}function _f(){return _f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_f.apply(null,arguments)}!function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"}(Lf||(Lf={}));let Ff=[],Wf=[];function zf(e){if(e<768)return!1;for(let t=0,n=Ff.length;;){let r=t+n>>1;if(e<Ff[r])n=r;else{if(!(e>=Wf[r]))return!0;t=r+1}if(t==n)return!1}}function Hf(e){return e>=127462&&e<=127487}(()=>{let e="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 t=0,n=0;t<e.length;t++)(t%2?Wf:Ff).push(n+=e[t])})();function Vf(e,t,n=!0,r=!0){return(n?qf:Uf)(e,t,r)}function qf(e,t,n){if(t==e.length)return t;t&&Kf(e.charCodeAt(t))&&Yf(e.charCodeAt(t-1))&&t--;let r=$f(e,t);for(t+=Gf(r);t<e.length;){let i=$f(e,t);if(8205==r||8205==i||n&&zf(i))t+=Gf(i),r=i;else{if(!Hf(i))break;{let n=0,r=t-2;for(;r>=0&&Hf($f(e,r));)n++,r-=2;if(n%2==0)break;t+=2}}}return t}function Uf(e,t,n){for(;t>0;){let r=qf(e,t-2,n);if(r<t)return r;t--}return 0}function $f(e,t){let n=e.charCodeAt(t);if(!Yf(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return Kf(r)?r-56320+(n-55296<<10)+65536:n}function Kf(e){return e>=56320&&e<57344}function Yf(e){return e>=55296&&e<56320}function Gf(e){return e<65536?1:2}class Xf{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]=op(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Qf.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=op(this,e,t);let n=[];return this.decompose(e,t,n,0),Qf.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),r=new tp(this),i=new tp(e);for(let e=t,o=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(o+=r.value.length,r.done||o>=n)return!0}}iter(e=1){return new tp(this,e)}iterRange(e,t=this.length){return new np(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new rp(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new Jf(e):Qf.from(Jf.split(e,[])):Xf.empty}}class Jf extends Xf{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let o=this.text[i],s=r+o.length;if((t?n:s)>=e)return new ip(r,s,n,o);r=s+1,n++}}decompose(e,t,n,r){let i=e<=0&&t>=this.length?this:new Jf(ep(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&r){let e=n.pop(),t=Zf(i.text,e.text.slice(),0,i.length);if(t.length<=32)n.push(new Jf(t,e.length+i.length));else{let e=t.length>>1;n.push(new Jf(t.slice(0,e)),new Jf(t.slice(e)))}}else n.push(i)}replace(e,t,n){if(!(n instanceof Jf))return super.replace(e,t,n);[e,t]=op(this,e,t);let r=Zf(this.text,Zf(n.text,ep(this.text,0,e)),t),i=this.length+n.length-(t-e);return r.length<=32?new Jf(r,i):Qf.from(Jf.split(r,[]),i)}sliceString(e,t=this.length,n="\n"){[e,t]=op(this,e,t);let r="";for(let i=0,o=0;i<=t&&o<this.text.length;o++){let s=this.text[o],a=i+s.length;i>e&&o&&(r+=n),e<a&&t>i&&(r+=s.slice(Math.max(0,e-i),t-i)),i=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let i of e)n.push(i),r+=i.length+1,32==n.length&&(t.push(new Jf(n,r)),n=[],r=-1);return r>-1&&t.push(new Jf(n,r)),t}}class Qf extends Xf{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let o=this.children[i],s=r+o.length,a=n+o.lines-1;if((t?a:s)>=e)return o.lineInner(e,t,n,r);r=s+1,n=a+1}}decompose(e,t,n,r){for(let i=0,o=0;o<=t&&i<this.children.length;i++){let s=this.children[i],a=o+s.length;if(e<=a&&t>=o){let i=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!i?n.push(s):s.decompose(e-o,t-o,n,i)}o=a+1}}replace(e,t,n){if([e,t]=op(this,e,t),n.lines<this.lines)for(let r=0,i=0;r<this.children.length;r++){let o=this.children[r],s=i+o.length;if(e>=i&&t<=s){let a=o.replace(e-i,t-i,n),l=this.lines-o.lines+a.lines;if(a.lines<l>>4&&a.lines>l>>6){let i=this.children.slice();return i[r]=a,new Qf(i,this.length-(t-e)+n.length)}return super.replace(i,s,a)}i=s+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=op(this,e,t);let r="";for(let i=0,o=0;i<this.children.length&&o<=t;i++){let s=this.children[i],a=o+s.length;o>e&&i&&(r+=n),e<a&&t>o&&(r+=s.sliceString(e-o,t-o,n)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Qf))return 0;let n=0,[r,i,o,s]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,i+=t){if(r==o||i==s)return n;let a=this.children[r],l=e.children[i];if(a!=l)return n+a.scanIdentical(l,t);n+=a.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new Jf(n,t)}let r=Math.max(32,n>>5),i=r<<1,o=r>>1,s=[],a=0,l=-1,c=[];function h(e){let t;if(e.lines>i&&e instanceof Qf)for(let t of e.children)h(t);else e.lines>o&&(a>o||!a)?(u(),s.push(e)):e instanceof Jf&&a&&(t=c[c.length-1])instanceof Jf&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new Jf(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>r&&u(),a+=e.lines,l+=e.length+1,c.push(e))}function u(){0!=a&&(s.push(1==c.length?c[0]:Qf.from(c,l)),l=-1,a=c.length=0)}for(let t of e)h(t);return u(),1==s.length?s[0]:new Qf(s,t)}}function Zf(e,t,n=0,r=1e9){for(let i=0,o=0,s=!0;o<e.length&&i<=r;o++){let a=e[o],l=i+a.length;l>=n&&(l>r&&(a=a.slice(0,r-i)),i<n&&(a=a.slice(n-i)),s?(t[t.length-1]+=a,s=!1):t.push(a)),i=l+1}return t}function ep(e,t,n){return Zf(e,[""],t,n)}Xf.empty=new Jf([""],0);class tp{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 Jf?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],o=i>>1,s=r instanceof Jf?r.text.length:r.children.length;if(o==(t>0?s:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&i)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(r instanceof Jf){let i=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=0==e?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[o+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof Jf?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class np{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new tp(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:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.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 rp{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=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=r,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(Xf.prototype[Symbol.iterator]=function(){return this.iter()},tp.prototype[Symbol.iterator]=np.prototype[Symbol.iterator]=rp.prototype[Symbol.iterator]=function(){return this});class ip{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}}function op(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function sp(e,t,n=!0,r=!0){return Vf(e,t,n,r)}function ap(e,t){let n=e.charCodeAt(t);if(!(r=n,r>=55296&&r<56320&&t+1!=e.length))return n;var r;let i=e.charCodeAt(t+1);return function(e){return e>=56320&&e<57344}(i)?i-56320+(n-55296<<10)+65536:n}function lp(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}function cp(e){return e<65536?1:2}const hp=/\r\n?|\n/;var up=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(up||(up={}));class dp{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 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],o=this.sections[t++];o<0?(e(n,r,i),r+=i):r+=o,n+=i}}iterChangedRanges(e,t=!1){gp(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];r<0?e.push(n,r):e.push(r,n)}return new dp(e)}composeDesc(e){return this.empty?e:e.empty?this:bp(this,e)}mapDesc(e,t=!1){return e.empty?this:vp(this,e,t)}mapPos(e,t=-1,n=up.Simple){let r=0,i=0;for(let o=0;o<this.sections.length;){let s=this.sections[o++],a=this.sections[o++],l=r+s;if(a<0){if(l>e)return i+(e-r);i+=s}else{if(n!=up.Simple&&l>=e&&(n==up.TrackDel&&r<e&&l>e||n==up.TrackBefore&&r<e||n==up.TrackAfter&&l>e))return null;if(l>e||l==e&&t<0&&!s)return e==r||t<0?i:i+a;i+=a}r=l}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=r+this.sections[n++];if(this.sections[n++]>=0&&r<=t&&i>=e)return!(r<e&&i>t)||"cover";r=i}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+n+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeDesc");return new dp(e)}static create(e){return new dp(e)}}class fp extends dp{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 gp(this,(t,n,r,i,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return vp(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,i=0;r<t.length;r+=2){let o=t[r],s=t[r+1];if(s>=0){t[r]=s,t[r+1]=o;let a=r>>1;for(;n.length<a;)n.push(Xf.empty);n.push(o?e.slice(i,i+o):Xf.empty)}i+=o}return new fp(t,n)}compose(e){return this.empty?e:e.empty?this:bp(this,e,!0)}map(e,t=!1){return e.empty?this:vp(this,e,t,!0)}iterChanges(e,t=!1){gp(this,e,t)}get desc(){return dp.create(this.sections)}filter(e){let t=[],n=[],r=[],i=new yp(this);e:for(let o=0,s=0;;){let a=o==e.length?1e9:e[o++];for(;s<a||s==a&&0==i.len;){if(i.done)break e;let e=Math.min(i.len,a-s);pp(r,e,-1);let o=-1==i.ins?-1:0==i.off?i.ins:0;pp(t,e,o),o>0&&mp(n,t,i.text),i.forward(e),s+=e}let l=e[o++];for(;s<l;){if(i.done)break e;let e=Math.min(i.len,l-s);pp(t,e,-1),pp(r,e,-1==i.ins?-1:0==i.off?i.ins:0),i.forward(e),s+=e}}return{changes:new fp(t,n),filtered:dp.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):0==r?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let r=[],i=[],o=0,s=null;function a(e=!1){if(!e&&!r.length)return;o<t&&pp(r,t-o,-1);let n=new fp(r,i);s=s?s.compose(n.map(s)):n,r=[],i=[],o=0}return function e(l){if(Array.isArray(l))for(let t of l)e(t);else if(l instanceof fp){if(l.length!=t)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${t})`);a(),s=s?s.compose(l.map(s)):l}else{let{from:e,to:s=e,insert:c}=l;if(e>s||e<0||s>t)throw new RangeError(`Invalid change range ${e} to ${s} (in doc of length ${t})`);let h=c?"string"==typeof c?Xf.of(c.split(n||hp)):c:Xf.empty,u=h.length;if(e==s&&0==u)return;e<o&&a(),e>o&&pp(r,e-o,-1),pp(r,s-e,u),mp(i,r,h),o=s}}(e),a(!s),s}static empty(e){return new fp(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if("number"==typeof i)t.push(i,-1);else{if(!Array.isArray(i)||"number"!=typeof i[0]||i.some((e,t)=>t&&"string"!=typeof e))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==i.length)t.push(i[0],0);else{for(;n.length<r;)n.push(Xf.empty);n[r]=Xf.of(i.slice(1)),t.push(i[0],n[r].length)}}}return new fp(t,n)}static createSet(e,t){return new fp(e,t)}}function pp(e,t,n,r=!1){if(0==t&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&0==t&&0==e[i]?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function mp(e,t,n){if(0==n.length)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(Xf.empty);e.push(n)}}function gp(e,t,n){let r=e.inserted;for(let i=0,o=0,s=0;s<e.sections.length;){let a=e.sections[s++],l=e.sections[s++];if(l<0)i+=a,o+=a;else{let c=i,h=o,u=Xf.empty;for(;c+=a,h+=l,l&&r&&(u=u.append(r[s-2>>1])),!(n||s==e.sections.length||e.sections[s+1]<0);)a=e.sections[s++],l=e.sections[s++];t(i,c,o,h,u),i=c,o=h}}}function vp(e,t,n,r=!1){let i=[],o=r?[]:null,s=new yp(e),a=new yp(t);for(let e=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(-1==s.ins&&-1==a.ins){let e=Math.min(s.len,a.len);pp(i,e,-1),s.forward(e),a.forward(e)}else if(a.ins>=0&&(s.ins<0||e==s.i||0==s.off&&(a.len<s.len||a.len==s.len&&!n))){let t=a.len;for(pp(i,a.ins,-1);t;){let n=Math.min(s.len,t);s.ins>=0&&e<s.i&&s.len<=n&&(pp(i,0,s.ins),o&&mp(o,i,s.text),e=s.i),s.forward(n),t-=n}a.next()}else{if(!(s.ins>=0)){if(s.done&&a.done)return o?fp.createSet(i,o):dp.create(i);throw new Error("Mismatched change set lengths")}{let t=0,n=s.len;for(;n;)if(-1==a.ins){let e=Math.min(n,a.len);t+=e,n-=e,a.forward(e)}else{if(!(0==a.ins&&a.len<n))break;n-=a.len,a.next()}pp(i,t,e<s.i?s.ins:0),o&&e<s.i&&mp(o,i,s.text),e=s.i,s.forward(s.len-n)}}}}function bp(e,t,n=!1){let r=[],i=n?[]:null,o=new yp(e),s=new yp(t);for(let e=!1;;){if(o.done&&s.done)return i?fp.createSet(r,i):dp.create(r);if(0==o.ins)pp(r,o.len,0,e),o.next();else if(0!=s.len||s.done){if(o.done||s.done)throw new Error("Mismatched change set lengths");{let t=Math.min(o.len2,s.len),n=r.length;if(-1==o.ins){let n=-1==s.ins?-1:s.off?0:s.ins;pp(r,t,n,e),i&&n&&mp(i,r,s.text)}else-1==s.ins?(pp(r,o.off?0:o.len,t,e),i&&mp(i,r,o.textBit(t))):(pp(r,o.off?0:o.len,s.off?0:s.ins,e),i&&!s.off&&mp(i,r,s.text));e=(o.ins>t||s.ins>=0&&s.len>t)&&(e||r.length>n),o.forward2(t),s.forward(t)}}else pp(r,0,s.ins,e),i&&mp(i,r,s.text),s.next()}}class yp{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-2==this.ins}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?Xf.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Xf.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class wp{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 16777215==e?void 0:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new wp(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return xp.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return xp.range(this.anchor,n)}eq(e,t=!1){return!(this.anchor!=e.anchor||this.head!=e.head||this.goalColumn!=e.goalColumn||t&&this.empty&&this.assoc!=e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return xp.range(e.anchor,e.head)}static create(e,t,n){return new wp(e,t,n)}}class xp{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:xp.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 1==this.ranges.length?this:new xp([this.main],0)}addRange(e,t=!0){return xp.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,xp.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)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new xp(e.ranges.map(e=>wp.fromJSON(e)),e.main)}static single(e,t=e){return new xp([xp.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;r<e.length;r++){let i=e[r];if(i.empty?i.from<=n:i.from<n)return xp.normalized(e.slice(),t);n=i.to}return new xp(e,t)}static cursor(e,t=0,n,r){return wp.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=r?r:16777215)<<6)}static range(e,t,n,r){let i=(null!=n?n:16777215)<<6|(null==r?7:Math.min(6,r));return t<e?wp.create(t,e,48|i):wp.create(e,t,(t>e?8:0)|i)}static normalized(e,t=0){let n=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(n);for(let n=1;n<e.length;n++){let r=e[n],i=e[n-1];if(r.empty?r.from<=i.to:r.from<i.to){let o=i.from,s=Math.max(r.to,i.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?xp.range(s,o):xp.range(o,s))}}return new xp(e,t)}}function kp(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let Sp=0;class Ep{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=Sp++,this.default=e([]),this.extensions="function"==typeof i?i(this):i}get reader(){return this}static define(e={}){return new Ep(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:Cp),!!e.static,e.enables)}of(e){return new Op([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Op(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Op(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}}function Cp(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class Op{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Sp++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,i=this.id,o=e[i]>>1,s=2==this.type,a=!1,l=!1,c=[];for(let n of this.dependencies)"doc"==n?a=!0:"selection"==n?l=!0:1&(null!==(t=e[n.id])&&void 0!==t?t:1)||c.push(e[n.id]);return{create:e=>(e.values[o]=n(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||Ap(e,c)){let t=n(e);if(s?!Np(t,e.values[o],r):!r(t,e.values[o]))return e.values[o]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[i];if(null!=l){let i=Vp(t,l);if(this.dependencies.every(n=>n instanceof Ep?t.facet(n)===e.facet(n):!(n instanceof Rp)||t.field(n,!1)==e.field(n,!1))||(s?Np(a=n(e),i,r):r(a=n(e),i)))return e.values[o]=i,0}else a=n(e);return e.values[o]=a,1}}}}function Np(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function Ap(e,t){let n=!1;for(let r of t)1&Hp(e,r)&&(n=!0);return n}function Tp(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),o=r.filter(e=>!(1&e)),s=e[t.id]>>1;function a(e){let n=[];for(let t=0;t<r.length;t++){let o=Vp(e,r[t]);if(2==i[t])for(let e of o)n.push(e);else n.push(o)}return t.combine(n)}return{create(e){for(let t of r)Hp(e,t);return e.values[s]=a(e),1},update(e,n){if(!Ap(e,o))return 0;let r=a(e);return t.compare(r,e.values[s])?0:(e.values[s]=r,1)},reconfigure(e,i){let o=Ap(e,r),l=i.config.facets[t.id],c=i.facet(t);if(l&&!o&&Cp(n,l))return e.values[s]=c,0;let h=a(e);return t.compare(h,c)?(e.values[s]=c,0):(e.values[s]=h,1)}}}const Mp=Ep.define({static:!0});class Rp{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(e){let t=new Rp(Sp++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Mp).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r,i=e.facet(Mp),o=n.facet(Mp);return(r=i.find(e=>e.field==this))&&r!=o.find(e=>e.field==this)?(e.values[t]=r.create(e),1):null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,Mp.of({field:this,create:e})]}get extension(){return this}}const Dp=4,Pp=3,Lp=2,Bp=1;function Ip(e){return t=>new _p(t,e)}const jp={highest:Ip(0),high:Ip(Bp),default:Ip(Lp),low:Ip(Pp),lowest:Ip(Dp)};class _p{constructor(e,t){this.inner=e,this.prec=t}}class Fp{of(e){return new Wp(this,e)}reconfigure(e){return Fp.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Wp{constructor(e,t){this.compartment=e,this.inner=t}}class zp{constructor(e,t,n,r,i,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let r=[],i=Object.create(null),o=new Map;for(let n of function(e,t,n){let r=[[],[],[],[],[]],i=new Map;function o(e,s){let a=i.get(e);if(null!=a){if(a<=s)return;let t=r[a].indexOf(e);t>-1&&r[a].splice(t,1),e instanceof Wp&&n.delete(e.compartment)}if(i.set(e,s),Array.isArray(e))for(let t of e)o(t,s);else if(e instanceof Wp){if(n.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),o(r,s)}else if(e instanceof _p)o(e.inner,e.prec);else if(e instanceof Rp)r[s].push(e),e.provides&&o(e.provides,s);else if(e instanceof Op)r[s].push(e),e.facet.extensions&&o(e.facet.extensions,Lp);else{let t=e.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(t,s)}}return o(e,Lp),r.reduce((e,t)=>e.concat(t))}(e,t,o))n instanceof Rp?r.push(n):(i[n.facet.id]||(i[n.facet.id]=[])).push(n);let s=Object.create(null),a=[],l=[];for(let e of r)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let c=null==n?void 0:n.config.facets;for(let e in i){let t=i[e],r=t[0].facet,o=c&&c[e]||[];if(t.every(e=>0==e.type))if(s[r.id]=a.length<<1|1,Cp(o,t))a.push(n.facet(r));else{let e=r.combine(t.map(e=>e.value));a.push(n&&r.compare(e,n.facet(r))?n.facet(r):e)}else{for(let e of t)0==e.type?(s[e.id]=a.length<<1|1,a.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[r.id]=l.length<<1,l.push(e=>Tp(e,r,t))}}let h=l.map(e=>e(s));return new zp(e,o,h,s,a,i)}}function Hp(e,t){if(1&t)return 2;let n=t>>1,r=e.status[n];if(4==r)throw new Error("Cyclic dependency between fields and/or facets");if(2&r)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Vp(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const qp=Ep.define(),Up=Ep.define({combine:e=>e.some(e=>e),static:!0}),$p=Ep.define({combine:e=>e.length?e[0]:void 0,static:!0}),Kp=Ep.define(),Yp=Ep.define(),Gp=Ep.define(),Xp=Ep.define({combine:e=>!!e.length&&e[0]});class Jp{constructor(e,t){this.type=e,this.value=t}static define(){return new Qp}}class Qp{of(e){return new Jp(this,e)}}class Zp{constructor(e){this.map=e}of(e){return new em(this,e)}}class em{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new em(this.type,t)}is(e){return this.type==e}static define(e={}){return new Zp(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}}em.reconfigure=em.define(),em.appendConfig=em.define();class tm{constructor(e,t,n,r,i,o){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=i,this.scrollIntoView=o,this._doc=null,this._state=null,n&&kp(n,t.newLength),i.some(e=>e.type==tm.time)||(this.annotations=i.concat(tm.time.of(Date.now())))}static create(e,t,n,r,i,o){return new tm(e,t,n,r,i,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(tm.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function nm(e,t){let n=[];for(let r=0,i=0;;){let o,s;if(r<e.length&&(i==t.length||t[i]>=e[r]))o=e[r++],s=e[r++];else{if(!(i<t.length))return n;o=t[i++],s=t[i++]}!n.length||n[n.length-1]<o?n.push(o,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function rm(e,t,n){var r;let i,o,s;return n?(i=t.changes,o=fp.empty(t.changes.length),s=e.changes.compose(t.changes)):(i=t.changes.map(e.changes),o=e.changes.mapDesc(t.changes,!0),s=e.changes.compose(i)),{changes:s,selection:t.selection?t.selection.map(o):null===(r=e.selection)||void 0===r?void 0:r.map(i),effects:em.mapEffects(e.effects,i).concat(em.mapEffects(t.effects,o)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function im(e,t,n){let r=t.selection,i=am(t.annotations);return t.userEvent&&(i=i.concat(tm.userEvent.of(t.userEvent))),{changes:t.changes instanceof fp?t.changes:fp.of(t.changes||[],n,e.facet($p)),selection:r&&(r instanceof xp?r:xp.single(r.anchor,r.head)),effects:am(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function om(e,t,n){let r=im(e,t.length?t[0]:{},e.doc.length);t.length&&!1===t[0].filter&&(n=!1);for(let i=1;i<t.length;i++){!1===t[i].filter&&(n=!1);let o=!!t[i].sequential;r=rm(r,im(e,t[i],o?r.changes.newLength:e.doc.length),o)}let i=tm.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return function(e){let t=e.startState,n=t.facet(Gp),r=e;for(let i=n.length-1;i>=0;i--){let o=n[i](e);o&&Object.keys(o).length&&(r=rm(r,im(t,o,e.changes.newLength),!0))}return r==e?e:tm.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}(n?function(e){let t=e.startState,n=!0;for(let r of t.facet(Kp)){let t=r(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:nm(n,t))}if(!0!==n){let r,i;if(!1===n)i=e.changes.invertedDesc,r=fp.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=tm.create(t,r,e.selection&&e.selection.map(i),em.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(Yp);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof tm?i:Array.isArray(i)&&1==i.length&&i[0]instanceof tm?i[0]:om(t,am(i),!1)}return e}(i):i)}tm.time=Jp.define(),tm.userEvent=Jp.define(),tm.addToHistory=Jp.define(),tm.remote=Jp.define();const sm=[];function am(e){return null==e?sm:Array.isArray(e)?e:[e]}var lm=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(lm||(lm={}));const cm=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let hm;try{hm=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function um(e){return t=>{if(!/\S/.test(t))return lm.Space;if(function(e){if(hm)return hm.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||cm.test(n)))return!0}return!1}(t))return lm.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return lm.Word;return lm.Other}}class dm{constructor(e,t,n,r,i,o){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,o&&(o._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)Hp(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null!=n)return Hp(this,n),Vp(this,n);if(t)throw new RangeError("Field is not present in this state")}update(...e){return om(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:r,compartments:i}=n;for(let t of e.effects)t.is(Fp.reconfigure)?(n&&(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),n=null),i.set(t.value.compartment,t.value.extension)):t.is(em.reconfigure)?(n=null,r=t.value):t.is(em.appendConfig)&&(n=null,r=am(r).concat(t.value));if(n)t=e.startState.values.slice();else{n=zp.resolve(r,i,this);let e=new dm(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null);t=e.values}let o=e.startState.facet(Up)?e.newSelection:e.newSelection.asSingle();new dm(n,e.newDoc,o,t,(t,n)=>n.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:xp.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],o=am(n.effects);for(let n=1;n<t.ranges.length;n++){let s=e(t.ranges[n]),a=this.changes(s.changes),l=a.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(l);let c=r.mapDesc(a,!0);i.push(s.range.map(c)),r=r.compose(l),o=em.mapEffects(o,l).concat(em.mapEffects(am(s.effects),c))}return{changes:r,selection:xp.create(i,t.mainIndex),effects:o}}changes(e=[]){return e instanceof fp?e:fp.of(e,this.doc.length,this.facet(dm.lineSeparator))}toText(e){return Xf.of(e.split(this.facet(dm.lineSeparator)||hp))}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 null==t?e.default:(Hp(this,t),Vp(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Rp&&null!=this.config.address[r.id]&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||"string"!=typeof e.doc)throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(n)for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let i=n[t],o=e[t];r.push(i.init(e=>i.spec.fromJSON(o,e)))}return dm.create({doc:e.doc,selection:xp.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=zp.resolve(e.extensions||[],new Map),n=e.doc instanceof Xf?e.doc:Xf.of((e.doc||"").split(t.staticFacet(dm.lineSeparator)||hp)),r=e.selection?e.selection instanceof xp?e.selection:xp.single(e.selection.anchor,e.selection.head):xp.single(0);return kp(r,n.length),t.staticFacet(Up)||(r=r.asSingle()),new dm(t,n,r,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(dm.tabSize)}get lineBreak(){return this.facet(dm.lineSeparator)||"\n"}get readOnly(){return this.facet(Xp)}phrase(e,...t){for(let t of this.facet(dm.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,n)=>{if("$"==n)return"$";let r=+(n||1);return!r||r>t.length?e:t[r-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(qp))for(let o of i(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return um(t.length?t[0]:"")}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),o=e-n,s=e-n;for(;o>0;){let e=sp(t,o,!1);if(i(t.slice(e,o))!=lm.Word)break;o=e}for(;s<r;){let e=sp(t,s);if(i(t.slice(s,e))!=lm.Word)break;s=e}return o==s?null:xp.range(o+n,s+n)}}function fm(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],o=r[e];if(void 0===o)r[e]=i;else if(o===i||void 0===i);else{if(!Object.hasOwnProperty.call(n,e))throw new Error("Config merge conflict for field "+e);r[e]=n[e](o,i)}}for(let e in t)void 0===r[e]&&(r[e]=t[e]);return r}dm.allowMultipleSelections=Up,dm.tabSize=Ep.define({combine:e=>e.length?e[0]:4}),dm.lineSeparator=$p,dm.readOnly=Xp,dm.phrases=Ep.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),dm.languageData=qp,dm.changeFilter=Kp,dm.transactionFilter=Yp,dm.transactionExtender=Gp,Fp.reconfigure=em.define();class pm{eq(e){return this==e}range(e,t=e){return gm.create(e,t,this)}}function mm(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}pm.prototype.startSide=pm.prototype.endSide=0,pm.prototype.point=!1,pm.prototype.mapMode=up.TrackDel;let gm=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function vm(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class bm{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let o=r,s=i.length;;){if(o==s)return o;let r=o+s>>1,a=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==o)return a>=0?o:s;a>=0?s=r:o=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,i);i<o;i++)if(!1===r(this.from[i]+e,this.to[i]+e,this.value[i]))return!1}map(e,t){let n=[],r=[],i=[],o=-1,s=-1;for(let a=0;a<this.value.length;a++){let l,c,h=this.value[a],u=this.from[a]+e,d=this.to[a]+e;if(u==d){let e=t.mapPos(u,h.startSide,h.mapMode);if(null==e)continue;if(l=c=e,h.startSide!=h.endSide&&(c=t.mapPos(u,h.endSide),c<l))continue}else if(l=t.mapPos(u,h.startSide),c=t.mapPos(d,h.endSide),l>c||l==c&&h.startSide>0&&h.endSide<=0)continue;(c-l||h.endSide-h.startSide)<0||(o<0&&(o=l),h.point&&(s=Math.max(s,c-l)),n.push(h),r.push(l-o),i.push(c-o))}return{mapped:n.length?new bm(r,i,n,s):null,pos:o}}}class ym{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new ym(e,t,n,r)}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:r=0,filterTo:i=this.length}=e,o=e.filter;if(0==t.length&&!o)return this;if(n&&(t=t.slice().sort(vm)),this.isEmpty)return t.length?ym.of(t):this;let s=new km(this,null,-1).goto(0),a=0,l=[],c=new wm;for(;s.value||a<t.length;)if(a<t.length&&(s.from-t[a].from||s.startSide-t[a].value.startSide)>=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==s.rangeIndex&&s.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(s.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(s.chunkIndex)||i<this.chunkPos[s.chunkIndex])&&c.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||r>s.to||i<s.from||o(s.from,s.to,s.value))&&(c.addInner(s.from,s.to,s.value)||l.push(gm.create(s.from,s.to,s.value))),s.next());return c.finishInner(this.nextLayer.isEmpty&&!l.length?ym.empty:this.nextLayer.update({add:l,filter:o,filterFrom:r,filterTo:i}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],r=-1;for(let i=0;i<this.chunk.length;i++){let o=this.chunkPos[i],s=this.chunk[i],a=e.touchesRange(o,o+s.length);if(!1===a)r=Math.max(r,s.maxPoint),t.push(s),n.push(e.mapPos(o));else if(!0===a){let{mapped:i,pos:a}=s.map(o,e);i&&(r=Math.max(r,i.maxPoint),t.push(i),n.push(a))}}let i=this.nextLayer.map(e);return 0==t.length?i:new ym(n,t,i||ym.empty,r)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],o=this.chunk[r];if(t>=i&&e<=i+o.length&&!1===o.between(i,e-i,t-i,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return Sm.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Sm.from(e).goto(t)}static compare(e,t,n,r,i=-1){let o=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),a=xm(o,s,n),l=new Cm(o,a,i),c=new Cm(s,a,i);n.iterGaps((e,t,n)=>Om(l,e,c,t,n,r)),n.empty&&0==n.length&&Om(l,0,c,0,0,r)}static eq(e,t,n=0,r){null==r&&(r=999999999);let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),o=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=o.length)return!1;if(!i.length)return!0;let s=xm(i,o),a=new Cm(i,s,0).goto(n),l=new Cm(o,s,0).goto(n);for(;;){if(a.to!=l.to||!Nm(a.active,l.active)||a.point&&(!l.point||!mm(a.point,l.point)))return!1;if(a.to>r)return!0;a.next(),l.next()}}static spans(e,t,n,r,i=-1){let o=new Cm(e,null,i).goto(t),s=t,a=o.openStart;for(;;){let e=Math.min(o.to,n);if(o.point){let n=o.activeForPoint(o.to),i=o.pointFrom<t?n.length+1:o.point.startSide<0?n.length:Math.min(n.length,a);r.point(s,e,o.point,n,i,o.pointRank),a=Math.min(o.openEnd(e),n.length)}else e>s&&(r.span(s,e,o.active,a),a=o.openEnd(e));if(o.to>n)return a+(o.point&&o.to>n?1:0);s=o.to,o.next()}}static of(e,t=!1){let n=new wm;for(let r of e instanceof gm?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(vm(t,r)>0)return e.slice().sort(vm);t=r}return e}(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return ym.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=ym.empty;r=r.nextLayer)t=new ym(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}ym.empty=new ym([],[],null,-1),ym.empty.nextLayer=ym.empty;class wm{finishChunk(e){this.chunks.push(new bm(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 wm)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(r<0)&&(250==this.from.length&&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(ym.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=ym.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function xm(e,t,n){let r=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&r.set(t.chunk[e],t.chunkPos[e]);let i=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let o=r.get(e.chunk[t]);null==o||(n?n.mapPos(o):o)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(o,o+e.chunk[t].length))||i.add(e.chunk[t])}return i}class km{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}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 t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}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}{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 Sm{constructor(e){this.heap=e}static from(e,t=null,n=-1){let r=[];for(let i=0;i<e.length;i++)for(let o=e[i];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&r.push(new km(o,t,n,i));return 1==r.length?r[0]:new Sm(r)}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 e=this.heap.length>>1;e>=0;e--)Em(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)Em(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)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(),Em(this.heap,0)}}}function Em(e,t){for(let n=e[t];;){let r=1+(t<<1);if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}class Cm{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=Sm.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){Am(this.active,e),Am(this.activeTo,e),Am(this.activeRank,e),this.minActive=Mm(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;Tm(this.active,t,n),Tm(this.activeTo,t,r),Tm(this.activeRank,t,i),e&&Tm(e,t,this.cursor.from),this.minActive=Mm(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&Am(n,r)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(n),this.cursor.next()}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)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 Om(e,t,n,r,i,o){e.goto(t),n.goto(r);let s=r+i,a=r,l=r-t,c=!!o.boundChange;for(let t=!1;;){let r=e.to+l-n.to,i=r||e.endSide-n.endSide,h=i<0?e.to+l:n.to,u=Math.min(h,s);if(e.point||n.point?(e.point&&n.point&&mm(e.point,n.point)&&Nm(e.activeForPoint(e.to),n.activeForPoint(n.to))||o.comparePoint(a,u,e.point,n.point),t=!1):(t&&o.boundChange(a),u>a&&!Nm(e.active,n.active)&&o.compareRange(a,u,e.active,n.active),c&&u<s&&(r||e.openEnd(h)!=n.openEnd(h))&&(t=!0)),h>s)break;a=h,i<=0&&e.next(),i>=0&&n.next()}}function Nm(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!mm(e[n],t[n]))return!1;return!0}function Am(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function Tm(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function Mm(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}function Rm(e,t,n=e.length){let r=0;for(let i=0;i<n&&i<e.length;)9==e.charCodeAt(i)?(r+=t-r%t,i++):(r++,i=sp(e,i));return r}function Dm(e,t,n,r){for(let r=0,i=0;;){if(i>=t)return r;if(r==e.length)break;i+=9==e.charCodeAt(r)?n-i%n:1,r=sp(e,r)}return!0===r?-1:e.length}const Pm="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),Lm="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),Bm="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class Im{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,o,s){let a=[],l=/^@(\w+)\b/.exec(e[0]),c=l&&"keyframes"==l[1];if(l&&null==t)return o.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),s,o);else if(s&&"object"==typeof s){if(!l)throw new RangeError("The value of a property ("+n+") should be a primitive value.");i(r(n),s,a,c)}else null!=s&&a.push(n.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+s+";")}(a.length||c)&&o.push((!n||l||s?e:e.map(n)).join(", ")+" {"+a.join(" ")+"}")}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=Bm[Pm]||1;return Bm[Pm]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let r=e[Lm],i=n&&n.nonce;r?i&&r.setNonce(i):r=new _m(e,i),r.mount(Array.isArray(t)?t:[t],e)}}let jm=new Map;class _m{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=jm.get(n);if(t)return e[Lm]=t;this.sheet=new r.CSSStyleSheet,jm.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Lm]=this}mount(e,t){let n=this.sheet,r=0,i=0;for(let t=0;t<e.length;t++){let o=e[t],s=this.modules.indexOf(o);if(s<i&&s>-1&&(this.modules.splice(s,1),i--,s=-1),-1==s){if(this.modules.splice(i++,0,o),n)for(let e=0;e<o.rules.length;e++)n.insertRule(o.rules[e],r++)}else{for(;i<s;)r+=this.modules[i++].rules.length;r+=o.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}for(var Fm={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:"'"},Wm={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},zm="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Hm="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Vm=0;Vm<10;Vm++)Fm[48+Vm]=Fm[96+Vm]=String(Vm);for(Vm=1;Vm<=24;Vm++)Fm[Vm+111]="F"+Vm;for(Vm=65;Vm<=90;Vm++)Fm[Vm]=String.fromCharCode(Vm+32),Wm[Vm]=String.fromCharCode(Vm);for(var qm in Fm)Wm.hasOwnProperty(qm)||(Wm[qm]=Fm[qm]);function Um(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];"string"==typeof i?e.setAttribute(r,i):null!=i&&(e[r]=i)}t++}for(;t<arguments.length;t++)$m(e,arguments[t]);return e}function $m(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var n=0;n<t.length;n++)$m(e,t[n])}}let Km="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Ym="undefined"!=typeof document?document:{documentElement:{style:{}}};const Gm=/Edge\/(\d+)/.exec(Km.userAgent),Xm=/MSIE \d/.test(Km.userAgent),Jm=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Km.userAgent),Qm=!!(Xm||Jm||Gm),Zm=!Qm&&/gecko\/(\d+)/i.test(Km.userAgent),eg=!Qm&&/Chrome\/(\d+)/.exec(Km.userAgent),tg="webkitFontSmoothing"in Ym.documentElement.style,ng=!Qm&&/Apple Computer/.test(Km.vendor),rg=ng&&(/Mobile\/\w+/.test(Km.userAgent)||Km.maxTouchPoints>2);var ig={mac:rg||/Mac/.test(Km.platform),windows:/Win/.test(Km.platform),linux:/Linux|X11/.test(Km.platform),ie:Qm,ie_version:Xm?Ym.documentMode||6:Jm?+Jm[1]:Gm?+Gm[1]:0,gecko:Zm,gecko_version:Zm?+(/Firefox\/(\d+)/.exec(Km.userAgent)||[0,0])[1]:0,chrome:!!eg,chrome_version:eg?+eg[1]:0,ios:rg,android:/Android\b/.test(Km.userAgent),webkit:tg,webkit_version:tg?+(/\bAppleWebKit\/(\d+)/.exec(Km.userAgent)||[0,0])[1]:0,safari:ng,safari_version:ng?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Km.userAgent)||[0,0])[1]:0,tabSize:null!=Ym.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function og(e,t){for(let n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}const sg=Object.create(null);function ag(e,t,n){if(e==t)return!0;e||(e=sg),t||(t=sg);let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let o of r)if(o!=n&&(-1==i.indexOf(o)||e[o]!==t[o]))return!1;return!0}function lg(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,"style"==i?e.style.cssText="":e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,"style"==i?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function cg(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}class hg{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 ug=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(ug||(ug={}));class dg extends pm{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new fg(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 mg(e,t,t,n,e.widget||null,!1)}static replace(e){let t,n,r=!!e.block;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:i,end:o}=gg(e,r);t=(i?r?-3e8:-1:5e8)-1,n=1+(o?r?2e8:1:-6e8)}return new mg(e,t,n,r,e.widget||null,!0)}static line(e){return new pg(e)}static set(e,t=!1){return ym.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}dg.none=ym.empty;class fg extends dg{constructor(e){let{start:t,end:n}=gg(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?og(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||sg}eq(e){return this==e||e instanceof fg&&this.tagName==e.tagName&&ag(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}fg.prototype.point=!1;class pg extends dg{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof pg&&this.spec.class==e.spec.class&&ag(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)}}pg.prototype.mapMode=up.TrackBefore,pg.prototype.point=!0;class mg extends dg{constructor(e,t,n,r,i,o){super(t,n,i,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?up.TrackBefore:up.TrackAfter:up.TrackDel}get type(){return this.startSide!=this.endSide?ug.WidgetRange:this.startSide<=0?ug.WidgetBefore:ug.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof mg&&(t=this.widget,n=e.widget,t==n||!!(t&&n&&t.compare(n)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide;var t,n}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)}}function gg(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return null==n&&(n=e.inclusive),null==r&&(r=e.inclusive),{start:null!=n?n:t,end:null!=r?r:t}}function vg(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}mg.prototype.point=!0;class bg extends pm{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof bg&&this.tagName==e.tagName&&ag(this.attributes,e.attributes)}static create(e){return new bg(e.tagName,e.attributes||sg)}static set(e,t=!1){return ym.of(e,t)}}function yg(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function wg(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function xg(e,t){if(!t.anchorNode)return!1;try{return wg(e,t.anchorNode)}catch(e){return!1}}function kg(e){return 3==e.nodeType?Bg(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function Sg(e,t,n,r){return!!n&&(Og(e,t,n,r,-1)||Og(e,t,n,r,1))}function Eg(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function Cg(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function Og(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Ng(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=Eg(e)+(i<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(i<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=i<0?Ng(e):0}}}function Ng(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Ag(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function Tg(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function Mg(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}bg.prototype.startSide=bg.prototype.endSide=-1;class Rg{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?Ng(t):0),n,Math.min(e.focusOffset,n?Ng(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}}let Dg,Pg=null;function Lg(e){if(e.setActive)return e.setActive();if(Pg)return e.focus(Pg);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==Pg?{get preventScroll(){return Pg={preventScroll:!0},!0}}:void 0),!Pg){Pg=!1;for(let e=0;e<t.length;){let n=t[e++],r=t[e++],i=t[e++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}}}function Bg(e,t,n=t){let r=Dg||(Dg=document.createRange());return r.setEnd(e,n),r.setStart(e,t),r}function Ig(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let o=new KeyboardEvent("keydown",i);o.synthetic=!0,e.dispatchEvent(o);let s=new KeyboardEvent("keyup",i);return s.synthetic=!0,e.dispatchEvent(s),o.defaultPrevented||s.defaultPrevented}function jg(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function _g(e,t){for(let n=e,r=t;;){if(3==n.nodeType&&r>0)return{node:n,offset:r};if(1==n.nodeType&&r>0){if("false"==n.contentEditable)return null;n=n.childNodes[r-1],r=Ng(n)}else{if(!n.parentNode||Cg(n))return null;r=Eg(n),n=n.parentNode}}}function Fg(e,t){for(let n=e,r=t;;){if(3==n.nodeType&&r<n.nodeValue.length)return{node:n,offset:r};if(1==n.nodeType&&r<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[r],r=0}else{if(!n.parentNode||Cg(n))return null;r=Eg(n)+1,n=n.parentNode}}}ig.safari&&ig.safari_version>=26&&(Pg=!1);class Wg{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new Wg(e.parentNode,Eg(e),t)}static after(e,t){return new Wg(e.parentNode,Eg(e)+1,t)}}var zg=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(zg||(zg={}));const Hg=zg.LTR,Vg=zg.RTL;function qg(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}const Ug=qg("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),$g=qg("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Kg=Object.create(null),Yg=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);Kg[t]=n,Kg[n]=-t}function Gg(e){return e<=247?Ug[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?$g[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}const Xg=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Jg{get dir(){return this.level%2?Vg:Hg}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,r){let i=-1;for(let o=0;o<e.length;o++){let s=e[o];if(s.from<=t&&s.to>=t){if(s.level==n)return o;(i<0||(0!=r?r<0?s.from<t:s.to>t:e[i].level>s.level))&&(i=o)}}if(i<0)throw new RangeError("Index out of range");return i}}function Qg(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!Qg(r.inner,i.inner))return!1}return!0}const Zg=[];function ev(e,t,n,r,i,o,s){let a=r%2?2:1;if(r%2==i%2)for(let l=t,c=0;l<n;){let t=!0,h=!1;if(c==o.length||l<o[c].from){let e=Zg[l];e!=a&&(t=!1,h=16==e)}let u=t||1!=a?null:[],d=t?r:r+1,f=l;e:for(;;)if(c<o.length&&f==o[c].from){if(h)break e;let p=o[c];if(!t)for(let e=p.to,t=c+1;;){if(e==n)break e;if(!(t<o.length&&o[t].from==e)){if(Zg[e]==a)break e;break}e=o[t++].to}if(c++,u)u.push(p);else{p.from>l&&s.push(new Jg(l,p.from,d)),tv(e,p.direction==Hg!=!(d%2)?r+1:r,i,p.inner,p.from,p.to,s),l=p.to}f=p.to}else{if(f==n||(t?Zg[f]!=a:Zg[f]==a))break;f++}u?ev(e,l,f,r+1,i,u,s):l<f&&s.push(new Jg(l,f,d)),l=f}else for(let l=n,c=o.length;l>t;){let n=!0,h=!1;if(!c||l>o[c-1].to){let e=Zg[l-1];e!=a&&(n=!1,h=16==e)}let u=n||1!=a?null:[],d=n?r:r+1,f=l;e:for(;;)if(c&&f==o[c-1].to){if(h)break e;let p=o[--c];if(!n)for(let e=p.from,n=c;;){if(e==t)break e;if(!n||o[n-1].to!=e){if(Zg[e-1]==a)break e;break}e=o[--n].from}if(u)u.push(p);else{p.to<l&&s.push(new Jg(p.to,l,d)),tv(e,p.direction==Hg!=!(d%2)?r+1:r,i,p.inner,p.from,p.to,s),l=p.from}f=p.from}else{if(f==t||(n?Zg[f-1]!=a:Zg[f-1]==a))break;f--}u?ev(e,f,l,r+1,i,u,s):f<l&&s.push(new Jg(f,l,d)),l=f}}function tv(e,t,n,r,i,o,s){let a=t%2?2:1;!function(e,t,n,r,i){for(let o=0;o<=r.length;o++){let s=o?r[o-1].to:t,a=o<r.length?r[o].from:n,l=o?256:i;for(let t=s,n=l,r=l;t<a;t++){let i=Gg(e.charCodeAt(t));512==i?i=n:8==i&&4==r&&(i=16),Zg[t]=4==i?2:i,7&i&&(r=i),n=i}for(let e=s,t=l,r=l;e<a;e++){let i=Zg[e];if(128==i)e<a-1&&t==Zg[e+1]&&24&t?i=Zg[e]=t:Zg[e]=256;else if(64==i){let i=e+1;for(;i<a&&64==Zg[i];)i++;let o=e&&8==t||i<n&&8==Zg[i]?1==r?1:8:256;for(let t=e;t<i;t++)Zg[t]=o;e=i-1}else 8==i&&1==r&&(Zg[e]=1);t=i,7&i&&(r=i)}}}(e,i,o,r,a),function(e,t,n,r,i){let o=1==i?2:1;for(let s=0,a=0,l=0;s<=r.length;s++){let c=s?r[s-1].to:t,h=s<r.length?r[s].from:n;for(let t,n,r,s=c;s<h;s++)if(n=Kg[t=e.charCodeAt(s)])if(n<0){for(let e=a-3;e>=0;e-=3)if(Yg[e+1]==-n){let t=Yg[e+2],n=2&t?i:4&t?1&t?o:i:0;n&&(Zg[s]=Zg[Yg[e]]=n),a=e;break}}else{if(189==Yg.length)break;Yg[a++]=s,Yg[a++]=t,Yg[a++]=l}else if(2==(r=Zg[s])||1==r){let e=r==i;l=e?0:1;for(let t=a-3;t>=0;t-=3){let n=Yg[t+2];if(2&n)break;if(e)Yg[t+2]|=2;else{if(4&n)break;Yg[t+2]|=4}}}}}(e,i,o,r,a),function(e,t,n,r){for(let i=0,o=r;i<=n.length;i++){let s=i?n[i-1].to:e,a=i<n.length?n[i].from:t;for(let l=s;l<a;){let s=Zg[l];if(256==s){let s=l+1;for(;;)if(s==a){if(i==n.length)break;s=n[i++].to,a=i<n.length?n[i].from:t}else{if(256!=Zg[s])break;s++}let c=1==o,h=c==(1==(s<t?Zg[s]:r))?c?1:2:r;for(let t=s,r=i,o=r?n[r-1].to:e;t>l;)t==o&&(t=n[--r].from,o=r?n[r-1].to:e),Zg[--t]=h;l=s}else o=s,l++}}}(i,o,r,a),ev(e,i,o,t,n,r,s)}function nv(e){return[new Jg(0,e,0)]}let rv="";function iv(e,t,n,r,i){var o;let s=r.head-e.from,a=Jg.find(t,s,null!==(o=r.bidiLevel)&&void 0!==o?o:-1,r.assoc),l=t[a],c=l.side(i,n);if(s==c){let e=a+=i?1:-1;if(e<0||e>=t.length)return null;l=t[a=e],s=l.side(!i,n),c=l.side(i,n)}let h=sp(e.text,s,l.forward(i,n));(h<l.from||h>l.to)&&(h=c),rv=e.text.slice(Math.min(s,h),Math.max(s,h));let u=a==(i?t.length-1:0)?null:t[a+(i?1:-1)];return u&&h==c&&u.level+(i?0:1)<l.level?xp.cursor(u.side(!i,n)+e.from,u.forward(i,n)?1:-1,u.level):xp.cursor(h+e.from,l.forward(i,n)?-1:1,l.level)}function ov(e,t,n){for(let r=t;r<n;r++){let t=Gg(e.charCodeAt(r));if(1==t)return Hg;if(2==t||4==t)return Vg}return Hg}const sv=Ep.define(),av=Ep.define(),lv=Ep.define(),cv=Ep.define(),hv=Ep.define(),uv=Ep.define(),dv=Ep.define(),fv=Ep.define(),pv=Ep.define(),mv=Ep.define({combine:e=>e.some(e=>e)}),gv=Ep.define({combine:e=>e.some(e=>e)}),vv=Ep.define();class bv{constructor(e,t="nearest",n="nearest",r=5,i=5,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=o}map(e){return e.empty?this:new bv(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 bv(xp.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const yv=em.define({map:(e,t)=>e.map(t)}),wv=em.define();function xv(e,t,n){let r=e.facet(cv);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)}const kv=Ep.define({combine:e=>!e.length||e[0]});let Sv=0;const Ev=Ep.define({combine:e=>e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})});class Cv{constructor(e,t,n,r,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(Ev.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Ev.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:r,provide:i,decorations:o}=t||{};return new Cv(Sv++,e,n,r,e=>{let t=[];return o&&t.push(Tv.of(t=>{let n=t.plugin(e);return n?o(n):dg.none})),i&&t.push(i(e)),t})}static fromClass(e,t){return Cv.define((t,n)=>new e(t,n),t)}}class Ov{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 e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(xv(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){xv(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){xv(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Nv=Ep.define(),Av=Ep.define(),Tv=Ep.define(),Mv=Ep.define(),Rv=Ep.define(),Dv=Ep.define(),Pv=Ep.define();function Lv(e,t){let n=e.state.facet(Pv);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return ym.spans(r,t.from,t.to,{point(){},span(e,n,r,o){let s=e-t.from,a=n-t.from,l=i;for(let e=r.length-1;e>=0;e--,o--){let n,i=r[e].spec.bidiIsolate;if(null==i&&(i=ov(t.text,s,a)),o>0&&l.length&&(n=l[l.length-1]).to==s&&n.direction==i)n.to=a,l=n.inner;else{let e={from:s,to:a,direction:i,inner:[]};l.push(e),l=e.inner}}}}),i}const Bv=Ep.define();function Iv(e){let t=0,n=0,r=0,i=0;for(let o of e.state.facet(Bv)){let s=o(e);s&&(null!=s.left&&(t=Math.max(t,s.left)),null!=s.right&&(n=Math.max(n,s.right)),null!=s.top&&(r=Math.max(r,s.top)),null!=s.bottom&&(i=Math.max(i,s.bottom)))}return{left:t,right:n,top:r,bottom:i}}const jv=Ep.define();class _v{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new _v(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 r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(0==t.length)return e;let n=[];for(let r=0,i=0,o=0;;){let s=r<e.length?e[r].fromB:1e9,a=i<t.length?t[i]:1e9,l=Math.min(s,a);if(1e9==l)break;let c=l+o,h=l,u=c;for(;;)if(i<t.length&&t[i]<=h){let n=t[i+1];i+=2,h=Math.max(h,n);for(let t=r;t<e.length&&e[t].fromB<=h;t++)o=e[t].toA-e[t].toB;u=Math.max(u,n+o)}else{if(!(r<e.length&&e[r].fromB<=h))break;{let t=e[r++];h=Math.max(h,t.toB),u=Math.max(u,t.toA),o=t.toA-t.toB}}n.push(new _v(c,u,l,h))}return n}}class Fv{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=fp.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let r=[];this.changes.iterChangedRanges((e,t,n,i)=>r.push(new _v(e,t,n,i))),this.changedRanges=r}static create(e,t,n){return new Fv(e,t,n)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}const Wv=[];class zv{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return 1&this.flags}get children(){return Wv}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,4&this.flags){this.flags&=-5;let e=this.domAttrs;e&&function(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;null==t[r]&&e.removeAttribute(r)}for(let n in t){let r=t[n];"style"==n?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=Eg(this.dom),r=this.length?e>0:t>0;return new Wg(this.parent.dom,n+(r?1:0),0==e||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&2&this.parent.flags&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof qv)return e;return null}static get(e){return e.cmTile}}class Hv extends zv{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(2&this.flags)return;super.sync(e);let t,n=this.dom,r=null,i=(null==e?void 0:e.node)==n?e:null,o=0;for(let s of this.children){if(s.sync(e),o+=s.length+s.breakAfter,t=r?r.nextSibling:n.firstChild,i&&t!=s.dom&&(i.written=!0),s.dom.parentNode==n)for(;t&&t!=s.dom;)t=Vv(t);else n.insertBefore(s.dom,t);r=s.dom}for(t=r?r.nextSibling:n.firstChild,i&&t&&(i.written=!0);t;)t=Vv(t);this.length=o}}function Vv(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class qv extends Hv{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=zv.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let o=n.children[r++];if(o instanceof Uv)t.push(r),n=o,r=0;else{let t=i+o.length,n=e(o,i);if(void 0!==n)return n;i=t+o.breakAfter}}}resolveBlock(e,t){let n,r,i=-1,o=-1;if(this.blockTiles((s,a)=>{let l=a+s.length;if(e>=a&&e<=l){if(s.isWidget()&&t>=-1&&t<=1){if(32&s.flags)return!0;16&s.flags&&(n=void 0)}(a<e||e==l&&(t<-1?s.length:s.covers(1)))&&(!n||!s.isWidget()&&n.isWidget())&&(n=s,i=e-a),(l>e||e==a&&(t>1?s.length:s.covers(-1)))&&(!r||!s.isWidget()&&r.isWidget())&&(r=s,o=e-a)}}),!n&&!r)throw new Error("No tile at position "+e);return n&&t<0||!r?{tile:n,offset:i}:{tile:r,offset:o}}}class Uv extends Hv{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return!!this.children.length&&(e<0?this.children[0].covers(-1):this.lastChild.covers(1))}get domAttrs(){return this.wrapper.attributes}static of(e,t){let n=new Uv(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class $v extends Hv{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,n){let r=new $v(t||document.createElement("div"),e);return t&&n||(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,n){let r=null,i=-1,o=null,s=-1;!function e(a,l){for(let c=0,h=0;c<a.children.length&&h<=l;c++){let u=a.children[c],d=h+u.length;d>=l&&(u.isComposite()?e(u,l-h):(!o||o.isHidden&&(t>0||n&&Kv(o,u)))&&(d>l||32&u.flags)?(o=u,s=l-h):(h<l||16&u.flags&&!u.isHidden)&&(r=u,i=l-h)),h=d}}(this,e);let a=(t<0?r:o)||r||o;return a?{tile:a,offset:a==r?i:s}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=kg(t);return n[n.length-1]||null}(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new Wg(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,16&e.flags?1:32&e.flags?-1:t);let i=n.tile.parent,o=!1;for(let e of i.children){if(o)return new Wg(e.dom,0);e==n.tile&&(o=!0)}}return new Wg(this.dom,0)}}function Kv(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}class Yv extends Hv{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let n=new Yv(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class Gv extends zv{constructor(e,t){super(e,t.length),this.text=t}sync(e){2&this.flags||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let r=e,i=e,o=0;0==e&&t<0||e==n&&t>=0?ig.chrome||ig.gecko||(e?(r--,o=1):i<n&&(i++,o=-1)):t<0?r--:i<n&&i++;let s=Bg(this.dom,r,i).getClientRects();if(!s.length)return null;let a=s[(o?o<0:t>=0)?0:s.length-1];return ig.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(s,e=>e.width)||a),o?Ag(a,o<0):a||null}static of(e,t){let n=new Gv(t||document.createTextNode(e),e);return t||(n.flags|=2),n}}class Xv extends zv{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return!(48&this.flags)&&(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return Ag(this.dom.getBoundingClientRect(),this.length?0==e:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=!!(16&this.flags)||!(32&this.flags)&&e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?0==i:i==t.length-1||n.top<n.bottom);i+=r?-1:1);return Ag(n,!r)}}get overrideDOMText(){if(!this.length)return Xf.empty;let{root:e}=this;if(!e)return Xf.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,n,r,i){return i||(i=e.toDOM(t),e.editable||(i.contentEditable="false")),new Xv(i,n,e,r)}}class Jv extends zv{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return Xf.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class Qv{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:o,parents:s}=this;for(;e||t>0;)if(r.isComposite())if(o){if(!e)break;n&&n.break(),e--,o=!1}else if(i==r.children.length){if(!e&&!s.length)break;n&&n.leave(r),o=!!r.breakAfter,({tile:r,index:i}=s.pop()),i++}else{let a=r.children[i],l=a.breakAfter;!(t>0?a.length<=e:a.length<e)||n&&!1===n.skip(a,0,a.length)&&a.isComposite?(s.push({tile:r,index:i}),r=a,i=0,n&&a.isComposite()&&n.enter(a)):(o=!!l,i++,e-=a.length)}else if(i==r.length)o=!!r.breakAfter,({tile:r,index:i}=s.pop()),i++;else{if(!e)break;{let t=Math.min(e,r.length-i);n&&n.skip(r,i,i+t),e-=t,i+=t}}return this.tile=r,this.index=i,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Zv{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}}class eb{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){var i;this.flushBuffer();let o=this.ensureMarks(t,n),s=o.lastChild;if(!s||!s.isText()||8&s.flags)o.append(r||Gv.of(e,null===(i=this.cache.find(Gv))||void 0===i?void 0:i.dom));else{this.cache.reused.set(s,2),(o.children[o.children.length-1]=new Gv(s.dom,s.text+e)).parent=o}this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?ab(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof Yv&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(ab(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=zv.get(n.dom);e&&e.setDOM(ab(n.dom))}let e=Yv.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=zv.get(e.text);i&&this.cache.reused.set(i,2);let o=new Gv(e.text,e.text.nodeValue);o.flags|=8,r.append(o)}addInlineWidget(e,t,n){let r=this.afterWidget&&48&e.flags&&(48&this.afterWidget.flags)==(48&e.flags);r||this.flushBuffer();let i=this.ensureMarks(t,n);r||16&e.flags||i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){(this.afterWidget||this.lastBlock).length+=e,this.pos+=e}addLineStart(e,t){var n;e||(e=sb);let r=$v.start(e,t||(null===(n=this.cache.find($v))||void 0===n?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var n;let r=this.curLine;for(let i=e.length-1;i>=0;i--){let o,s=e[i];if(t>0&&(o=r.lastChild)&&o instanceof Yv&&o.mark.eq(s))r=o,t--;else{let e=Yv.of(s,null===(n=this.cache.find(Yv,e=>e.mark.eq(s)))||void 0===n?void 0:n.dom);r.append(e),r=e,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;e&&ob(this.curLine,!1)&&("BR"==e.dom.nodeName||!e.isWidget()||ig.ios&&ob(this.curLine,!0))||this.curLine.append(this.cache.findWidget(cb,0,32)||new Xv(cb.toDOM(),0,cb,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new Zv(e.from,e.to,e.value,e.rank),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-t.rank||this.wrappers[n-1].to-t.to)<0;)n--;this.wrappers.splice(n,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let n of this.wrappers){let r=t.lastChild;if(n.from<this.pos&&r instanceof Uv&&r.wrapper.eq(n.wrapper))t=r;else{let r=Uv.of(n.wrapper,null===(e=this.cache.find(Uv,e=>e.wrapper.eq(n.wrapper)))||void 0===e?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return null!=e&&!e.breakAfter&&(!e.isWidget()||(160&e.flags)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(Jv,void 0,1);return n&&(n.flags=t),n||new Jv(t)}flushBuffer(){!this.afterWidget||32&this.afterWidget.flags||(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class tb{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw new Error("Ran out of text content when drawing inline views");this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}}const nb=[Xv,$v,Gv,Yv,Jv,Uv,qv];for(let e=0;e<nb.length;e++)nb[e].bucket=e;class rb{constructor(e){this.view=e,this.buckets=nb.map(()=>[]),this.index=nb.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],o=this.index[r];for(let e=i.length-1;e>=0;e--){let s=(e+o)%i.length,a=i[s];if((!t||t(a))&&!this.reused.has(a))return i.splice(s,1),s<o&&this.index[r]--,this.reused.set(a,n),a}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,o=0;;i++){if(i==r.length){if(o)return null;o=1,i=0}let s=r[i];if(!this.reused.has(s)&&(0==o?s.widget.compare(e):s.widget.constructor==e.constructor&&e.updateDOM(s.dom,this.view)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,s.widget==e&&s.length==t&&(497&s.flags)==n?(this.reused.set(s,1),s):(this.reused.set(s,2),new Xv(s.dom,t,e,-498&s.flags|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class ib{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new rb(e),this.text=new tb(e.state.doc),this.builder=new eb(this.cache,new qv(e,e.contentDOM),ym.iter(n)),this.cache.reused.set(t,2),this.old=new Qv(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,o=0;;){let s=o<e.length?e[o++]:null,a=s?s.fromA:this.old.root.length;if(a>r){let e=a-r;this.preserve(e,!o,!s),r=a,i+=e}if(!s)break;t&&s.fromA<=t.range.fromA&&s.toA>=t.range.toA?(this.forward(s.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,s.toA),this.emit(t.range.toB,s.toB)):(this.forward(s.fromA,s.toA),this.emit(i,s.toB)),i=s.toB,r=s.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=function(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof Yv&&t.push(r.mark)}return t}(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let o=n>0||t<e.length?Xv.of(e.widget,this.view,n-t,496&e.flags,this.cache.maybeReuse(e)):this.cache.reuse(e);256&o.flags?(o.flags&=-2,this.builder.addBlockWidget(o)):(this.builder.ensureLine(null),this.builder.addInlineWidget(o,r,i),i=r.length)}else if(e.isText())this.builder.ensureLine(null),t||n!=e.length?(this.cache.add(e),this.builder.addText(e.text.slice(t,n),r,i)):this.builder.addText(e.text,r,i,this.cache.reuse(e)),i=r.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof Jv)this.cache.add(e);else{if(!(e instanceof Yv))return!1;this.builder.ensureLine(null),this.builder.addMark(e,r,i),this.cache.reused.set(e,1),i=r.length}this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof Yv&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&(r.length=i=0):e instanceof Yv&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=0,o=ym.spans(this.decorations,e,t,{point:(e,t,o,s,a,l)=>{if(o instanceof mg){if(this.disallowBlockEffectsFor[l]){if(o.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.view.state.doc.lineAt(e).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(i=s.length,a>s.length)r.continueWidget(t-e);else{let i=o.widget||(o.block?lb.block:lb.inline),l=function(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;e.block&&(t|=256);return t}(o),c=this.cache.findWidget(i,t-e,l)||Xv.of(i,this.view,t-e,l);o.block?(o.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(c)):(r.ensureLine(n),r.addInlineWidget(c,s,a))}n=null}else n=function(e,t){let n=t.spec.attributes,r=t.spec.class;if(!n&&!r)return e;e||(e={class:"cm-line"});n&&og(n,e);r&&(e.class+=" "+r);return e}(n,o);t>e&&this.text.skip(t-e)},span:(e,t,i,o)=>{for(let s=e;s<t;){let e=this.text.next(Math.min(512,t-s));null==e?(r.addLineStartIfNotCovered(n),r.addBreak(),s++):(r.ensureLine(n),r.addText(e,i,o),s+=e.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=o>i,this.openMarks=o}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=zv.get(r);if(r==this.view.contentDOM)break;e instanceof Yv?t.push(e):(null==e?void 0:e.isLine())?n=e:"DIV"!=r.nodeName||n||r==this.view.contentDOM?t.push(Yv.of(new fg({tagName:r.nodeName.toLowerCase(),attributes:cg(r)}),r)):n=new $v(r,sb)}return{line:n,marks:t}}}function ob(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}const sb={class:"cm-line"};function ab(e){let t=zv.get(e);return t&&t.setDOM(e.cloneNode()),e}class lb extends hg{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}}lb.inline=new lb("span"),lb.block=new lb("div");const cb=new class extends hg{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class hb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=dg.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.updateDeco(),this.tile=new qv(e,e.contentDOM),this.updateInner([new _v(0,0,0,e.state.doc.length)],null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>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 r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(t=this.domChanged)||void 0===t?void 0:t.newSel)?r=this.domChanged.newSel.head:function(e,t){let n=!1;t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)});return n}(e.changes,this.hasComposition)||e.selectionSet||(r=e.state.selection.main.head));let i=r>-1?function(e,t,n){let r=db(e,n);if(!r)return null;let{node:i,from:o,to:s}=r,a=i.nodeValue;if(/[\n\r]/.test(a))return null;if(e.state.doc.sliceString(r.from,r.to)!=a)return null;let l=t.invertedDesc;return{range:new _v(l.mapPos(o),l.mapPos(s),o,s),text:i}}(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:t,to:r}=this.hasComposition;n=new _v(t,r,e.changes.mapPos(t,-1),e.changes.mapPos(r,1)).addToSet(n.slice())}this.hasComposition=i?{from:i.range.fromB,to:i.range.toB}:null,(ig.ie||ig.chrome)&&!i&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,s=this.blockWrappers;this.updateDeco();let a=function(e,t,n){let r=new fb;return ym.compare(e,t,n,r),r.changes}(o,this.decorations,e.changes);a.length&&(n=_v.extendWithRanges(n,a));let l=function(e,t,n){let r=new pb;return ym.compare(e,t,n,r),r.changes}(s,this.blockWrappers,e.changes);return l.length&&(n=_v.extendWithRanges(n,l)),i&&!n.some(e=>e.fromA<=i.range.fromA&&e.toA>=i.range.toA)&&(n=i.range.addToSet(n.slice())),!(2&this.tile.flags&&0==n.length)&&(this.updateInner(n,i),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new ib(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);this.tile=r.run(e,t),ub(n,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=ig.chrome||ig.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),!r||!r.written&&n.selectionRange.focusNode==r.node&&this.tile.dom.contains(r.node)||(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof mb&&r.push(e.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(wv)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){!e&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,o=!i&&!(this.view.state.facet(kv)||n.tabIndex>-1)&&xg(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||o))return;let s=this.forceSelection;this.forceSelection=!1;let a,l,c=this.view.state.selection.main;if(c.empty?l=a=this.inlineDOMNearPos(c.anchor,c.assoc||1):(l=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),a=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),ig.gecko&&c.empty&&!this.hasComposition&&(1==(h=a).node.nodeType&&h.node.firstChild&&(0==h.offset||"false"==h.node.childNodes[h.offset-1].contentEditable)&&(h.offset==h.node.childNodes.length||"false"==h.node.childNodes[h.offset].contentEditable))){let e=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null)),a=l=new Wg(e,0),s=!0}var h;let u=this.view.observer.selectionRange;!s&&u.focusNode&&(Sg(a.node,a.offset,u.anchorNode,u.anchorOffset)&&Sg(l.node,l.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,c))||(this.view.observer.ignore(()=>{ig.android&&ig.chrome&&n.contains(u.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=yg(this.view.root);if(e)if(c.empty){if(ig.gecko){let e=function(e,t){return 1!=e.nodeType?0:(t&&"false"==e.childNodes[t-1].contentEditable?1:0)|(t<e.childNodes.length&&"false"==e.childNodes[t].contentEditable?2:0)}(a.node,a.offset);if(e&&3!=e){let t=(1==e?_g:Fg)(a.node,a.offset);t&&(a=new Wg(t.node,t.offset))}}e.collapse(a.node,a.offset),null!=c.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=c.bidiLevel)}else if(e.extend){e.collapse(a.node,a.offset);try{e.extend(l.node,l.offset)}catch(e){}}else{let t=document.createRange();c.anchor>c.head&&([a,l]=[l,a]),t.setEnd(l.node,l.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}else;o&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(a,l)),this.impreciseAnchor=a.precise?null:new Wg(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new Wg(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Sg(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=yg(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!(n&&t.empty&&t.assoc&&n.modify))return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let s=o.posAtStart;if(t.head==s||t.head==s+o.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let h=e.observer.selectionRange;e.docView.posFromDOM(h.anchorNode,h.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return 2&this.tile.dom.compareDocumentPosition(e)?0:this.view.state.doc.length;let r=n.posAtStart;if(!n.isComposite())return n.isText()?e==n.dom?r+t:r+(t?n.length:0):r;{let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=0==Ng(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;0==r&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!zv.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r,i=-1,o=!1,s=-1,a=!1;return this.tile.blockTiles((t,l)=>{if(t.isWidget()){if(32&t.flags&&l>=e)return!0;16&t.flags&&(o=!0)}else{let c=l+t.length;if(l<=e&&(n=t,i=e-l,o=c<e),c>=e&&!r&&(r=t,s=e-l,a=l>e),l>e&&r)return!0}}),n||r?(o&&r?n=null:a&&n&&(r=null),n&&t<0||!r?n.domIn(i,t):r.domIn(s,t)):this.domAtPos(e,t)}coordsAt(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof mb?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;return function e(t,n){if(t.isComposite())for(let r of t.children){if(r.length>=n){let t=e(r,n);if(t)return t}if((n-=r.length)<0)break}else if(t.isText()&&n<t.length){let e=sp(t.text,n);if(e==n)return null;let r=Bg(t.dom,n,e).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,o=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,s=-1,a=this.view.textDirection==zg.LTR,l=0,c=(e,h,u)=>{for(let d=0;d<e.children.length&&!(h>r);d++){let r=e.children[d],f=h+r.length,p=r.dom.getBoundingClientRect(),{height:m}=p;if(u&&!d&&(l+=p.top-u.top),r instanceof Uv)f>n&&c(r,h,p);else if(h>=n&&(l>0&&t.push(-l),t.push(m+l),l=0,o)){let e=r.dom.lastChild,t=e?kg(e):[];if(t.length){let e=t[t.length-1],n=a?e.right-p.left:p.right-e.left;n>s&&(s=n,this.minWidth=i,this.minWidthFrom=h,this.minWidthTo=f)}}u&&d==e.children.length-1&&(l+=u.bottom-p.bottom),h=f+r.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return"rtl"==getComputedStyle(t.dom).direction?zg.RTL:zg.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t,n=0;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=kg(r.dom);if(1!=e.length)return;n+=e[0].width,t=e[0].height}if(n)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:n/e.length,textHeight:t}}});if(e)return e;let t,n,r,i=document.createElement("div");return i.className="cm-line",i.style.width="99999px",i.style.position="absolute",i.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(i);let e=kg(i.firstChild)[0];t=i.getBoundingClientRect().height,n=e&&e.width?e.width/27:7,r=e&&e.height?e.height:t,i.remove()}),{lineHeight:t,charWidth:n,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],o=i?i.from-1:this.view.state.doc.length;if(o>n){let r=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(dg.replace({widget:new mb(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!i)break;n=i.to+1}return dg.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Tv).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),n=!1,r=this.view.state.facet(Rv).map((e,t)=>{let r="function"==typeof e;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(ym.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(Mv).map(e=>"function"==typeof e?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);return this.view.scrollDOM.scrollTop=t.top-e.yMargin,void(this.view.scrollDOM.scrollLeft=e.xMargin)}for(let t of this.view.state.facet(vv))try{if(t(this.view,e.range,e))return!0}catch(e){xv(this.view.state,e,"scroll handler")}let t,{range:n}=e,r=this.coordsAt(n.head,n.empty?n.assoc:n.head>n.anchor?-1:1);if(!r)return;!n.empty&&(t=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,t.left),top:Math.min(r.top,t.top),right:Math.max(r.right,t.right),bottom:Math.max(r.bottom,t.bottom)});let i=Iv(this.view),o={left:r.left-i.left,top:r.top-i.top,right:r.right+i.right,bottom:r.bottom+i.bottom},{offsetWidth:s,offsetHeight:a}=this.view.scrollDOM;!function(e,t,n,r,i,o,s,a){let l=e.ownerDocument,c=l.defaultView||window;for(let h=e,u=!1;h&&!u;)if(1==h.nodeType){let e,d=h==l.body,f=1,p=1;if(d)e=Tg(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(u=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let t=h.getBoundingClientRect();({scaleX:f,scaleY:p}=Mg(h,t)),e={left:t.left,right:t.left+h.clientWidth*f,top:t.top,bottom:t.top+h.clientHeight*p}}let m=0,g=0;if("nearest"==i)t.top<e.top?(g=t.top-(e.top+s),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+s)):t.bottom>e.bottom&&(g=t.bottom-e.bottom+s,n<0&&t.top-g<e.top&&(g=t.top-(e.top+s)));else{let r=t.bottom-t.top,o=e.bottom-e.top;g=("center"==i&&r<=o?t.top+r/2-o/2:"start"==i||"center"==i&&n<0?t.top-s:t.bottom-o+s)-e.top}if("nearest"==r?t.left<e.left?(m=t.left-(e.left+o),n>0&&t.right>e.right+m&&(m=t.right-e.right+o)):t.right>e.right&&(m=t.right-e.right+o,n<0&&t.left<e.left+m&&(m=t.left-(e.left+o))):m=("center"==r?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==r==a?t.left-o:t.right-(e.right-e.left)+o)-e.left,m||g)if(d)c.scrollBy(m,g);else{let e=0,n=0;if(g){let e=h.scrollTop;h.scrollTop+=g/p,n=(h.scrollTop-e)*p}if(m){let t=h.scrollLeft;h.scrollLeft+=m/f,e=(h.scrollLeft-t)*f}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-m)<1&&(r="nearest"),n&&Math.abs(n-g)<1&&(i="nearest")}if(d)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),h=h.assignedSlot||h.parentNode}else{if(11!=h.nodeType)break;h=h.host}}(this.view.scrollDOM,o,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,s),-s),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==zg.LTR)}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){ub(this.tile)}}function ub(e,t){let n=null==t?void 0:t.get(e);if(1!=n){null==n&&e.destroy();for(let n of e.children)ub(n,t)}}function db(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=_g(n.focusNode,n.focusOffset),i=Fg(n.focusNode,n.focusOffset),o=r||i;if(i&&r&&i.node!=r.node){let t=zv.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)o=i;else if(e.docView.lastCompositionAfterCursor){let e=zv.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(o=i)}}if(e.docView.lastCompositionAfterCursor=o!=r,!o)return null;let s=t-o.offset;return{from:s,to:s+o.node.nodeValue.length,node:o.node}}let fb=class{constructor(){this.changes=[]}compareRange(e,t){vg(e,t,this.changes)}comparePoint(e,t){vg(e,t,this.changes)}boundChange(e){vg(e,e,this.changes)}};class pb{constructor(){this.changes=[]}compareRange(e,t){vg(e,t,this.changes)}comparePoint(){}boundChange(e){vg(e,e,this.changes)}}class mb extends hg{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}}function gb(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;e&&(i.type!=ug.Text||e.type==i.type&&!(n<0?i.from<t:i.to>t))||(e=i)}}return e||r}return r}function vb(e,t,n,r){let i=e.state.doc.lineAt(t.head),o=e.bidiSpans(i),s=e.textDirectionAt(i.from);for(let a=t,l=null;;){let t=iv(i,o,s,a,n),c=rv;if(!t){if(i.number==(n?e.state.doc.lines:1))return a;c="\n",i=e.state.doc.line(i.number+(n?1:-1)),o=e.bidiSpans(i),t=e.visualLineSide(i,!n)}if(l){if(!l(c))return a}else{if(!r)return t;l=r(c)}a=t}}function bb(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(e,i,o)=>{if(t>e&&t<i){let o=r||n||(t-e<i-t?-1:1);t=o<0?e:i,r=o}});if(!r)return t}}function yb(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],o=null;if(i.empty){let t=bb(e,i.from,0);t!=i.from&&(o=xp.cursor(t,-1))}else{let t=bb(e,i.from,-1),n=bb(e,i.to,1);t==i.from&&n==i.to||(o=xp.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}o&&(n||(n=t.ranges.slice()),n[r]=o)}return n?xp.create(n,t.mainIndex):t}function wb(e,t,n){let r=bb(e.state.facet(Dv).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:xp.cursor(r,r<n.from?1:-1)}class xb{constructor(e,t){this.pos=e,this.assoc=t}}function kb(e,t,n,r){let i,o=e.contentDOM.getBoundingClientRect(),s=o.top+e.viewState.paddingTop,{x:a,y:l}=t,c=l-s;for(;;){if(c<0)return new xb(0,1);if(c>e.viewState.docHeight)return new xb(e.state.doc.length,-1);if(i=e.elementAtHeight(c),null==r)break;if(i.type==ug.Text){let t=e.docView.coordsAt(r<0?i.from:i.to,r);if(t&&(r<0?t.top<=c+s:t.bottom>=c+s))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?i.bottom+t:i.top-t}if(e.viewport.from>=i.to||e.viewport.to<=i.from){if(n)return null;if(i.type==ug.Text){let t=function(e,t,n,r,i){let o=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;o+=Math.floor((i-n.top-.5*(e.defaultLineHeight-t))/t)*e.viewState.heightOracle.lineLength}let s=e.state.sliceDoc(n.from,n.to);return n.from+Dm(s,o,e.state.tabSize)}(e,o,i,a,l);return new xb(t,t==i.from?1:-1)}}if(i.type!=ug.Text)return c<(i.top+i.bottom)/2?new xb(i.from,1):new xb(i.to,-1);let h=e.docView.lineAt(i.from,2);return h&&h.length==i.length||(h=e.docView.lineAt(i.from,-2)),Sb(e,h,i.from,a,l)}function Sb(e,t,n,r,i){let o=-1,s=null,a=1e9,l=1e9,c=i,h=i,u=(e,t)=>{for(let n=0;n<e.length;n++){let u=e[n];if(u.top==u.bottom)continue;let d=u.left>r?u.left-r:u.right<r?r-u.right:0,f=u.top>i?u.top-i:u.bottom<i?i-u.bottom:0;u.top<=h&&u.bottom>=c&&(c=Math.min(u.top,c),h=Math.max(u.bottom,h),f=0),(o<0||(f-l||d-a)<0)&&(o>=0&&l&&a<d&&s.top<=h-2&&s.bottom>=c+2?l=0:(o=t,a=d,l=f,s=u))}};if(t.isText()){for(let e=0;e<t.length;){let n=sp(t.text,e);if(u(Bg(t.dom,e,n).getClientRects(),e),!a&&!l)break;e=n}return r>(s.left+s.right)/2==(Eb(e,o+n)==zg.LTR)?new xb(n+sp(t.text,o),-1):new xb(n+o,1)}{if(!t.length)return new xb(n,1);for(let e=0;e<t.children.length;e++){let n=t.children[e];if(!(48&n.flags)&&(u((1==n.dom.nodeType?n.dom:Bg(n.dom,0,n.length)).getClientRects(),e),!a&&!l))break}let c=t.children[o],h=t.posBefore(c,n);return c.isComposite()||c.isText()?Sb(e,c,h,Math.max(s.left,Math.min(s.right,r)),i):r>(s.left+s.right)/2==(Eb(e,o+n)==zg.LTR)?new xb(h+c.length,-1):new xb(h,1)}}function Eb(e,t){let n=e.state.doc.lineAt(t);return e.bidiSpans(n)[Jg.find(e.bidiSpans(n),t-n.from,-1,1)].dir}const Cb="￿";class Ob{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(dm.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Cb}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=zv.get(r),o=r.nextSibling;if(o==t){(null==i?void 0:i.breakAfter)&&!o&&n!=this.view.contentDOM&&this.lineBreak();break}let s=zv.get(o);(i&&s?i.breakAfter:(i?i.breakAfter:Cg(r))||Cg(o)&&("BR"!=r.nodeName||(null==i?void 0:i.isWidget()))&&this.text.length>e)&&!Ab(o,t)&&this.lineBreak(),r=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,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i,o=-1,s=1;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(i=r.exec(t))&&(o=i.index,s=i[0].length),this.append(t.slice(n,o<0?t.length:o)),o<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);n=o+s}}readNode(e){let t=zv.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&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)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(Nb(e,n.node,n.offset)?t:0))}}function Nb(e,t,n){for(;;){if(!t||n<Ng(t))return!1;if(t==e)return!0;n=Eg(t)+1,t=t.parentNode}}function Ab(e,t){let n;for(;e!=t&&e;e=e.nextSibling){let t=zv.get(e);if(!(null==t?void 0:t.isWidget()))return!1;t&&(n||(n=[])).push(t)}if(n)for(let e of n){let t=e.overrideDOMText;if(null==t?void 0:t.length)return!1}return!0}class Tb{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class Mb{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=Rb(e.docView.tile,t,n,0))){let t=i||o?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}=e.observer.selectionRange;n&&(t.push(new Tb(n,r)),i==n&&o==r||t.push(new Tb(i,o)));return t}(e),n=new Ob(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,r=2==e.length?e[1].pos:n;return n>-1&&r>-1?xp.single(n+t,r+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!wg(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=o&&o.node==t.anchorNode&&o.offset==t.anchorOffset||!wg(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((ig.ios||ig.chrome)&&e.state.selection.main.empty&&n!=r&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,r),i=Math.max(n,r),o=s.from-t,a=s.to-i;0!=o&&1!=o&&0!=t||0!=a&&-1!=a&&i!=e.state.doc.length||(n=0,r=e.state.doc.length)}e.inputState.composing>-1&&e.state.selection.ranges.length>1?this.newSel=e.state.selection.replaceRange(xp.range(r,n)):this.newSel=xp.single(r,n)}}}function Rb(e,t,n,r){if(e.isComposite()){let i=-1,o=-1,s=-1,a=-1;for(let l=0,c=r,h=r;l<e.children.length;l++){let r=e.children[l],u=c+r.length;if(c<t&&u>n)return Rb(r,t,n,c);if(u>=t&&-1==i&&(i=l,o=c),c>n&&r.dom.parentNode==e.dom){s=l,a=h;break}h=u,c=u+r.breakAfter}return{from:o,to:a<0?r+e.length:a,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:s<e.children.length&&s>=0?e.children[s].dom:null}}return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function Db(e,t){let n,{newSel:r}=t,i=e.state.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:r,to:s}=t.bounds,a=i.from,l=null;(8===o||ig.android&&t.text.length<s-r)&&(a=i.to,l="end");let c=Lb(e.state.doc.sliceString(r,s,Cb),t.text,a-r,l);c&&(ig.chrome&&13==o&&c.toB==c.from+2&&t.text.slice(c.from,c.toB)==Cb+Cb&&c.toB--,n={from:r+c.from,to:r+c.toA,insert:Xf.of(t.text.slice(c.from,c.toB).split(Cb))})}else r&&(!e.hasFocus&&e.state.facet(kv)||Bb(r,i))&&(r=null);if(!n&&!r)return!1;if(!n&&t.typeOver&&!i.empty&&r&&r.main.empty?n={from:i.from,to:i.to,insert:e.state.doc.slice(i.from,i.to)}:(ig.mac||ig.android)&&n&&n.from==n.to&&n.from==i.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(r&&2==n.insert.length&&(r=xp.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:Xf.of([n.insert.toString().replace("."," ")])}):n&&n.from>=i.from&&n.to<=i.to&&(n.from!=i.from||n.to!=i.to)&&i.to-i.from-(n.to-n.from)<=4?n={from:i.from,to:i.to,insert:e.state.doc.slice(i.from,n.from).append(n.insert).append(e.state.doc.slice(n.to,i.to))}:e.state.doc.lineAt(i.from).to<i.to&&e.docView.lineHasWidget(i.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:i.from,to:i.to,insert:e.state.toText(e.inputState.insertingText)}:ig.chrome&&n&&n.from==n.to&&n.from==i.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(r&&(r=xp.single(r.main.anchor-1,r.main.head-1)),n={from:i.from,to:i.to,insert:Xf.of([" "])}),n)return Pb(e,n,r,o);if(r&&!Bb(r,i)){let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),n=e.inputState.lastSelectionOrigin,"select.pointer"==n&&(r=yb(e.state.facet(Dv).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function Pb(e,t,n,r=-1){if(ig.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(ig.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&" "==e.state.sliceDoc(t.from,i.from))&&1==t.insert.length&&2==t.insert.lines&&Ig(e.contentDOM,"Enter",13)||(t.from==i.from-1&&t.to==i.to&&0==t.insert.length||8==r&&t.insert.length<t.to-t.from&&t.to>i.head)&&Ig(e.contentDOM,"Backspace",8)||t.from==i.from&&t.to==i.to+1&&0==t.insert.length&&Ig(e.contentDOM,"Delete",46)))return!0;let o,s=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let a=()=>o||(o=function(e,t,n){let r,i=e.state,o=i.selection.main,s=-1;if(t.from==t.to&&t.from<o.from||t.from>o.to){let n=t.from<o.from?-1:1,r=n<0?o.from:o.to,a=bb(i.facet(Dv).map(t=>t(e)),r,n);t.from==a&&(s=a)}if(s>-1)r={changes:t,selection:xp.cursor(t.from+t.insert.length,-1)};else if(t.from>=o.from&&t.to<=o.to&&t.to-t.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=o.from<t.from?i.sliceDoc(o.from,t.from):"",s=o.to>t.to?i.sliceDoc(t.to,o.to):"";r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+s))}else{let s=i.changes(t),a=n&&n.main.to<=s.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=o.to+10&&t.to>=o.to-10){let l,c=e.state.sliceDoc(t.from,t.to),h=n&&db(e,n.main.head);if(h){let e=t.insert.length-(t.to-t.from);l={from:h.from,to:h.to-e}}else l=e.state.doc.lineAt(o.head);let u=o.to-t.to;r=i.changeByRange(n=>{if(n.from==o.from&&n.to==o.to)return{changes:s,range:a||n.map(s)};let r=n.to-u,h=r-c.length;if(e.state.sliceDoc(h,r)!=c||r>=l.from&&h<=l.to)return{range:n};let d=i.changes({from:h,to:r,insert:t.insert}),f=n.to-o.to;return{changes:d,range:a?xp.range(Math.max(0,a.anchor+f),Math.max(0,a.head+f)):n.map(d)}})}else r={changes:s,selection:a&&i.selection.replaceRange(a)}}let a="input.type";(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,a+=".compose",e.inputState.compositionFirstChange&&(a+=".start",e.inputState.compositionFirstChange=!1));return i.update(r,{userEvent:a,scrollIntoView:!0})}(e,t,n));return e.state.facet(uv).some(n=>n(e,t.from,t.to,s,a))||e.dispatch(a()),!0}function Lb(e,t,n,r){let i=Math.min(e.length,t.length),o=0;for(;o<i&&e.charCodeAt(o)==t.charCodeAt(o);)o++;if(o==i&&e.length==t.length)return null;let s=e.length,a=t.length;for(;s>0&&a>0&&e.charCodeAt(s-1)==t.charCodeAt(a-1);)s--,a--;if("end"==r){n-=s+Math.max(0,o-Math.min(s,a))-o}if(s<o&&e.length<t.length){o-=n<=o&&n>=s?o-n:0,a=o+(a-s),s=o}else if(a<o){o-=n<=o&&n>=a?o-n:0,s=o+(s-a),a=o}return{from:o,toA:s,toB:a}}function Bb(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}class Ib{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,ig.safari&&e.contentDOM.addEventListener("input",()=>null),ig.gecko&&function(e){sy.has(e)||(sy.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}(e.contentDOM.ownerDocument)}handleEvent(e){(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n,r=t.target;r!=e.contentDOM;r=r.parentNode)if(!r||11==r.nodeType||(n=zv.get(r))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(t))return!1;return!0})(this.view,e)&&!this.ignoreDuringComposition(e)&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?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 e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=_b(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if("scroll"!=e){let i=!t[e].handlers.length,o=n[e];o&&i!=!o.handlers.length&&(r.removeEventListener(e,this.handleEvent),o=null),o||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)"scroll"==e||t[e]||r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=e.keyCode&&zb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),ig.android&&ig.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return!ig.ios||e.synthetic||e.altKey||e.metaKey||!((t=Fb.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||Wb.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(229!=e.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0)}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&(!("Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,Ig(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0)))}ignoreDuringComposition(e){return!(!/^key/.test(e.type)||e.synthetic)&&(this.composing>0||!!(ig.safari&&!ig.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}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 jb(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){xv(n.state,e)}}}function _b(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(jb(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(jb(t.value,r))}}for(let e in qb)n(e).handlers.push(qb[e]);for(let e in Ub)n(e).observers.push(Ub[e]);return t}const Fb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Wb="dthko",zb=[16,17,18,20,91,92,224,225];function Hb(e){return.7*Math.max(0,e)+8}class Vb{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=function(e){let t,n,r=e.ownerDocument;for(let i=e.parentNode;i&&!(i==r.body||t&&n);)if(1==i.nodeType)!n&&i.scrollHeight>i.clientHeight&&(n=i),!t&&i.scrollWidth>i.clientWidth&&(t=i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}return{x:t,y:n}}(e.contentDOM),this.atoms=e.state.facet(Dv).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener("mousemove",this.move=this.move.bind(this)),i.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(dm.allowMultipleSelections)&&function(e,t){let n=e.state.facet(sv);return n.length?n[0](t):ig.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=yg(e.root);if(!r||0==r.rangeCount)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)||1!=ey(t))&&null}start(e){!1===this.dragging&&this.select(e)}move(e){if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(t=this.startEvent,n=e,Math.max(Math.abs(t.clientX-n.clientX),Math.abs(t.clientY-n.clientY))<10))return;var t,n;this.select(this.lastEvent=e);let r=0,i=0,o=0,s=0,a=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:o,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let c=Iv(this.view);e.clientX-c.left<=o+6?r=-Hb(o-e.clientX):e.clientX+c.right>=a-6&&(r=Hb(e.clientX-a)),e.clientY-c.top<=s+6?i=-Hb(s-e.clientY):e.clientY+c.bottom>=l-6&&(i=Hb(e.clientY-l)),this.setScrollSpeed(r,i)}up(e){null==this.dragging&&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),!1===this.dragging&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=yb(this.atoms,this.style.get(e,this.extend,this.multiple));!this.mustSelect&&n.eq(t.state.selection,!1===this.dragging)||this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}const qb=Object.create(null),Ub=Object.create(null),$b=ig.ie&&ig.ie_version<15||ig.ios&&ig.webkit_version<604;function Kb(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function Yb(e,t){t=Kb(e.state,fv,t);let n,{state:r}=e,i=1,o=r.toText(t),s=o.lines==r.selection.ranges.length,a=null!=ny&&r.selection.ranges.every(e=>e.empty)&&ny==o.toString();if(a){let e=-1;n=r.changeByRange(n=>{let a=r.doc.lineAt(n.from);if(a.from==e)return{range:n};e=a.from;let l=r.toText((s?o.line(i++).text:t)+r.lineBreak);return{changes:{from:a.from,insert:l},range:xp.cursor(n.from+l.length)}})}else n=s?r.changeByRange(e=>{let t=o.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:xp.cursor(e.from+t.length)}}):r.replaceSelection(o);e.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}function Gb(e,t,n,r){if(1==r)return xp.cursor(t,n);if(2==r)return function(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),o=t-i.from;if(0==i.length)return xp.cursor(t);0==o?n=1:o==i.length&&(n=-1);let s=o,a=o;n<0?s=sp(i.text,o,!1):a=sp(i.text,o);let l=r(i.text.slice(s,a));for(;s>0;){let e=sp(i.text,s,!1);if(r(i.text.slice(e,s))!=l)break;s=e}for(;a<i.length;){let e=sp(i.text,a);if(r(i.text.slice(a,e))!=l)break;a=e}return xp.range(s+i.from,a+i.from)}(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),o=r?r.posAtStart:i.from,s=r?r.posAtEnd:i.to;return s<e.state.doc.length&&s==i.to&&s++,xp.range(o,s)}}Ub.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},qb.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),Ub.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},Ub.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},qb.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(lv))if(n=r(e,t),n)break;if(n||0!=t.button||(n=function(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=ey(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,o,s){let a,l=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c=Gb(e,l.pos,l.assoc,r);if(n.pos!=l.pos&&!o){let t=Gb(e,n.pos,n.assoc,r),i=Math.min(t.from,c.from),o=Math.max(t.to,c.to);c=i<c.from?xp.range(i,o):xp.range(o,i)}return o?i.replaceRange(i.main.extend(c.from,c.to)):s&&1==r&&i.ranges.length>1&&(a=function(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return xp.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}(i,l.pos))?a:s?i.addRange(c):xp.create([c])}}}(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new Vb(e,t,n,r)),r&&e.observer.ignore(()=>{Lg(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),!1===i.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};const Xb=ig.ie&&ig.ie_version<=11;let Jb=null,Qb=0,Zb=0;function ey(e){if(!Xb)return e.detail;let t=Jb,n=Zb;return Jb=e,Zb=Date.now(),Qb=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(Qb+1)%3:1}function ty(e,t,n,r){if(!(n=Kb(e.state,fv,n)))return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:o}=e.inputState,s=r&&o&&function(e,t){let n=e.state.facet(av);return n.length?n[0](t):ig.mac?!t.altKey:!t.ctrlKey}(e,t)?{from:o.from,to:o.to}:null,a={from:i,insert:n},l=e.state.changes(s?[s,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:s?"move.drop":"input.drop"}),e.inputState.draggedContent=null}qb.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=xp.range(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",Kb(e.state,pv,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},qb.dragend=e=>(e.inputState.draggedContent=null,!1),qb.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,o=()=>{++i==n.length&&ty(e,t,r.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=o,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),o()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return ty(e,t,n,!0),!0}return!1},qb.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=$b?null:t.clipboardData;return n?(Yb(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(function(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{e.focus(),n.remove(),Yb(e,n.value)},50)}(e),!1)};let ny=null;qb.copy=qb.cut=(e,t)=>{let n=yg(e.root);if(n&&!xg(e.contentDOM,n))return!1;let{text:r,ranges:i,linewise:o}=function(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let o=e.doc.lineAt(r);o.number>i&&(t.push(o.text),n.push({from:o.from,to:Math.min(e.doc.length,o.to+1)})),i=o.number}r=!0}return{text:Kb(e,pv,t.join(e.lineBreak)),ranges:n,linewise:r}}(e.state);if(!r&&!o)return!1;ny=o?r:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=$b?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",r),!0):(function(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}(e,r),!1)};const ry=Jp.define();function iy(e,t){let n=[];for(let r of e.facet(dv)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:ry.of(!0)}):null}function oy(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=iy(e.state,t);n?e.dispatch(n):e.update([])}},10)}Ub.focus=e=>{e.inputState.lastFocusTime=Date.now(),e.scrollDOM.scrollTop||!e.inputState.lastScrollTop&&!e.inputState.lastScrollLeft||(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),oy(e)},Ub.blur=e=>{e.observer.clearSelectionRange(),oy(e)},Ub.compositionstart=Ub.compositionupdate=e=>{e.observer.editContext||(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},Ub.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,ig.chrome&&ig.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},Ub.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},qb.beforeinput=(e,t)=>{var n,r;if("insertText"!=t.inputType&&"insertCompositionText"!=t.inputType||(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),"insertReplacementText"==t.inputType&&e.observer.editContext){let r=null===(n=t.dataTransfer)||void 0===n?void 0:n.getData("text/plain"),i=t.getTargetRanges();if(r&&i.length){let t=i[0],n=e.posAtDOM(t.startContainer,t.startOffset),o=e.posAtDOM(t.endContainer,t.endOffset);return Pb(e,{from:n,to:o,insert:e.state.toText(r)},null),!0}}let i;if(ig.chrome&&ig.android&&(i=Fb.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(i.key,i.keyCode),"Backspace"==i.key||"Delete"==i.key)){let t=(null===(r=window.visualViewport)||void 0===r?void 0:r.height)||0;setTimeout(()=>{var n;((null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return ig.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),ig.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>Ub.compositionend(e,t),20),!1};const sy=new Set;const ay=["pre-wrap","normal","pre-line","break-spaces"];let ly=!1;function cy(){ly=!1}class hy{constructor(e){this.lineWrapping=e,this.doc=Xf.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){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return ay.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(10*r)]||(t=!0,this.heightSamples[Math.floor(10*r)]=!0)}return t}refresh(e,t,n,r,i,o){let s=ay.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=s||Math.abs(n-this.charWidth)>.1;if(this.lineWrapping=s,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,a){this.heightSamples={};for(let e=0;e<o.length;e++){let t=o[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return a}}class uy{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class dy{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return"number"==typeof this._content?ug.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 mg?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new dy(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var fy=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(fy||(fy={}));const py=.001;class my{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>py&&(ly=!0),this.height=e)}replace(e,t,n){return my.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,o=n.doc;for(let s=r.length-1;s>=0;s--){let{fromA:a,toA:l,fromB:c,toB:h}=r[s],u=i.lineAt(a,fy.ByPosNoHeight,n.setDoc(t),0,0),d=u.to>=l?u:i.lineAt(l,fy.ByPosNoHeight,n,0,0);for(h+=d.to-l,l=d.to;s>0&&u.from<=r[s-1].toA;)a=r[s-1].fromA,c=r[s-1].fromB,s--,a<u.from&&(u=i.lineAt(a,fy.ByPosNoHeight,n,0,0));c+=u.from-a,a=u.from;let f=Sy.build(n.setDoc(o),e,c,h);i=gy(i,i.replace(a,l,f))}return i.updateHeight(n,0)}static empty(){return new yy(0,0,0)}static of(e){if(1==e.length)return e[0];let t=0,n=e.length,r=0,i=0;for(;;)if(t==n)if(r>2*i){let i=e[t-1];i.break?e.splice(--t,1,i.left,null,i.right):e.splice(--t,1,i.left,i.right),n+=1+i.break,r-=i.size}else{if(!(i>2*r))break;{let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,i-=t.size}}else if(r<i){let n=e[t++];n&&(r+=n.size)}else{let t=e[--n];t&&(i+=t.size)}let o=0;return null==e[t-1]?(o=1,t--):null==e[t]&&(o=1,n++),new xy(my.of(e.slice(0,t)),o,my.of(e.slice(n)))}}function gy(e,t){return e==t?e:(e.constructor!=t.constructor&&(ly=!0),t)}my.prototype.size=1;const vy=dg.replace({});class by extends my{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new dy(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new dy(r,0,n,this.spaceAbove,vy):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let o=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(o):o}forEachLine(e,t,n,r,i,o){e<=i+this.length&&t>=i&&o(this.lineAt(0,fy.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class yy extends by{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new dy(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,n){let r=n[0];return 1==n.length&&(r instanceof yy||r instanceof wy&&4&r.flags)&&Math.abs(this.length-r.length)<10?(r instanceof wy?r=new yy(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):my.of(n)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,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 wy extends my{constructor(e){super(e,0)}heightMetrics(e,t){let n,r=e.doc.lineAt(t).number,i=e.doc.lineAt(t+this.length).number,o=i-r+1,s=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*o);n=t/o,this.length>o+1&&(s=(this.height-t)/(this.length-o-1))}else n=this.height/o;return{firstLine:r,lastLine:i,perLine:n,perChar:s}}blockAt(e,t,n,r){let{firstLine:i,lastLine:o,perLine:s,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),o=t.doc.lineAt(i),l=s+o.length*a,c=Math.max(n,e-l/2);return new dy(o.from,o.length,c,l,0)}{let r=Math.max(0,Math.min(o-i,Math.floor((e-n)/s))),{from:a,length:l}=t.doc.line(i+r);return new dy(a,l,n+s*r,s,0)}}lineAt(e,t,n,r,i){if(t==fy.ByHeight)return this.blockAt(e,n,r,i);if(t==fy.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new dy(t,r-t,0,0,0)}let{firstLine:o,perLine:s,perChar:a}=this.heightMetrics(n,i),l=n.doc.lineAt(e),c=s+l.length*a,h=l.number-o,u=r+s*h+a*(l.from-i-h);return new dy(l.from,l.length,Math.max(r,Math.min(u,r+this.height-c)),c,0)}forEachLine(e,t,n,r,i,o){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:s,perLine:a,perChar:l}=this.heightMetrics(n,i);for(let c=e,h=r;c<=t;){let t=n.doc.lineAt(c);if(c==e){let n=t.number-s;h+=a*n+l*(e-i-n)}let r=a+l*t.length;o(new dy(t.from,t.length,h,r,0)),h+=r,c=t.to+1}}replace(e,t,n){let r=this.length-t;if(r>0){let e=n[n.length-1];e instanceof wy?n[n.length-1]=new wy(e.length+r):n.push(null,new wy(r-1))}if(e>0){let t=n[0];t instanceof wy?n[0]=new wy(e+t.length):n.unshift(new wy(e-1),null)}return my.of(n)}decomposeLeft(e,t){t.push(new wy(e-1),null)}decomposeRight(e,t){t.push(null,new wy(this.length-e-1))}updateHeight(e,t=0,n=!1,r){let i=t+this.length;if(r&&r.from<=t+this.length&&r.more){let n=[],o=Math.max(t,r.from),s=-1;for(r.from>t&&n.push(new wy(r.from-t-1).updateHeight(e,t));o<=i&&r.more;){let t=e.doc.lineAt(o).length;n.length&&n.push(null);let i=r.heights[r.index++],a=0;i<0&&(a=-i,i=r.heights[r.index++]),-1==s?s=i:Math.abs(i-s)>=py&&(s=-2);let l=new yy(t,i,a);l.outdated=!1,n.push(l),o+=t+1}o<=i&&n.push(null,new wy(i-o).updateHeight(e,o));let a=my.of(n);return(s<0||Math.abs(a.height-this.height)>=py||Math.abs(s-this.heightMetrics(e,t).perLine)>=py)&&(ly=!0),gy(this,a)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class xy extends my{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 1&this.flags}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let o=r+this.left.height,s=i+this.left.length+this.break,a=t==fy.ByHeight?e<o:e<s,l=a?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,o,s);if(this.break||(a?l.to<s:l.from>s))return l;let c=t==fy.ByPosNoHeight?fy.ByPosNoHeight:fy.ByPos;return a?l.join(this.right.lineAt(s,c,n,o,s)):this.left.lineAt(s,c,n,r,i).join(l)}forEachLine(e,t,n,r,i,o){let s=r+this.left.height,a=i+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,r,i,o),t>=a&&this.right.forEachLine(e,t,n,s,a,o);else{let l=this.lineAt(a,fy.ByPos,n,r,i);e<l.from&&this.left.forEachLine(e,l.from-1,n,r,i,o),l.to>=e&&l.from<=t&&o(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,s,a,o)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)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-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let o=i.length;for(let e of n)i.push(e);if(e>0&&ky(i,o-1),t<this.length){let e=i.length;this.decomposeRight(t,i),ky(i,e)}return my.of(i)}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,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?my.of(this.break?[e,null,t]:[e,t]):(this.left=gy(this.left,e),this.right=gy(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,r){let{left:i,right:o}=this,s=t+i.length+this.break,a=null;return r&&r.from<=t+i.length&&r.more?a=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=s+o.length&&r.more?a=o=o.updateHeight(e,s,n,r):o.updateHeight(e,s,n),a?this.balanced(i,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function ky(e,t){let n,r;null==e[t]&&(n=e[t-1])instanceof wy&&(r=e[t+1])instanceof wy&&e.splice(t-1,3,new wy(n.length+1+r.length))}class Sy{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 e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof yy?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new yy(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new by(o,r,n)):(o||i||r>=5)&&this.addLineDeco(r,i,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||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new yy(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new wy(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 yy)return e;let t=new yy(0,-1,0);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 r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof yy||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new yy(0,-1,0));let n=e;for(let e of this.nodes)e instanceof yy&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,r){let i=new Sy(n,e);return ym.spans(t,n,r,i,0),i.finish(n)}}class Ey{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&vg(e,t,this.changes,5)}}function Cy(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,o=Math.max(0,n.left),s=Math.min(i.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=r.body;)if(1==t.nodeType){let n=t,r=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=r.overflow){let r=n.getBoundingClientRect();o=Math.max(o,r.left),s=Math.min(s,r.right),a=Math.max(a,r.top),l=Math.min(t==e.parentNode?i.innerHeight:l,r.bottom)}t="absolute"==r.position||"fixed"==r.position?n.offsetParent:n.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:o-n.left,right:Math.max(o,s)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function Oy(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}class Ny{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return dg.replace({widget:new Ay(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class Ay extends hg{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 Ty{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=Py,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=zg.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Av).some(e=>"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new hy(t),this.stateDeco=Ly(e),this.heightMap=my.empty().applyChanges(this.stateDeco,Xf.empty,this.heightOracle.setDoc(e.doc),[new _v(0,0,0,e.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=dg.set(this.lineGaps.map(e=>e.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new My(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Py:new By(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(Iy(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=Ly(this.state);let r=e.changedRanges,i=_v.extendWithRanges(r,function(e,t,n){let r=new Ey;return ym.compare(e,t,n,r,0),r.changes}(n,this.stateDeco,e?e.changes:fp.empty(this.state.doc.length))),o=this.heightMap.height,s=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);cy(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=o||ly)&&(e.flags|=2),s?(this.scrollAnchorPos=e.changes.mapPos(s.from,-1),this.scrollAnchorHeight=s.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=i.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 l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(l||!e.changes.empty||2&e.flags)&&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.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(gv)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?zg.RTL:zg.LTR;let o=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent,s=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=s.height;this.contentDOMHeight=s.height,this.mustMeasureContent=!1;let l=0,c=0;if(s.width&&s.height){let{scaleX:e,scaleY:n}=Mg(t,s);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,l|=16,o=a=!0)}let h=(parseInt(n.paddingTop)||0)*this.scaleY,u=(parseInt(n.paddingBottom)||0)*this.scaleY;this.paddingTop==h&&this.paddingBottom==u||(this.paddingTop=h,this.paddingBottom=u,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=jg(e.scrollDOM);let f=(this.printing?Oy:Cy)(t,this.paddingTop),p=f.top-this.pixelViewport.top,m=f.bottom-this.pixelViewport.bottom;this.pixelViewport=f;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(a=!0)),!this.inView&&!this.scrollTarget&&!function(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}(e.dom))return 0;let v=s.width;if(this.contentDOMWidth==v&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=s.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(o=!0),o||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:s,textHeight:a}=e.docView.measureTextSize();o=n>0&&r.refresh(i,n,s,a,Math.max(5,v/s),t),o&&(e.docView.minWidth=0,l|=16)}p>0&&m>0?c=Math.max(p,m):p<0&&m<0&&(c=Math.min(p,m)),cy();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(o?my.empty().applyChanges(this.stateDeco,Xf.empty,this.heightOracle,[new _v(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new uy(n.from,i))}ly&&(l|=2)}let b=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(2&l&&(l|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),l|=this.updateForViewport()),(2&l||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}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)),r=this.heightMap,i=this.heightOracle,{visibleTop:o,visibleBottom:s}=this,a=new My(r.lineAt(o-1e3*n,fy.ByHeight,i,0,0).from,r.lineAt(s+1e3*(1-n),fy.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<a.from||e>a.to){let n,o=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=r.lineAt(e,fy.ByPos,i,0,0);n="center"==t.y?(s.top+s.bottom)/2-o/2:"start"==t.y||"nearest"==t.y&&e<a.from?s.top:s.bottom-o,a=new My(r.lineAt(n-500,fy.ByHeight,i,0,0).from,r.lineAt(n+o+500,fy.ByHeight,i,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new My(this.heightMap.lineAt(n,fy.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,fy.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,fy.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,fy.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:s}=this;return(0==e||r<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=s+Math.max(10,Math.min(n,250)))&&r>o-2e3&&i<s+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new Ny(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,o=r<<1;if(this.defaultTextDirection!=zg.LTR&&!n)return[];let s=[],a=(r,o,l,c)=>{if(o-r<i)return;let h=this.state.selection.main,u=[h.from];h.empty||u.push(h.to);for(let e of u)if(e>r&&e<o)return a(r,e-10,l,c),void a(e+10,o,l,c);let d=function(e,t){for(let n of e)if(t(n))return n;return}(e,e=>e.from>=l.from&&e.to<=l.to&&Math.abs(e.from-r)<i&&Math.abs(e.to-o)<i&&!u.some(t=>e.from<t&&e.to>t));if(!d){if(o<l.to&&t&&n&&t.visibleRanges.some(e=>e.from<=o&&e.to>=o)){let e=t.moveToLineBoundary(xp.cursor(o),!1,!0).head;e>r&&(o=e)}let e=this.gapSize(l,r,o,c);d=new Ny(r,o,e,n||e<2e6?e:2e6)}s.push(d)},l=t=>{if(t.length<o||t.type!=ug.Text)return;let i=function(e,t,n){let r=[],i=e,o=0;ym.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),o+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),o+=t-i);return{total:o,ranges:r}}(t.from,t.to,this.stateDeco);if(i.total<o)return;let s,l,c=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let e,n,o=r/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=c){let r=Dy(i,c),s=((this.visibleBottom-this.visibleTop)/2+o)/t.height;e=r-s,n=r+s}else e=(this.visibleTop-t.top-o)/t.height,n=(this.visibleBottom-t.top+o)/t.height;s=Ry(i,e),l=Ry(i,n)}else{let n=i.total*this.heightOracle.charWidth,o=r*this.heightOracle.charWidth,a=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+a<this.pixelViewport.left&&(a=n.size-n.displaySize);let h,u,d=this.pixelViewport.left+a,f=this.pixelViewport.right+a;if(null!=c){let e=Dy(i,c),t=((f-d)/2+o)/n;h=e-t,u=e+t}else h=(d-o)/n,u=(f+o)/n;s=Ry(i,h),l=Ry(i,u)}s>t.from&&a(t.from,s,t,i),l<t.to&&a(l,t.to,t,i)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(l):l(e);return s}gapSize(e,t,n,r){let i=Dy(r,n)-Dy(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){Ny.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=dg.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];ym.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t<n.length&&!(8&r);t++){let i=this.visibleRanges[t],o=n[t];i.from==o.from&&i.to==o.to||(r|=4,e&&e.mapPos(i.from,-1)==o.from&&e.mapPos(i.to,1)==o.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Iy(this.heightMap.lineAt(e,fy.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)||Iy(this.heightMap.lineAt(this.scaler.fromDOM(e),fy.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 Iy(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 My{constructor(e,t){this.from=e,this.to=t}}function Ry({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],o=i-n;if(r<=o)return n+r;r-=o}}function Dy(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}const Py={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};function Ly(e){let t=e.facet(Tv).filter(e=>"function"!=typeof e),n=e.facet(Rv).filter(e=>"function"!=typeof e);return n.length&&t.push(ym.join(n)),t}class By{constructor(e,t,n){let r=0,i=0,o=0;this.viewports=n.map(({from:n,to:i})=>{let o=t.lineAt(n,fy.ByPos,e,0,0).top,s=t.lineAt(i,fy.ByPos,e,0,0).bottom;return r+=s-o,{from:n,to:i,top:o,bottom:s,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let e of this.viewports)e.domTop=o+(e.top-i)*this.scale,o=e.domBottom=e.domTop+(e.bottom-e.top),i=e.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}eq(e){return e instanceof By&&(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))}}function Iy(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new dy(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>Iy(e,t)):e._content)}const jy=Ep.define({combine:e=>e.join(" ")}),_y=Ep.define({combine:e=>e.indexOf(!0)>-1}),Fy=Im.newName(),Wy=Im.newName(),zy=Im.newName(),Hy={"&light":"."+Wy,"&dark":"."+zy};function Vy(e,t,n){return new Im(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!n||!n[t])throw new RangeError(`Unsupported selector: ${t}`);return n[t]}):e+" "+t})}const qy=Vy("."+Fy,{"&":{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"}},Hy),Uy={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},$y=ig.ie&&ig.ie_version<=11;class Ky{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Rg,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 e of t)this.queue.push(e);(ig.ie&&ig.ie_version<=11||ig.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),!window.EditContext||!ig.android||!1===e.constructor.EDIT_CONTEXT||ig.chrome&&ig.chrome_version<126||(this.editContext=new Xy(e),e.state.facet(kv)&&(e.contentDOM.editContext=this.editContext.editContext)),$y&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var e;(null===(e=this.view.docView)||void 0===e?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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(e=>{e.length>0&&e[e.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){("change"!=e.type&&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,r=this.selectionRange;if(n.state.facet(kv)?n.root.activeElement!=this.dom:!xg(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);i&&i.isWidget()&&i.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(ig.ie&&ig.ie_version<=11||ig.android&&ig.chrome)&&!n.state.selection.main.empty&&r.focusNode&&Sg(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=yg(e.root);if(!t)return!1;let n=ig.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Gy(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",r,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",r,!0),n?Gy(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=xg(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,Ng(n));;)if(r){if(1!=n.nodeType)return!1;let e=n.childNodes[r-1];"false"==e.contentEditable?r--:(n=e,r=Ng(n))}else{if(n==e)return!0;r=Eg(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(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(1==n.nodeType)!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(11!=n.nodeType)break;n=n.host}if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.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,Uy),$y&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),$y&&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 e=()=>{let e=this.delayedAndroidKey;if(e){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&Ig(this.dom,e.key,e.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null===(n=this.delayedAndroidKey)||void 0===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,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),-1==t?({from:t,to:n}=e):(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&xg(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new Mb(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}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,r=Db(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!Bb(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty("attributes"==e.type),"childList"==e.type){let n=Yy(t,e.previousSibling||e.target.previousSibling,-1),r=Yy(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{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(kv)!=e.state.facet(kv)&&(e.view.contentDOM.editContext=e.state.facet(kv)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(n=this.resizeScroll)||void 0===n||n.disconnect();for(let e of this.scrollTargets)e.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 Yy(e,t,n){for(;t;){let r=zv.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i!=e.dom?i:n>0?t.nextSibling:t.previousSibling}return null}function Gy(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,o=t.endOffset,s=e.docView.domAtPos(e.state.selection.main.anchor,1);return Sg(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}class Xy{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 r=e.state.selection.main,{anchor:i,head:o}=r,s=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:s,drifted:!1});let l=a-s>n.text.length;s==this.from&&i<this.from?s=i:a==this.to&&i>this.to&&(a=i);let c=Lb(e.state.sliceDoc(s,a),n.text,(l?r.from:r.to)-s,l?"end":null);if(!c){let t=xp.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));return void(Bb(t,r)||e.dispatch({selection:t,userEvent:"select"}))}let h={from:c.from+s,to:c.toA+s,insert:Xf.of(n.text.slice(c.from,c.toB).split("\n"))};if((ig.mac||ig.android)&&h.from==o-1&&/^\. ?$/.test(n.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(h={from:s,to:a,insert:Xf.of([n.text.replace("."," ")])}),this.pendingContextChange=h,!e.state.readOnly){let t=this.to-this.from+(h.to-h.from+h.insert.length);Pb(e,h,xp.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),h.from<h.to&&!h.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),o=this.toEditorPos(n.rangeEnd);t<o;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),o=this.toEditorPos(e.rangeEnd);if(i<o){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+" ":"Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":""}${/thin/i.test(r)?1:2}px`;n.push(dg.mark({attributes:{style:e}}).range(i,o))}}}e.dispatch({effects:wv.of(dg.set(n))})},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:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=yg(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,o,s,a,l)=>{if(n)return;let c=l.length-(o-i);if(r&&o>=r.to){if(r.from==i&&r.to==o&&r.insert.eq(l))return r=this.pendingContextChange=null,t+=c,void(this.to+=c);r=null,this.revertPending(e.state)}if(i+=t,(o+=t)<=this.from)this.from+=c,this.to+=c;else if(i<this.to){if(i<this.from||o>this.to||this.to-this.from+l.length>3e4)return void(n=!0);this.editContext.updateText(this.toContextPos(i),this.toContextPos(o),l.toString()),this.to+=c}t+=c}),r&&!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(e=>!e.isUserEvent("input.type")&&e.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)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(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))),r=this.toContextPos(t.head);this.editContext.selectionStart==n&&this.editContext.selectionEnd==r||this.editContext.updateSelection(n,r)}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>3e4)}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 Jy{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&&(e=>e.forEach(e=>n(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new Ty(e.state||dm.create(e)),e.scrollTo&&e.scrollTo.is(yv)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ev).map(e=>new Ov(e));for(let e of this.plugins)e.update(this);this.observer=new Ky(this),this.inputState=new Ib(this),this.inputState.ensureHandlers(this.plugins),this.docView=new hb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(t=document.fonts)||void 0===t?void 0:t.ready)&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=!0,this.requestMeasure()})}dispatch(...e){let t=1==e.length&&e[0]instanceof tm?e:1==e.length&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,n=!1,r=!1,i=this.state;for(let t of e){if(t.startState!=i)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");i=t.state}if(this.destroyed)return void(this.viewState.state=i);let o=this.hasFocus,s=0,a=null;e.some(e=>e.annotation(ry))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=iy(i,o),a||(s=1));let l=this.observer.delayedAndroidKey,c=null;if(l?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(c=null)):this.observer.clear(),i.facet(dm.phrases)!=this.state.facet(dm.phrases))return this.setState(i);t=Fv.create(this,i,e),t.flags|=s;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(h&&(h=h.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;h=new bv(e.empty?e:xp.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(yv)&&(h=e.value.clip(this.state))}this.viewState.update(t,h),this.bidiCache=ew.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),n=this.docView.update(t),this.state.facet(jv)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(t.startState.facet(jy)!=t.state.facet(jy)&&(this.viewState.mustMeasureContent=!0),(n||r||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!t.empty)for(let e of this.state.facet(hv))try{e(t)}catch(e){xv(this.state,e,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Db(this,c)&&l.force&&Ig(this.contentDOM,l.key,l.keyCode)})}setState(e){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new Ty(e),this.plugins=e.facet(Ev).map(e=>new Ov(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new hb(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(Ev),n=e.state.facet(Ev);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new Ov(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].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(e){xv(this.state,e,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,r=n.scrollTop*this.scaleY,{scrollAnchorPos:i,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(o<0)if(jg(n))i=-1,o=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,o=e.top}this.updateState=1;let s=this.viewState.measure(this);if(!s&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5)break;let a=[];4&s||([this.measureRequests,a]=[a,this.measureRequests]);let l=a.map(e=>{try{return e.read(this)}catch(e){return xv(this.state,e),Zy}}),c=Fv.create(this,this.state,[]),h=!1;c.flags|=s,t?t.flags|=s:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),h=this.docView.update(c),h&&this.docViewUpdate());for(let e=0;e<a.length;e++)if(l[e]!=Zy)try{let t=a[e];t.write&&t.write(l[e],this)}catch(e){xv(this.state,e)}if(h&&this.docView.updateSelection(!0),!c.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}{let e=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-o;if(e>1||e<-1){r+=e,n.scrollTop=r/this.scaleY,o=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(hv))e(t)}get themeClasses(){return Fy+" "+(this.state.facet(_y)?zy:Wy)+" "+this.state.facet(jy)}updateAttrs(){let e=tw(this,Nv,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(kv)?"true":"false",class:"cm-content",style:`${ig.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),tw(this,Av,t);let n=this.observer.ignore(()=>{let n=lg(this.contentDOM,this.contentAttrs,t),r=lg(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let e of n.effects)if(e.is(Jy.announce)){t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value}}mountStyles(){this.styleModules=this.state.facet(jv);let e=this.state.facet(Jy.cspNonce);Im.mount(this.root,this.styleModules.concat(qy).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&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(null!=e.key)for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key)return void(this.measureRequests[t]=e);this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.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 wb(this,e,vb(this,e,t,n))}moveByGroup(e,t){return wb(this,e,vb(this,e,t,t=>function(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==lm.Space&&(i=t),i==t}}(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return xp.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return function(e,t,n,r){let i=gb(e,t.head,t.assoc||-1),o=r&&i.type==ug.Text&&(e.lineWrapping||i.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head):null;if(o){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),s=e.posAtCoords({x:n==(r==zg.LTR)?t.right-1:t.left+1,y:(o.top+o.bottom)/2});if(null!=s)return xp.cursor(s,n?-1:1)}return xp.cursor(n?i.to:i.from,n?-1:1)}(this,e,t,n)}moveVertically(e,t,n){return wb(this,e,function(e,t,n,r){let i=t.head,o=n?1:-1;if(i==(n?e.state.doc.length:0))return xp.cursor(i,t.assoc);let s,a=t.goalColumn,l=e.contentDOM.getBoundingClientRect(),c=e.coordsAtPos(i,t.assoc||-1),h=e.documentTop;if(c)null==a&&(a=c.left-l.left),s=o<0?c.top:c.bottom;else{let t=e.viewState.lineBlockAt(i);null==a&&(a=Math.min(l.right-l.left,e.defaultCharacterWidth*(i-t.from))),s=(o<0?t.top:t.bottom)+h}let u=kb(e,{x:l.left+a,y:s+(null!=r?r:e.viewState.heightOracle.textHeight>>1)*o},!1,o);return xp.cursor(u.pos,u.assoc,void 0,a)}(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=kb(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),kb(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 r=this.state.doc.lineAt(e),i=this.bidiSpans(r);return Ag(n,i[Jg.find(i,e-r.from,-1,t)].dir==zg.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(mv)||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>Qy)return nv(e.length);let t,n=this.textDirectionAt(e.from);for(let r of this.bidiCache)if(r.from==e.from&&r.dir==n&&(r.fresh||Qg(r.isolates,t=Lv(this,e))))return r.order;t||(t=Lv(this,e));let r=function(e,t,n){if(!e)return[new Jg(0,0,t==Vg?1:0)];if(t==Hg&&!n.length&&!Xg.test(e))return nv(e.length);if(n.length)for(;e.length>Zg.length;)Zg[Zg.length]=256;let r=[],i=t==Hg?0:1;return tv(e,i,i,n,0,e.length,r),r}(e.text,n,t);return this.bidiCache.push(new ew(e.from,e.to,n,t,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||ig.safari&&(null===(e=this.inputState)||void 0===e?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Lg(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?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 yv.of(new bv("number"==typeof e?xp.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 yv.of(new bv(xp.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Cv.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Cv.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Im.newName(),r=[jy.of(n),jv.of(Vy(`.${n}`,e))];return t&&t.dark&&r.push(_y.of(!0)),r}static baseTheme(e){return jp.lowest(jv.of(Vy("."+Fy,e,Hy)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&zv.get(n)||zv.get(e);return(null===(t=null==r?void 0:r.root)||void 0===t?void 0:t.view)||null}}Jy.styleModule=jv,Jy.inputHandler=uv,Jy.clipboardInputFilter=fv,Jy.clipboardOutputFilter=pv,Jy.scrollHandler=vv,Jy.focusChangeEffect=dv,Jy.perLineTextDirection=mv,Jy.exceptionSink=cv,Jy.updateListener=hv,Jy.editable=kv,Jy.mouseSelectionStyle=lv,Jy.dragMovesSelection=av,Jy.clickAddsSelectionRange=sv,Jy.decorations=Tv,Jy.blockWrappers=Mv,Jy.outerDecorations=Rv,Jy.atomicRanges=Dv,Jy.bidiIsolatedRanges=Pv,Jy.scrollMargins=Bv,Jy.darkTheme=_y,Jy.cspNonce=Ep.define({combine:e=>e.length?e[0]:""}),Jy.contentAttributes=Av,Jy.editorAttributes=Nv,Jy.lineWrapping=Jy.contentAttributes.of({class:"cm-lineWrapping"}),Jy.announce=em.define();const Qy=4096,Zy={};class ew{constructor(e,t,n,r,i,o){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=o}static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let n=[],r=e.length?e[e.length-1].dir:zg.LTR;for(let i=Math.max(0,e.length-10);i<e.length;i++){let o=e[i];o.dir!=r||t.touchesRange(o.from,o.to)||n.push(new ew(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function tw(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],o="function"==typeof t?t(e):t;o&&og(o,n)}return n}const nw=ig.mac?"mac":ig.windows?"win":ig.linux?"linux":"key";function rw(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}const iw=jp.default(Jy.domEventHandlers({keydown:(e,t)=>uw(aw(t.state),e,t,"editor")})),ow=Ep.define({enables:iw}),sw=new WeakMap;function aw(e){let t=e.facet(ow),n=sw.get(t);return n||sw.set(t,n=function(e,t=nw){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(null==n)r[e]=t;else if(n!=t)throw new Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},o=(e,r,o,s,a)=>{var l,c;let h=n[e]||(n[e]=Object.create(null)),u=r.split(/ (?!$)/).map(e=>function(e,t){const n=e.split(/-(?!$)/);let r,i,o,s,a=n[n.length-1];"Space"==a&&(a=" ");for(let e=0;e<n.length-1;++e){const a=n[e];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else{if(!/^mod$/i.test(a))throw new Error("Unrecognized modifier name: "+a);"mac"==t?s=!0:i=!0}}return r&&(a="Alt-"+a),i&&(a="Ctrl-"+a),s&&(a="Meta-"+a),o&&(a="Shift-"+a),a}(e,t));for(let t=1;t<u.length;t++){let n=u.slice(0,t).join(" ");i(n,!0),h[n]||(h[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=lw={view:t,prefix:n,scope:e};return setTimeout(()=>{lw==r&&(lw=null)},cw),!0}]})}let d=u.join(" ");i(d,!1);let f=h[d]||(h[d]={preventDefault:!1,stopPropagation:!1,run:(null===(c=null===(l=h._any)||void 0===l?void 0:l.run)||void 0===c?void 0:c.slice())||[]});o&&f.run.push(o),s&&(f.preventDefault=!0),a&&(f.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(" "):["editor"];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,hw))}let i=r[t]||r.key;if(i)for(let t of e)o(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&o(t,"Shift-"+i,r.shift,r.preventDefault,r.stopPropagation)}return n}(t.reduce((e,t)=>e.concat(t),[]))),n}let lw=null;const cw=4e3;let hw=null;function uw(e,t,n,r){hw=t;let i=function(e){var t=!(zm&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Hm&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Wm:Fm)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(t),o=cp(ap(i,0))==i.length&&" "!=i,s="",a=!1,l=!1,c=!1;lw&&lw.view==n&&lw.scope==r&&(s=lw.prefix+" ",zb.indexOf(t.keyCode)<0&&(l=!0,lw=null));let h,u,d=new Set,f=e=>{if(e){for(let t of e.run)if(!d.has(t)&&(d.add(t),t(n)))return e.stopPropagation&&(c=!0),!0;e.preventDefault&&(e.stopPropagation&&(c=!0),l=!0)}return!1},p=e[r];return p&&(f(p[s+rw(i,t,!o)])?a=!0:!o||!(t.altKey||t.metaKey||t.ctrlKey)||ig.windows&&t.ctrlKey&&t.altKey||ig.mac&&t.altKey&&!t.ctrlKey&&!t.metaKey||!(h=Fm[t.keyCode])||h==i?o&&t.shiftKey&&f(p[s+rw(i,t,!0)])&&(a=!0):(f(p[s+rw(h,t,!0)])||t.shiftKey&&(u=Wm[t.keyCode])!=i&&u!=h&&f(p[s+rw(u,t,!1)]))&&(a=!0),!a&&f(p._any)&&(a=!0)),l&&(a=!0),a&&c&&t.stopPropagation(),hw=null,a}class dw{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(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 r=e.coordsAtPos(n.head,n.assoc||1);if(!r)return[];let i=fw(e);return[new dw(t,r.left-i.left,r.top-i.top,null,r.bottom-r.top)]}return function(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),o=e.textDirection==zg.LTR,s=e.contentDOM,a=s.getBoundingClientRect(),l=fw(e),c=s.querySelector(".cm-line"),h=c&&window.getComputedStyle(c),u=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),d=a.right-(h?parseInt(h.paddingRight):0),f=gb(e,r,1),p=gb(e,i,-1),m=f.type==ug.Text?f:null,g=p.type==ug.Text?p:null;m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=pw(e,r,1,m));g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=pw(e,i,-1,g));if(m&&g&&m.from==g.from&&m.to==g.to)return b(y(n.from,n.to,m));{let t=m?y(n.from,null,m):w(f,!1),r=g?y(null,n.to,g):w(p,!0),i=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<r.top?i.push(v(u,t.bottom,d,r.top)):t.bottom<r.top&&e.elementAtHeight((t.bottom+r.top)/2).type==ug.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),b(t).concat(i).concat(b(r))}function v(e,n,r,i){return new dw(t,e-l.left,n-l.top,r-e,i-n)}function b({top:e,bottom:t,horizontal:n}){let r=[];for(let i=0;i<n.length;i+=2)r.push(v(n[i],e,n[i+1],t));return r}function y(t,n,r){let i=1e9,s=-1e9,a=[];function l(t,n,l,c,h){let f=e.coordsAtPos(t,t==r.to?-2:2),p=e.coordsAtPos(l,l==r.from?2:-2);f&&p&&(i=Math.min(f.top,p.top,i),s=Math.max(f.bottom,p.bottom,s),h==zg.LTR?a.push(o&&n?u:f.left,o&&c?d:p.right):a.push(!o&&c?u:p.left,!o&&n?d:f.right))}let c=null!=t?t:r.from,h=null!=n?n:r.to;for(let r of e.visibleRanges)if(r.to>c&&r.from<h)for(let i=Math.max(r.from,c),o=Math.min(r.to,h);;){let r=e.state.doc.lineAt(i);for(let s of e.bidiSpans(r)){let e=s.from+r.from,a=s.to+r.from;if(e>=o)break;a>i&&l(Math.max(e,i),null==t&&e<=c,Math.min(a,o),null==n&&a>=h,s.dir)}if(i=r.to+1,i>=o)break}return 0==a.length&&l(c,null==t,h,null==n,e.textDirection),{top:i,bottom:s,horizontal:a}}function w(e,t){let n=a.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}(e,t,n)}}function fw(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==zg.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function pw(e,t,n,r){let i=e.coordsAtPos(t,2*n);if(!i)return r;let o=e.dom.getBoundingClientRect(),s=(i.top+i.bottom)/2,a=e.posAtCoords({x:o.left+1,y:s}),l=e.posAtCoords({x:o.right-1,y:s});return null==a||null==l?r:{from:Math.max(r.from,Math.min(a,l)),to:Math.min(r.to,Math.max(a,l))}}class mw{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(gw)!=e.state.facet(gw)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){!1!==this.layer.updateOnDocViewUpdate&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(gw);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((e,t)=>{return n=e,r=this.drawn[t],!(n.constructor==r.constructor&&n.eq(r));var n,r})){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,ig.safari&&ig.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 gw=Ep.define();function vw(e){return[Cv.define(t=>new mw(t,e)),gw.of(e)]}const bw=Ep.define({combine:e=>fm(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function yw(e){return e.startState.facet(bw)!=e.state.facet(bw)}const ww=vw({above:!0,markers(e){let{state:t}=e,n=t.facet(bw),r=[];for(let i of t.selection.ranges){let o=i==t.selection.main;if(i.empty||n.drawRangeCursor){let t=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",n=i.empty?i:xp.cursor(i.head,i.head>i.anchor?-1:1);for(let i of dw.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");let n=yw(e);return n&&xw(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){xw(t.state,e)},class:"cm-cursorLayer"});function xw(e,t){t.style.animationDuration=e.facet(bw).cursorBlinkRate+"ms"}const kw=vw({above:!1,markers:e=>e.state.selection.ranges.map(t=>t.empty?[]:dw.forRange(e,"cm-selectionBackground",t)).reduce((e,t)=>e.concat(t)),update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||yw(e),class:"cm-selectionLayer"}),Sw=jp.highest(Jy.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"}}}})),Ew=em.define({map:(e,t)=>null==e?null:t.mapPos(e)}),Cw=Rp.define({create:()=>null,update:(e,t)=>(null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(Ew)?t.value:e,e))}),Ow=Cv.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(Cw);null==n?null!=this.cursor&&(null===(t=this.cursor)||void 0===t||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(Cw)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(Cw),n=null!=t&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(Cw)!=e&&this.view.dispatch({effects:Ew.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){e.target!=this.view.contentDOM&&this.view.contentDOM.contains(e.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Nw(e,t,n,r,i){t.lastIndex=0;for(let o,s=e.iterRange(n,r),a=n;!s.next().done;a+=s.value.length)if(!s.lineBreak)for(;o=t.exec(s.value);)i(a+o.index,o)}class Aw{constructor(e){const{regexp:t,decoration:n,decorate:r,boundary:i,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,r)this.addMatch=(e,t,n,i)=>r(i,n,n+e[0].length,e,t);else if("function"==typeof n)this.addMatch=(e,t,r,i)=>{let o=n(e,t,r);o&&i(r,r+e[0].length,o)};else{if(!n)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(e,t,r,i)=>i(r,r+e[0].length,n)}this.boundary=i,this.maxLength=o}createDeco(e){let t=new wm,n=t.add.bind(t);for(let{from:t,to:r}of function(e,t){let n=e.visibleRanges;if(1==n.length&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let r=[];for(let{from:i,to:o}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),o=Math.min(e.state.doc.lineAt(o).to,o+t),r.length&&r[r.length-1].to>=i?r[r.length-1].to=o:r.push({from:i,to:o});return r}(e,this.maxLength))Nw(e.state.doc,this.regexp,t,r,(t,r)=>this.addMatch(r,e,t,n));return t.finish()}updateDeco(e,t){let n=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((t,i,o,s)=>{s>=e.view.viewport.from&&o<=e.view.viewport.to&&(n=Math.min(o,n),r=Math.max(s,r))}),e.viewportMoved||r-n>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),n,r):t}updateRange(e,t,n,r){for(let i of e.visibleRanges){let o=Math.max(i.from,n),s=Math.min(i.to,r);if(s>=o){let n=e.state.doc.lineAt(o),r=n.to<s?e.state.doc.lineAt(s):n,a=Math.max(i.from,n.from),l=Math.min(i.to,r.to);if(this.boundary){for(;o>n.from;o--)if(this.boundary.test(n.text[o-1-n.from])){a=o;break}for(;s<r.to;s++)if(this.boundary.test(r.text[s-r.from])){l=s;break}}let c,h=[],u=(e,t,n)=>h.push(n.range(e,t));if(n==r)for(this.regexp.lastIndex=a-n.from;(c=this.regexp.exec(n.text))&&c.index<l-n.from;)this.addMatch(c,e,c.index+n.from,u);else Nw(e.state.doc,this.regexp,a,l,(t,n)=>this.addMatch(n,e,t,u));t=t.update({filterFrom:a,filterTo:l,filter:(e,t)=>e<a||t>l,add:h})}}return t}}const Tw=null!=/x/.unicode?"gu":"g",Mw=new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\ufeff-]",Tw),Rw={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 Dw=null;const Pw=Ep.define({combine(e){let t=fm(e,{render:null,specialChars:Mw,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==Dw&&"undefined"!=typeof document&&document.body){let t=document.body.style;Dw=null!=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)}return Dw||!1}())&&(t.specialChars=new RegExp("\t|"+t.specialChars.source,Tw)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,Tw)),t}});let Lw=null;class Bw extends hg{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=function(e){return e>=32?"•":10==e?"␤":String.fromCharCode(9216+e)}(this.code),n=e.state.phrase("Control character")+" "+(Rw[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,t);if(r)return r;let i=document.createElement("span");return i.textContent=t,i.title=n,i.setAttribute("aria-label",n),i.className="cm-specialChar",i}ignoreEvent(){return!1}}class Iw extends hg{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent="\t",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}const jw=dg.line({class:"cm-activeLine"}),_w=Cv.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(jw.range(i.from)),t=i.from)}return dg.set(n)}},{decorations:e=>e.decorations});class Fw extends hg{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild("string"==typeof this.content?document.createTextNode(this.content):"function"==typeof this.content?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?kg(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=Ag(t[0],"rtl"!=n.direction),i=parseInt(n.lineHeight);return r.bottom-r.top>1.5*i?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}}const Ww=2e3;function zw(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,o=i>Ww?-1:i==r.length?function(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}(e,t.clientX):Rm(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:o,off:i}}function Hw(e,t){let n=zw(e,t),r=e.state.selection;return n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(t,i,o){let s=zw(e,t);if(!s)return r;let a=function(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),o=[];if(t.off>Ww||n.off>Ww||t.col<0||n.col<0){let s=Math.min(t.off,n.off),a=Math.max(t.off,n.off);for(let t=r;t<=i;t++){let n=e.doc.line(t);n.length<=a&&o.push(xp.range(n.from+s,n.to+a))}}else{let s=Math.min(t.col,n.col),a=Math.max(t.col,n.col);for(let t=r;t<=i;t++){let n=e.doc.line(t),r=Dm(n.text,s,e.tabSize,!0);if(r<0)o.push(xp.cursor(n.to));else{let t=Dm(n.text,a,e.tabSize);o.push(xp.range(n.from+r,n.from+t))}}}return o}(e.state,n,s);return a.length?o?xp.create(a.concat(r.ranges)):xp.create(a):r}}:null}const Vw={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},qw={style:"cursor: crosshair"};const Uw="-10000px";class $w{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let o=[],s=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],a=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(a=e)}if(a<0)o[n]=this.createTooltipView(r,n?o[n-1]:null),s&&(s[n]=!!r.above);else{let r=o[n]=this.tooltipViews[a];s&&(s[n]=t[a]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)o.indexOf(e)<0&&(this.removeTooltipView(e),null===(n=e.destroy)||void 0===n||n.call(e));return t&&(s.forEach((e,n)=>t[n]=e),t.length=s.length),this.input=r,this.tooltips=i,this.tooltipViews=o,!0}}function Kw(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const Yw=Ep.define({combine:e=>{var t,n,r;return{position:ig.ios?"absolute":(null===(t=e.find(e=>e.position))||void 0===t?void 0:t.position)||"fixed",parent:(null===(n=e.find(e=>e.parent))||void 0===n?void 0:n.parent)||null,tooltipSpace:(null===(r=e.find(e=>e.tooltipSpace))||void 0===r?void 0:r.tooltipSpace)||Kw}}}),Gw=new WeakMap,Xw=Cv.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(Yw);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new $w(e,ex,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.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 e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(Yw);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let e=document.createElement("div");e.className="cm-tooltip-arrow",n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=Uw,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),null===(e=t.destroy)||void 0===e||e.call(t);this.parent&&this.container.remove(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(n=this.intersectionObserver)||void 0===n||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(ig.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||"absolute"==this.position)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=Iv(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(Yw).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let e of this.manager.tooltipViews)e.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:o}=e,s=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:h}=c,u=e.pos[a],d=e.size[a];if(!u||!1!==l.clip&&(u.bottom<=Math.max(n.top,r.top)||u.top>=Math.min(n.bottom,r.bottom)||u.right<Math.max(n.left,r.left)-.1||u.left>Math.min(n.right,r.right)+.1)){h.style.top=Uw;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=null!==(t=Gw.get(c))&&void 0!==t?t:d.bottom-d.top,v=c.offset||Zw,b=this.view.textDirection==zg.LTR,y=d.width>r.right-r.left?b?r.left:r.right-d.width:b?Math.max(r.left,Math.min(u.left-(f?14:0)+v.x,r.right-m)):Math.min(Math.max(r.left,u.left-m+(f?14:0)-v.x),r.right-m),w=this.above[a];!l.strictSide&&(w?u.top-g-p-v.y<r.top:u.bottom+g+p+v.y>r.bottom)&&w==r.bottom-u.bottom>u.top-r.top&&(w=this.above[a]=!w);let x=(w?u.top-r.top:r.bottom-u.bottom)-p;if(x<g&&!1!==c.resize){if(x<this.view.defaultLineHeight){h.style.top=Uw;continue}Gw.set(c,g),h.style.height=(g=x)/o+"px"}else h.style.height&&(h.style.height="");let k=w?u.top-g-p-v.y:u.bottom+p+v.y,S=y+m;if(!0!==c.overlap)for(let e of s)e.left<S&&e.right>y&&e.top<k+g&&e.bottom>k&&(k=w?e.top-g-2-p:e.bottom+p+2);if("absolute"==this.position?(h.style.top=(k-e.parent.top)/o+"px",Jw(h,(y-e.parent.left)/i)):(h.style.top=k/o+"px",Jw(h,y/i)),f){let e=u.left+(b?v.x:-v.x)-(y+14-7);f.style.left=e/i+"px"}!0!==c.overlap&&s.push({left:y,top:k,right:S,bottom:k+g}),h.classList.toggle("cm-tooltip-above",w),h.classList.toggle("cm-tooltip-below",!w),c.positioned&&c.positioned(e.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 e of this.manager.tooltipViews)e.dom.style.top=Uw}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Jw(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const Qw=Jy.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"}}}),Zw={x:0,y:0},ex=Ep.define({enables:[Xw,Qw]}),tx=Ep.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])});class nx{static create(e){return new nx(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new $w(e,tx,(e,t)=>this.createHostedView(e,t),e=>e.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)null===(e=t.destroy)||void 0===e||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(void 0!==r)if(void 0===t)t=r;else if(t!==r)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 rx=ex.compute([tx],e=>{let t=e.facet(tx);return 0===t.length?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var t;return null!==(t=e.end)&&void 0!==t?t:e.pos})),create:nx.create,above:t[0].above,arrow:t.some(e=>e.arrow)}});class ix{constructor(e,t,n,r,i){this.view=e,this.source=t,this.field=n,this.setHover=r,this.hoverTime=i,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.tile.nearest(t.target);if(!n)return;let r,i=1;if(n.isWidget())r=n.posAtStart;else{if(r=e.posAtCoords(t),null==r)return;let n=e.coordsAtPos(r);if(!n||t.y<n.top||t.y>n.bottom||t.x<n.left-e.defaultCharacterWidth||t.x>n.right+e.defaultCharacterWidth)return;let o=e.bidiSpans(e.state.doc.lineAt(r)).find(e=>e.from<=r&&e.to>=r),s=o&&o.dir==zg.RTL?-1:1;i=t.x<n.left?-s:s}let o=this.source(e,r,i);if(null==o?void 0:o.then){let t=this.pending={pos:r};o.then(n=>{this.pending==t&&(this.pending=null,!n||Array.isArray(n)&&!n.length||e.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])}))},t=>xv(e.state,t,"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(Xw),t=e?e.manager.tooltips.findIndex(e=>e.create==nx.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:r,tooltip:i}=this;if(r.length&&i&&!function(e,t){let n,{left:r,right:i,top:o,bottom:s}=e.getBoundingClientRect();if(n=e.querySelector(".cm-tooltip-arrow")){let e=n.getBoundingClientRect();o=Math.min(e.top,o),s=Math.max(e.bottom,s)}return t.clientX>=r-ox&&t.clientX<=i+ox&&t.clientY>=o-ox&&t.clientY<=s+ox}(i.dom,e)||this.pending){let{pos:i}=r[0]||this.pending,o=null!==(n=null===(t=r[0])||void 0===t?void 0:t.end)&&void 0!==n?n:i;(i==o?this.view.posAtCoords(this.lastMove)==i:function(e,t,n,r,i){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,s)<i)return!1;let a=e.posAtCoords({x:r,y:i},!1);return a>=t&&a<=n}(this.view,i,o,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:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.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),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const ox=4;function sx(e,t={}){let n=em.define(),r=Rp.define({create:()=>[],update(e,r){if(e.length&&(t.hideOnChange&&(r.docChanged||r.selection)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(r,e))),r.docChanged)){let t=[];for(let n of e){let e=r.changes.mapPos(n.pos,-1,up.TrackDel);if(null!=e){let i=Object.assign(Object.create(null),n);i.pos=e,null!=i.end&&(i.end=r.changes.mapPos(i.end)),t.push(i)}}e=t}for(let t of r.effects)t.is(n)&&(e=t.value),t.is(lx)&&(e=[]);return e},provide:e=>tx.from(e)});return{active:r,extension:[r,Cv.define(i=>new ix(i,e,r,n,t.hoverTime||300)),rx]}}function ax(e,t){let n=e.plugin(Xw);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const lx=em.define(),cx=Ep.define({combine(e){let t,n;for(let r of e)t=t||r.topContainer,n=n||r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function hx(e,t){let n=e.plugin(ux),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const ux=Cv.fromClass(class{constructor(e){this.input=e.state.facet(px),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(cx);this.top=new dx(e,!0,t.topContainer),this.bottom=new dx(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}update(e){let t=e.state.facet(cx);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new dx(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new dx(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(px);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],o=[],s=[];for(let n of t){let t,a=this.specs.indexOf(n);a<0?(t=n(e.view),s.push(t)):(t=this.panels[a],t.update&&t.update(e)),r.push(t),(t.top?i:o).push(t)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(o);for(let e of s)e.dom.classList.add("cm-panel"),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>Jy.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class dx{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(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));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 e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=fx(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=fx(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 fx(e){let t=e.nextSibling;return e.remove(),t}const px=Ep.define({enables:ux});function mx(e,t){let n,r=new Promise(e=>n=e),i=e=>function(e,t,n){let r=t.content?t.content(e,()=>s(null)):null;if(!r){if(r=Um("form"),t.input){let e=Um("input",t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add("cm-textfield"),e.name||(e.name="input"),r.appendChild(Um("label",(t.label||"")+": ",e))}else r.appendChild(document.createTextNode(t.label||""));r.appendChild(document.createTextNode(" ")),r.appendChild(Um("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let i="FORM"==r.nodeName?[r]:r.querySelectorAll("form");for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener("keydown",e=>{27==e.keyCode?(e.preventDefault(),s(null)):13==e.keyCode&&(e.preventDefault(),s(t))}),t.addEventListener("submit",e=>{e.preventDefault(),s(t)})}let o=Um("div",r,Um("button",{onclick:()=>s(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));t.class&&(o.className=t.class);function s(t){o.contains(o.ownerDocument.activeElement)&&e.focus(),n(t)}return o.classList.add("cm-dialog"),{dom:o,top:t.top,mount:()=>{if(t.focus){let e;e="string"==typeof t.focus?r.querySelector(t.focus):r.querySelector("input")||r.querySelector("button"),e&&"select"in e?e.select():e&&"focus"in e&&e.focus()}}}}(e,t,n);e.state.field(gx,!1)?e.dispatch({effects:vx.of(i)}):e.dispatch({effects:em.appendConfig.of(gx.init(()=>[i]))});let o=bx.of(i);return{close:o,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(gx).indexOf(i)>-1&&e.dispatch({effects:o})}),t))}}const gx=Rp.define({create:()=>[],update(e,t){for(let n of t.effects)n.is(vx)?e=[n.value].concat(e):n.is(bx)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>px.computeN([e],t=>t.field(e))}),vx=em.define(),bx=em.define();class yx extends pm{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}yx.prototype.elementClass="",yx.prototype.toDOM=void 0,yx.prototype.mapMode=up.TrackBefore,yx.prototype.startSide=yx.prototype.endSide=-1,yx.prototype.point=!0;const wx=Ep.define(),xx=Ep.define(),kx={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ym.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Sx=Ep.define();function Ex(e){return[Ox(),Sx.of({...kx,...e})]}const Cx=Ep.define({combine:e=>e.some(e=>e)});function Ox(e){let t=[Nx];return e&&!1===e.fixed&&t.push(Cx.of(!0)),t}const Nx=Cv.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.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=e.state.facet(Sx).map(t=>new Rx(e,t)),this.fixed=!e.state.facet(Cx);for(let e of this.gutters)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.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(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<.8*(n.to-n.from))}if(e.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(Cx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=ym.iter(this.view.state.facet(wx),this.view.viewport.from),r=[],i=this.gutters.map(e=>new Mx(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let o of e.type)if(o.type==ug.Text&&t){Tx(n,r,o.from);for(let e of i)e.line(this.view,o,r);t=!1}else if(o.widget)for(let e of i)e.widget(this.view,o)}else if(e.type==ug.Text){Tx(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(Sx),n=e.state.facet(Sx),r=e.docChanged||e.heightChanged||e.viewportChanged||!ym.eq(e.startState.facet(wx),e.state.facet(wx),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new Rx(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>Jy.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||0==n.gutters.length||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==zg.LTR?{left:r,right:i}:{right:r,left:i}})});function Ax(e){return Array.isArray(e)?e:[e]}function Tx(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class Mx{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=ym.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let t=new Dx(e,o,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,o,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];Tx(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let o=this.gutter;(0!=r.length||o.config.renderEmptyElements)&&this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(xx)){let i=n(e,t.widget,t);i&&(r||(r=[])).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Rx{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,r=>{let i,o=r.target;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let e=o.getBoundingClientRect();i=(e.top+e.bottom)/2}else i=r.clientY;let s=e.lineBlockAtHeight(i-e.documentTop);t.domEventHandlers[n](e,s,r)&&r.preventDefault()});this.markers=Ax(t.markers(e)),t.initialSpacer&&(this.spacer=new Dx(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=Ax(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!ym.eq(this.markers,t,n.from,n.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}destroy(){for(let e of this.elements)e.destroy()}}class Dx{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),function(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n="cm-gutterElement",r=this.dom.firstChild;for(let i=0,o=0;;){let s=o,a=i<t.length?t[i++]:null,l=!1;if(a){let e=a.elementClass;e&&(n+=" "+e);for(let e=o;e<this.markers.length;e++)if(this.markers[e].compare(a)){s=e,l=!0;break}}else s=this.markers.length;for(;o<s;){let e=this.markers[o++];if(e.toDOM){e.destroy(r);let t=r.nextSibling;r.remove(),r=t}}if(!a)break;a.toDOM&&(l?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),l&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}}const Px=Ep.define(),Lx=Ep.define(),Bx=Ep.define({combine:e=>fm(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let r=n[e],i=t[e];n[e]=r?(e,t,n)=>r(e,t,n)||i(e,t,n):i}return n}})});class Ix extends yx{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function jx(e,t){return e.state.facet(Bx).formatNumber(t,e.state)}const _x=Sx.compute([Bx],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(Px),lineMarker:(e,t,n)=>n.some(e=>e.toDOM)?null:new Ix(jx(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,n)=>{for(let r of e.state.facet(Lx)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(Bx)!=e.state.facet(Bx),initialSpacer:e=>new Ix(jx(e,Fx(e.state.doc.lines))),updateSpacer(e,t){let n=jx(t.view,Fx(t.view.state.doc.lines));return n==e.number?e:new Ix(n)},domEventHandlers:e.facet(Bx).domEventHandlers,side:"before"}));function Fx(e){let t=9;for(;t<e;)t=10*t+9;return t}const Wx=new class extends yx{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},zx=wx.compute(["selection"],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(Wx.range(i)))}return ym.of(t)});const Hx=1024;let Vx=0;class qx{constructor(e,t){this.from=e,this.to=t}}class Ux{constructor(e={}){this.id=Vx++,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"function"!=typeof e&&(e=Yx.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}Ux.closedBy=new Ux({deserialize:e=>e.split(" ")}),Ux.openedBy=new Ux({deserialize:e=>e.split(" ")}),Ux.group=new Ux({deserialize:e=>e.split(" ")}),Ux.isolate=new Ux({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}}),Ux.contextHash=new Ux({perNode:!0}),Ux.lookAhead=new Ux({perNode:!0}),Ux.mounted=new Ux({perNode:!0});class $x{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[Ux.mounted.id]}}const Kx=Object.create(null);class Yx{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):Kx,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),r=new Yx(e.name||"",t,e.id,n);if(e.props)for(let n of e.props)if(Array.isArray(n)||(n=n(r)),n){if(n[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}return r}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(Ux.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return e=>{for(let n=e.prop(Ux.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}}Yx.none=new Yx("",Object.create(null),0,8);class Gx{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 r=null;for(let t of e){let e=t(n);if(e){r||(r=Object.assign({},n.props));let t=e[1],i=e[0];i.combine&&i.id in r&&(t=i.combine(r[i.id],t)),r[i.id]=t}}t.push(r?new Yx(n.name,r,n.id,n.flags):n)}return new Gx(t)}}const Xx=new WeakMap,Jx=new WeakMap;var Qx;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"}(Qx||(Qx={}));class Zx{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=$x.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let n=e.toString();n&&(t&&(t+=","),t+=n)}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 dk(this.topNode,e)}cursorAt(e,t=0,n=0){let r=Xx.get(this)||this.topNode,i=new dk(r);return i.moveTo(e,t),Xx.set(this,i._tree),i}get topNode(){return new ok(this,0,0,null)}resolve(e,t=0){let n=rk(Xx.get(this)||this.topNode,e,t,!1);return Xx.set(this,n),n}resolveInner(e,t=0){let n=rk(Jx.get(this)||this.topNode,e,t,!0);return Jx.set(this,n),n}resolveStack(e,t=0){return function(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof ok?r:r.context.parent;e;e=e.parent)if(e.index<0){let o=e.parent;(i||(i=[r])).push(o.resolve(t,n)),e=o}else{let o=$x.get(e.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let s=new ok(o.tree,o.overlay[0].from+e.from,-1,e);(i||(i=[r])).push(rk(s,t,n,!1))}}return i?hk(i):r}(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,o=e.mode||0,s=(o&Qx.IncludeAnonymous)>0;for(let e=this.cursor(o|Qx.IncludeAnonymous);;){let o=!1;if(e.from<=i&&e.to>=r&&(!s&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;o=!0}for(;o&&n&&(s||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;o=!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:gk(Yx.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,n)=>new Zx(this.type,e,t,n,this.propValues),e.makeTree||((e,t,n)=>new Zx(Yx.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=Hx,reused:o=[],minRepeatType:s=r.types.length}=e,a=Array.isArray(n)?new ek(n,n.length):n,l=r.types,c=0,h=0;function u(e,t,n,b,y,w){let{id:x,start:k,end:S,size:E}=a,C=h,O=c;if(E<0){if(a.next(),-1==E){let t=o[x];return n.push(t),void b.push(k-e)}if(-3==E)return void(c=x);if(-4==E)return void(h=x);throw new RangeError(`Unrecognized record size: ${E}`)}let N,A,T=l[x],M=k-e;if(S-k<=i&&(A=g(a.pos-t,y))){let t=new Uint16Array(A.size-A.skip),n=a.pos-A.size,i=t.length;for(;a.pos>n;)i=v(A.start,t,i);N=new tk(t,S-A.start,r),M=A.start-e}else{let e=a.pos-E;a.next();let t=[],n=[],r=x>=s?x:-1,o=0,l=S;for(;a.pos>e;)r>=0&&a.id==r&&a.size>=0?(a.end<=l-i&&(p(t,n,k,o,a.end,l,r,C,O),o=t.length,l=a.end),a.next()):w>2500?d(k,e,t,n):u(k,e,t,n,r,w+1);if(r>=0&&o>0&&o<t.length&&p(t,n,k,o,k,l,r,C,O),t.reverse(),n.reverse(),r>-1&&o>0){let e=f(T,O);N=gk(T,t,n,0,t.length,0,S-k,e,e)}else N=m(T,t,n,S-k,C-S,O)}n.push(N),b.push(M)}function d(e,t,n,o){let s=[],l=0,c=-1;for(;a.pos>t;){let{id:e,start:t,end:n,size:r}=a;if(r>4)a.next();else{if(c>-1&&t<c)break;c<0&&(c=n-i),s.push(e,t,n),l++,a.next()}}if(l){let t=new Uint16Array(4*l),i=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-i,t[n++]=s[e+2]-i,t[n++]=n;n.push(new tk(t,s[2]-i,r)),o.push(i-e)}}function f(e,t){return(n,r,i)=>{let o,s,a=0,l=n.length-1;if(l>=0&&(o=n[l])instanceof Zx){if(!l&&o.type==e&&o.length==i)return o;(s=o.prop(Ux.lookAhead))&&(a=r[l]+o.length+s)}return m(e,n,r,i,a,t)}}function p(e,t,n,i,o,s,a,l,c){let h=[],u=[];for(;e.length>i;)h.push(e.pop()),u.push(t.pop()+n-o);e.push(m(r.types[a],h,u,s-o,l-s,c)),t.push(o-n)}function m(e,t,n,r,i,o,s){if(o){let e=[Ux.contextHash,o];s=s?[e].concat(s):[e]}if(i>25){let e=[Ux.lookAhead,i];s=s?[e].concat(s):[e]}return new Zx(e,t,n,r,s)}function g(e,t){let n=a.fork(),r=0,o=0,l=0,c=n.end-i,h={size:0,start:0,skip:0};e:for(let i=n.pos-e;n.pos>i;){let e=n.size;if(n.id==t&&e>=0){h.size=r,h.start=o,h.skip=l,l+=4,r+=4,n.next();continue}let a=n.pos-e;if(e<0||a<i||n.start<c)break;let u=n.id>=s?4:0,d=n.start;for(n.next();n.pos>a;){if(n.size<0){if(-3!=n.size&&-4!=n.size)break e;u+=4}else n.id>=s&&(u+=4);n.next()}o=d,r+=e,l+=u}return(t<0||r==e)&&(h.size=r,h.start=o,h.skip=l),h.size>4?h:void 0}function v(e,t,n){let{id:r,start:i,end:o,size:l}=a;if(a.next(),l>=0&&r<s){let s=n;if(l>4){let r=a.pos-(l-4);for(;a.pos>r;)n=v(e,t,n)}t[--n]=s,t[--n]=o-e,t[--n]=i-e,t[--n]=r}else-3==l?c=r:-4==l&&(h=r);return n}let b=[],y=[];for(;a.pos>0;)u(e.start||0,e.bufferStart||0,b,y,-1,0);let w=null!==(t=e.length)&&void 0!==t?t:b.length?y[0]+b[0].length:0;return new Zx(l[e.topID],b.reverse(),y.reverse(),w)}(e)}}Zx.empty=new Zx(Yx.none,[],[],0);class ek{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 ek(this.buffer,this.index)}}class tk{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Yx.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],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),n==(e+=4))return i;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return i+"("+o.join(",")+")"}findChild(e,t,n,r,i){let{buffer:o}=this,s=-1;for(let a=e;a!=t&&!(nk(i,r,o[a+1],o[a+2])&&(s=a,n>0));a=o[a+3]);return s}slice(e,t,n){let r=this.buffer,i=new Uint16Array(t-e),o=0;for(let s=e,a=0;s<t;){i[a++]=r[s++],i[a++]=r[s++]-n;let t=i[a++]=r[s++]-n;i[a++]=r[s++]-e,o=Math.max(o,t)}return new tk(i,o,this.set)}}function nk(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function rk(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof ok&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=r?0:Qx.IgnoreOverlays;if(r)for(let r=e,s=r.parent;s;r=s,s=r.parent)r instanceof ok&&r.index<0&&(null===(i=s.enter(t,n,o))||void 0===i?void 0:i.from)!=r.from&&(e=s);for(;;){let r=e.enter(t,n,o);if(!r)return e;e=r}}class ik{cursor(e=0){return new dk(this,e)}getChild(e,t=null,n=null){let r=sk(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return sk(this,e,t,n)}resolve(e,t=0){return rk(this,e,t,!1)}resolveInner(e,t=0){return rk(this,e,t,!0)}matchContext(e){return ak(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class ok extends ik{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}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,r,i=0){var o;for(let s=this;;){for(let{children:a,positions:l}=s._tree,c=t>0?a.length:-1;e!=c;e+=t){let c=a[e],h=l[e]+s.from;if(i&Qx.EnterBracketed&&c instanceof Zx&&null===(null===(o=$x.get(c))||void 0===o?void 0:o.overlay)&&(h>=n||h+c.length<=n)||nk(r,n,h,h+c.length))if(c instanceof tk){if(i&Qx.ExcludeBuffers)continue;let o=c.findChild(0,c.buffer.length,t,n-h,r);if(o>-1)return new ck(new lk(s,c,e,h),null,o)}else if(i&Qx.IncludeAnonymous||!c.type.isAnonymous||fk(c)){let o;if(!(i&Qx.IgnoreMounts)&&(o=$x.get(c))&&!o.overlay)return new ok(o.tree,h,e,s);let a=new ok(c,h,e,s);return i&Qx.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?c.children.length-1:0,t,n,r,i)}}if(i&Qx.IncludeAnonymous||!s.type.isAnonymous)return null;if(e=s.index>=0?s.index+t:t<0?-1:s._parent._tree.children.length,s=s._parent,!s)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)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let r;if(!(n&Qx.IgnoreOverlays)&&(r=$x.get(this._tree))&&r.overlay){let i=e-this.from,o=n&Qx.EnterBracketed&&r.bracketed;for(let{from:e,to:n}of r.overlay)if((t>0||o?e<=i:e<i)&&(t<0||o?n>=i:n>i))return new ok(r.tree,r.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 sk(e,t,n,r){let i=e.cursor(),o=[];if(!i.firstChild())return o;if(null!=n)for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return o;for(;;){if(null!=r&&i.type.is(r))return o;if(i.type.is(t)&&o.push(i.node),!i.nextSibling())return null==r?o:[]}}function ak(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}class lk{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class ck extends ik{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:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return i<0?null:new ck(this.context,this,i)}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)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&Qx.ExcludeBuffers)return null;let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new ck(this.context,this,i)}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 ck(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 ck(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let o=n.buffer[this.index+1];e.push(n.slice(r,i,o)),t.push(0)}return new Zx(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function hk(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof ok&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new uk(i,n)}class uk{constructor(e,t){this.heads=e,this.node=t}get next(){return hk(this.heads)}}class dk{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~Qx.EnterBracketed,e instanceof ok)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.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)}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return!!e&&(e instanceof ok?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}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:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}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&Qx.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Qx.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Qx.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));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;({index:t,_parent:n}=n))if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&Qx.IncludeAnonymous||e instanceof tk||!e.type.isAnonymous||fk(e))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 r=this.index,i=this.stack.length;i>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=i+1;break e}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new ck(this.buffer,t,this.stack[e]);return this.bufferNode=new ck(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return ak(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return ak(this._tree,e,r);let o=n[t.buffer[this.stack[i]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function fk(e){return e.children.some(e=>e instanceof tk||!e.type.isAnonymous||fk(e))}const pk=new WeakMap;function mk(e,t){if(!e.isAnonymous||t instanceof tk||t.type!=e)return 1;let n=pk.get(t);if(null==n){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof Zx)){n=1;break}n+=mk(e,r)}pk.set(t,n)}return n}function gk(e,t,n,r,i,o,s,a,l){let c=0;for(let n=r;n<i;n++)c+=mk(e,t[n]);let h=Math.ceil(1.5*c/8),u=[],d=[];return function t(n,r,i,s,a){for(let c=i;c<s;){let i=c,f=r[c],p=mk(e,n[c]);for(c++;c<s;c++){let t=mk(e,n[c]);if(p+t>=h)break;p+=t}if(c==i+1){if(p>h){let e=n[i];t(e.children,e.positions,0,e.children.length,r[i]+a);continue}u.push(n[i])}else{let t=r[c-1]+n[c-1].length-f;u.push(gk(e,n,r,i,c,f,t,null,l))}d.push(f+a-o)}}(t,n,r,i,0),(a||l)(u,d,s)}class vk{constructor(e,t,n,r,i=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(i?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let r=[new vk(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&r.push(n);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],i=1,o=e.length?e[0]:null;for(let s=0,a=0,l=0;;s++){let c=s<t.length?t[s]:null,h=c?c.fromA:1e9;if(h-a>=n)for(;o&&o.from<h;){let t=o;if(a>=t.from||h<=t.to||l){let e=Math.max(t.from,a)-l,n=Math.min(t.to,h)-l;t=e>=n?null:new vk(e,n,t.tree,t.offset+l,s>0,!!c)}if(t&&r.push(t),o.to>h)break;o=i<e.length?e[i++]:null}if(!c)break;a=c.toA,l=c.toA-c.toB}return r}}class bk{startParse(e,t,n){return"string"==typeof e&&(e=new yk(e)),n=n?n.length?n.map(e=>new qx(e.from,e.to)):[new qx(0,0)]:[new qx(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}}class yk{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 Ux({perNode:!0});let wk=0;class xk{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=wk++}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="string"==typeof e?e:"?";if(e instanceof xk&&(t=e),null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let r=new xk(n,[],null,[]);if(r.set.push(r),t)for(let e of t.set)r.set.push(e);return r}static defineModifier(e){let t=new Sk(e);return e=>e.modified.indexOf(t)>-1?e:Sk.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}}let kk=0;class Sk{constructor(e){this.name=e,this.instances=[],this.id=kk++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(n=>{return n.base==e&&(r=t,i=n.modified,r.length==i.length&&r.every((e,t)=>e==i[t]));var r,i});if(n)return n;let r=[],i=new xk(e.name,r,e,t);for(let e of t)e.instances.push(i);let o=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}(t);for(let t of e.set)if(!t.modified.length)for(let e of o)r.push(Sk.get(t,e));return i}}function Ek(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(" "))if(e){let n=[],i=2,o=e;for(let t=0;;){if("..."==o&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!r)throw new RangeError("Invalid path: "+e);if(n.push("*"==r[0]?"":'"'==r[0][0]?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){i=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);o=e.slice(t)}let s=n.length-1,a=n[s];if(!a)throw new RangeError("Invalid path: "+e);let l=new Ok(r,i,s>0?n.slice(0,s):null);t[a]=l.sort(t[a])}}return Ck.add(t)}const Ck=new Ux({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let o=new Ok(i.tags,i.mode,i.context);n?n.next=o:r=o,n=o}return r}});class Ok{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}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}}function Nk(e,t){let n=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)n[e.id]=t.class;else n[t.tag.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+" "+r:r;break}}return t},scope:r}}function Ak(e,t,n,r=0,i=e.length){let o=new Tk(r,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),r,i,"",o.highlighters),o.flush(i)}Ok.empty=new Ok([],2,null);class Tk{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,r,i){let{type:o,from:s,to:a}=e;if(s>=n||a<=t)return;o.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(o)));let l=r,c=function(e){let t=e.type.prop(Ck);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||Ok.empty,h=function(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+" "+e:e)}return n}(i,c.tags);if(h&&(l&&(l+=" "),l+=h,1==c.mode&&(r+=(r?" ":"")+h)),this.startSpan(Math.max(t,s),l),c.opaque)return;let u=e.tree&&e.tree.prop(Ux.mounted);if(u&&u.overlay){let o=e.node.enter(u.overlay[0].from+s,1),c=this.highlighters.filter(e=>!e.scope||e.scope(u.tree.type)),h=e.firstChild();for(let d=0,f=s;;d++){let p=d<u.overlay.length?u.overlay[d]:null,m=p?p.from+s:a,g=Math.max(t,f),v=Math.min(n,m);if(g<v&&h)for(;e.from<v&&(this.highlightRange(e,g,v,r,i),this.startSpan(Math.min(v,e.to),l),!(e.to>=m)&&e.nextSibling()););if(!p||m>n)break;f=p.to+s,f>t&&(this.highlightRange(o.cursor(),Math.max(t,p.from+s),Math.min(n,f),"",c),this.startSpan(Math.min(n,f),l))}h&&e.parent()}else if(e.firstChild()){u&&(r="");do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),l)}}while(e.nextSibling());e.parent()}}}const Mk=xk.define,Rk=Mk(),Dk=Mk(),Pk=Mk(Dk),Lk=Mk(Dk),Bk=Mk(),Ik=Mk(Bk),jk=Mk(Bk),_k=Mk(),Fk=Mk(_k),Wk=Mk(),zk=Mk(),Hk=Mk(),Vk=Mk(Hk),qk=Mk(),Uk={comment:Rk,lineComment:Mk(Rk),blockComment:Mk(Rk),docComment:Mk(Rk),name:Dk,variableName:Mk(Dk),typeName:Pk,tagName:Mk(Pk),propertyName:Lk,attributeName:Mk(Lk),className:Mk(Dk),labelName:Mk(Dk),namespace:Mk(Dk),macroName:Mk(Dk),literal:Bk,string:Ik,docString:Mk(Ik),character:Mk(Ik),attributeValue:Mk(Ik),number:jk,integer:Mk(jk),float:Mk(jk),bool:Mk(Bk),regexp:Mk(Bk),escape:Mk(Bk),color:Mk(Bk),url:Mk(Bk),keyword:Wk,self:Mk(Wk),null:Mk(Wk),atom:Mk(Wk),unit:Mk(Wk),modifier:Mk(Wk),operatorKeyword:Mk(Wk),controlKeyword:Mk(Wk),definitionKeyword:Mk(Wk),moduleKeyword:Mk(Wk),operator:zk,derefOperator:Mk(zk),arithmeticOperator:Mk(zk),logicOperator:Mk(zk),bitwiseOperator:Mk(zk),compareOperator:Mk(zk),updateOperator:Mk(zk),definitionOperator:Mk(zk),typeOperator:Mk(zk),controlOperator:Mk(zk),punctuation:Hk,separator:Mk(Hk),bracket:Vk,angleBracket:Mk(Vk),squareBracket:Mk(Vk),paren:Mk(Vk),brace:Mk(Vk),content:_k,heading:Fk,heading1:Mk(Fk),heading2:Mk(Fk),heading3:Mk(Fk),heading4:Mk(Fk),heading5:Mk(Fk),heading6:Mk(Fk),contentSeparator:Mk(_k),list:Mk(_k),quote:Mk(_k),emphasis:Mk(_k),strong:Mk(_k),link:Mk(_k),monospace:Mk(_k),strikethrough:Mk(_k),inserted:Mk(),deleted:Mk(),changed:Mk(),invalid:Mk(),meta:qk,documentMeta:Mk(qk),annotation:Mk(qk),processingInstruction:Mk(qk),definition:xk.defineModifier("definition"),constant:xk.defineModifier("constant"),function:xk.defineModifier("function"),standard:xk.defineModifier("standard"),local:xk.defineModifier("local"),special:xk.defineModifier("special")};for(let e in Uk){let t=Uk[e];t instanceof xk&&(t.name=e)}var $k;Nk([{tag:Uk.link,class:"tok-link"},{tag:Uk.heading,class:"tok-heading"},{tag:Uk.emphasis,class:"tok-emphasis"},{tag:Uk.strong,class:"tok-strong"},{tag:Uk.keyword,class:"tok-keyword"},{tag:Uk.atom,class:"tok-atom"},{tag:Uk.bool,class:"tok-bool"},{tag:Uk.url,class:"tok-url"},{tag:Uk.labelName,class:"tok-labelName"},{tag:Uk.inserted,class:"tok-inserted"},{tag:Uk.deleted,class:"tok-deleted"},{tag:Uk.literal,class:"tok-literal"},{tag:Uk.string,class:"tok-string"},{tag:Uk.number,class:"tok-number"},{tag:[Uk.regexp,Uk.escape,Uk.special(Uk.string)],class:"tok-string2"},{tag:Uk.variableName,class:"tok-variableName"},{tag:Uk.local(Uk.variableName),class:"tok-variableName tok-local"},{tag:Uk.definition(Uk.variableName),class:"tok-variableName tok-definition"},{tag:Uk.special(Uk.variableName),class:"tok-variableName2"},{tag:Uk.definition(Uk.propertyName),class:"tok-propertyName tok-definition"},{tag:Uk.typeName,class:"tok-typeName"},{tag:Uk.namespace,class:"tok-namespace"},{tag:Uk.className,class:"tok-className"},{tag:Uk.macroName,class:"tok-macroName"},{tag:Uk.propertyName,class:"tok-propertyName"},{tag:Uk.operator,class:"tok-operator"},{tag:Uk.comment,class:"tok-comment"},{tag:Uk.meta,class:"tok-meta"},{tag:Uk.invalid,class:"tok-invalid"},{tag:Uk.punctuation,class:"tok-punctuation"}]);const Kk=new Ux;const Yk=new Ux;class Gk{constructor(e,t,n=[],r=""){this.data=e,this.name=r,dm.prototype.hasOwnProperty("tree")||Object.defineProperty(dm.prototype,"tree",{get(){return Qk(this)}}),this.parser=t,this.extension=[aS.of(this),dm.languageData.of((e,t,n)=>{let r=Xk(e,t,n),i=r.type.prop(Kk);if(!i)return[];let o=e.facet(i),s=r.type.prop(Yk);if(s){let i=r.resolve(t-r.from,n);for(let t of s)if(t.test(i,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(o)}}return o})].concat(n)}isActiveAt(e,t,n=-1){return Xk(e,t,n).type.prop(Kk)==this.data}findRegions(e){let t=e.facet(aS);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(Kk)==this.data)return void n.push({from:t,to:t+e.length});let i=e.prop(Ux.mounted);if(i){if(i.tree.prop(Kk)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof Zx&&r(i,e.positions[n]+t)}};return r(Qk(e),0),n}get allowsNesting(){return!0}}function Xk(e,t,n){let r=e.facet(aS),i=Qk(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,Qx.ExcludeBuffers|Qx.EnterBracketed))e.type.isTop&&(i=e);return i}Gk.setState=em.define();class Jk extends Gk{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=(n=e.languageData,Ep.define({combine:n?e=>e.concat(n):void 0}));var n;return new Jk(t,e.parser.configure({props:[Kk.add(e=>e.isTop?t:void 0)]}),e.name)}configure(e,t){return new Jk(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Qk(e){let t=e.field(Gk.state,!1);return t?t.tree:Zx.empty}class Zk{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 eS=null;class tS{constructor(e,t,n=[],r,i,o,s,a){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=o,this.skipped=s,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new tS(e,t,[],Zx.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Zk(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=Zx.empty&&this.isDone(null!=t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r){if(this.fragments=this.withoutTempSkipped(vk.addTree(r,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=r,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||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(vk.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=eS;eS=this;try{return e()}finally{eS=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=nS(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:i,viewport:o,skipped:s}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,n,r,i)=>t.push({fromA:e,toA:n,fromB:r,toB:i})),n=vk.applyChanges(n,t),r=Zx.empty,i=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){s=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);n<r&&s.push({from:n,to:r})}}}return new tS(this.parser,t,n,r,i,o,s,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 t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=nS(this.fragments,n,r),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(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 bk{createParse(t,n,r){let i=r[0].from,o=r[r.length-1].to,s={parsedPos:i,advance(){let t=eS;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=o,new Zx(Yx.none,[],[],o-i)},stoppedAt:null,stopAt(){}};return s}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return eS}}function nS(e,t,n){return vk.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class rS{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 rS(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=tS.create(e.facet(aS).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new rS(n)}}Gk.state=Rp.define({create:rS.init,update(e,t){for(let e of t.effects)if(e.is(Gk.setState))return e.value;return t.startState.facet(aS)!=t.state.facet(aS)?rS.init(t.state):e.apply(t)}});let iS=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(iS=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const oS="undefined"!=typeof navigator&&(null===($k=navigator.scheduling)||void 0===$k?void 0:$k.isInputPending)?()=>navigator.scheduling.isInputPending():null,sS=Cv.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(Gk.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(Gk.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=iS(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:r}}=this.view,i=n.field(Gk.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!oS?Math.max(25,e.timeRemaining()-5):1e9),s=i.context.treeLen<r&&n.doc.length>r+1e3,a=i.context.work(()=>oS&&oS()||Date.now()>o,r+(s?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Gk.setState.of(new rS(i.context))})),this.chunkBudget>0&&(!a||s)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>xv(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),aS=Ep.define({combine:e=>e.length?e[0]:null,enables:e=>[Gk.state,sS,Jy.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class lS{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const cS=Ep.define(),hS=Ep.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function uS(e){let t=e.facet(hS);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function dS(e,t){let n="",r=e.tabSize,i=e.facet(hS)[0];if("\t"==i){for(;t>=r;)n+="\t",t-=r;i=" "}for(let e=0;e<t;e++)n+=i;return n}function fS(e,t){e instanceof dm&&(e=new pS(e));for(let n of e.state.facet(cS)){let r=n(e,t);if(void 0!==r)return r}let n=Qk(e.state);return n.length>=t?function(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return gS(r,e,n)}(e,n,t):null}class pS{constructor(e,t={}){this.state=e,this.options=t,this.unit=uS(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return null!=r&&r>=n.from&&r<=n.to?i&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(i+=o-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return Rm(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const mS=new Ux;function gS(e,t,n){for(let r=e;r;r=r.next){let e=vS(r.node);if(e)return e(yS.create(t,n,r))}return 0}function vS(e){let t=e.type.prop(mS);if(t)return t;let n,r=e.firstChild;if(r&&(n=r.type.prop(Ux.closedBy))){let t=e.lastChild,r=t&&n.indexOf(t.name)>-1;return e=>function(e,t,n,r,i){let o=e.textAfter,s=o.match(/^\s*/)[0].length,a=r&&o.slice(s,s+r.length)==r||i==e.pos+s,l=t?function(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,o=e.state.doc.lineAt(n.from),s=null==i||i<=o.from?o.to:Math.min(o.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=s)return null;let e=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}(e):null;return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}(e,!0,1,void 0,r&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?bS:null}function bS(){return 0}class yS extends pS{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 yS(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(wS(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return gS(this.context.next,this.base,this.pos)}}function wS(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function xS({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const kS=Ep.define(),SS=new Ux;function ES(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function CS(e,t,n){for(let r of e.facet(kS)){let i=r(e,t,n);if(i)return i}return function(e,t,n){let r=Qk(e);if(r.length<n)return null;let i=null;for(let o=r.resolveStack(n,1);o;o=o.next){let s=o.node;if(s.to<=n||s.from>n)continue;if(i&&s.from<t)break;let a=s.type.prop(SS);if(a&&(s.to<r.length-50||r.length==e.doc.length||!ES(s))){let r=a(s,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(i=r)}}return i}(e,t,n)}function OS(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}const NS=em.define({map:OS}),AS=em.define({map:OS});function TS(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}const MS=Rp.define({create:()=>dg.none,update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((t,n)=>e=RS(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(NS)&&!PS(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(_S),i=r?dg.replace({widget:new HS(r(t.state,n.value))}):zS;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(AS)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=RS(e,t.selection.main.head)),e},provide:e=>Jy.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if("number"!=typeof r||"number"!=typeof i)throw new RangeError("Invalid JSON for fold state");t.push(zS.range(r,i))}return dg.set(t,!0)}});function RS(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function DS(e,t,n){var r;let i=null;return null===(r=e.field(MS,!1))||void 0===r||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function PS(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function LS(e,t){return e.field(MS,!1)?t:t.concat(em.appendConfig.of(FS()))}function BS(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return Jy.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const IS=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of TS(e)){let n=CS(e.state,t.from,t.to);if(n)return e.dispatch({effects:LS(e.state,[NS.of(n),BS(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(MS,!1))return!1;let t=[];for(let n of TS(e)){let r=DS(e.state,n.from,n.to);r&&t.push(AS.of(r),BS(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),o=CS(t,i.from,i.to);o&&n.push(NS.of(o)),r=(o?e.lineBlockAt(o.to):i).to+1}return n.length&&e.dispatch({effects:LS(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(MS,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(AS.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],jS={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},_S=Ep.define({combine:e=>fm(e,jS)});function FS(e){let t=[MS,US];return e&&t.push(_S.of(e)),t}function WS(e,t){let{state:n}=e,r=n.facet(_S),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=DS(e.state,n.from,n.to);r&&e.dispatch({effects:AS.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let o=document.createElement("span");return o.textContent=r.placeholderText,o.setAttribute("aria-label",n.phrase("folded code")),o.title=n.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=i,o}const zS=dg.replace({widget:new class extends hg{toDOM(e){return WS(e,null)}}});class HS extends hg{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return WS(e,this.value)}}const VS={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class qS extends yx{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}}const US=Jy.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 $S{constructor(e,t){let n;function r(e){let t=Im.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;const i="string"==typeof t.all?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof Gk?e=>e.prop(Kk)==o.data:o?e=>e==o:void 0,this.style=Nk(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new Im(n):null,this.themeType=t.themeType}static define(e,t){return new $S(e,t||{})}}const KS=Ep.define(),YS=Ep.define({combine:e=>e.length?[e[0]]:null});function GS(e){let t=e.facet(KS);return t.length?t:e.facet(YS)}function XS(e,t){let n,r=[QS];return e instanceof $S&&(e.module&&r.push(Jy.styleModule.of(e.module)),n=e.themeType),(null==t?void 0:t.fallback)?r.push(YS.of(e)):n?r.push(KS.computeN([Jy.darkTheme],t=>t.facet(Jy.darkTheme)==("dark"==n)?[e]:[])):r.push(KS.of(e)),r}class JS{constructor(e){this.markCache=Object.create(null),this.tree=Qk(e.state),this.decorations=this.buildDeco(e,GS(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Qk(e.state),n=GS(e.state),r=n!=GS(e.startState),{viewport:i}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&o>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return dg.none;let n=new wm;for(let{from:r,to:i}of e.visibleRanges)Ak(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=dg.mark({class:r})))},r,i);return n.finish()}}const QS=jp.high(Cv.fromClass(JS,{decorations:e=>e.decorations})),ZS=$S.define([{tag:Uk.meta,color:"#404740"},{tag:Uk.link,textDecoration:"underline"},{tag:Uk.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Uk.emphasis,fontStyle:"italic"},{tag:Uk.strong,fontWeight:"bold"},{tag:Uk.strikethrough,textDecoration:"line-through"},{tag:Uk.keyword,color:"#708"},{tag:[Uk.atom,Uk.bool,Uk.url,Uk.contentSeparator,Uk.labelName],color:"#219"},{tag:[Uk.literal,Uk.inserted],color:"#164"},{tag:[Uk.string,Uk.deleted],color:"#a11"},{tag:[Uk.regexp,Uk.escape,Uk.special(Uk.string)],color:"#e40"},{tag:Uk.definition(Uk.variableName),color:"#00f"},{tag:Uk.local(Uk.variableName),color:"#30a"},{tag:[Uk.typeName,Uk.namespace],color:"#085"},{tag:Uk.className,color:"#167"},{tag:[Uk.special(Uk.variableName),Uk.macroName],color:"#256"},{tag:Uk.definition(Uk.propertyName),color:"#00c"},{tag:Uk.comment,color:"#940"},{tag:Uk.invalid,color:"#f00"}]),eE=Jy.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),tE="()[]{}",nE=Ep.define({combine:e=>fm(e,{afterCursor:!0,brackets:tE,maxScanDistance:1e4,renderMatch:oE})}),rE=dg.mark({class:"cm-matchingBracket"}),iE=dg.mark({class:"cm-nonmatchingBracket"});function oE(e){let t=[],n=e.matched?rE:iE;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const sE=Rp.define({create:()=>dg.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(nE);for(let e of t.state.selection.ranges){if(!e.empty)continue;let i=uE(t.state,e.head,-1,r)||e.head>0&&uE(t.state,e.head-1,1,r)||r.afterCursor&&(uE(t.state,e.head,1,r)||e.head<t.state.doc.length&&uE(t.state,e.head+1,-1,r));i&&(n=n.concat(r.renderMatch(i,t.state)))}return dg.set(n,!0)},provide:e=>Jy.decorations.from(e)}),aE=[sE,eE];const lE=new Ux;function cE(e,t,n){let r=e.prop(t<0?Ux.openedBy:Ux.closedBy);if(r)return r;if(1==e.name.length){let r=n.indexOf(e.name);if(r>-1&&r%2==(t<0?1:0))return[n[r+t]]}return null}function hE(e){let t=e.type.prop(lE);return t?t(e.node):e}function uE(e,t,n,r={}){let i=r.maxScanDistance||1e4,o=r.brackets||tE,s=Qk(e),a=s.resolveInner(t,n);for(let r=a;r;r=r.parent){let i=cE(r.type,n,o);if(i&&r.from<r.to){let s=hE(r);if(s&&(n>0?t>=s.from&&t<s.to:t>s.from&&t<=s.to))return dE(e,t,n,r,s,i,o)}}return function(e,t,n,r,i,o,s){let a=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=s.indexOf(a);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},h=e.doc.iterRange(t,n>0?e.doc.length:0),u=0;for(let e=0;!h.next().done&&e<=o;){let o=h.value;n<0&&(e+=o.length);let a=t+e*n;for(let e=n>0?0:o.length-1,t=n>0?o.length:-1;e!=t;e+=n){let t=s.indexOf(o[e]);if(!(t<0||r.resolveInner(a+e,1).type!=i))if(t%2==0==n>0)u++;else{if(1==u)return{start:c,end:{from:a+e,to:a+e+1},matched:t>>1==l>>1};u--}}n>0&&(e+=o.length)}return h.done?{start:c,matched:!1}:null}(e,t,n,s,a.type,i,o)}function dE(e,t,n,r,i,o,s){let a=r.parent,l={from:i.from,to:i.to},c=0,h=null==a?void 0:a.cursor();if(h&&(n<0?h.childBefore(r.from):h.childAfter(r.to)))do{if(n<0?h.to<=r.from:h.from>=r.to){if(0==c&&o.indexOf(h.type.name)>-1&&h.from<h.to){let e=hE(h);return{start:l,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(cE(h.type,n,s))c++;else if(cE(h.type,-n,s)){if(0==c){let e=hE(h);return{start:l,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}c--}}}while(n<0?h.prevSibling():h.nextSibling());return{start:l,matched:!1}}const fE=Object.create(null),pE=[Yx.none],mE=[],gE=Object.create(null),vE=Object.create(null);for(let[e,t]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"]])vE[e]=yE(fE,t);function bE(e,t){mE.indexOf(e)>-1||mE.push(e)}function yE(e,t){let n=[];for(let r of t.split(" ")){let t=[];for(let n of r.split(".")){let r=e[n]||Uk[n];r?"function"==typeof r?t.length?t=t.map(r):bE(n):t.length?bE(n):t=Array.isArray(r)?r:[r]:bE(n)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(e=>e.id),o=gE[i];if(o)return o.id;let s=gE[i]=Yx.define({id:pE.length,name:r,props:[Ek({[r]:n})]});return pE.push(s),s.id}zg.RTL,zg.LTR;function wE(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return!!i&&(r(n.update(i)),!0)}}const xE=wE(NE,0),kE=wE(OE,0),SE=wE((e,t)=>OE(e,t,function(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}(t)),0);function EE(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const CE=50;function OE(e,t,n=t.selection.ranges){let r=n.map(e=>EE(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>function(e,{open:t,close:n},r,i){let o,s,a=e.sliceDoc(r-CE,r),l=e.sliceDoc(i,i+CE),c=/\s*$/.exec(a)[0].length,h=/^\s*/.exec(l)[0].length,u=a.length-c;if(a.slice(u-t.length,u)==t&&l.slice(h,h+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:i+h,margin:h&&1}};i-r<=2*CE?o=s=e.sliceDoc(r,i):(o=e.sliceDoc(r,r+CE),s=e.sliceDoc(i-CE,i));let d=/^\s*/.exec(o)[0].length,f=/\s*$/.exec(s)[0].length,p=s.length-f-n.length;return o.slice(d,d+t.length)==t&&s.slice(p,p+n.length)==n?{open:{pos:r+d+t.length,margin:/\s/.test(o.charAt(d+t.length))?1:0},close:{pos:i-f-n.length,margin:/\s/.test(s.charAt(p-1))?1:0}}:null}(t,r[n],e.from,e.to));if(2!=e&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+" "},{from:e.to,insert:" "+r[t].close}]))};if(1!=e&&i.some(e=>e)){let e=[];for(let t,n=0;n<i.length;n++)if(t=i[n]){let i=r[n],{open:o,close:s}=t;e.push({from:o.pos-i.open.length,to:o.pos+o.margin},{from:s.pos-s.margin,to:s.pos+i.close.length})}return{changes:e}}return null}function NE(e,t,n=t.selection.ranges){let r=[],i=-1;for(let{from:e,to:o}of n){let n=r.length,s=1e9,a=EE(t,e).line;if(a){for(let n=e;n<=o;){let l=t.doc.lineAt(n);if(l.from>i&&(e==o||o>l.from)){i=l.from;let e=/^\s*/.exec(l.text)[0].length,t=e==l.length,n=l.text.slice(e,e+a.length)==a?e:-1;e<l.text.length&&e<s&&(s=e),r.push({line:l,comment:n,token:a,indent:e,empty:t,single:!1})}n=l.to+1}if(s<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=s);r.length==n+1&&(r[n].single=!0)}}if(2!=e&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:o,single:s}of r)!s&&o||e.push({from:t.from+i,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,o=r+i.length;" "==t.text[o-t.from]&&o++,e.push({from:r,to:o})}return{changes:e}}return null}const AE=Jp.define(),TE=Jp.define(),ME=Ep.define(),RE=Ep.define({combine:e=>fm(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}),DE=Rp.define({create:()=>YE.empty,update(e,t){let n=t.state.facet(RE),r=t.annotation(AE);if(r){let i=_E.fromTransaction(t,r.selection),o=r.side,s=0==o?e.undone:e.done;return s=i?FE(s,s.length,n.minDepth,i):VE(s,t.startState.selection),new YE(0==o?r.rest:s,0==o?s:r.rest)}let i=t.annotation(TE);if("full"!=i&&"before"!=i||(e=e.isolate()),!1===t.annotation(tm.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let o=_E.fromTransaction(t),s=t.annotation(tm.time),a=t.annotation(tm.userEvent);return o?e=e.addChanges(o,s,a,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,a,n.newGroupDelay)),"full"!=i&&"after"!=i||(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new YE(e.done.map(_E.fromJSON),e.undone.map(_E.fromJSON))});function PE(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(DE,!1);if(!i)return!1;let o=i.pop(e,n,t);return!!o&&(r(o),!0)}}const LE=PE(0,!1),BE=PE(1,!1),IE=PE(0,!0),jE=PE(1,!0);class _E{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(e){return new _E(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new _E(e.changes&&fp.fromJSON(e.changes),[],e.mapped&&dp.fromJSON(e.mapped),e.startSelection&&xp.fromJSON(e.startSelection),e.selectionsAfter.map(xp.fromJSON))}static fromTransaction(e,t){let n=zE;for(let t of e.startState.facet(ME)){let r=t(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new _E(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,zE)}static selection(e){return new _E(void 0,zE,void 0,void 0,e)}}function FE(e,t,n,r){let i=t+1>n+20?t-n-1:0,o=e.slice(i,t);return o.push(r),o}function WE(e,t){return e.length?t.length?e.concat(t):e:t}const zE=[],HE=200;function VE(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-HE));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),FE(e,e.length-1,1e9,n.setSelAfter(r)))}return[_E.selection([t])]}function qE(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function UE(e,t){if(!e.length)return e;let n=e.length,r=zE;for(;n;){let i=$E(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[_E.selection(r)]:zE}function $E(e,t,n){let r=WE(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):zE,n);if(!e.changes)return _E.selection(r);let i=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new _E(i,em.mapEffects(e.effects,t),s,e.startSelection.map(o),r)}const KE=/^(input\.type|delete)($|\.)/;class YE{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new YE(this.done,this.undone):this}addChanges(e,t,n,r,i){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&e.changes&&(!n||KE.test(n))&&(!s.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(i,function(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,o)=>{for(let e=0;e<n.length;){let t=n[e++],s=n[e++];o>=t&&i<=s&&(r=!0)}}),r}(s.changes,e.changes))||"input.type.compose"==n)?FE(o,o.length-1,r.minDepth,new _E(e.changes.compose(s.changes),WE(em.mapEffects(e.effects,s.changes),s.effects),s.mapped,s.startSelection,zE)):FE(o,o.length,r.minDepth,e),new YE(o,zE,t,n)}addSelection(e,t,n,r){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:zE;return i.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(o=i[i.length-1],s=e,o.ranges.length==s.ranges.length&&0===o.ranges.filter((e,t)=>e.empty!=s.ranges[t].empty).length)?this:new YE(VE(this.done,e),this.undone,t,n);var o,s}addMapping(e){return new YE(UE(this.done,e),UE(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=0==e?this.done:this.undone;if(0==r.length)return null;let i=r[r.length-1],o=i.selectionsAfter[0]||t.selection;if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:AE.of({side:e,rest:qE(r),selection:o}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let n=1==r.length?zE:r.slice(0,r.length-1);return i.mapped&&(n=UE(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:AE.of({side:e,rest:n,selection:o}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}YE.empty=new YE(zE,zE);const GE=[{key:"Mod-z",run:LE,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:BE,preventDefault:!0},{linux:"Ctrl-Shift-z",run:BE,preventDefault:!0},{key:"Mod-u",run:IE,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:jE,preventDefault:!0}];function XE(e,t){return xp.create(e.ranges.map(t),e.mainIndex)}function JE(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function QE({state:e,dispatch:t},n){let r=XE(e.selection,n);return!r.eq(e.selection,!0)&&(t(JE(e,r)),!0)}function ZE(e,t){return xp.cursor(t?e.to:e.from)}function eC(e,t){return QE(e,n=>n.empty?e.moveByChar(n,t):ZE(n,t))}function tC(e){return e.textDirectionAt(e.state.selection.main.head)==zg.LTR}const nC=e=>eC(e,!tC(e)),rC=e=>eC(e,tC(e));function iC(e,t){return QE(e,n=>n.empty?e.moveByGroup(n,t):ZE(n,t))}function oC(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function sC(e,t,n){let r,i,o=Qk(e).resolveInner(t.head),s=n?Ux.closedBy:Ux.openedBy;for(let r=t.head;;){let t=n?o.childAfter(r):o.childBefore(r);if(!t)break;oC(e,t,s)?o=t:r=n?t.to:t.from}return i=o.type.prop(s)&&(r=n?uE(e,o.from,1):uE(e,o.to,-1))&&r.matched?n?r.end.to:r.end.from:n?o.to:o.from,xp.cursor(i,n?-1:1)}function aC(e,t){return QE(e,n=>{if(!n.empty)return ZE(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const lC=e=>aC(e,!1),cC=e=>aC(e,!0);function hC(e){let t,n=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,i=0;if(n){for(let t of e.state.facet(Jy.scrollMargins)){let n=t(e);(null==n?void 0:n.top)&&(r=Math.max(null==n?void 0:n.top,r)),(null==n?void 0:n.bottom)&&(i=Math.max(null==n?void 0:n.bottom,i))}t=e.scrollDOM.clientHeight-r-i}else t=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:i,selfScroll:n,height:Math.max(e.defaultLineHeight,t-5)}}function uC(e,t){let n,r=hC(e),{state:i}=e,o=XE(i.selection,n=>n.empty?e.moveVertically(n,t,r.height):ZE(n,t));if(o.eq(i.selection))return!1;if(r.selfScroll){let t=e.coordsAtPos(i.selection.main.head),s=e.scrollDOM.getBoundingClientRect(),a=s.top+r.marginTop,l=s.bottom-r.marginBottom;t&&t.top>a&&t.bottom<l&&(n=Jy.scrollIntoView(o.main.head,{y:"start",yMargin:t.top-a}))}return e.dispatch(JE(i,o),{effects:n}),!0}const dC=e=>uC(e,!1),fC=e=>uC(e,!0);function pC(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=xp.cursor(r.from+n))}return i}function mC(e,t){let n=XE(e.state.selection,e=>{let n=t(e);return xp.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return!n.eq(e.state.selection)&&(e.dispatch(JE(e.state,n)),!0)}function gC(e,t){return mC(e,n=>e.moveByChar(n,t))}const vC=e=>gC(e,!tC(e)),bC=e=>gC(e,tC(e));function yC(e,t){return mC(e,n=>e.moveByGroup(n,t))}function wC(e,t){return mC(e,n=>e.moveVertically(n,t))}const xC=e=>wC(e,!1),kC=e=>wC(e,!0);function SC(e,t){return mC(e,n=>e.moveVertically(n,t,hC(e).height))}const EC=e=>SC(e,!1),CC=e=>SC(e,!0),OC=({state:e,dispatch:t})=>(t(JE(e,{anchor:0})),!0),NC=({state:e,dispatch:t})=>(t(JE(e,{anchor:e.doc.length})),!0),AC=({state:e,dispatch:t})=>(t(JE(e,{anchor:e.selection.main.anchor,head:0})),!0),TC=({state:e,dispatch:t})=>(t(JE(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function MC(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let o=n.doc.lineAt(r.head);if(t?o.to<e.state.doc.length:o.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<o.from||r.head>o.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(JE(n,xp.create(i,i.length-1))),!0)}function RC(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:o}=r;if(i==o){let s=t(r);s<i?(n="delete.backward",s=DC(e,s,!1)):s>i&&(n="delete.forward",s=DC(e,s,!0)),i=Math.min(i,s),o=Math.max(o,s)}else i=DC(e,i,!1),o=DC(e,o,!0);return i==o?{range:r}:{changes:{from:i,to:o},range:xp.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?Jy.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function DC(e,t,n){if(e instanceof Jy)for(let r of e.state.facet(Jy.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}const PC=(e,t,n)=>RC(e,r=>{let i,o,s=r.from,{state:a}=e,l=a.doc.lineAt(s);if(n&&!t&&s>l.from&&s<l.from+200&&!/[^ \t]/.test(i=l.text.slice(0,s-l.from))){if("\t"==i[i.length-1])return s-1;let e=Rm(i,a.tabSize)%uS(a)||uS(a);for(let t=0;t<e&&" "==i[i.length-1-t];t++)s--;o=s}else o=sp(l.text,s-l.from,t,t)+l.from,o==s&&l.number!=(t?a.doc.lines:1)?o+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(l.text.slice(o-l.from,s-l.from))&&(o=sp(l.text,o-l.from,!1,!1)+l.from);return o}),LC=e=>PC(e,!1,!0),BC=e=>PC(e,!0,!1),IC=(e,t)=>RC(e,n=>{let r=n.head,{state:i}=e,o=i.doc.lineAt(r),s=i.charCategorizer(r);for(let e=null;;){if(r==(t?o.to:o.from)){r==n.head&&o.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let a=sp(o.text,r-o.from,t)+o.from,l=o.text.slice(Math.min(r,a)-o.from,Math.max(r,a)-o.from),c=s(l);if(null!=e&&c!=e)break;" "==l&&r==n.head||(e=c),r=a}return r}),jC=e=>IC(e,!1);function _C(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(r.empty||r.to!=o.from||(o=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=o.to,e.ranges.push(r)}else t.push({from:i.from,to:o.to,ranges:[r]});n=o.number+1}return t}function FC(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of _C(e)){if(n?t.to==e.doc.length:0==t.from)continue;let o=e.doc.lineAt(n?t.to+1:t.from-1),s=o.length+1;if(n){r.push({from:t.to,to:o.to},{from:t.from,insert:o.text+e.lineBreak});for(let n of t.ranges)i.push(xp.range(Math.min(e.doc.length,n.anchor+s),Math.min(e.doc.length,n.head+s)))}else{r.push({from:o.from,to:t.from},{from:t.to,insert:e.lineBreak+o.text});for(let e of t.ranges)i.push(xp.range(e.anchor-s,e.head-s))}}return!!r.length&&(t(e.update({changes:r,scrollIntoView:!0,selection:xp.create(i,e.selection.mainIndex),userEvent:"move.line"})),!0)}function WC(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of _C(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const zC=VC(!1),HC=VC(!0);function VC(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,o=t.doc.lineAt(r),s=!e&&r==i&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,r=Qk(e).resolveInner(t),i=r.childBefore(t),o=r.childAfter(t);return i&&o&&i.to<=t&&o.from>=t&&(n=i.type.prop(Ux.closedBy))&&n.indexOf(o.name)>-1&&e.doc.lineAt(i.to).from==e.doc.lineAt(o.from).from&&!/\S/.test(e.sliceDoc(i.to,o.from))?{from:i.to,to:o.from}:null}(t,r);e&&(r=i=(i<=o.to?o:t.doc.lineAt(i)).to);let a=new pS(t,{simulateBreak:r,simulateDoubleBreak:!!s}),l=fS(a,r);for(null==l&&(l=Rm(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));i<o.to&&/\s/.test(o.text[i-o.from]);)i++;s?({from:r,to:i}=s):r>o.from&&r<o.from+100&&!/\S/.test(o.text.slice(0,r))&&(r=o.from);let c=["",dS(t,l)];return s&&c.push(dS(t,a.lineIndent(o.from,-1))),{changes:{from:r,to:i,insert:Xf.of(c)},range:xp.cursor(r+1+c[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function qC(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let o=r.from;o<=r.to;){let s=e.doc.lineAt(o);s.number>n&&(r.empty||r.to>s.from)&&(t(s,i,r),n=s.number),o=s.to+1}let o=e.changes(i);return{changes:i,range:xp.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const UC=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(qC(e,(t,n)=>{n.push({from:t.from,insert:e.facet(hS)})}),{userEvent:"input.indent"})),!0),$C=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(qC(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Rm(r,e.tabSize),o=0,s=dS(e,Math.max(0,i-uS(e)));for(;o<r.length&&o<s.length&&r.charCodeAt(o)==s.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+r.length,insert:s.slice(o)})}),{userEvent:"delete.dedent"})),!0),KC=[{key:"Ctrl-b",run:nC,shift:vC,preventDefault:!0},{key:"Ctrl-f",run:rC,shift:bC},{key:"Ctrl-p",run:lC,shift:xC},{key:"Ctrl-n",run:cC,shift:kC},{key:"Ctrl-a",run:e=>QE(e,t=>xp.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>mC(e,t=>xp.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>QE(e,t=>xp.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>mC(e,t=>xp.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:BC},{key:"Ctrl-h",run:LC},{key:"Ctrl-k",run:e=>RC(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})},{key:"Ctrl-Alt-h",run:jC},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:Xf.of(["",""])},range:xp.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:sp(r.text,n-r.from,!1)+r.from,o=n==r.to?n+1:sp(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:o,insert:e.doc.slice(n,o).append(e.doc.slice(i,n))},range:xp.cursor(o)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:fC}],YC=[{key:"ArrowLeft",run:nC,shift:vC,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>iC(e,!tC(e)),shift:e=>yC(e,!tC(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>QE(e,t=>pC(e,t,!tC(e))),shift:e=>mC(e,t=>pC(e,t,!tC(e))),preventDefault:!0},{key:"ArrowRight",run:rC,shift:bC,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>iC(e,tC(e)),shift:e=>yC(e,tC(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>QE(e,t=>pC(e,t,tC(e))),shift:e=>mC(e,t=>pC(e,t,tC(e))),preventDefault:!0},{key:"ArrowUp",run:lC,shift:xC,preventDefault:!0},{mac:"Cmd-ArrowUp",run:OC,shift:AC},{mac:"Ctrl-ArrowUp",run:dC,shift:EC},{key:"ArrowDown",run:cC,shift:kC,preventDefault:!0},{mac:"Cmd-ArrowDown",run:NC,shift:TC},{mac:"Ctrl-ArrowDown",run:fC,shift:CC},{key:"PageUp",run:dC,shift:EC},{key:"PageDown",run:fC,shift:CC},{key:"Home",run:e=>QE(e,t=>pC(e,t,!1)),shift:e=>mC(e,t=>pC(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:OC,shift:AC},{key:"End",run:e=>QE(e,t=>pC(e,t,!0)),shift:e=>mC(e,t=>pC(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:NC,shift:TC},{key:"Enter",run:zC,shift:zC},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:LC,shift:LC,preventDefault:!0},{key:"Delete",run:BC,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:jC,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>IC(e,!0),preventDefault:!0},{mac:"Mod-Backspace",run:e=>RC(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),preventDefault:!0},{mac:"Mod-Delete",run:e=>RC(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),preventDefault:!0}].concat(KC.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),GC=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>QE(e,t=>sC(e.state,t,!tC(e))),shift:e=>mC(e,t=>sC(e.state,t,!tC(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>QE(e,t=>sC(e.state,t,tC(e))),shift:e=>mC(e,t=>sC(e.state,t,tC(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>FC(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>WC(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>FC(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>WC(e,t,!0)},{key:"Mod-Alt-ArrowUp",run:e=>MC(e,!1)},{key:"Mod-Alt-ArrowDown",run:e=>MC(e,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=xp.create([n.main]):n.main.empty||(r=xp.create([xp.cursor(n.main.head)])),!!r&&(t(JE(e,r)),!0)}},{key:"Mod-Enter",run:HC},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=_C(e).map(({from:t,to:n})=>xp.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:xp.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=XE(e.selection,t=>{let n=Qk(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return xp.range(n.to,n.from)}return t});return!n.eq(e.selection)&&(t(JE(e,n)),!0)},preventDefault:!0},{key:"Mod-[",run:$C},{key:"Mod-]",run:UC},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new pS(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),i=qC(e,(t,i,o)=>{let s=fS(r,t.from);if(null==s)return;/\S/.test(t.text)||(s=0);let a=/^\s*/.exec(t.text)[0],l=dS(e,s);(a!=l||o.from<t.from+a.length)&&(n[t.from]=s,i.push({from:t.from,to:t.from+a.length,insert:l}))});return i.changes.empty||t(e.update(i,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(_C(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=XE(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>function(e,t,n){let r=!1,i=XE(e.selection,t=>{let i=uE(e,t.head,-1)||uE(e,t.head,1)||t.head>0&&uE(e,t.head-1,1)||t.head<e.doc.length&&uE(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let o=i.start.from==t.head?i.end.to:i.end.from;return n?xp.range(t.anchor,o):xp.cursor(o)});return!!r&&(t(JE(e,i)),!0)}(e,t,!1)},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=EE(e.state,n.from);return r.line?xE(e):!!r.block&&SE(e)}},{key:"Alt-A",run:kE},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat(YC),XC={key:"Tab",run:UC,shift:$C},JC="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class QC{constructor(e,t,n=0,r=e.length,i,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,r),this.bufferStart=n,this.normalize=i?e=>i(JC(e)):JC,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 ap(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=lp(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=cp(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let o=r.charCodeAt(e),s=this.match(o,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(s)return this.value=s,this;break}i==n&&e<t.length&&t.charCodeAt(e)==o&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],o=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,o=!0)),o||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}}"undefined"!=typeof Symbol&&(QC.prototype[Symbol.iterator]=function(){return this});const ZC={from:-1,to:-1,match:/.*/.exec("")},eO="gm"+(null==/x/.unicode?"":"u");class tO{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine="",this.done=!1,this.value=ZC,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new iO(e,t,n,r,i);this.re=new RegExp(t,eO+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=oO(e,r),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,r=n+t[0].length;if(this.matchPos=oO(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const nO=new WeakMap;class rO{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=nO.get(e);if(!r||r.from>=n||r.to<=t){let r=new rO(t,e.sliceString(t,n));return nO.set(e,r),r}if(r.from==t&&r.to==n)return r;let{text:i,from:o}=r;return o>t&&(i=e.sliceString(t,o)+i,o=t),r.to<n&&(i+=e.sliceString(r.to,n)),nO.set(e,new rO(o,i)),new rO(t,i.slice(t-o,n-o))}}class iO{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=ZC,this.matchPos=oO(e,r),this.re=new RegExp(t,eO+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=rO.get(e,r,this.chunkEnd(r+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 e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=oO(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=rO.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function oO(e,t){if(t>=e.length)return t;let n,r=e.lineAt(t);for(;t<r.to&&(n=r.text.charCodeAt(t-r.from))>=56320&&n<57344;)t++;return t}"undefined"!=typeof Symbol&&(tO.prototype[Symbol.iterator]=iO.prototype[Symbol.iterator]=function(){return this});const sO={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},aO=Ep.define({combine:e=>fm(e,sO,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});const lO=dg.mark({class:"cm-selectionMatch"}),cO=dg.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function hO(e,t,n,r){return!(0!=n&&e(t.sliceDoc(n-1,n))==lm.Word||r!=t.doc.length&&e(t.sliceDoc(r,r+1))==lm.Word)}const uO=Cv.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(aO),{state:n}=e,r=n.selection;if(r.ranges.length>1)return dg.none;let i,o=r.main,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return dg.none;let e=n.wordAt(o.head);if(!e)return dg.none;s=n.charCategorizer(o.head),i=n.sliceDoc(e.from,e.to)}else{let e=o.to-o.from;if(e<t.minSelectionLength||e>200)return dg.none;if(t.wholeWords){if(i=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!hO(s,n,o.from,o.to)||!function(e,t,n,r){return e(t.sliceDoc(n,n+1))==lm.Word&&e(t.sliceDoc(r-1,r))==lm.Word}(s,n,o.from,o.to))return dg.none}else if(i=n.sliceDoc(o.from,o.to),!i)return dg.none}let a=[];for(let r of e.visibleRanges){let e=new QC(n.doc,i,r.from,r.to);for(;!e.next().done;){let{from:r,to:i}=e.value;if((!s||hO(s,n,r,i))&&(o.empty&&r<=o.from&&i>=o.to?a.push(cO.range(r,i)):(r>=o.to||i<=o.from)&&a.push(lO.range(r,i)),a.length>t.maxMatches))return dg.none}}return dg.set(a)}},{decorations:e=>e.decorations}),dO=Jy.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const fO=Ep.define({combine:e=>fm(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new HO(e),scrollToMatch:e=>Jy.scrollIntoView(e)})});class pO{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||function(e){try{return new RegExp(e,eO),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new xO(this):new vO(this)}getCursor(e,t=0,n){let r=e.doc?e:dm.create({doc:e});return null==n&&(n=r.doc.length),this.regexp?bO(this,r,t,n):gO(this,r,t,n)}}class mO{constructor(e){this.spec=e}}function gO(e,t,n,r){let i;return e.wholeWord&&(i=function(e,t){return(n,r,i,o)=>((o>n||o+i.length<r)&&(o=Math.max(0,n-2),i=e.sliceString(o,Math.min(e.length,r+2))),!(t(yO(i,n-o))==lm.Word&&t(wO(i,n-o))==lm.Word||t(wO(i,r-o))==lm.Word&&t(yO(i,r-o))==lm.Word))}(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=function(e,t,n){return(r,i,o,s)=>{if(n&&!n(r,i,o,s))return!1;let a=r>=s&&i<=s+o.length?o.slice(r-s,i-s):t.doc.sliceString(r,i);return e(a,t,r,i)}}(e.test,t,i)),new QC(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}class vO extends mO{constructor(e){super(e)}nextMatch(e,t,n){let r=gO(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=gO(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=gO(this.spec,e,n,r),o=null;for(;!i.nextOverlapping().done;)o=i.value;if(o)return o;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||(r=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),!r||r.from==t&&r.to==n?null:r}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=gO(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=gO(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}function bO(e,t,n,r){let i;var o;return e.wholeWord&&(o=t.charCategorizer(t.selection.main.head),i=(e,t,n)=>!n[0].length||(o(yO(n.input,n.index))!=lm.Word||o(wO(n.input,n.index))!=lm.Word)&&(o(wO(n.input,n.index+n[0].length))!=lm.Word||o(yO(n.input,n.index+n[0].length))!=lm.Word)),e.test&&(i=function(e,t,n){return(r,i,o)=>(!n||n(r,i,o))&&e(o[0],t,r,i)}(e.test,t,i)),new tO(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function yO(e,t){return e.slice(sp(e,t,!1),t)}function wO(e,t){return e.slice(t,sp(e,t))}class xO extends mO{nextMatch(e,t,n){let r=bO(this.spec,e,n,e.doc.length).next();return r.done&&(r=bO(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-1e4*r),o=bO(this.spec,e,i,n),s=null;for(;!o.next().done;)s=o.value;if(s&&(i==t||s.from>i+10))return s;if(i==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 t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=bO(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=bO(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}const kO=em.define(),SO=em.define(),EO=Rp.define({create:e=>new CO(IO(e).create(),null),update(e,t){for(let n of t.effects)n.is(kO)?e=new CO(n.value.create(),e.panel):n.is(SO)&&(e=new CO(e.query,n.value?BO:null));return e},provide:e=>px.from(e,e=>e.panel)});class CO{constructor(e,t){this.query=e,this.panel=t}}const OO=dg.mark({class:"cm-searchMatch"}),NO=dg.mark({class:"cm-searchMatch cm-searchMatch-selected"}),AO=Cv.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(EO))}update(e){let t=e.state.field(EO);(t!=e.startState.field(EO)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return dg.none;let{view:n}=this,r=new wm;for(let t=0,i=n.visibleRanges,o=i.length;t<o;t++){let{from:s,to:a}=i[t];for(;t<o-1&&a>i[t+1].from-500;)a=i[++t].to;e.highlight(n.state,s,a,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?NO:OO)})}return r.finish()}},{decorations:e=>e.decorations});function TO(e){return t=>{let n=t.state.field(EO,!1);return n&&n.query.spec.valid?e(t,n):FO(t)}}const MO=TO((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=xp.single(r.from,r.to),o=e.state.facet(fO);return e.dispatch({selection:i,effects:[$O(e,r),o.scrollToMatch(i.main,e)],userEvent:"select.search"}),_O(e),!0}),RO=TO((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let o=xp.single(i.from,i.to),s=e.state.facet(fO);return e.dispatch({selection:o,effects:[$O(e,i),s.scrollToMatch(o.main,e)],userEvent:"select.search"}),_O(e),!0}),DO=TO((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!(!n||!n.length)&&(e.dispatch({selection:xp.create(n.map(e=>xp.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),PO=TO((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let o=t.nextMatch(n,r,r);if(!o)return!1;let s,a,l=o,c=[],h=[];l.from==r&&l.to==i&&(a=n.toText(t.getReplacement(l)),c.push({from:l.from,to:l.to,insert:a}),l=t.nextMatch(n,l.from,l.to),h.push(Jy.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+".")));let u=e.state.changes(c);return l&&(s=xp.single(l.from,l.to).map(u),h.push($O(e,l)),h.push(n.facet(fO).scrollToMatch(s.main,e))),e.dispatch({changes:u,selection:s,effects:h,userEvent:"input.replace"}),!0}),LO=TO((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:Jy.announce.of(r),userEvent:"input.replace.all"}),!0});function BO(e){return e.state.facet(fO).createPanel(e)}function IO(e,t){var n,r,i,o,s;let a=e.selection.main,l=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!l)return t;let c=e.facet(fO);return new pO({search:(null!==(n=null==t?void 0:t.literal)&&void 0!==n?n:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(r=null==t?void 0:t.caseSensitive)&&void 0!==r?r:c.caseSensitive,literal:null!==(i=null==t?void 0:t.literal)&&void 0!==i?i:c.literal,regexp:null!==(o=null==t?void 0:t.regexp)&&void 0!==o?o:c.regexp,wholeWord:null!==(s=null==t?void 0:t.wholeWord)&&void 0!==s?s:c.wholeWord})}function jO(e){let t=hx(e,BO);return t&&t.dom.querySelector("[main-field]")}function _O(e){let t=jO(e);t&&t==e.root.activeElement&&t.select()}const FO=e=>{let t=e.state.field(EO,!1);if(t&&t.panel){let n=jO(e);if(n&&n!=e.root.activeElement){let r=IO(e.state,t.query.spec);r.valid&&e.dispatch({effects:kO.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[SO.of(!0),t?kO.of(IO(e.state,t.query.spec)):em.appendConfig.of(YO)]});return!0},WO=e=>{let t=e.state.field(EO,!1);if(!t||!t.panel)return!1;let n=hx(e,BO);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:SO.of(!1)}),!0},zO=[{key:"Mod-f",run:FO,scope:"editor search-panel"},{key:"F3",run:MO,shift:RO,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:MO,shift:RO,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:WO,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,o=[],s=0;for(let t=new QC(e.doc,e.sliceDoc(r,i));!t.next().done;){if(o.length>1e3)return!1;t.value.from==r&&(s=o.length),o.push(xp.range(t.value.from,t.value.to))}return t(e.update({selection:xp.create(o,s),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=mx(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i)return void e.dispatch({effects:r});let o=t.doc.lineAt(t.selection.main.head),[,s,a,l,c]=i,h=l?+l.slice(1):0,u=a?+a:o.number;if(a&&c){let e=u/100;s&&(e=e*("-"==s?-1:1)+o.number/t.doc.lines),u=Math.round(t.doc.lines*e)}else a&&s&&(u=u*("-"==s?-1:1)+o.number);let d=t.doc.line(Math.max(1,Math.min(t.doc.lines,u))),f=xp.cursor(d.from+Math.max(0,Math.min(h,d.length)));e.dispatch({effects:[r,Jy.scrollIntoView(f.from,{y:"center"})],selection:f})}),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return(({state:e,dispatch:t})=>{let{selection:n}=e,r=xp.create(n.ranges.map(t=>e.wordAt(t.head)||xp.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)})({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=function(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),o=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new QC(e.doc,t,r[r.length-1].to);;){if(i.next(),!i.done){if(n&&r.some(e=>e.from==i.value.from))continue;if(o){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}if(n)return null;i=new QC(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}}(e,r);return!!i&&(t(e.update({selection:e.selection.addRange(xp.range(i.from,i.to),!1),effects:Jy.scrollIntoView(i.to)})),!0)},preventDefault:!0}];class HO{constructor(e){this.view=e;let t=this.query=e.state.field(EO).query.spec;function n(e,t,n){return Um("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=Um("input",{value:t.search,placeholder:VO(e,"Find"),"aria-label":VO(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Um("input",{value:t.replace,placeholder:VO(e,"Replace"),"aria-label":VO(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Um("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Um("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Um("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=Um("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",()=>MO(e),[VO(e,"next")]),n("prev",()=>RO(e),[VO(e,"previous")]),n("select",()=>DO(e),[VO(e,"all")]),Um("label",null,[this.caseField,VO(e,"match case")]),Um("label",null,[this.reField,VO(e,"regexp")]),Um("label",null,[this.wordField,VO(e,"by word")]),...e.state.readOnly?[]:[Um("br"),this.replaceField,n("replace",()=>PO(e),[VO(e,"replace")]),n("replaceAll",()=>LO(e),[VO(e,"replace all")])],Um("button",{name:"close",onclick:()=>WO(e),"aria-label":VO(e,"close"),type:"button"},["×"])])}commit(){let e=new pO({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:kO.of(e)}))}keydown(e){var t,n,r;t=this.view,n=e,r="search-panel",uw(aw(t.state),n,t,r)?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?RO:MO)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),PO(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(kO)&&!e.value.eq(this.query)&&this.setQuery(e.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(fO).top}}function VO(e,t){return e.state.phrase(t)}const qO=30,UO=/[\s\.,:;?!]/;function $O(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,o=Math.max(r.from,t-qO),s=Math.min(i,n+qO),a=e.state.sliceDoc(o,s);if(o!=r.from)for(let e=0;e<qO;e++)if(!UO.test(a[e+1])&&UO.test(a[e])){a=a.slice(e);break}if(s!=i)for(let e=a.length-1;e>a.length-qO;e--)if(!UO.test(a[e-1])&&UO.test(a[e])){a=a.slice(0,e);break}return Jy.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${r.number}.`)}const KO=Jy.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"}}),YO=[EO,jp.low(AO),KO];class GO{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Qk(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),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(eN(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return null==this.abortListeners}addEventListener(e,t,n){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function XO(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function JO(e){let t=e.map(e=>"string"==typeof e?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=XO(t)+XO(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}class QO{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}}function ZO(e){return e.selection.main.from}function eN(e,t){var n;let{source:r}=e,i=t&&"^"!=r[0],o="$"!=r[r.length-1];return i||o?new RegExp(`${i?"^":""}(?:${r})${o?"$":""}`,null!==(n=e.flags)&&void 0!==n?n:e.ignoreCase?"i":""):e}const tN=Jp.define();function nN(e,t,n,r){let{main:i}=e.selection,o=n-i.from,s=r-i.from;return{...e.changeByRange(a=>{if(a!=i&&n!=r&&e.sliceDoc(a.from+o,a.from+s)!=e.sliceDoc(n,r))return{range:a};let l=e.toText(t);return{changes:{from:a.from+o,to:r==i.from?a.to:a.from+s,insert:l},range:xp.cursor(a.from+o+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const rN=new WeakMap;function iN(e){if(!Array.isArray(e))return e;let t=rN.get(e);return t||rN.set(e,t=JO(e)),t}const oN=em.define(),sN=em.define();class aN{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=ap(e,t),r=cp(n);this.chars.push(n);let i=e.slice(t,t+r),o=i.toUpperCase();this.folded.push(ap(o==i?i.toLowerCase():o,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:o}=this;if(1==t.length){let r=ap(e,0),i=cp(r),o=i==e.length?0:-100;if(r==t[0]);else{if(r!=n[0])return null;o+=-200}return this.ret(o,[0,i])}let s=e.indexOf(this.pattern);if(0==s)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,l=0;if(s<0){for(let i=0,o=Math.min(e.length,200);i<o&&l<a;){let o=ap(e,i);o!=t[l]&&o!=n[l]||(r[l++]=i),i+=cp(o)}if(l<a)return null}let c=0,h=0,u=!1,d=0,f=-1,p=-1,m=/[a-z]/.test(e),g=!0;for(let r=0,l=Math.min(e.length,200),v=0;r<l&&h<a;){let l=ap(e,r);s<0&&(c<a&&l==t[c]&&(i[c++]=r),d<a&&(l==t[d]||l==n[d]?(0==d&&(f=r),p=r+1,d++):d=0));let b,y=l<255?l>=48&&l<=57||l>=97&&l<=122?2:l>=65&&l<=90?1:0:(b=lp(l))!=b.toLowerCase()?1:b!=b.toUpperCase()?2:0;(!r||1==y&&m||0==v&&0!=y)&&(t[h]==l||n[h]==l&&(u=!0)?o[h++]=r:o.length&&(g=!1)),v=y,r+=cp(l)}return h==a&&0==o[0]&&g?this.result((u?-200:0)-100,o,e):d==a&&0==f?this.ret(-200-e.length+(p==e.length?0:-100),[0,p]):s>-1?this.ret(-700-e.length,[s,s+this.pattern.length]):d==a?this.ret(-900-e.length,[f,p]):h==a?this.result((u?-200:0)-100-700+(g?0:-1100),o,e):2==t.length?null:this.result((r[0]?-700:0)-200-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?cp(ap(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}}class lN{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 null==n?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const cN=Ep.define({combine:e=>fm(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:uN,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||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=>hN(e(n),t(n)),optionClass:(e,t)=>n=>hN(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function hN(e,t){return e?t?e+" "+t:e:t}function uN(e,t,n,r,i,o){let s,a,l=e.textDirection==zg.RTL,c=l,h=!1,u="top",d=t.left-i.left,f=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(c&&d<Math.min(p,f)?c=!1:!c&&f<Math.min(p,d)&&(c=!0),p<=(c?d:f))s=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,a=Math.min(400,c?d:f);else{h=!0,a=Math.min(400,(l?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=m||e>t.top?s=n.bottom-t.top:(u="bottom",s=t.bottom-n.top)}return{style:`${u}: ${s/((t.bottom-t.top)/o.offsetHeight)}px; max-width: ${a/((t.right-t.left)/o.offsetWidth)}px`,class:"cm-completionInfo-"+(h?l?"left-narrow":"right-narrow":c?"left":"right")}}function dN(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class fN{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:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:i,selected:o}=r.open,s=e.state.facet(cN);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>"cm-completionIcon-"+e)),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement("span");i.className="cm-completionLabel";let o=e.displayLabel||e.label,s=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>s&&i.appendChild(document.createTextNode(o.slice(s,t)));let a=i.appendChild(document.createElement("span"));a.appendChild(document.createTextNode(o.slice(t,n))),a.className="cm-completionMatchedText",s=n}return s<o.length&&i.appendChild(document.createTextNode(o.slice(s))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=dN(i.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",n=>{let{options:r}=e.state.field(t).open;for(let t,i=n.target;i&&i!=this.dom;i=i.parentNode)if("LI"==i.nodeName&&(t=/-(\d+)$/.exec(i.id))&&+t[1]<r.length)return this.applyCompletion(e,r[+t[1]]),void n.preventDefault()}),this.dom.addEventListener("focusout",t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(cN).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:sN.of(null)})}),this.showOptions(i,r.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),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=r){let{options:i,selected:o,disabled:s}=n.open;r.open&&r.open.options==i||(this.range=dN(i.length,o,e.state.facet(cN).maxRenderedOptions),this.showOptions(i,n.id)),this.updateSel(),s!=(null===(t=r.open)||void 0===t?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);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=dN(t.options.length,t.selected,this.view.state.facet(cN).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let o="string"==typeof i?document.createTextNode(i):i(r);if(!o)return;"then"in o?o.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>xv(this.view.state,e,"completion info")):(this.addInfoPane(o,r),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(65535*Math.random()).toString(16),null!=e.nodeType)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)"LI"==n.nodeName&&n.id?r==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby")):r--;return t&&function(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}(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(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(cN).positionInfo(this.view,t,r,n,i,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 r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",e=>{e.target==r&&e.preventDefault()});let i=null;for(let o=n.from;o<n.to;o++){let{completion:s,match:a}=e[o],{section:l}=s;if(l){let e="string"==typeof l?l:l.name;if(e!=i&&(o>n.from||0==n.from))if(i=e,"string"!=typeof l&&l.header)r.appendChild(l.header(l));else{r.appendChild(document.createElement("completion-section")).textContent=e}}const c=r.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let h=this.optionClass(s);h&&(c.className=h);for(let e of this.optionContent){let t=e(s,this.view.state,this.view,a);t&&c.appendChild(t)}}return n.from&&r.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function pN(e,t){return n=>new fN(n,e,t)}function mN(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class gN{constructor(e,t,n,r,i,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new gN(this.options,wN(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,r,i,o){if(r&&!o&&e.some(e=>e.isPending))return r.setDisabled();let s=function(e,t){let n=[],r=null,i=null,o=e=>{n.push(e);let{section:t}=e.completion;if(t){r||(r=[]);let e="string"==typeof t?t:t.name;r.some(t=>t.name==e)||r.push("string"==typeof t?{name:e}:t)}},s=t.facet(cN);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(!1===r.result.filter)for(let t of r.result.options)o(new QO(t,r.source,e?e(t):[],1e9-n.length));else{let n,a=t.sliceDoc(r.from,r.to),l=s.filterStrict?new lN(a):new aN(a);for(let t of r.result.options)if(n=l.match(t.label)){let s=t.displayLabel?e?e(t,n.matched):[]:n.matched,a=n.score+(t.boost||0);if(o(new QO(t,r.source,s,a)),"object"==typeof t.section&&"dynamic"===t.section.rank){let{name:e}=t.section;i||(i=Object.create(null)),i[e]=Math.max(a,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,o=(e,t)=>("dynamic"===e.rank&&"dynamic"===t.rank?i[t.name]-i[e.name]:0)||("number"==typeof e.rank?e.rank:1e9)-("number"==typeof t.rank?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(o))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e["string"==typeof n?n:n.name])}}let a=[],l=null,c=s.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||c(e.completion,t.completion))){let t=e.completion;!l||l.label!=t.label||l.detail!=t.detail||null!=l.type&&null!=t.type&&l.type!=t.type||l.apply!=t.apply||l.boost!=t.boost?a.push(e):mN(e.completion)>mN(l)&&(a[a.length-1]=e),l=e.completion}return a}(e,t);if(!s.length)return r&&e.some(e=>e.isPending)?r.setDisabled():null;let a=t.facet(cN).selectOnOpen?0:-1;if(r&&r.selected!=a&&-1!=r.selected){let e=r.options[r.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){a=t;break}}return new gN(s,wN(n,a),{pos:e.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:TN,above:i.aboveCursor},r?r.timestamp:Date.now(),a,!1)}map(e){return new gN(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new gN(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class vN{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new vN(xN,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(cN),r=(n.override||t.languageDataAt("autocomplete",ZO(t)).map(iN)).map(t=>(this.active.find(e=>e.source==t)||new SN(t,this.active.some(e=>0!=e.state)?1:0)).update(e,n));r.length==this.active.length&&r.every((e,t)=>e==this.active[t])&&(r=this.active);let i=this.open,o=e.effects.some(e=>e.is(CN));i&&e.docChanged&&(i=i.map(e.changes)),e.selection||r.some(t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to))||!function(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,o=r==t.length;if(i||o)return i==o;if(e[n++].result!=t[r++].result)return!1}}(r,this.active)||o?i=gN.build(r,t,this.id,i,n,o):i&&i.disabled&&!r.some(e=>e.isPending)&&(i=null),!i&&r.every(e=>!e.isPending)&&r.some(e=>e.hasResult())&&(r=r.map(e=>e.hasResult()?new SN(e.source,0):e));for(let t of e.effects)t.is(ON)&&(i=i&&i.setSelected(t.value,this.id));return r==this.active&&i==this.open?this:new vN(r,this.id,i)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?bN:yN}}const bN={"aria-autocomplete":"list"},yN={};function wN(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const xN=[];function kN(e,t){if(e.isUserEvent("input.complete")){let n=e.annotation(tN);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class SN{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return 1==this.state}update(e,t){let n=kN(e,t),r=this;(8&n||16&n&&this.touches(e))&&(r=new SN(r.source,0)),4&n&&0==r.state&&(r=new SN(this.source,1)),r=r.updateFor(e,n);for(let t of e.effects)if(t.is(oN))r=new SN(r.source,1,t.value);else if(t.is(sN))r=new SN(r.source,0);else if(t.is(CN))for(let e of t.value)e.source==r.source&&(r=e);return r}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(ZO(e.state))}}class EN extends SN{constructor(e,t,n,r,i,o){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=o}hasResult(){return!0}updateFor(e,t){var n;if(!(3&t))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let i=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),s=ZO(e.state);if(s>o||!r||2&t&&(ZO(e.startState)==this.from||s<this.limit))return new SN(this.source,4&t?1:0);let a=e.changes.mapPos(this.limit);return function(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return"function"==typeof e?e(i,n,r,t):eN(e,!0).test(i)}(r.validFor,e.state,i,o)?new EN(this.source,this.explicit,a,r,i,o):r.update&&(r=r.update(r,i,o,new GO(e.state,s,!1)))?new EN(this.source,this.explicit,a,r,r.from,null!==(n=r.to)&&void 0!==n?n:ZO(e.state)):new SN(this.source,1,this.explicit)}map(e){if(e.empty)return this;return(this.result.map?this.result.map(this.result,e):this.result)?new EN(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new SN(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}const CN=em.define({map:(e,t)=>e.map(e=>e.map(t))}),ON=em.define(),NN=Rp.define({create:()=>vN.start(),update:(e,t)=>e.update(t),provide:e=>[ex.from(e,e=>e.tooltip),Jy.contentAttributes.from(e,e=>e.attrs)]});function AN(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(NN).active.find(e=>e.source==t.source);return r instanceof EN&&("string"==typeof n?e.dispatch({...nN(e.state,n,r.from,r.to),annotations:tN.of(t.completion)}):n(e,t.completion,r.from,r.to),!0)}const TN=pN(NN,AN);function MN(e,t="option"){return n=>{let r=n.state.field(NN,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(cN).interactionDelay)return!1;let i,o=1;"page"==t&&(i=ax(n,r.open.tooltip))&&(o=Math.max(2,Math.floor(i.dom.offsetHeight/i.dom.querySelector("li").offsetHeight)-1));let{length:s}=r.open.options,a=r.open.selected>-1?r.open.selected+o*(e?1:-1):e?0:s-1;return a<0?a="page"==t?0:s-1:a>=s&&(a="page"==t?s-1:0),n.dispatch({effects:ON.of(a)}),!0}}const RN=e=>!!e.state.field(NN,!1)&&(e.dispatch({effects:oN.of(!0)}),!0);class DN{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const PN=Cv.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(NN).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(NN),n=e.state.facet(cN);if(!e.selectionSet&&!e.docChanged&&e.startState.field(NN)==t)return;let r=e.transactions.some(e=>{let t=kN(e,n);return 8&t||(e.selection||e.docChanged)&&!(3&t)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>50&&Date.now()-n.time>1e3){for(let e of n.context.abortListeners)try{e()}catch(e){xv(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(oN)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,0!=this.composing)for(let t of e.transactions)t.isUserEvent("input.type")?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(NN);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(cN).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=ZO(t),r=new GO(t,n,e.explicit,this.view),i=new DN(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(e=>{i.context.aborted||(i.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:sN.of(null)}),xv(this.view.state,e)})}scheduleAccept(){this.running.every(e=>void 0!==e.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(cN).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(cN),r=this.view.state.field(NN);for(let i=0;i<this.running.length;i++){let o=this.running[i];if(void 0===o.done)continue;if(this.running.splice(i--,1),o.done){let r=ZO(o.updates.length?o.updates[0].startState:this.view.state),i=Math.min(r,o.done.from+(o.active.explicit?0:1)),s=new EN(o.active.source,o.active.explicit,i,o.done,o.done.from,null!==(e=o.done.to)&&void 0!==e?e:r);for(let e of o.updates)s=s.update(e,n);if(s.hasResult()){t.push(s);continue}}let s=r.active.find(e=>e.source==o.active.source);if(s&&s.isPending)if(null==o.done){let e=new SN(o.active.source,0);for(let t of o.updates)e=e.update(t,n);e.isPending||t.push(e)}else this.startQuery(s)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:CN.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(NN,!1);if(t&&t.tooltip&&this.view.state.facet(cN).closeOnBlur){let n=t.open&&ax(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:sN.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:oN.of(!1)}),20),this.composing=0}}}),LN="object"==typeof navigator&&/Win/.test(navigator.platform),BN=jp.highest(Jy.domEventHandlers({keydown(e,t){let n=t.state.field(NN,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&(!LN||!e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),o=r.completion.commitCharacters||i.result.commitCharacters;return o&&o.indexOf(e.key)>-1&&AN(t,r),!1}})),IN=Jy.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"}}}),jN={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},_N=em.define({map(e,t){let n=t.mapPos(e,-1,up.TrackAfter);return null==n?void 0:n}}),FN=new class extends pm{};FN.startSide=1,FN.endSide=-1;const WN=Rp.define({create:()=>ym.empty,update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(_N)&&(e=e.update({add:[FN.range(n.value,n.value+1)]}));return e}});const zN="()[]{}<>«»»«[]{}";function HN(e){for(let t=0;t<16;t+=2)if(zN.charCodeAt(t)==e)return zN.charAt(t+1);return lp(e<128?e:e+1)}function VN(e,t){return e.languageDataAt("closeBrackets",t)[0]||jN}const qN="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),UN=Jy.inputHandler.of((e,t,n,r)=>{if((qN?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||2==r.length&&1==cp(ap(r,0))||t!=i.from||n!=i.to)return!1;let o=function(e,t){let n=VN(e,e.selection.main.head),r=n.brackets||jN.brackets;for(let i of r){let o=HN(ap(i,0));if(t==i)return o==i?JN(e,i,r.indexOf(i+i+i)>-1,n):GN(e,i,o,n.before||jN.before);if(t==o&&KN(e,e.selection.main.from))return XN(e,i,o)}return null}(e.state,r);return!!o&&(e.dispatch(o),!0)}),$N=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=VN(e,e.selection.main.head).brackets||jN.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=function(e,t){let n=e.sliceString(t-2,t);return cp(ap(n,0))==n.length?n:n.slice(1)}(e.doc,t.head);for(let i of n)if(i==r&&YN(e.doc,t.head)==HN(ap(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:xp.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:"delete.backward"})),!r}}];function KN(e,t){let n=!1;return e.field(WN).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function YN(e,t){let n=e.sliceString(t,t+2);return n.slice(0,cp(ap(n,0)))}function GN(e,t,n,r){let i=null,o=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:_N.of(o.to+t.length),range:xp.range(o.anchor+t.length,o.head+t.length)};let s=YN(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:_N.of(o.head+t.length),range:xp.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function XN(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&YN(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:xp.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function JN(e,t,n,r){let i=r.stringPrefixes||jN.stringPrefixes,o=null,s=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:_N.of(r.to+t.length),range:xp.range(r.anchor+t.length,r.head+t.length)};let s,a=r.head,l=YN(e.doc,a);if(l==t){if(QN(e,a))return{changes:{insert:t+t,from:a},effects:_N.of(a+t.length),range:xp.cursor(a+t.length)};if(KN(e,a)){let r=n&&e.sliceDoc(a,a+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:a,to:a+r.length,insert:r},range:xp.cursor(a+r.length)}}}else{if(n&&e.sliceDoc(a-2*t.length,a)==t+t&&(s=ZN(e,a-2*t.length,i))>-1&&QN(e,s))return{changes:{insert:t+t+t+t,from:a},effects:_N.of(a+t.length),range:xp.cursor(a+t.length)};if(e.charCategorizer(a)(l)!=lm.Word&&ZN(e,a,i)>-1&&!function(e,t,n,r){let i=Qk(e).resolveInner(t,-1),o=r.reduce((e,t)=>Math.max(e,t.length),0);for(let s=0;s<5;s++){let s=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+o)),a=s.indexOf(n);if(!a||a>-1&&r.indexOf(s.slice(0,a))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+a;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let l=i.to==t&&i.parent;if(!l)break;i=l}return!1}(e,a,t,i))return{changes:{insert:t+t,from:a},effects:_N.of(a+t.length),range:xp.cursor(a+t.length)}}return{range:o=r}});return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function QN(e,t){let n=Qk(e).resolveInner(t+1);return n.parent&&n.from==t}function ZN(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=lm.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=lm.Word)return n}return-1}const eA=[{key:"Ctrl-Space",run:RN},{mac:"Alt-`",run:RN},{mac:"Alt-i",run:RN},{key:"Escape",run:e=>{let t=e.state.field(NN,!1);return!(!t||!t.active.some(e=>0!=e.state))&&(e.dispatch({effects:sN.of(null)}),!0)}},{key:"ArrowDown",run:MN(!0)},{key:"ArrowUp",run:MN(!1)},{key:"PageDown",run:MN(!0,"page")},{key:"PageUp",run:MN(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(NN,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(cN).interactionDelay)&&AN(e,t.open.options[t.open.selected])}}],tA=jp.highest(ow.computeN([cN],e=>e.facet(cN).defaultKeymap?[eA]:[]));class nA{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class rA{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let r=n.facet(mA).markerFilter;r&&(e=r(e,n));let i=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new wm,s=[],a=0,l=n.doc.iter(),c=0,h=n.doc.length;for(let e=0;;){let t,n,r=e==i.length?null:i[e];if(!r&&!s.length)break;if(s.length)t=a,n=s.reduce((e,t)=>Math.min(e,t.to),r&&r.from>t?r.from:1e8);else{if(t=r.from,t>h)break;n=r.to,s.push(r),e++}for(;e<i.length;){let r=i[e];if(r.from!=t||!(r.to>r.from||r.to==t)){n=Math.min(r.from,n);break}s.push(r),e++,n=Math.min(r.to,n)}n=Math.min(n,h);let u=!1;if(s.some(e=>e.from==t&&(e.to==n||n==h))&&(u=t==n,!u&&n-t<10)){let e=t-(c+l.value.length);e>0&&(l.next(e),c=t);for(let e=t;;){if(e>=n){u=!0;break}if(!l.lineBreak&&c+l.value.length>e)break;e=c+l.value.length,c+=l.value.length,l.next()}}let d=CA(s);if(u)o.add(t,t,dg.widget({widget:new yA(d),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");o.add(t,n,dg.mark({class:"cm-lintRange cm-lintRange-"+d+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>n)}))}if(a=n,a==h)break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1)}let u=o.finish();return new rA(u,t,iA(u))}}function iA(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(r){if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new nA(r.from,n,r.diagnostic)}else r=new nA(e,n,t||i.diagnostics[0])}),r}function oA(e,t){return e.field(cA,!1)?t:t.concat(em.appendConfig.of(OA))}const sA=em.define(),aA=em.define(),lA=em.define(),cA=Rp.define({create:()=>new rA(dg.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=iA(n,e.selected.diagnostic,i)||iA(n,null,i)}!n.size&&i&&t.state.facet(mA).autoPanel&&(i=null),e=new rA(n,i,r)}for(let n of t.effects)if(n.is(sA)){let r=t.state.facet(mA).autoPanel?n.value.length?xA.open:null:e.panel;e=rA.init(n.value,r,t.state)}else n.is(aA)?e=new rA(e.diagnostics,n.value?xA.open:null,e.selected):n.is(lA)&&(e=new rA(e.diagnostics,e.panel,n.value));return e},provide:e=>[px.from(e,e=>e.panel),Jy.decorations.from(e,e=>e.diagnostics)]}),hA=dg.mark({class:"cm-lintRange cm-lintRange-active"});function uA(e,t,n){let r,{diagnostics:i}=e.state.field(cA),o=-1,s=-1;i.between(t-(n<0?1:0),t+(n>0?1:0),(e,i,{spec:a})=>{if(t>=e&&t<=i&&(e==i||(t>e||n>0)&&(t<i||n<0)))return r=a.diagnostics,o=e,s=i,!1});let a=e.state.facet(mA).tooltipFilter;return r&&a&&(r=a(r,e.state)),r?{pos:o,end:s,above:e.state.doc.lineAt(o).to<s,create:()=>({dom:dA(e,r)})}:null}function dA(e,t){return Um("ul",{class:"cm-tooltip-lint"},t.map(t=>bA(e,t,!1)))}const fA=e=>{let t=e.state.field(cA,!1);return!(!t||!t.panel)&&(e.dispatch({effects:aA.of(!1)}),!0)},pA=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(cA,!1);t&&t.panel||e.dispatch({effects:oA(e.state,[aA.of(!0)])});let n=hx(e,xA.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(cA,!1);if(!t)return!1;let n=e.state.selection.main,r=t.diagnostics.iter(n.to+1);return!(!r.value&&(r=t.diagnostics.iter(0),!r.value||r.from==n.from&&r.to==n.to))&&(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],mA=Ep.define({combine:e=>({sources:e.map(e=>e.source).filter(e=>null!=e),...fm(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:gA,tooltipFilter:gA,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})})});function gA(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function vA(e){let t=[];if(e)e:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue e}}t.push("")}return t}function bA(e,t,n){var r;let i=n?vA(t.actions):[];return Um("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},Um("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(r=t.actions)||void 0===r?void 0:r.map((n,r)=>{let o=!1,s=r=>{if(r.preventDefault(),o)return;o=!0;let i=iA(e.state.field(cA).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:a}=n,l=i[r]?a.indexOf(i[r]):-1,c=l<0?a:[a.slice(0,l),Um("u",a.slice(l,l+1)),a.slice(l+1)];return Um("button",{type:"button",class:"cm-diagnosticAction"+(n.markClass?" "+n.markClass:""),onclick:s,onmousedown:s,"aria-label":` Action: ${a}${l<0?"":` (access key "${i[r]})"`}.`},c)}),t.source&&Um("div",{class:"cm-diagnosticSource"},t.source))}class yA extends hg{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Um("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class wA{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=bA(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class xA{constructor(e){this.view=e,this.items=[];this.list=Um("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)fA(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:n}=this.items[this.selectedIndex],r=vA(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=iA(this.view.state.field(cA).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}}t.preventDefault()},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=Um("div",{class:"cm-panel-lint"},this.list,Um("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>fA(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(cA).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(cA),n=0,r=!1,i=null,o=new Set;for(e.between(0,this.view.state.doc.length,(e,s,{spec:a})=>{for(let e of a.diagnostics){if(o.has(e))continue;o.add(e);let s,a=-1;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){a=t;break}a<0?(s=new wA(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[a],a>n&&(this.items.splice(n,a-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute("aria-selected")||(s.dom.setAttribute("aria-selected","true"),i=s):s.dom.hasAttribute("aria-selected")&&s.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();0==this.items.length&&(this.items.push(new wA(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),i?(this.list.setAttribute("aria-activedescendant",i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.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=iA(this.view.state.field(cA).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:lA.of(t)})}static open(e){return new xA(e)}}function kA(e){return function(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const SA=Jy.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:kA("#d11")},".cm-lintRange-warning":{backgroundImage:kA("orange")},".cm-lintRange-info":{backgroundImage:kA("#999")},".cm-lintRange-hint":{backgroundImage:kA("#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 EA(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function CA(e){let t="hint",n=1;for(let r of e){let e=EA(r.severity);e>n&&(n=e,t=r.severity)}return t}const OA=[cA,Jy.decorations.compute([cA],e=>{let{selected:t,panel:n}=e.field(cA);return t&&n&&t.from!=t.to?dg.set([hA.range(t.from,t.to)]):dg.none}),sx(uA,{hideOn:function(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(mA).hideOn(e,n,r);if(null!=i)return i;let o=e.startState.doc.lineAt(t.pos);return!(!e.effects.some(e=>e.is(sA))&&!e.changes.touchesRange(o.from,Math.max(o.to,r)))}}),SA];var NA=function(e){void 0===e&&(e={});var{crosshairCursor:t=!1}=e,n=[];!1!==e.closeBracketsKeymap&&(n=n.concat($N)),!1!==e.defaultKeymap&&(n=n.concat(GC)),!1!==e.searchKeymap&&(n=n.concat(zO)),!1!==e.historyKeymap&&(n=n.concat(GE)),!1!==e.foldKeymap&&(n=n.concat(IS)),!1!==e.completionKeymap&&(n=n.concat(eA)),!1!==e.lintKeymap&&(n=n.concat(pA));var r=[];return!1!==e.lineNumbers&&r.push(function(e={}){return[Bx.of(e),Ox(),_x]}()),!1!==e.highlightActiveLineGutter&&r.push(zx),!1!==e.highlightSpecialChars&&r.push(function(e={}){return[Pw.of(e),Lw||(Lw=Cv.fromClass(class{constructor(e){this.view=e,this.decorations=dg.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(Pw)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new Aw({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,o=ap(t[0],0);if(9==o){let e=i.lineAt(r),t=n.state.tabSize,o=Rm(e.text,t,r-e.from);return dg.replace({widget:new Iw((t-o%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=dg.replace({widget:new Bw(e,o)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(Pw);e.startState.facet(Pw)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))]}()),!1!==e.history&&r.push(function(e={}){return[DE,RE.of(e),Jy.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?LE:"historyRedo"==e.inputType?BE:null;return!!n&&(e.preventDefault(),n(t))}})]}()),!1!==e.foldGutter&&r.push(function(e={}){let t={...VS,...e},n=new qS(t,!0),r=new qS(t,!1),i=Cv.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(aS)!=e.state.facet(aS)||e.startState.field(MS,!1)!=e.state.field(MS,!1)||Qk(e.startState)!=Qk(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new wm;for(let i of e.viewportLineBlocks){let o=DS(e.state,i.from,i.to)?r:CS(e.state,i.from,i.to)?n:null;o&&t.add(i.from,i.from,o)}return t.finish()}}),{domEventHandlers:o}=t;return[i,Ex({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(i))||void 0===t?void 0:t.markers)||ym.empty},initialSpacer:()=>new qS(t,!1),domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let r=DS(e.state,t.from,t.to);if(r)return e.dispatch({effects:AS.of(r)}),!0;let i=CS(e.state,t.from,t.to);return!!i&&(e.dispatch({effects:NS.of(i)}),!0)}}}),FS()]}()),!1!==e.drawSelection&&r.push(function(e={}){return[bw.of(e),ww,kw,Sw,gv.of(!0)]}()),!1!==e.dropCursor&&r.push([Cw,Ow]),!1!==e.allowMultipleSelections&&r.push(dm.allowMultipleSelections.of(!0)),!1!==e.indentOnInput&&r.push(dm.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+200)return e;let o=n.sliceString(i.from,r);if(!t.some(e=>e.test(o)))return e;let{state:s}=e,a=-1,l=[];for(let{head:e}of s.selection.ranges){let t=s.doc.lineAt(e);if(t.from==a)continue;a=t.from;let n=fS(s,t.from);if(null==n)continue;let r=/^\s*/.exec(t.text)[0],i=dS(s,n);r!=i&&l.push({from:t.from,to:t.from+r.length,insert:i})}return l.length?[e,{changes:l,sequential:!0}]:e})),!1!==e.syntaxHighlighting&&r.push(XS(ZS,{fallback:!0})),!1!==e.bracketMatching&&r.push(function(e={}){return[nE.of(e),aE]}()),!1!==e.closeBrackets&&r.push([UN,WN]),!1!==e.autocompletion&&r.push(function(e={}){return[BN,NN,cN.of(e),PN,tA,IN]}()),!1!==e.rectangularSelection&&r.push(function(e){let t=(null==e?void 0:e.eventFilter)||(e=>e.altKey&&0==e.button);return Jy.mouseSelectionStyle.of((e,n)=>t(n)?Hw(e,n):null)}()),!1!==t&&r.push(function(e={}){let[t,n]=Vw[e.key||"Alt"],r=Cv.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){e.keyCode!=t&&n(e)||this.set(!1)},mousemove(e){this.set(n(e))}}});return[r,Jy.contentAttributes.of(e=>{var t;return(null===(t=e.plugin(r))||void 0===t?void 0:t.isDown)?qw:null})]}()),!1!==e.highlightActiveLine&&r.push(_w),!1!==e.highlightSelectionMatches&&r.push(function(e){let t=[dO,uO];return e&&t.push(aO.of(e)),t}()),e.tabSize&&"number"==typeof e.tabSize&&r.push(hS.of(" ".repeat(e.tabSize))),r.concat([ow.of(n.flat())]).filter(Boolean)};const AA="#e06c75",TA="#abb2bf",MA="#7d8799",RA="#d19a66",DA="#2c313a",PA="#282c34",LA="#353a42",BA="#528bff",IA=[Jy.theme({"&":{color:TA,backgroundColor:PA},".cm-content":{caretColor:BA},".cm-cursor, .cm-dropCursor":{borderLeftColor:BA},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"#3E4451"},".cm-panels":{backgroundColor:"#21252b",color:TA},".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:PA,color:MA,border:"none"},".cm-activeLineGutter":{backgroundColor:DA},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:LA},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:LA,borderBottomColor:LA},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:DA,color:TA}}},{dark:!0}),XS($S.define([{tag:Uk.keyword,color:"#c678dd"},{tag:[Uk.name,Uk.deleted,Uk.character,Uk.propertyName,Uk.macroName],color:AA},{tag:[Uk.function(Uk.variableName),Uk.labelName],color:"#61afef"},{tag:[Uk.color,Uk.constant(Uk.name),Uk.standard(Uk.name)],color:RA},{tag:[Uk.definition(Uk.name),Uk.separator],color:TA},{tag:[Uk.typeName,Uk.className,Uk.number,Uk.changed,Uk.annotation,Uk.modifier,Uk.self,Uk.namespace],color:"#e5c07b"},{tag:[Uk.operator,Uk.operatorKeyword,Uk.url,Uk.escape,Uk.regexp,Uk.link,Uk.special(Uk.string)],color:"#56b6c2"},{tag:[Uk.meta,Uk.comment],color:MA},{tag:Uk.strong,fontWeight:"bold"},{tag:Uk.emphasis,fontStyle:"italic"},{tag:Uk.strikethrough,textDecoration:"line-through"},{tag:Uk.link,color:MA,textDecoration:"underline"},{tag:Uk.heading,fontWeight:"bold",color:AA},{tag:[Uk.atom,Uk.bool,Uk.special(Uk.variableName)],color:RA},{tag:[Uk.processingInstruction,Uk.string,Uk.inserted],color:"#98c379"},{tag:Uk.invalid,color:"#ffffff"}]))];var jA=Jy.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),_A=function(e){void 0===e&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:r=!1,theme:i="light",placeholder:o="",basicSetup:s=!0}=e,a=[];switch(t&&a.unshift(ow.of([XC])),s&&("boolean"==typeof s?a.unshift(NA()):a.unshift(NA(s))),o&&a.unshift(function(e){let t=Cv.fromClass(class{constructor(t){this.view=t,this.placeholder=e?dg.set([dg.widget({widget:new Fw(e),side:1}).range(0)]):dg.none}get decorations(){return this.view.state.doc.length?dg.none:this.placeholder}},{decorations:e=>e.decorations});return"string"==typeof e?[t,Jy.contentAttributes.of({"aria-placeholder":e})]:t}(o)),i){case"light":a.push(jA);break;case"dark":a.push(IA);break;case"none":break;default:a.push(i)}return!1===n&&a.push(Jy.editable.of(!1)),r&&a.push(dm.readOnly.of(!0)),[...a]};class FA{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(e=>{try{e()}catch(e){}})}}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 WA{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),0===this.latches.size&&this.stop()}start(){null===this.interval&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){null!==this.interval&&(clearInterval(this.interval),this.interval=null)}}var zA=null,HA=Jp.define(),VA=[];function qA(t){var{value:n,selection:r,onChange:i,onStatistics:o,onCreateEditor:s,onUpdate:a,extensions:l=VA,autoFocus:c,theme:h="light",height:u=null,minHeight:d=null,maxHeight:f=null,width:p=null,minWidth:m=null,maxWidth:g=null,placeholder:v="",editable:b=!0,readOnly:y=!1,indentWithTab:w=!0,basicSetup:x=!0,root:k,initialState:S}=t,[E,C]=e.useState(),[O,N]=e.useState(),[A,T]=e.useState(),M=e.useState(()=>({current:null}))[0],R=e.useState(()=>({current:null}))[0],D=Jy.theme({"&":{height:u,minHeight:d,maxHeight:f,width:p,minWidth:m,maxWidth:g},"& .cm-scroller":{height:"100% !important"}}),P=Jy.updateListener.of(e=>{if(e.docChanged&&"function"==typeof i&&!e.transactions.some(e=>e.annotation(HA))){M.current?M.current.reset():(M.current=new FA(()=>{if(R.current){var e=R.current;R.current=null,e()}M.current=null},200),("undefined"==typeof window?new WA:(zA||(zA=new WA),zA)).add(M.current));var t=e.state.doc.toString();i(t,e)}o&&o((e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)}))(e))}),L=[P,D,..._A({theme:h,editable:b,readOnly:y,placeholder:v,indentWithTab:w,basicSetup:x})];return a&&"function"==typeof a&&L.push(Jy.updateListener.of(a)),L=L.concat(l),e.useLayoutEffect(()=>{if(E&&!A){var e={doc:n,selection:r,extensions:L},t=S?dm.fromJSON(S.json,e,S.fields):dm.create(e);if(T(t),!O){var i=new Jy({state:t,parent:E,root:k});N(i),s&&s(i,t)}}return()=>{O&&(T(void 0),N(void 0))}},[E,A]),e.useEffect(()=>{t.container&&C(t.container)},[t.container]),e.useEffect(()=>()=>{O&&(O.destroy(),N(void 0)),M.current&&(M.current.cancel(),M.current=null)},[O]),e.useEffect(()=>{c&&O&&O.focus()},[c,O]),e.useEffect(()=>{O&&O.dispatch({effects:em.reconfigure.of(L)})},[h,l,u,d,f,p,m,g,v,b,y,w,x,i,a]),e.useEffect(()=>{if(void 0!==n){var e=O?O.state.doc.toString():"";if(O&&n!==e){var t=()=>{O&&n!==O.state.doc.toString()&&O.dispatch({changes:{from:0,to:O.state.doc.toString().length,insert:n||""},annotations:[HA.of(!0)]})};M.current&&!M.current.isDone?R.current=t:t()}}},[n,O]),{state:A,setState:T,view:O,setView:N,container:E,setContainer:C}}var UA=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],$A=e.forwardRef((n,r)=>{var{className:i,value:o="",selection:s,extensions:a=[],onChange:l,onStatistics:c,onCreateEditor:h,onUpdate:u,autoFocus:d,theme:f="light",height:p,minHeight:m,maxHeight:g,width:v,minWidth:b,maxWidth:y,basicSetup:w,placeholder:x,indentWithTab:k,editable:S,readOnly:E,root:C,initialState:O}=n,N=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(n,UA),A=e.useRef(null),{state:T,view:M,container:R,setContainer:D}=qA({root:C,value:o,autoFocus:d,theme:f,height:p,minHeight:m,maxHeight:g,width:v,minWidth:b,maxWidth:y,basicSetup:w,placeholder:x,indentWithTab:k,editable:S,readOnly:E,selection:s,onChange:l,onStatistics:c,onCreateEditor:h,onUpdate:u,extensions:a,initialState:O});e.useImperativeHandle(r,()=>({editor:A.current,state:T,view:M}),[A,R,T,M]);var P=e.useCallback(e=>{A.current=e,D(e)},[D]);if("string"!=typeof o)throw new Error("value must be typeof string but got "+typeof o);var L="string"==typeof f?"cm-theme-"+f:"cm-theme";return t.jsx("div",_f({ref:P,className:L+(i?" "+i:"")},N))});$A.displayName="CodeMirror";class KA{constructor(e,t,n,r,i,o,s,a,l,c=0,h){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=o,this.buffer=s,this.bufferBase=a,this.curContext=l,this.lookAhead=c,this.parent=h}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let r=e.parser.context;return new KA(e,[],t,n,n,0,[],0,r?new YA(r,r.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,r=65535&e,{parser:i}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),s=i.dynamicPrecedence(r);if(s&&(this.score+=s),0==n)return this.pushState(i.getGoto(this.state,r,!0),this.reducePos),r<i.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),void this.reduceContext(r,this.reducePos);let a=this.stack.length-3*(n-1)-(262144&e?6:0),l=a?this.stack[a-2]:this.p.ranges[0].from,c=this.reducePos-l;c>=2e3&&!(null===(t=this.p.parser.nodeSet.types[r])||void 0===t?void 0:t.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=l,this.p.lastBigReductionSize=c));let h=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-h;if(r<i.minRepeatTerm||131072&e){let e=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,l,e,u+4,!0)}if(262144&e)this.state=this.stack[a];else{let e=this.stack[a-3];this.state=i.getGoto(e,r,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(r,l)}storeNode(e,t,n,r=4,i=!1){if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this,r=this.buffer.length;if(0==r&&e.parent&&(r=e.bufferBase-e.parent.bufferBase,e=e.parent),r>0&&0==e.buffer[r-4]&&e.buffer[r-1]>-1){if(t==n)return;if(e.buffer[r-2]>=t)return void(e.buffer[r-2]=n)}}if(i&&this.pos!=n){let i=this.buffer.length;if(i>0&&(0!=this.buffer[i-4]||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}else this.buffer.push(e,t,n,r)}shift(e,t,n,r){if(131072&e)this.pushState(65535&e,this.pos);else if(262144&e)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:o}=this.p;this.pos=r;let s=o.stateFlag(i,1);!s&&(r>n||t<=o.maxNode)&&(this.reducePos=r),this.pushState(i,s?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){65536&e?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,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),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new KA(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,r,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 GA(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==n)return!1;if(!(65536&n))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 n=[];for(let r,i=0;i<t.length;i+=2)(r=t[i+1])!=this.state&&this.p.parser.hasAction(r,e)&&n.push(t[i],r);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>1&t&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(65536&t))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=65535&t,i=this.stack.length-3*n;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(null==e)return!1;t=e}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=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(393216&t);else if(65536&t){let n=(t>>19)-i;if(n>1){let r=65535&t,i=this.stack.length-3*n;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(null!=e)return e}})};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(3!=this.stack.length)return!1;let{parser:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!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||-3!=this.buffer[e])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||-4!=this.buffer[e])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new YA(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return!(e<=this.lookAhead)&&(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class YA{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class GA{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=65535&e,n=e>>19;0==n?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(n-1);let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}}class XA{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,0==this.index&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new XA(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(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,0==this.index&&this.maybeNext()}fork(){return new XA(this.stack,this.pos,this.index)}}function JA(e,t=Uint16Array){if("string"!=typeof e)return e;let n=null;for(let r=0,i=0;r<e.length;){let o=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(126==t){o=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),o+=i,n)break;o*=46}n?n[i++]=o:n=new t(o)}return n}class QA{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const ZA=new QA;class eT{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=ZA,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,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}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,n,r=this.chunkOff+e;if(r>=0&&r<this.chunk.length)t=this.pos+e,n=this.chunk.charCodeAt(r);else{let r=this.resolveOffset(e,1);if(null==r)return-1;if(t=r,t>=this.chunk2Pos&&t<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(t-this.chunk2Pos);else{let e=this.rangeIndex,r=this.range;for(;r.to<=t;)r=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=t),t+this.chunk2.length>r.to&&(this.chunk2=this.chunk2.slice(0,r.to-t)),n=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),n}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(null==n||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=ZA,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 r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}}class tT{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;!function(e,t,n,r,i,o){let s=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;0!=(a&e[s]);){let n=e[s+1];for(let r=s+3;r<n;r+=2)if((e[r+1]&a)>0){let n=e[r];if(l.allows(n)&&(-1==t.token.value||t.token.value==n||rT(n,t.token.value,i,o))){t.acceptToken(n);break}}let r=t.next,c=0,h=e[s+2];if(!(t.next<0&&h>c&&65535==e[n+3*h-3])){for(;c<h;){let i=c+h>>1,o=n+i+(i<<1),a=e[o],l=e[o+1]||65536;if(r<a)h=i;else{if(!(r>=l)){s=e[o+2],t.advance();continue e}c=i+1}}break}s=e[n+3*h-1]}}(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}function nT(e,t,n){for(let r,i=t;65535!=(r=e[i]);i++)if(r==n)return i-t;return-1}function rT(e,t,n,r){let i=nT(n,r,t);return i<0||nT(n,r,e)<i}tT.prototype.contextual=tT.prototype.fallback=tT.prototype.extend=!1,tT.prototype.fallback=tT.prototype.extend=!1;const iT="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let oT=null;function sT(e,t,n){let r=e.cursor(Qx.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}class aT{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?sT(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?sT(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],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],o=this.start[t]+n.positions[r];if(o>e)return this.nextStart=o,null;if(i instanceof Zx){if(o==e){if(o<this.safeFrom)return null;let e=o+i.length;if(e<=this.safeTo){let t=i.prop(Ux.lookAhead);if(!t||e+t<this.fragment.to)return i}}this.index[t]++,o+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+i.length}}}class lT{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new QA)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,o=r.stateSlot(e.state,3),s=e.curContext?e.curContext.hash:0,a=0;for(let r=0;r<i.length;r++){if(!(1<<r&o))continue;let l=i[r],c=this.tokens[r];if((!n||l.fallback)&&((l.contextual||c.start!=e.pos||c.mask!=o||c.context!=s)&&(this.updateCachedToken(c,l,e),c.mask=o,c.context=s),c.lookAhead>c.end+25&&(a=Math.max(c.lookAhead,a)),0!=c.value)){let r=t;if(c.extended>-1&&(t=this.addActions(e,c.extended,c.end,t)),t=this.addActions(e,c.value,c.end,t),!l.extend&&(n=c,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),n||e.pos!=this.stream.end||(n=new QA,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 QA,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){1&i?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:o}=e.p,{data:s}=o;for(let e=0;e<2;e++)for(let a=o.stateSlot(i,e?2:1);;a+=3){if(65535==s[a]){if(1!=s[a+1]){0==r&&2==s[a+1]&&(r=this.putAction(fT(s,a+2),t,n,r));break}a=fT(s,a+2)}s[a]==t&&(r=this.putAction(fT(s,a+1),t,n,r))}return r}}class cT{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,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 eT(t,r),this.tokens=new lT(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[KA.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>4*e.bufferLength?new aT(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e,t,n=this.stacks,r=this.minStackPos,i=this.stacks=[];if(this.bigReductionCount>300&&1==n.length){let[e]=n;for(;e.forceReduce()&&e.stack.length&&e.stack[e.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<n.length;o++){let s=n[o];for(;;){if(this.tokens.mainToken=null,s.pos>r)i.push(s);else{if(this.advanceStack(s,i,n))continue;{e||(e=[],t=[]),e.push(s);let n=this.tokens.getMainToken(s);t.push(n.value,n.end)}}break}}if(!i.length){let t=e&&function(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||null!=e&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}(e);if(t)return this.stackToTree(t);if(this.parser.strict)throw new SyntaxError("No parse at "+r);this.recovering||(this.recovering=5)}if(this.recovering&&e){let n=null!=this.stoppedAt&&e[0].pos>this.stoppedAt?e[0]:this.runRecovery(e,t,i);if(n)return this.stackToTree(n.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(i.length>e)for(i.sort((e,t)=>t.score-e.score);i.length>e;)i.pop();i.some(e=>e.reducePos>r)&&this.recovering--}else if(i.length>1){e:for(let e=0;e<i.length-1;e++){let t=i[e];for(let n=e+1;n<i.length;n++){let r=i[n];if(t.sameState(r)||t.buffer.length>500&&r.buffer.length>500){if(!((t.score-r.score||t.buffer.length-r.buffer.length)>0)){i.splice(e--,1);continue e}i.splice(n--,1)}}}i.length>12&&(i.sort((e,t)=>t.score-e.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let e=1;e<i.length;e++)i[e].pos<this.minStackPos&&(this.minStackPos=i[e].pos);return null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let r=e.pos,{parser:i}=this;iT&&this.stackID(e);if(null!=this.stoppedAt&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(r);o;){let r=this.parser.nodeSet.types[o.type.id]==o.type?i.getGoto(e.state,o.type.id):-1;if(r>-1&&o.length&&(!t||(o.prop(Ux.contextHash)||0)==n))return e.useNode(o,r),!0;if(!(o instanceof Zx)||0==o.children.length||o.positions[0]>0)break;let s=o.children[0];if(!(s instanceof Zx&&0==o.positions[0]))break;o=s}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let i=0;i<s.length;){let o=s[i++],a=s[i++],l=s[i++],c=i==s.length||!n,h=c?e:e.split(),u=this.tokens.mainToken;if(h.apply(o,a,u?u.start:h.pos,l),c)return!0;h.pos>r?t.push(h):n.push(h)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return hT(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=t[o<<1],l=t[1+(o<<1)],c=iT?this.stackID(s)+" -> ":"";if(s.deadEnd){if(i)continue;if(i=!0,s.restart(),this.advanceFully(s,n))continue}let h=s.split(),u=c;for(let e=0;e<10&&h.forceReduce();e++){if(this.advanceFully(h,n))break;iT&&(u=this.stackID(h)+" -> ")}for(let e of s.recoverByInsert(a))this.advanceFully(e,n);this.stream.end>s.pos?(l==s.pos&&(l++,a=0),s.recoverByDelete(a,l),hT(s,n)):(!r||r.score<h.score)&&(r=h)}return r}stackToTree(e){return e.close(),Zx.build({buffer:XA.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=(oT||(oT=new WeakMap)).get(e);return t||oT.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function hT(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e))return void(t[n].score<e.score&&(t[n]=e))}t.push(e)}class uT{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||0==this.disabled[e]}}class dT extends bk{constructor(e){if(super(),this.wrappers=[],14!=e.version)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push("");let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<t.length;e++)r.push([]);function i(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];"string"==typeof e&&(e=Ux[e]);for(let n=1;n<t.length;){let r=t[n++];if(r>=0)i(r,e,t[n++]);else{let o=t[n+-r];for(let s=-r;s>0;s--)i(t[n++],e,o);n++}}}this.nodeSet=new Gx(t.map((t,i)=>Yx.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:0==i,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Hx;let o=JA(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(pT),this.states=JA(e.states,Uint32Array),this.data=JA(e.stateData),this.goto=JA(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>"number"==typeof e?new tT(o,e):e),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 r=new cT(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],o=1&t,s=r[i++];if(o&&n)return s;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return s;if(o)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i,o=this.stateSlot(e,r?2:1);;o+=3){if(65535==(i=n[o])){if(1!=n[o+1]){if(2==n[o+1])return fT(n,o+2);break}i=n[o=fT(n,o+2)]}if(i==t||0==i)return fT(n,o+1)}return 0}stateSlot(e,t){return this.states[6*e+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);null==r;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=fT(this.data,n+2)}r=t(fT(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(65535==this.data[n]){if(1!=this.data[n+1])break;n=fT(this.data,n+2)}if(!(1&this.data[n+2])){let e=this.data[n+1];t.some((t,n)=>1&n&&t==e)||t.push(this.data[n],e)}}return t}configure(e){let t=Object.assign(Object.create(dT.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(t=>{let n=e.tokenizers.find(e=>e.from==t);return n?n.to:t})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,r)=>{let i=e.specializers.find(e=>e.from==n.external);if(!i)return n;let o=Object.assign(Object.assign({},n),{external:i.to});return t.specializers[r]=pT(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),null!=e.strict&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),null!=e.bufferLength&&(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 null==t?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 e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n,i=this.dialects[t[e]];65535!=(n=this.data[i++]);)(r||(r=new Uint8Array(this.maxTerm+1)))[n]=1;return new uT(e,n,r)}static deserialize(e){return new dT(e)}}function fT(e,t){return e[t]|e[t+1]<<16}function pT(e){if(e.external){let t=e.extend?1:0;return(n,r)=>e.external(n,r)<<1|t}return e.get}const mT=Ek({String:Uk.string,Number:Uk.number,"True False":Uk.bool,PropertyName:Uk.propertyName,Null:Uk.null,", :":Uk.separator,"[ ]":Uk.squareBracket,"{ }":Uk.brace}),gT=dT.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:[mT],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}),vT=Jk.define({name:"json",parser:gT.configure({props:[mS.add({Object:xS({except:/^\s*\}/}),Array:xS({except:/^\s*\]/})}),SS.add({"Object Array":function(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function bT(e){return yT.apply(this,arguments)}function yT(){return yT=h(f().m(function e(t){var n,r;return f().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return e.a(2);case 1:if(!(null===(n=null===navigator||void 0===navigator?void 0:navigator.clipboard)||void 0===n?void 0:n.writeText)){e.n=3;break}return e.n=2,navigator.clipboard.writeText(t);case 2:return e.a(2);case 3:(r=document.createElement("textarea")).value=t,r.style.position="fixed",r.style.left="-9999px",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r);case 4:return e.a(2)}},e)})),yT.apply(this,arguments)}function wT(e){var t=e.value,n=e.title;if(null==t||""===t)return s.createElement("span",null,"-");var r,i=If(t),o=i.ok,a=i.pretty,l=i.compact,c=l.length>80?l.slice(0,80)+"…":l;return s.createElement(cf,null,s.createElement(hf,{asChild:!0},s.createElement("button",{type:"button",className:"max-w-xs truncate text-left font-mono text-xs text-muted-foreground hover:underline",title:"点击查看 JSON"},c)),s.createElement(ff,{className:"max-w-3xl"},s.createElement(pf,null,s.createElement(gf,null,n||"JSON")),s.createElement("div",{className:"flex items-center justify-end gap-2"},s.createElement(at,{variant:"outline",size:"sm",onClick:(r=h(f().m(function e(){return f().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,bT(a);case 1:Fa.success("已复制 JSON"),e.n=3;break;case 2:e.p=2,e.v,Fa.error("复制失败");case 3:return e.a(2)}},e,null,[[0,2]])})),function(){return r.apply(this,arguments)})},"复制")),s.createElement("pre",{className:"max-h-[60vh] overflow-auto rounded-md bg-muted p-3 text-xs font-mono whitespace-pre-wrap break-all"},a),!o&&s.createElement("div",{className:"text-xs text-destructive"},i.ok?"":i.message)))}function xT(e){e.id;var t=e.value;e.required;var n,r=e.disabled,i=e.onChange,o=m(s.useState(null),2),a=o[0],l=o[1];return s.createElement("div",{className:"space-y-2"},s.createElement("div",{className:"flex items-center justify-end gap-2"},s.createElement(at,{type:"button",variant:"outline",size:"sm",disabled:!!r,onClick:function(){if(!r){var e=(t||"").trim();if(e){var n=jf(e,2);n.ok?(i(n.formatted),l(null)):l(n.message)}}}},"格式化"),s.createElement(at,{type:"button",variant:"outline",size:"sm",onClick:(n=h(f().m(function e(){return f().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,bT(t||"");case 1:Fa.success("已复制"),e.n=3;break;case 2:e.p=2,e.v,Fa.error("复制失败");case 3:return e.a(2)}},e,null,[[0,2]])})),function(){return n.apply(this,arguments)})},"复制")),s.createElement("div",{className:"w-full max-w-full overflow-hidden rounded-md border bg-background"},s.createElement($A,{className:"w-full max-w-full",editable:!r,value:t||"",height:"220px",basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0},extensions:[new lS(vT),Jy.lineWrapping],onChange:function(e){r||(i(e),function(e){var t=(e||"").trim();if(!t)return l(null),!0;var n=If(t);n.ok?l(null):l(n.message)}(e))}})),a&&s.createElement("div",{className:"text-xs text-destructive"},a))}var kT=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("div",{className:"relative w-full overflow-x-auto"},s.createElement("table",Object.assign({ref:t,className:qe("w-full min-w-max caption-bottom text-sm",n)},r)))});kT.displayName="Table";var ST=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("thead",Object.assign({ref:t,className:qe("[&_tr]:border-b",n)},r))});ST.displayName="TableHeader";var ET=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("tbody",Object.assign({ref:t,className:qe("[&_tr:last-child]:border-0",n)},r))});ET.displayName="TableBody";var CT=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("tfoot",Object.assign({ref:t,className:qe("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",n)},r))});CT.displayName="TableFooter";var OT=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("tr",Object.assign({ref:t,className:qe("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",n)},r))});OT.displayName="TableRow";var NT=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("th",Object.assign({ref:t,className:qe("h-12 px-4 text-left align-middle font-medium text-muted-foreground whitespace-nowrap [&:has([role=checkbox])]:pr-0",n)},r))});NT.displayName="TableHead";var AT=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("td",Object.assign({ref:t,className:qe("p-4 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",n)},r))});AT.displayName="TableCell";var TT=s.forwardRef(function(e,t){var n=e.className,r=G(e,["className"]);return s.createElement("caption",Object.assign({ref:t,className:qe("mt-4 text-sm text-muted-foreground",n)},r))});TT.displayName="TableCaption";var MT=ot("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function RT(e){var t=e.className,n=e.variant,r=G(e,["className","variant"]);return s.createElement("div",Object.assign({className:qe(MT({variant:n}),t)},r))}function DT(){return"".concat(Date.now(),"_").concat(Math.random().toString(16).slice(2))}function PT(e){return"integer"===e||"float"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"gt",label:"大于"},{value:"gte",label:"大于等于"},{value:"lt",label:"小于"},{value:"lte",label:"小于等于"},{value:"in",label:"属于(多个)"},{value:"isNull",label:"为空(NULL)"}]:"boolean"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"isNull",label:"为空(NULL)"}]:"date"===e||"datetime"===e?[{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"gt",label:"晚于/大于"},{value:"gte",label:"晚于等于/大于等于"},{value:"lt",label:"早于/小于"},{value:"lte",label:"早于等于/小于等于"},{value:"isNull",label:"为空(NULL)"}]:[{value:"contains",label:"包含"},{value:"startsWith",label:"开头是"},{value:"endsWith",label:"结尾是"},{value:"eq",label:"等于"},{value:"neq",label:"不等于"},{value:"in",label:"属于(多个)"},{value:"isNull",label:"为空(NULL)"}]}function LT(t){var n,r,i=e.useMemo(function(){var e=[];e.push.apply(e,g([{column:"id",label:"ID",type:"id"},{column:"created_at",label:"创建时间",type:"datetime"},{column:"updated_at",label:"更新时间",type:"datetime"}]));var n,r=u(t.fields||[]);try{for(r.s();!(n=r.n()).done;){var i=n.value;if((null==i?void 0:i.name)&&("json"!==i.type&&"jsonb"!==i.type))if("relation"===i.type&&i.relation){var o=i.relation.foreignKey||"".concat(i.relation.target,"_id");e.push({column:o,label:"".concat(i.comment||i.name,"(关联)"),type:"relation"})}else e.push({column:i.name,label:i.comment||i.name,type:i.type})}}catch(e){r.e(e)}finally{r.f()}var s=new Set;return e.filter(function(e){return!s.has(e.column)&&(s.add(e.column),!0)})},[t.fields]),o=e.useMemo(function(){return new Map(i.map(function(e){return[e.column,e]}))},[i]),s=e.useMemo(function(){return new Map(i.map(function(e){return[e.column,e.type]}))},[i]),a=m(e.useState([]),2),l=a[0],c=a[1];e.useEffect(function(){c(function(e,t){return(e||[]).map(function(e){if(t.get(e.column),"is"===e.operator&&(null===e.value||"null"===e.value))return{id:DT(),column:e.column,operator:"isNull",value:""};if(("ilike"===e.operator||"like"===e.operator)&&"string"==typeof e.value){var n=e.value;if(n.startsWith("%")&&n.endsWith("%")&&n.length>=2)return{id:DT(),column:e.column,operator:"contains",value:n.slice(1,-1)};if(n.endsWith("%"))return{id:DT(),column:e.column,operator:"startsWith",value:n.slice(0,-1)};if(n.startsWith("%"))return{id:DT(),column:e.column,operator:"endsWith",value:n.slice(1)}}if("in"===e.operator){var r=Array.isArray(e.value)?e.value:[];return{id:DT(),column:e.column,operator:"in",value:r.join(",")}}return{id:DT(),column:e.column,operator:["eq","neq","gt","gte","lt","lte"].includes(e.operator)?e.operator:"eq",value:void 0===e.value||null===e.value?"":String(e.value)}})}(t.value||[],s))},[JSON.stringify(t.value),i.length]);var h=function(e,t){c(function(n){return n.map(function(n){var r,i;if(n.id!==e)return n;var s=Object.assign(Object.assign({},n),t);if(t.column&&t.column!==n.column){var a=PT((null===(r=o.get(t.column))||void 0===r?void 0:r.type)||"string");s.operator=(null===(i=a[0])||void 0===i?void 0:i.value)||"eq",s.value=""}return t.operator&&"isNull"===t.operator&&(s.value=""),s})})};return e.createElement("div",{className:"space-y-3"},e.createElement("div",{className:"flex items-center justify-between gap-3"},e.createElement(ya,{className:"text-base font-medium flex items-center gap-2"},e.createElement(R,{className:"h-4 w-4"}),"动态筛选"),e.createElement("div",{className:"flex items-center gap-2"},(null===(n=t.value)||void 0===n?void 0:n.length)>0&&e.createElement(RT,{variant:"secondary"},"已应用 ",t.value.length," 条"),e.createElement(at,{type:"button",variant:"outline",size:"sm",onClick:function(){var e=i[0];if(e){var t=PT(e.type);c(function(n){var r;return[].concat(g(n),[{id:DT(),column:e.column,operator:(null===(r=t[0])||void 0===r?void 0:r.value)||"eq",value:""}])})}}},e.createElement(F,{className:"h-4 w-4 mr-1"}),"添加条件"))),0===l.length?e.createElement("div",{className:"text-sm text-muted-foreground border rounded-lg p-3 bg-muted/20"},"暂无筛选条件(可添加条件后点击“应用”)"):e.createElement("div",{className:"space-y-2"},l.map(function(t){var n=o.get(t.column),r=(null==n?void 0:n.type)||"string",s=PT(r),a="isNull"!==t.operator;return e.createElement("div",{key:t.id,className:"grid grid-cols-12 gap-2 items-center"},e.createElement("div",{className:"col-span-5"},e.createElement(Bd,{value:t.column,onValueChange:function(e){return h(t.id,{column:e})}},e.createElement(jd,{className:"h-10"},e.createElement(Id,{placeholder:"字段"})),e.createElement(Wd,null,i.map(function(t){return e.createElement(Hd,{key:t.column,value:t.column},t.label," (",t.column,")")})))),e.createElement("div",{className:"col-span-3"},e.createElement(Bd,{value:t.operator,onValueChange:function(e){return h(t.id,{operator:e})}},e.createElement(jd,{className:"h-10"},e.createElement(Id,{placeholder:"操作符"})),e.createElement(Wd,null,s.map(function(t){return e.createElement(Hd,{key:t.value,value:t.value},t.label)})))),e.createElement("div",{className:"col-span-3"},a?"boolean"===r?e.createElement(Bd,{value:t.value,onValueChange:function(e){return h(t.id,{value:e})}},e.createElement(jd,{className:"h-10"},e.createElement(Id,{placeholder:"值"})),e.createElement(Wd,null,e.createElement(Hd,{value:"true"},"true"),e.createElement(Hd,{value:"false"},"false"))):e.createElement(lt,{className:"h-10",placeholder:"in"===t.operator?"多个值用逗号分隔":"值",type:"integer"===r||"float"===r?"number":"date"===r?"date":"datetime"===r?"datetime-local":"text",value:t.value,onChange:function(e){return h(t.id,{value:e.target.value})}}):e.createElement("div",{className:"h-10 flex items-center text-sm text-muted-foreground"},"无需填写")),e.createElement("div",{className:"col-span-1 flex justify-end"},e.createElement(at,{type:"button",variant:"ghost",size:"sm",className:"h-9 w-9 p-0",onClick:function(){return e=t.id,void c(function(t){return t.filter(function(t){return t.id!==e})});var e}},e.createElement(K,{className:"h-4 w-4"}))))})),e.createElement("div",{className:"flex items-center justify-end gap-2"},e.createElement(at,{type:"button",variant:"outline",onClick:function(){c([]),t.onChange([])},disabled:0===l.length&&0===((null===(r=t.value)||void 0===r?void 0:r.length)||0)},"清空"),e.createElement(at,{type:"button",onClick:function(){var e=function(e,t){var n,r,i=[],o=u(e);try{for(o.s();!(r=o.n()).done;){var s=r.value,a=t.get(s.column);if(a&&s.operator)if("isNull"!==s.operator){var l=null!==(n=s.value)&&void 0!==n?n:"",c=String(l).trim();if(c)if("contains"!==s.operator)if("startsWith"!==s.operator)if("endsWith"!==s.operator)if("in"!==s.operator)i.push({column:a.column,operator:s.operator,value:c});else{var h=c.split(",").map(function(e){return e.trim()}).filter(Boolean);i.push({column:a.column,operator:"in",value:h})}else i.push({column:a.column,operator:"ilike",value:"%".concat(c)});else i.push({column:a.column,operator:"ilike",value:"".concat(c,"%")});else i.push({column:a.column,operator:"ilike",value:"%".concat(c,"%")})}else i.push({column:a.column,operator:"is",value:null})}}catch(e){o.e(e)}finally{o.f()}return i}(l,o);t.onChange(e)},disabled:0===l.length},"应用")))}function BT(){var t,n=m(e.useState([]),2),r=n[0],o=n[1],s=m(e.useState(null),2),a=s[0],l=s[1],c=m(e.useState([]),2),u=c[0],p=c[1],g=m(e.useState(!1),2),v=g[0],b=g[1],y=m(e.useState(!1),2),w=y[0],x=y[1],k=m(e.useState(null),2),S=k[0],E=k[1],N=m(e.useState({}),2),A=N[0],T=N[1],M=m(e.useState(1),2),D=M[0],P=M[1],B=m(e.useState(10),2),I=B[0];B[1];var j=m(e.useState(0),2),_=j[0],z=j[1],V=m(e.useState(""),2),U=V[0],$=V[1],K=m(e.useState(!1),2),Y=K[0],G=K[1],X=m(e.useState(null),2),J=X[0],Q=X[1],Z=m(e.useState(!0),2),ee=Z[0],te=Z[1],ne=m(e.useState([]),2),re=ne[0],ie=ne[1],oe=m(e.useState(!1),2),se=oe[0],ae=oe[1],le=function(e){return Array.isArray(e)?e:Array.isArray(null==e?void 0:e.models)?e.models:Array.isArray(null==e?void 0:e.data)?e.data:Array.isArray(null==e?void 0:e.items)?e.items:[]},ce=function(e){var t;if(e&&Array.isArray(e.data)){var n="number"==typeof e.total?e.total:"number"==typeof(null===(t=e.pagination)||void 0===t?void 0:t.total)?e.pagination.total:e.data.length;return{rows:e.data,total:n}}if(e&&Array.isArray(e.rows)){var r="number"==typeof e.total?e.total:e.rows.length;return{rows:e.rows,total:r}}return Array.isArray(e)?{rows:e,total:e.length}:{rows:[],total:0}},he=function(e){return!e||!e.readOnly&&!1!==e.editable};e.useEffect(function(){ue()},[]),e.useEffect(function(){a&&de()},[a,D,I,U,re]);var ue=function(){var e=h(f().m(function e(){var t;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:return te(!0),e.p=1,e.n=2,ah();case 2:t=e.v,o(le(t.data)),e.n=4;break;case 3:e.p=3,e.v,Fa.error("加载模型列表失败");case 4:return e.p=4,te(!1),e.f(4);case 5:return e.a(2)}},e,null,[[1,3,4,5]])}));return function(){return e.apply(this,arguments)}}(),de=function(){var e=h(f().m(function e(){var t,n,r;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(a){e.n=1;break}return e.a(2);case 1:return b(!0),e.p=2,t={page:D,limit:I},U&&(t.search=U),re.length>0&&(t.filters=re),e.n=3,gh(a.table_name,t);case 3:if((n=e.v).success){e.n=4;break}return Fa.error(n.message||"加载数据失败"),p([]),z(0),e.a(2);case 4:r=ce(n.data),p(r.rows),z(r.total),e.n=6;break;case 5:e.p=5,e.v,Fa.error("加载数据失败"),p([]),z(0);case 6:return e.p=6,b(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}(),fe=function(){var e=h(f().m(function e(t){var n;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("确定要删除这条数据吗?此操作不可撤销。")){e.n=1;break}return e.a(2);case 1:return Q(t.id),e.p=2,e.n=3,wh(null==a?void 0:a.table_name,t.id);case 3:(n=e.v).success?(Fa.success("删除成功"),de()):Fa.error(n.message||"删除失败"),e.n=5;break;case 4:e.p=4,e.v,Fa.error("删除失败");case 5:return e.p=5,Q(null),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),pe=function(){var e=h(f().m(function e(){var t,n,r,i,o;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(a){e.n=1;break}return e.a(2);case 1:if(G(!0),e.p=2,t={},a.json_schema.fields.forEach(function(e){if("id"!==e.name&&he(e)){var n=A[e.name];if("date"!==e.type&&"datetime"!==e.type||(n=n?new Date(n).toISOString():null),"json"===e.type||"jsonb"===e.type){var r=(n||"").toString().trim();if(r){var i=If(r);if(!i.ok)throw new Error("字段 ".concat(e.comment||e.name,":").concat(i.message));n=i.value}else n=null}t[e.name]=n}}),!S){e.n=4;break}return e.n=3,yh(a.table_name,Object.assign(Object.assign({},t),{id:S.id}));case 3:(n=e.v).success?(Fa.success("更新成功"),x(!1),de()):Fa.error(n.message||"更新失败"),e.n=6;break;case 4:return e.n=5,bh(a.table_name,t);case 5:(r=e.v).success?(Fa.success("创建成功"),x(!1),de()):Fa.error(r.message||"创建失败");case 6:e.n=8;break;case 7:e.p=7,o=e.v,i=o instanceof Error?o.message:"操作失败",Fa.error(i);case 8:return e.p=8,G(!1),e.f(8);case 9:return e.a(2)}},e,null,[[2,7,8,9]])}));return function(){return e.apply(this,arguments)}}();return e.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},e.createElement("div",{className:"container mx-auto px-6 py-8 space-y-6"},e.createElement("div",{className:"space-y-2"},e.createElement("h1",{className:"text-3xl font-bold tracking-tight"},"数据列表"),e.createElement("p",{className:"text-muted-foreground"},"选择模型查看和管理数据")),e.createElement(wa,{className:"border-2 shadow-lg"},e.createElement(xa,{className:"bg-muted/30"},e.createElement("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4"},e.createElement("div",null,e.createElement(ka,null,"数据管理"),e.createElement(Sa,null,"选择数据模型进行查看和管理")),a&&e.createElement(at,{onClick:function(){E(null),T({}),x(!0)},className:"w-full md:w-auto"},e.createElement(F,{className:"h-4 w-4 mr-2"}),"新建数据"))),e.createElement(Ea,{className:"space-y-6 pt-6"},e.createElement("div",{className:"flex flex-col md:flex-row gap-4"},e.createElement("div",{className:"flex-1 space-y-2"},e.createElement(ya,{htmlFor:"model",className:"text-base font-medium flex items-center gap-2"},e.createElement(R,{className:"h-4 w-4"}),"选择数据模型"),e.createElement(Bd,{value:(null===(t=null==a?void 0:a.id)||void 0===t?void 0:t.toString())||"",onValueChange:function(e){var t=r.find(function(t){return t.id.toString()===e});l(t||null),P(1),$(""),ie([])},disabled:ee},e.createElement(jd,{className:"h-11"},ee?e.createElement("div",{className:"flex items-center gap-2"},e.createElement(L,{className:"h-4 w-4 animate-spin"}),e.createElement("span",null,"加载中...")):e.createElement(Id,{placeholder:"请选择模型"})),e.createElement(Wd,null,r.map(function(t){return e.createElement(Hd,{key:t.id,value:t.id.toString()},t.name," (",t.table_name,")")})))),a&&e.createElement("div",{className:"flex-1 space-y-2"},e.createElement(ya,{htmlFor:"search",className:"text-base font-medium flex items-center gap-2"},e.createElement(W,{className:"h-4 w-4"}),"搜索"),e.createElement("div",{className:"relative"},e.createElement(W,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.createElement(lt,{id:"search",placeholder:"搜索数据...",value:U,onChange:function(e){return $(e.target.value)},className:"pl-10 h-11"})))),a&&e.createElement(e.Fragment,null,e.createElement("div",{className:"flex items-center justify-end"},e.createElement(at,{type:"button",variant:"outline",className:"h-10",onClick:function(){return ae(!0)}},e.createElement(R,{className:"h-4 w-4 mr-2"}),"筛选",re.length>0?"(".concat(re.length,")"):"")),e.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},e.createElement("div",{className:"text-sm text-muted-foreground"},"共 ",e.createElement("span",{className:"font-semibold text-foreground"},_)," 条数据"),e.createElement(RT,{variant:"outline"},a.name)),e.createElement("div",{className:"rounded-lg border overflow-hidden"},e.createElement("div",{className:"overflow-x-auto"},e.createElement(kT,null,e.createElement(ST,null,e.createElement(OT,{className:"bg-muted/50"},e.createElement(NT,{className:"font-semibold w-20"},"ID"),a.json_schema.fields.map(function(t){return e.createElement(NT,{key:t.name,className:"font-semibold"},t.comment||t.name)}),e.createElement(NT,{className:"font-semibold"},"创建时间"),e.createElement(NT,{className:"font-semibold"},"更新时间"),e.createElement(NT,{className:"font-semibold w-32 text-center"},"操作"))),e.createElement(ET,null,v?Array.from({length:3}).map(function(t,n){return e.createElement(OT,{key:n},e.createElement(AT,{colSpan:a.json_schema.fields.length+4},e.createElement("div",{className:"flex items-center gap-2 py-4"},e.createElement(L,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.createElement("span",{className:"text-sm text-muted-foreground"},"加载中..."))))}):0===u.length?e.createElement(OT,null,e.createElement(AT,{colSpan:a.json_schema.fields.length+4,className:"text-center py-12"},e.createElement("div",{className:"flex flex-col items-center gap-2 text-muted-foreground"},e.createElement(W,{className:"h-8 w-8"}),e.createElement("p",null,"暂无数据")))):u.map(function(t,n){return e.createElement(OT,{key:t.id,className:n%2==0?"bg-muted/20":""},e.createElement(AT,{className:"font-mono font-medium"},t.id),a.json_schema.fields.map(function(n){return e.createElement(AT,{key:n.name},function(t,n){return"boolean"===t.type?e.createElement(RT,{variant:n?"default":"secondary"},n?"是":"否"):"date"===t.type||"datetime"===t.type?n?i(n).format("YYYY-MM-DD HH:mm:ss"):"-":"text"===t.type&&n&&n.length>50?e.createElement("span",{className:"max-w-xs truncate block",title:n},n.substring(0,50),"..."):"json"===t.type||"jsonb"===t.type?e.createElement(wT,{value:n,title:t.comment||t.name}):n||"-"}(n,t[n.name]))}),e.createElement(AT,{className:"text-sm text-muted-foreground"},i(t.created_at).format("YYYY-MM-DD HH:mm")),e.createElement(AT,{className:"text-sm text-muted-foreground"},i(t.updated_at).format("YYYY-MM-DD HH:mm")),e.createElement(AT,null,e.createElement("div",{className:"flex items-center justify-center gap-2"},e.createElement(at,{variant:"ghost",size:"sm",onClick:function(){return function(e){E(e);var t={};null==a||a.json_schema.fields.forEach(function(n){if("id"!==n.name){var r=e[n.name];"date"!==n.type&&"datetime"!==n.type||(r=r?i(r).format("YYYY-MM-DDTHH:mm"):""),"json"!==n.type&&"jsonb"!==n.type||(r=null==r||""===r?"":"string"==typeof r?r:JSON.stringify(r,null,2)),t[n.name]=r}}),T(t),x(!0)}(t)},className:"h-8 w-8 p-0"},e.createElement(H,{className:"h-4 w-4"})),e.createElement(at,{variant:"ghost",size:"sm",onClick:function(){return fe(t)},disabled:J===t.id,className:"h-8 w-8 p-0 text-destructive hover:text-destructive"},J===t.id?e.createElement(L,{className:"h-4 w-4 animate-spin"}):e.createElement(q,{className:"h-4 w-4"})))))}))))),_>I&&e.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},e.createElement("div",{className:"text-sm text-muted-foreground"},"第 ",e.createElement("span",{className:"font-semibold text-foreground"},D)," 页, 共 ",e.createElement("span",{className:"font-semibold text-foreground"},Math.ceil(_/I))," 页"),e.createElement("div",{className:"flex gap-2"},e.createElement(at,{variant:"outline",size:"sm",onClick:function(){return P(Math.max(1,D-1))},disabled:1===D||v},e.createElement(C,{className:"h-4 w-4 mr-1"}),"上一页"),e.createElement(at,{variant:"outline",size:"sm",onClick:function(){return P(Math.min(Math.ceil(_/I),D+1))},disabled:D>=Math.ceil(_/I)||v},"下一页",e.createElement(O,{className:"h-4 w-4 ml-1"}))))))),a&&e.createElement(cf,{open:se,onOpenChange:ae},e.createElement(ff,{className:"max-w-3xl"},e.createElement(pf,null,e.createElement(gf,{className:"text-xl"},"筛选"),e.createElement(bf,{className:"text-sm"},a.name," - ",a.table_name)),e.createElement("div",{className:"py-2"},e.createElement(LT,{fields:a.json_schema.fields,value:re,onChange:function(e){ie(e),P(1)}})),e.createElement(mf,{className:"gap-2"},e.createElement(at,{variant:"outline",onClick:function(){return ae(!1)}},"关闭")))),e.createElement(cf,{open:w,onOpenChange:x},e.createElement(ff,{className:"max-w-3xl max-h-[85vh] overflow-y-auto"},e.createElement(pf,null,e.createElement(gf,{className:"text-2xl"},S?"编辑数据":"新建数据"),e.createElement(bf,{className:"text-base"},null==a?void 0:a.name," - ",null==a?void 0:a.table_name)),e.createElement("div",{className:"space-y-4 py-4"},null==a?void 0:a.json_schema.fields.map(function(t){return function(t){if("id"===t.name)return null;var n=he(t);switch(t.type){case"boolean":return e.createElement("div",{key:t.name,className:"flex items-center space-x-3 p-4 rounded-lg border bg-card"},e.createElement(af,{id:t.name,checked:A[t.name]||!1,disabled:!n,onCheckedChange:function(e){return T(Object.assign(Object.assign({},A),d({},t.name,e)))}}),e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium cursor-pointer"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")));case"date":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lt,{id:t.name,type:"date",value:A[t.name]||"",disabled:!n,onChange:function(e){return T(Object.assign(Object.assign({},A),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"datetime":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lt,{id:t.name,type:"datetime-local",value:A[t.name]||"",disabled:!n,onChange:function(e){return T(Object.assign(Object.assign({},A),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"text":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lf,{id:t.name,rows:4,value:A[t.name]||"",disabled:!n,onChange:function(e){return T(Object.assign(Object.assign({},A),d({},t.name,e.target.value)))},required:t.required,className:"resize-none"}));case"json":case"jsonb":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(xT,{id:t.name,value:A[t.name]||"",required:t.required,disabled:!n,onChange:function(e){return T(Object.assign(Object.assign({},A),d({},t.name,e)))}}));case"integer":case"float":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lt,{id:t.name,type:"number",value:A[t.name]||"",disabled:!n,onChange:function(e){return T(Object.assign(Object.assign({},A),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));default:return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lt,{id:t.name,type:"email"===t.type?"email":"text",maxLength:t.maxLength,value:A[t.name]||"",disabled:!n,onChange:function(e){return T(Object.assign(Object.assign({},A),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}))}}(t)})),e.createElement(mf,{className:"gap-2"},e.createElement(at,{variant:"outline",onClick:function(){return x(!1)},disabled:Y},"取消"),e.createElement(at,{onClick:pe,disabled:Y},Y?e.createElement(e.Fragment,null,e.createElement(L,{className:"h-4 w-4 mr-2 animate-spin"}),S?"更新中...":"创建中..."):S?"更新":"创建"))))))}function IT(e){return/^https?:\/\//i.test(e)}function jT(t){var n=t.url;return e.createElement("div",{className:"flex items-center gap-2 max-w-[360px]"},e.createElement(Xs,null,e.createElement(Js,{asChild:!0},e.createElement("a",{href:n,target:"_blank",rel:"noreferrer",className:"inline-flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded border bg-muted",title:"点击打开原图"},e.createElement("img",{src:n,alt:"",className:"h-full w-full object-cover",onError:function(e){e.currentTarget.style.display="none"}}))),e.createElement(Qs,{side:"right",className:"p-2"},e.createElement("img",{src:n,alt:"",className:"max-h-64 max-w-64 rounded object-contain",onError:function(e){e.currentTarget.style.display="none"}}))),e.createElement("a",{href:n,target:"_blank",rel:"noreferrer",className:"truncate text-primary underline-offset-2 hover:underline",title:n},n))}function _T(t){var n=t.model,r=m(e.useState([]),2),o=r[0],s=r[1],a=m(e.useState(!1),2),l=a[0],c=a[1],u=m(e.useState(!1),2),p=u[0],g=u[1],v=m(e.useState(!1),2),b=v[0],y=v[1],w=m(e.useState(null),2),x=w[0],k=w[1],S=m(e.useState({}),2),E=S[0],N=S[1],A=m(e.useState(1),2),M=A[0],D=A[1],P=m(e.useState(10),2),B=P[0];P[1];var I=m(e.useState(0),2),j=I[0],_=I[1],z=m(e.useState(""),2),V=z[0],U=z[1],$=m(e.useState(!1),2),K=$[0],Y=$[1],G=m(e.useState(null),2),X=G[0],J=G[1],Q=m(e.useState({}),2),Z=Q[0],ee=Q[1],te=m(e.useState([]),2),ne=te[0],re=te[1],ie=e.useMemo(function(){return ne.length?JSON.stringify(ne):""},[ne]),oe=function(e){return!e.readOnly&&!1!==e.editable};e.useEffect(function(){n&&ae()},[null==n?void 0:n.table_name,M,B,V,ie]);var se=function(){var e=h(f().m(function e(t){var n,r,i,o,s;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if("relation"===t.type&&t.relation){e.n=1;break}return e.a(2);case 1:if(n=t.relation,r=n.target,i=n.displayField,o="".concat(r,"_").concat(i||"name"),!Z[o]){e.n=2;break}return e.a(2);case 2:return e.p=2,e.n=3,vh(r,{displayField:i||"name",limit:200});case 3:(s=e.v).success&&s.data&&ee(function(e){return Object.assign(Object.assign({},e),d({},o,s.data))}),e.n=5;break;case 4:e.p=4,e.v;case 5:return e.a(2)}},e,null,[[2,4]])}));return function(t){return e.apply(this,arguments)}}();e.useEffect(function(){p&&n&&n.json_schema.fields.filter(function(e){return"relation"===e.type&&e.relation}).forEach(function(e){return se(e)})},[p,n]);var ae=function(){var e=h(f().m(function e(){var t,r,i,o;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n){e.n=1;break}return e.a(2);case 1:return c(!0),e.p=2,i={page:M,limit:B},V&&(i.search=V),ne.length>0&&(i.filters=ne),e.n=3,gh(n.table_name,i);case 3:if((o=e.v).success){e.n=4;break}return Fa.error(o.message||"加载数据失败"),s([]),_(0),e.a(2);case 4:s((null===(t=o.data)||void 0===t?void 0:t.data)||[]),_((null===(r=o.data)||void 0===r?void 0:r.total)||0),e.n=6;break;case 5:e.p=5,e.v,Fa.error("加载数据失败"),s([]),_(0);case 6:return e.p=6,c(!1),e.f(6);case 7:return e.a(2)}},e,null,[[2,5,6,7]])}));return function(){return e.apply(this,arguments)}}(),le=function(){var e=h(f().m(function e(t){var r;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(confirm("确定要删除这条数据吗?此操作不可撤销。")){e.n=1;break}return e.a(2);case 1:return J(t.id),e.p=2,e.n=3,wh(null==n?void 0:n.table_name,t.id);case 3:(r=e.v).success?(Fa.success("删除成功"),ae()):Fa.error(r.message||"删除失败"),e.n=5;break;case 4:e.p=4,e.v,Fa.error("删除失败");case 5:return e.p=5,J(null),e.f(5);case 6:return e.a(2)}},e,null,[[2,4,5,6]])}));return function(t){return e.apply(this,arguments)}}(),ce=function(){var e=h(f().m(function e(){var t,r,i,o,s,a;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n){e.n=1;break}return e.a(2);case 1:if(Y(!0),e.p=2,t={},n.json_schema.fields.forEach(function(e){if("id"!==e.name&&oe(e))if("relation"===e.type&&e.relation){var n=e.relation.foreignKey||"".concat(e.relation.target,"_id");t[n]=E[n]}else{var r=E[e.name];if("date"!==e.type&&"datetime"!==e.type||(r=r?new Date(r).toISOString():null),"json"===e.type||"jsonb"===e.type){var i=(r||"").toString().trim();if(i){var o=If(i);if(!o.ok)throw new Error("字段 ".concat(e.comment||e.name,":").concat(o.message));r=o.value}else r=null}t[e.name]=r}}),!x){e.n=4;break}return r=Object.assign(Object.assign({},t),{id:x.id}),e.n=3,yh(n.table_name,r);case 3:(i=e.v).success?(Fa.success("更新成功"),g(!1),ae()):Fa.error(i.message||"更新失败"),e.n=6;break;case 4:return e.n=5,bh(n.table_name,t);case 5:(o=e.v).success?(Fa.success("创建成功"),g(!1),ae()):Fa.error(o.message||"创建失败");case 6:e.n=8;break;case 7:e.p=7,a=e.v,s=a instanceof Error?a.message:"操作失败",Fa.error(s);case 8:return e.p=8,Y(!1),e.f(8);case 9:return e.a(2)}},e,null,[[2,7,8,9]])}));return function(){return e.apply(this,arguments)}}(),he=function(t,n,r){if("string"==typeof n){var o=n.trim();if(o&&function(e){var t,n=e.trim();if(!n)return!1;if(n.startsWith("data:image/"))return!0;if(!IT(n))return!1;var r=(null===(t=n.split("#")[0])||void 0===t?void 0:t.split("?")[0])||n;return/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(r)}(o))return e.createElement(jT,{url:o});if(o&&IT(o))return e.createElement("a",{href:o,target:"_blank",rel:"noreferrer",className:"max-w-[360px] truncate text-primary underline-offset-2 hover:underline block",title:o},o)}if("boolean"===t.type)return e.createElement(RT,{variant:n?"default":"secondary"},n?"是":"否");if("date"===t.type||"datetime"===t.type)return n?i(n).format("YYYY-MM-DD HH:mm:ss"):"-";if("text"===t.type&&n&&n.length>50)return e.createElement("span",{className:"max-w-xs truncate block",title:n},n.substring(0,50),"...");if("json"===t.type||"jsonb"===t.type)return e.createElement(wT,{value:n,title:t.comment||t.name});if("relation"===t.type&&t.relation&&r){var s=t.relation.displayField,a=void 0===s?"name":s,l=r["".concat(t.name,"_data")];if(l)return e.createElement(RT,{variant:"outline"},l[a]||"ID: ".concat(l.id));var c=r[t.relation.foreignKey||"".concat(t.relation.target,"_id")];return c?"ID: ".concat(c):"-"}return n||"-"};return n?e.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},e.createElement("div",{className:"w-full py-4 space-y-4"},e.createElement("div",{className:"space-y-1"},e.createElement("div",{className:"flex items-center gap-3"},e.createElement("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-lg bg-primary/10 text-primary"},e.createElement(T,{className:"h-4 w-4"})),e.createElement("div",null,e.createElement("h1",{className:"text-2xl font-bold tracking-tight leading-tight"},n.name),e.createElement("p",{className:"text-sm text-muted-foreground"},"表名: ",n.table_name)))),e.createElement(wa,{className:"border-2 shadow-lg"},e.createElement(xa,{className:"bg-muted/30"},e.createElement("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-4"},e.createElement("div",null,e.createElement(ka,null,"数据管理"),e.createElement(Sa,null,"查看和管理 ",n.name," 的数据")),e.createElement(at,{onClick:function(){k(null),N({}),g(!0)},className:"w-full md:w-auto"},e.createElement(F,{className:"h-4 w-4 mr-2"}),"新建数据"))),e.createElement(Ea,{className:"space-y-4 pt-4"},e.createElement("div",{className:"flex flex-col md:flex-row md:items-center gap-3"},e.createElement("div",{className:"flex-1"},e.createElement(ya,{htmlFor:"search",className:"sr-only"},"搜索"),e.createElement("div",{className:"relative"},e.createElement(W,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.createElement(lt,{id:"search",placeholder:"搜索数据...",value:V,onChange:function(e){return U(e.target.value)},className:"pl-10 h-10"}))),e.createElement(at,{type:"button",variant:"outline",className:"h-10",onClick:function(){return y(!0)}},e.createElement(R,{className:"h-4 w-4 mr-2"}),"筛选",ne.length>0?"(".concat(ne.length,")"):"")),e.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},e.createElement("div",{className:"text-sm text-muted-foreground"},"共 ",e.createElement("span",{className:"font-semibold text-foreground"},j)," 条数据"),e.createElement(RT,{variant:"outline"},n.name)),e.createElement("div",{className:"rounded-lg border overflow-hidden"},e.createElement(kT,null,e.createElement(ST,null,e.createElement(OT,{className:"bg-muted/50"},e.createElement(NT,{className:"font-semibold w-20"},"ID"),n.json_schema.fields.map(function(t){return e.createElement(NT,{key:t.name,className:"font-semibold"},t.comment||t.name)}),e.createElement(NT,{className:"font-semibold"},"创建时间"),e.createElement(NT,{className:"font-semibold"},"更新时间"),e.createElement(NT,{className:qe("font-semibold w-32 text-center sticky right-0 z-30 bg-background","before:content-[''] before:absolute before:inset-y-0 before:left-0 before:w-px before:bg-border","after:content-[''] after:absolute after:inset-y-0 after:left-[-16px] after:w-4 after:bg-gradient-to-l after:from-background after:to-transparent","shadow-[-10px_0_16px_-14px_rgba(0,0,0,0.35)]")},"操作"))),e.createElement(ET,null,l?Array.from({length:3}).map(function(t,r){return e.createElement(OT,{key:r},e.createElement(AT,{colSpan:n.json_schema.fields.length+4},e.createElement("div",{className:"flex items-center gap-2 py-4"},e.createElement(L,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.createElement("span",{className:"text-sm text-muted-foreground"},"加载中..."))))}):0===o.length?e.createElement(OT,null,e.createElement(AT,{colSpan:n.json_schema.fields.length+4,className:"text-center py-12"},e.createElement("div",{className:"flex flex-col items-center gap-2 text-muted-foreground"},e.createElement(W,{className:"h-8 w-8"}),e.createElement("p",null,"暂无数据")))):o.map(function(t,r){return e.createElement(OT,{key:t.id,className:qe("group",r%2==0?"bg-muted/20":"")},e.createElement(AT,{className:"font-mono font-medium max-w-[220px] truncate",title:String(t.id)},t.id),n.json_schema.fields.map(function(n){return e.createElement(AT,{key:n.name},he(n,t[n.name],t))}),e.createElement(AT,{className:"text-sm text-muted-foreground"},i(t.created_at).format("YYYY-MM-DD HH:mm")),e.createElement(AT,{className:"text-sm text-muted-foreground"},i(t.updated_at).format("YYYY-MM-DD HH:mm")),e.createElement(AT,{className:qe("sticky right-0 z-20 bg-background","before:content-[''] before:absolute before:inset-y-0 before:left-0 before:w-px before:bg-border","after:content-[''] after:absolute after:inset-y-0 after:left-[-16px] after:w-4 after:bg-gradient-to-l after:from-background after:to-transparent","shadow-[-10px_0_16px_-14px_rgba(0,0,0,0.25)]","group-hover:bg-muted/50")},e.createElement("div",{className:"flex items-center justify-center gap-2"},e.createElement(at,{variant:"ghost",size:"sm",onClick:function(){return function(e){k(e);var t={};null==n||n.json_schema.fields.forEach(function(n){if("id"!==n.name)if("relation"===n.type&&n.relation){var r=n.relation.foreignKey||"".concat(n.relation.target,"_id");t[r]=e[r]}else{var o=e[n.name];"date"!==n.type&&"datetime"!==n.type||(o=o?i(o).format("YYYY-MM-DDTHH:mm"):""),"json"!==n.type&&"jsonb"!==n.type||(o=null==o||""===o?"":"string"==typeof o?o:JSON.stringify(o,null,2)),t[n.name]=o}}),N(t),g(!0)}(t)},className:"h-8 w-8 p-0"},e.createElement(H,{className:"h-4 w-4"})),e.createElement(at,{variant:"ghost",size:"sm",onClick:function(){return le(t)},disabled:X===t.id,className:"h-8 w-8 p-0 text-destructive hover:text-destructive"},X===t.id?e.createElement(L,{className:"h-4 w-4 animate-spin"}):e.createElement(q,{className:"h-4 w-4"})))))})))),j>B&&e.createElement("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50 border"},e.createElement("div",{className:"text-sm text-muted-foreground"},"第 ",e.createElement("span",{className:"font-semibold text-foreground"},M)," 页, 共 ",e.createElement("span",{className:"font-semibold text-foreground"},Math.ceil(j/B))," 页"),e.createElement("div",{className:"flex gap-2"},e.createElement(at,{variant:"outline",size:"sm",onClick:function(){return D(Math.max(1,M-1))},disabled:1===M||l},e.createElement(C,{className:"h-4 w-4 mr-1"}),"上一页"),e.createElement(at,{variant:"outline",size:"sm",onClick:function(){return D(Math.min(Math.ceil(j/B),M+1))},disabled:M>=Math.ceil(j/B)||l},"下一页",e.createElement(O,{className:"h-4 w-4 ml-1"})))))),e.createElement(cf,{open:b,onOpenChange:y},e.createElement(ff,{className:"max-w-3xl"},e.createElement(pf,null,e.createElement(gf,{className:"text-xl"},"筛选"),e.createElement(bf,{className:"text-sm"},n.name," - ",n.table_name)),e.createElement("div",{className:"py-2"},e.createElement(LT,{fields:n.json_schema.fields,value:ne,onChange:function(e){re(e),D(1)}})),e.createElement(mf,{className:"gap-2"},e.createElement(at,{variant:"outline",onClick:function(){return y(!1)}},"关闭")))),e.createElement(cf,{open:p,onOpenChange:g},e.createElement(ff,{className:"max-w-3xl max-h-[85vh] overflow-y-auto"},e.createElement(pf,null,e.createElement(gf,{className:"text-2xl"},x?"编辑数据":"新建数据"),e.createElement(bf,{className:"text-base"},n.name," - ",n.table_name)),e.createElement("div",{className:"space-y-4 py-4"},n.json_schema.fields.map(function(t){return function(t){if("id"===t.name)return null;var n=oe(t);switch(t.type){case"boolean":return e.createElement("div",{key:t.name,className:"flex items-center space-x-3 p-4 rounded-lg border bg-card"},e.createElement(af,{id:t.name,checked:E[t.name]||!1,disabled:!n,onCheckedChange:function(e){return N(Object.assign(Object.assign({},E),d({},t.name,e)))}}),e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium cursor-pointer"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")));case"date":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lt,{id:t.name,type:"date",value:E[t.name]||"",disabled:!n,onChange:function(e){return N(Object.assign(Object.assign({},E),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"datetime":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lt,{id:t.name,type:"datetime-local",value:E[t.name]||"",disabled:!n,onChange:function(e){return N(Object.assign(Object.assign({},E),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"text":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lf,{id:t.name,rows:4,value:E[t.name]||"",disabled:!n,onChange:function(e){return N(Object.assign(Object.assign({},E),d({},t.name,e.target.value)))},required:t.required,className:"resize-none"}));case"json":case"jsonb":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(xT,{id:t.name,value:E[t.name]||"",required:t.required,disabled:!n,onChange:function(e){return N(Object.assign(Object.assign({},E),d({},t.name,e)))}}));case"integer":case"float":return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lt,{id:t.name,type:"number",value:E[t.name]||"",disabled:!n,onChange:function(e){return N(Object.assign(Object.assign({},E),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}));case"relation":if(!t.relation)return null;var r=t.relation,i=r.target,o=r.displayField,s=void 0===o?"name":o,a="".concat(i,"_").concat(s),l=Z[a]||[],c=t.relation.foreignKey||"".concat(i,"_id"),h=void 0!==E[c]&&null!==E[c]?String(E[c]):"",u=l.find(function(e){return String(e.id)===h});return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(Bd,{value:h,disabled:!n,onValueChange:function(e){var t=parseInt(e,10),n=!isNaN(t)&&String(t)===e;N(Object.assign(Object.assign({},E),d({},c,n?t:e)))}},e.createElement(jd,{className:"h-11"},e.createElement(Id,{placeholder:"请选择".concat(t.comment||t.name)},u?u.label:h?"ID: ".concat(h):"请选择".concat(t.comment||t.name))),e.createElement(Wd,null,0===l.length?e.createElement(Hd,{value:"_loading",disabled:!0},"加载中..."):l.map(function(t){return e.createElement(Hd,{key:t.id,value:String(t.id)},t.label)}))));default:return e.createElement("div",{key:t.name,className:"space-y-2"},e.createElement(ya,{htmlFor:t.name,className:"text-base font-medium"},t.comment||t.name,t.required&&e.createElement("span",{className:"text-destructive ml-1"},"*")),e.createElement(lt,{id:t.name,type:"email"===t.type?"email":"text",maxLength:t.maxLength,value:E[t.name]||"",disabled:!n,onChange:function(e){return N(Object.assign(Object.assign({},E),d({},t.name,e.target.value)))},required:t.required,className:"h-11"}))}}(t)})),e.createElement(mf,{className:"gap-2"},e.createElement(at,{variant:"outline",onClick:function(){return g(!1)},disabled:K},"取消"),e.createElement(at,{onClick:ce,disabled:K},K?e.createElement(e.Fragment,null,e.createElement(L,{className:"h-4 w-4 mr-2 animate-spin"}),x?"更新中...":"创建中..."):x?"更新":"创建")))))):e.createElement("div",{className:"min-h-[calc(100vh-4rem)] bg-gradient-to-br from-background via-background to-muted/20"},e.createElement("div",{className:"w-full py-4"},e.createElement(wa,{className:"border-2"},e.createElement(Ea,{className:"py-16 text-center"},e.createElement(T,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),e.createElement("p",{className:"text-lg text-muted-foreground"},"请选择数据模型")))))}function FT(t){var n=t.model;return e.createElement(_T,{key:n.id,model:n})}function WT(t){return t.models.map(function(t){return{path:"/data/list-".concat(t.id),name:t.name,icon:e.createElement(V),component:function(){return e.createElement(FT,{model:t})}}})}var zT=function(t){return[{path:"/login",name:"登录",icon:e.createElement(I),component:xh},{name:"数据管理",icon:e.createElement(A),path:"/data",component:BT,routes:g(WT(t))}]},HT=z,VT=U,qT=j;function UT(t){var n=t.inputModels,r=t.skipAuth,i=void 0!==r&&r,o=m(e.useState("/data"),2),s=o[0],a=o[1],l=m(e.useState([]),2);l[0],l[1];var c=m(e.useState(!1),2),d=c[0],p=c[1],g=m(e.useState(null),2),v=g[0],b=g[1],y=m(e.useState(!0),2),w=y[0],x=y[1],k=e.useMemo(function(){return zT({models:n.models})},[n.models]);e.useEffect(function(){if(i)return p(!0),b(null),x(!1),void("/login"===s&&a("/data"));var e=function(){var e=h(f().m(function e(){var t,n;return f().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,ph()){e.n=1;break}return p(!1),a("/login"),x(!1),e.a(2);case 1:return e.p=1,e.n=2,uh();case 2:if(e.v.success){e.n=3;break}throw new Error("token验证失败");case 3:if(!(t=mh())){e.n=4;break}b(t),e.n=6;break;case 4:return e.n=5,dh();case 5:(n=e.v).success&&n.data&&(b(n.data),localStorage.setItem("cms_user",JSON.stringify(n.data)));case 6:p(!0),"/login"===s&&a("/data"),e.n=8;break;case 7:e.p=7,e.v,fh(),p(!1),b(null),a("/login");case 8:e.n=10;break;case 9:e.p=9,e.v,p(!1),b(null),a("/login");case 10:return e.p=10,x(!1),e.f(10);case 11:return e.a(2)}},e,null,[[1,7],[0,9,10,11]])}));return function(){return e.apply(this,arguments)}}();e()},[i]);var S=function(e,t){b(t),p(!0),a("/data"),Fa.success("欢迎回来,".concat(t.username,"!"))},E=function(e,t){var n,r=u(e);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(i.path===t)return i;if(i.routes){var o=E(i.routes,t);if(o)return o}}}catch(e){r.e(e)}finally{r.f()}return null};if(w)return e.createElement("div",{className:"flex min-h-screen items-center justify-center bg-background"},e.createElement("div",{className:"space-y-4"},e.createElement(Ue,{className:"h-12 w-48"}),e.createElement(Ue,{className:"h-4 w-64"})));if(!d)return e.createElement(xh,{onLoginSuccess:S});var C=k.filter(function(e){return"/login"!==e.path}),O=function(t){if(!t)return T;if(e.isValidElement(t)){var n=t.type;if(n&&"function"==typeof n){var r=n.name||"";if(r.includes("Home"))return D;if(r.includes("Table"))return V;if(r.includes("Database"))return T;if(r.includes("File"))return M}}return T},N=C.flatMap(function(e){return e.routes&&e.routes.length>0?e.routes.map(function(e){return{title:e.name,icon:O(e.icon),path:e.path}}):[{title:e.name,icon:O(e.icon),path:e.path}]});return e.createElement(ta,null,e.createElement(na,{variant:"inset"},e.createElement(oa,{className:"border-b border-sidebar-border"},e.createElement("div",{className:"flex items-center gap-2 px-2 py-1"},e.createElement("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-primary"},e.createElement(HT,{className:"w-4 h-4 text-primary-foreground"})),e.createElement("span",{className:"font-semibold text-lg"},"WE0-CMS"))),e.createElement(aa,null,e.createElement(la,null,e.createElement(ca,null,"Navigation"),e.createElement(ha,null,e.createElement(ua,null,N.map(function(t){return e.createElement(da,{key:t.path},e.createElement(pa,{onClick:function(){return a(t.path)},isActive:(n=t.path,s===n||s.startsWith(n+"/")),tooltip:t.title},e.createElement(t.icon,{className:"w-4 h-4"}),e.createElement("span",null,t.title)));var n}))))),e.createElement(sa,{className:"border-t border-sidebar-border"},e.createElement(ua,null,!i&&v&&e.createElement(e.Fragment,null,e.createElement(da,null,e.createElement(pa,{tooltip:v.username||"User"},e.createElement(VT,{className:"w-4 h-4"}),e.createElement("span",{className:"truncate"},v.username))),e.createElement(da,null,e.createElement(pa,{onClick:function(){window.confirm("确定要登出系统吗?")&&(fh(),localStorage.removeItem("cms_token"),localStorage.removeItem("cms_user"),p(!1),b(null),a("/login"),Fa.success("已成功登出"))},tooltip:"Logout"},e.createElement(qT,{className:"w-4 h-4"}),e.createElement("span",null,"Logout"))))))),e.createElement(ia,null,e.createElement("header",{className:"flex h-14 items-center gap-4 border-b bg-background px-6"},e.createElement(ra,null),e.createElement("h1",{className:"text-lg font-semibold"},function(){if("/login"===s)return"Login";var e=E(k,s);return(null==e?void 0:e.name)||"数据管理"}())),e.createElement("main",{className:"flex-1 p-6"},function(){if(!i&&"/login"===s)return e.createElement(xh,{onLoginSuccess:S});if(i&&"/login"===s)return e.createElement(BT,null);var t=E(k,s);if(t){var n=t.component;return e.createElement(n,null)}return e.createElement(BT,null)}())))}exports.CmsLayoutShadcn=UT,exports.cmsRoutes=zT,exports.default=UT,exports.setSessionId=function(e){th=e;try{localStorage.setItem("cms_session_id",e)}catch(e){}};
16
16
  //# sourceMappingURL=index.js.map