{"version":3,"file":"index.mjs","sources":["../../../../../../node_modules/@codemirror/lang-json/dist/index.js"],"sourcesContent":["import { parser } from '@lezer/json';\nimport { LRLanguage, indentNodeProp, continuedIndent, foldNodeProp, foldInside, LanguageSupport } from '@codemirror/language';\n\n/**\nCalls\n[`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)\non the document and, if that throws an error, reports it as a\nsingle diagnostic.\n*/\nconst jsonParseLinter = () => (view) => {\n    try {\n        JSON.parse(view.state.doc.toString());\n    }\n    catch (e) {\n        if (!(e instanceof SyntaxError))\n            throw e;\n        const pos = getErrorPosition(e, view.state.doc);\n        return [{\n                from: pos,\n                message: e.message,\n                severity: 'error',\n                to: pos\n            }];\n    }\n    return [];\n};\nfunction getErrorPosition(error, doc) {\n    let m;\n    if (m = error.message.match(/at position (\\d+)/))\n        return Math.min(+m[1], doc.length);\n    if (m = error.message.match(/at line (\\d+) column (\\d+)/))\n        return Math.min(doc.line(+m[1]).from + (+m[2]) - 1, doc.length);\n    return 0;\n}\n\n/**\nA language provider that provides JSON parsing.\n*/\nconst jsonLanguage = /*@__PURE__*/LRLanguage.define({\n    name: \"json\",\n    parser: /*@__PURE__*/parser.configure({\n        props: [\n            /*@__PURE__*/indentNodeProp.add({\n                Object: /*@__PURE__*/continuedIndent({ except: /^\\s*\\}/ }),\n                Array: /*@__PURE__*/continuedIndent({ except: /^\\s*\\]/ })\n            }),\n            /*@__PURE__*/foldNodeProp.add({\n                \"Object Array\": foldInside\n            })\n        ]\n    }),\n    languageData: {\n        closeBrackets: { brackets: [\"[\", \"{\", '\"'] },\n        indentOnInput: /^\\s*[\\}\\]]$/\n    }\n});\n/**\nJSON language support.\n*/\nfunction json() {\n    return new LanguageSupport(jsonLanguage);\n}\n\nexport { json, jsonLanguage, jsonParseLinter };\n"],"names":["jsonLanguage","LRLanguage","parser","indentNodeProp","continuedIndent","foldNodeProp","foldInside","json","LanguageSupport"],"mappings":";;AAsCK,MAACA,IAA4B,gBAAAC,EAAW,OAAO;AAAA,EAChD,MAAM;AAAA,EACN,QAAqB,gBAAAC,EAAO,UAAU;AAAA,IAClC,OAAO;AAAA,MACU,gBAAAC,EAAe,IAAI;AAAA,QAC5B,QAAqB,gBAAAC,EAAgB,EAAE,QAAQ,SAAQ,CAAE;AAAA,QACzD,OAAoB,gBAAAA,EAAgB,EAAE,QAAQ,SAAQ,CAAE;AAAA,MACxE,CAAa;AAAA,MACY,gBAAAC,EAAa,IAAI;AAAA,QAC1B,gBAAgBC;AAAA,MAChC,CAAa;AAAA,IACb;AAAA,EACA,CAAK;AAAA,EACD,cAAc;AAAA,IACV,eAAe,EAAE,UAAU,CAAC,KAAK,KAAK,GAAG,EAAC;AAAA,IAC1C,eAAe;AAAA,EACvB;AACA,CAAC;AAID,SAASC,IAAO;AACZ,SAAO,IAAIC,EAAgBR,CAAY;AAC3C;","x_google_ignoreList":[0]}