{"version":3,"sources":["browser/monaco-context-key-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAE,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAE3D,qBACa,uBAAwB,SAAQ,iBAAiB;IAE1D,aAAa,CAAC,EAAE,WAAW,CAAC;IAE5B,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,CAAC,iBAAiB,CAAC;IACjF,SAAS,CAAC,QAAQ,CAAC,WAAW,sDAA6D;IAE3F,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC;IAIrE,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO;IAUzD,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS;IAOtD,SAAS,CAAC,IAAI,IAAI,IAAI;IAQtB,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,oBAAoB,GAAG,SAAS;CAWpF","file":"../../src/browser/monaco-context-key-service.d.ts","sourcesContent":["import {inject, injectable, postConstruct} from 'inversify';\r\nimport {ContextKey, ContextKeyService} from '@tartjs/core';\r\n\r\n@injectable()\r\nexport class MonacoContextKeyService extends ContextKeyService {\r\n\r\n    activeContext?: HTMLElement;\r\n    @inject(monaco.contextKeyService.ContextKeyService)\r\n    protected readonly contextKeyService: monaco.contextKeyService.ContextKeyService;\r\n    protected readonly expressions = new Map<string, monaco.contextkey.ContextKeyExpression>();\r\n\r\n    createKey<T>(key: string, defaultValue: T | undefined): ContextKey<T> {\r\n        return this.contextKeyService.createKey(key, defaultValue);\r\n    }\r\n\r\n    match(expression: string, context?: HTMLElement): boolean {\r\n        const ctx = context || this.activeContext || (window.document.activeElement instanceof HTMLElement ? window.document.activeElement : undefined);\r\n        const parsed = this.parse(expression);\r\n        if (!ctx) {\r\n            return this.contextKeyService.contextMatchesRules(parsed);\r\n        }\r\n        const keyContext = this.contextKeyService.getContext(ctx);\r\n        return monaco.keybindings.KeybindingResolver.contextMatchesRules(keyContext, parsed);\r\n    }\r\n\r\n    parseKeys(expression: string): Set<string> | undefined {\r\n        const expr = monaco.contextkey.ContextKeyExpr.deserialize(expression);\r\n        // @ts-ignore\r\n        return expr ? new Set<string>(expr.keys()) : expr;\r\n    }\r\n\r\n    @postConstruct()\r\n    protected init(): void {\r\n        this.contextKeyService.onDidChangeContext(e =>\r\n            this.fireDidChange({\r\n                affects: keys => e.affectsSome(keys)\r\n            })\r\n        );\r\n    }\r\n\r\n    protected parse(when: string): monaco.contextkey.ContextKeyExpression | undefined {\r\n        let expression = this.expressions.get(when);\r\n        if (!expression) {\r\n            expression = monaco.contextkey.ContextKeyExpr.deserialize(when);\r\n            if (expression) {\r\n                this.expressions.set(when, expression);\r\n            }\r\n        }\r\n        return expression;\r\n    }\r\n\r\n}\r\n"]}