import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { DragDropModule } from '@angular/cdk/drag-drop';
import { CommonModule } from '@angular/common';
import { Component, Input, ViewChild, ViewContainerRef, booleanAttribute, effect, forwardRef, inject, input, model, signal } from '@angular/core';
import { toObservable } from '@angular/core/rxjs-interop';
import { FormControl, FormsModule, NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatDialog } from '@angular/material/dialog';
import { MatExpansionModule } from '@angular/material/expansion';
import { MatIconModule } from '@angular/material/icon';
import { MatListModule } from '@angular/material/list';
import { MatSidenavModule } from '@angular/material/sidenav';
import { MatTabsModule } from '@angular/material/tabs';
import { MatTooltipModule } from '@angular/material/tooltip';
import { NgmCommonModule, NgmHighlightDirective, ResizerModule } from '@metad/ocap-angular/common';
import { OcapCoreModule } from '@metad/ocap-angular/core';
import { NgmBaseEditorDirective } from '@metad/ocap-angular/formula';
import { MDXReference, NgmMDXEditorComponent } from '@metad/ocap-angular/mdx';
import { NgmParameterCreateComponent } from '@metad/ocap-angular/parameter';
import { C_MEASURES, Syntax, getEntityCalculations, getEntityParameters, isIndicatorMeasureProperty, isPropertyMeasure } from '@metad/ocap-core';
import { TranslateModule } from '@ngx-translate/core';
import { negate, sortBy } from 'lodash-es';
import { MarkdownModule } from 'ngx-markdown';
import { combineLatestWith, firstValueFrom, map, of, startWith, switchMap } from 'rxjs';
import { NgmEntitySchemaComponent } from '../entity-schema/entity-schema.component';
import { EntityCapacity } from '../entity-schema/types';
import { NgmEntityPropertyComponent } from '../property/property.component';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/forms";
import * as i3 from "@angular/cdk/drag-drop";
import * as i4 from "@angular/material/sidenav";
import * as i5 from "@angular/material/tabs";
import * as i6 from "@angular/material/icon";
import * as i7 from "@angular/material/button";
import * as i8 from "@angular/material/list";
import * as i9 from "@angular/material/tooltip";
import * as i10 from "@angular/material/expansion";
import * as i11 from "@ngx-translate/core";
import * as i12 from "ngx-markdown";
import * as i13 from "@metad/ocap-angular/core";
import * as i14 from "@metad/ocap-angular/common";
export class NgmCalculatedMeasureComponent {
    get story() {
        return this._story;
    }
    set story(value) {
        this._story = coerceBooleanProperty(value);
    }
    get calculatedMemberHighlight() {
        return this.calculatedMemberSearch.value;
    }
    get fnHighlight() {
        return this.fnSearchControl.value;
    }
    constructor() {
        this.Syntax = Syntax;
        this.EntityCapacity = EntityCapacity;
        this.FUNCTIONS = [];
        this._dialog = inject(MatDialog);
        this._viewContainerRef = inject(ViewContainerRef);
        this.dsCoreService = input();
        this.dataSettings = input();
        this.entityType = input();
        this.syntax = input();
        this._story = false;
        this.disabled = input(false, {
            transform: booleanAttribute
        });
        this.opened = input(false, {
            transform: booleanAttribute
        });
        this.drawerOpened = model(false);
        this.calculatedMemberSearch = new FormControl('');
        this.fnSearchControl = new FormControl(null);
        this.statement = new FormControl(null);
        this.calculations = [];
        this.editorOptions = signal({ wordWrap: false });
        this.calculations$ = toObservable(this.entityType).pipe(map(getEntityCalculations), map((values) => [
            ...sortBy(values.filter(negate(isIndicatorMeasureProperty)), 'calculationType'),
            ...values.filter(isIndicatorMeasureProperty)
        ]), combineLatestWith(this.calculatedMemberSearch.valueChanges.pipe(startWith(''))), map(([values, search]) => values.filter((v) => v.caption?.toLowerCase().includes(search.toLowerCase()) || v.name.toLowerCase().includes(search.toLowerCase()))));
        this.parameters$ = toObservable(this.entityType).pipe(map(getEntityParameters));
        this.functions$ = of(sortBy(MDXReference.FUNCTIONS, 'label')).pipe(switchMap((functions) => this.fnSearchControl.valueChanges.pipe(startWith(''), map((text) => {
            text = text?.trim().toLowerCase();
            return text ? functions.filter((item) => item.label.toLowerCase().includes(text)) : functions;
        }))));
        effect(() => {
            if (this.opened()) {
                this.drawerOpened.set(this.opened());
            }
        }, { allowSignalWrites: true });
        effect(() => {
            this.disabled() ? this.statement.disable() : this.statement.enable();
        });
    }
    writeValue(obj) {
        this.statement.setValue(obj);
    }
    registerOnChange(fn) {
        this._onChange = fn;
    }
    registerOnTouched(fn) {
        //
    }
    setDisabledState(isDisabled) {
        isDisabled ? this.statement.disable() : this.statement.enable();
    }
    toggleSideMenu() {
        this.drawerOpened.update((v) => !v);
    }
    async openCreateParameter(parameter) {
        const result = await firstValueFrom(this._dialog
            .open(NgmParameterCreateComponent, {
            viewContainerRef: this._viewContainerRef,
            data: {
                dataSettings: this.dataSettings(),
                entityType: this.entityType(),
                // coreService: this.coreService,
                dimension: {}, // TODO
                name: parameter?.name
            }
        })
            .afterClosed());
        if (result) {
            // 参数创建成功
            console.debug(result);
        }
    }
    dropPredicate(item) {
        return ['ngm-calculated-measure__entity-schema', 'ngm-calculated-calculations', 'ngm-calculated-parameters', 'ngm-calculated-functions'].includes(item.dropContainer.id);
    }
    drop(event) {
        if (event.container.id === 'ngm-calculated-editor') {
            if (event.previousContainer.id === 'ngm-calculated-calculations') {
                this.editor.insert(`[${C_MEASURES}].[${event.item.data.name}]`);
            }
            else if (event.previousContainer.id === 'ngm-calculated-parameters') {
                this.editor.insert(`[@${event.item.data.name}]`);
            }
            else if (event.previousContainer.id === 'ngm-calculated-measure__entity-schema') {
                if (isPropertyMeasure(event.item.data)) {
                    this.editor.insert(`[${C_MEASURES}].[${event.item.data.name}]`);
                }
                else {
                    this.editor.insert(event.item.data.name);
                }
            }
            else if (typeof event.item.data === 'string') {
                this.editor.insert(event.item.data);
            }
        }
    }
    onBlur() {
        this._onChange?.(this.statement.value);
    }
    toggleWrap() {
        this.editorOptions.update((state) => ({
            ...state,
            wordWrap: !state.wordWrap
        }));
    }
    openHelp(event) {
        window.open('https://docs.microsoft.com/en-us/sql/mdx/mdx-function-reference-mdx', '_blank');
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgmCalculatedMeasureComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.12", type: NgmCalculatedMeasureComponent, isStandalone: true, selector: "ngm-calculated-measure", inputs: { dsCoreService: { classPropertyName: "dsCoreService", publicName: "dsCoreService", isSignal: true, isRequired: false, transformFunction: null }, dataSettings: { classPropertyName: "dataSettings", publicName: "dataSettings", isSignal: true, isRequired: false, transformFunction: null }, entityType: { classPropertyName: "entityType", publicName: "entityType", isSignal: true, isRequired: false, transformFunction: null }, syntax: { classPropertyName: "syntax", publicName: "syntax", isSignal: true, isRequired: false, transformFunction: null }, story: { classPropertyName: "story", publicName: "story", isSignal: false, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, opened: { classPropertyName: "opened", publicName: "opened", isSignal: true, isRequired: false, transformFunction: null }, drawerOpened: { classPropertyName: "drawerOpened", publicName: "drawerOpened", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { drawerOpened: "drawerOpenedChange" }, host: { classAttribute: "ngm-calculated-measure" }, providers: [
            {
                provide: NG_VALUE_ACCESSOR,
                multi: true,
                useExisting: forwardRef(() => NgmCalculatedMeasureComponent)
            }
        ], viewQueries: [{ propertyName: "editor", first: true, predicate: ["editor"], descendants: true }], ngImport: i0, template: "<mat-drawer-container class=\"flex flex-1\" [hasBackdrop]=\"false\" autosize>\n  <mat-drawer #drawer class=\"ngm-calculated-measure__drawer\"\n    mode=\"side\" position=\"end\" ngmResizer [resizerWidth]=\"330\"\n    [(opened)]=\"drawerOpened\"\n    (openedChange)=\"$event?helper.realignInkBar():''\">\n    <mat-tab-group #helper class=\"ngm-calculated-measure__helpers\" mat-stretch-tabs=\"false\" >\n      <mat-tab [label]=\"'Ngm.Calculation.DIMENSION_MEMBERS' | translate: {Default: 'Dimension Members'}\"\n        id=\"ngm-calculated-measure__entity-schema\"\n        cdkDropList\n        [cdkDropListData]=\"[]\"\n      >\n        <ngm-entity-schema class=\"flex-1 max-w-full w-full\"\n          [dsCoreService]=\"dsCoreService()\"\n          [dataSettings]=\"dataSettings()\"\n          [capacities]=\"[\n            EntityCapacity.Dimension,\n            EntityCapacity.Measure\n          ]\">\n        </ngm-entity-schema>\n      </mat-tab>\n\n      <mat-tab [label]=\"'Ngm.Calculation.CALCULATED_MEMBERS' | translate: {Default: 'Calculated Members'}\">\n        <div class=\"max-w-full w-full flex flex-col justify-start items-stretch overflow-hidden\">\n          <ngm-search class=\"m-1\" [formControl]=\"calculatedMemberSearch\"></ngm-search>\n          <mat-list role=\"list\" class=\"flex-1 max-w-full w-full overflow-auto\" displayDensity=\"cosy\"\n            id=\"ngm-calculated-calculations\"\n            cdkDropList\n            [cdkDropListData]=\"calculations\"\n            (cdkDropListDropped)=\"drop($event)\"\n            >\n            <mat-list-item role=\"listitem\" *ngFor=\"let property of calculations$ | async\" class=\"hover:bg-neutral-100 dark:hover:bg-neutral-800\"\n              cdkDrag\n              [cdkDragData]=\"property\"\n            >\n              <ngm-entity-property class=\"flex-1\" [property]=\"property\"></ngm-entity-property> <!-- [highlight]=\"calculatedMemberHighlight\" -->\n                <div *cdkDragPlaceholder></div>\n            </mat-list-item>\n          </mat-list>\n        </div>\n\n      </mat-tab>\n\n    @if (story) {\n      <mat-tab [label]=\"'Ngm.Calculation.PARAMETERS' | translate: {Default: 'Parameters'}\">\n        <ng-template matTabContent>\n          <div class=\"w-full flex flex-col justify-start items-stretch p-4\">\n            <button mat-button displayDensity=\"cosy\" ngmAppearance=\"dashed\" (click)=\"openCreateParameter()\">\n              <div class=\"flex justify-center items-center\">\n                <mat-icon fontSet=\"material-icons-round\">add</mat-icon>\n                {{ 'Ngm.Calculation.PARAMETERS' | translate: {Default: 'Parameters'} }}\n              </div>\n            </button>\n\n            <mat-list role=\"list\" displayDensity=\"compact\"\n              id=\"ngm-calculated-parameters\"\n              cdkDropList\n              [cdkDropListData]=\"calculations\"\n            >\n              <mat-list-item role=\"listitem\" *ngFor=\"let property of parameters$ | async\" class=\"rounded-lg overflow-hidden hover:bg-gray-100\"\n                cdkDrag\n                [cdkDragData]=\"property\"\n              >\n                <div class=\"flex justify-between items-center\">\n                  <ngm-entity-property class=\"flex-1\" [property]=\"property\"></ngm-entity-property>\n                  <button mat-icon-button class=\"ngm-calculated-measure__parameter-edit\" (click)=\"openCreateParameter(property)\">\n                    <mat-icon fontSet=\"material-icons-round\">edit</mat-icon>\n                  </button>\n                </div>\n\n                <div *cdkDragPlaceholder></div>\n              </mat-list-item>\n            </mat-list>\n          </div>\n        </ng-template>\n      </mat-tab>\n    }\n\n      <mat-tab [label]=\"'Ngm.Calculation.Formulas' | translate: {Default: 'Formulas'}\">\n        <ng-template matTabContent>\n          <div class=\"flex-1 flex flex-col justify-start items-stretch overflow-auto\">\n            <ngm-search class=\"p-2\" [formControl]=\"fnSearchControl\"></ngm-search>\n          \n            <mat-accordion id=\"ngm-calculated-functions\" cdkDropList\n              [cdkDropListData]=\"FUNCTIONS\">\n              @for (f of functions$ | async; track f) {\n                <mat-expansion-panel hideToggle class=\"mat-elevation-z\" style=\"background: transparent\">\n                  <mat-expansion-panel-header>\n                    <mat-panel-title cdkDrag\n                      [cdkDragData]=\"f.insertText\">\n                      <span [ngmHighlight]=\"fnHighlight\" [caseSensitive]=\"false\" customClasses=\"bg-transparent font-semibold text-amber-500\"\n                        [content]=\"f.label\">\n                      </span>\n                    </mat-panel-title>\n                  </mat-expansion-panel-header>\n        \n                  <ng-template matExpansionPanelContent>\n                    <div class=\"my-2 text-xs font-mono italic\">\n                      {{f.expression}}\n                    </div>\n                    <markdown [textContent]=\"f.documentation\" class=\"\"></markdown>\n                  </ng-template>\n                </mat-expansion-panel>\n              }\n            </mat-accordion>\n          </div>\n        </ng-template>\n      </mat-tab>\n    </mat-tab-group>\n\n    <div ngmResizerBar resizerBarPosition=\"left\" style=\"z-index: 1;\" class=\"absolute top-0\"\n      cdkDrag\n      cdkDragLockAxis=\"x\"\n    ></div>\n  </mat-drawer>\n\n  <mat-drawer-content class=\"flex flex-col justify-between items-stretch\">\n    <div class=\"p-2 flex justify-between items-center\">\n      <div class=\"flex items-center\">\n        <ng-content select=\"[icon]\"></ng-content>\n        <span class=\"text-lg font-medium\">\n          {{ 'Ngm.Calculation.EDIT_FORMULA' | translate: {Default: \"Edit Formula\"} }}\n        </span>\n      </div>\n\n      <div class=\"flex justify-around items-center gap-1\">\n        <ng-content select=\".ngm-calculated-measure__action\"></ng-content>\n\n        <button type=\"button\" class=\"action-btn action-btn-m w-7 h-7\"\n          [class.text-primary-500]=\"editorOptions().wordWrap\"\n          (click)=\"toggleWrap()\"\n        >\n          <i class=\"ri-text-wrap text-base\"></i>\n        </button>\n\n        <button type=\"button\" class=\"action-btn action-btn-m w-7 h-7\"\n          [class.text-primary-500]=\"drawerOpened()\"\n          [matTooltip]=\"'Ngm.Calculation.ToggleSidebar' | translate: {Default: 'Toggle Sidebar'}\"\n          matTooltipPosition=\"above\"\n          (click)=\"toggleSideMenu()\"\n        >\n          @if (drawerOpened()) {\n            <i class=\"ri-sidebar-unfold-line text-base\"></i>\n          } @else {\n            <i class=\"ri-sidebar-fold-line text-base\"></i>  \n          }\n        </button>\n      </div>\n    </div>\n\n    @if (syntax()===Syntax.MDX) {\n      <ngm-mdx-editor #editor class=\"ngm-calculated-measure__monaco-editor pac-cdk-drop__list pac-cdk-drop__area flex-1\"\n        id=\"ngm-calculated-editor\"\n        cdkDropList\n        [cdkDropListEnterPredicate]=\"dropPredicate\"\n        [cdkDropListData]=\"calculations\"\n        (cdkDropListDropped)=\"drop($event)\"\n        [entityType]=\"entityType()\"\n        [formControl]=\"statement\"\n        [options]=\"editorOptions()\"\n        (blur)=\"onBlur()\"\n      />\n    } @else if (syntax()===Syntax.SQL) {\n    <!-- <ngm-editor-sql class=\"ngm-calculated-measure__monaco-editor flex-1\"\n        id=\"ngm-calculated-editor\"\n        cdkDropList\n        [cdkDropListData]=\"calculations\"\n        (cdkDropListDropped)=\"drop($event)\"\n        [entityType]=\"entityType()\"\n        [formControl]=\"statement\"\n    >\n    </ngm-editor-sql> -->\n    }\n\n    <ngm-drawer-trigger class=\"absolute -right-2 top-1/2 -translate-y-1/2 z-40\"\n      side=\"right\"\n      [(opened)]=\"drawerOpened\"\n      [matTooltip]=\"'Ngm.Calculation.ToggleSidebar' | translate: {Default: 'Toggle Sidebar'}\"\n    />\n  </mat-drawer-content>\n</mat-drawer-container>\n", styles: [":host{--mat-sidenav-container-divider-color: var(--ngm-color-outline-variant);display:flex;flex-direction:row;align-items:stretch}:host .ngm-calculated-measure__drawer{overflow:visible}:host .ngm-calculated-measure__drawer .ngm-calculated-measure__drawer-anchor{position:absolute;left:-40px;top:0;opacity:.5}:host .ngm-calculated-measure__drawer .ngm-calculated-measure__drawer-anchor:hover{opacity:1}:host .ngm-calculated-measure__monaco-editor{flex:1}:host .ngm-calculated-measure__formula-functions{flex:1}:host .ngm-calculated-measure__formula-functions .ngm-mdx-functions__function-option .ngm-mdx-functions__help-trigger{opacity:0;visibility:hidden;transition:all .3s ease-in-out}:host .ngm-calculated-measure__formula-functions .ngm-mdx-functions__function-option:hover .ngm-mdx-functions__help-trigger{opacity:1;visibility:visible}:host::ng-deep .ngm-calculated-measure__helpers .mat-mdc-tab-header{--mdc-secondary-navigation-tab-container-height: 38px}:host::ng-deep .ngm-calculated-measure__helpers .mdc-tab{display:flex;min-width:0px;align-items:center;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:host::ng-deep .ngm-calculated-measure__helpers .mdc-tab:after{content:\"\";height:15px;width:2px;position:absolute;right:0;border-radius:2px;--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity))}:is(.dark :host::ng-deep .ngm-calculated-measure__helpers .mdc-tab):after{--tw-bg-opacity: 1;background-color:rgb(64 64 64 / var(--tw-bg-opacity))}:host::ng-deep .ngm-calculated-measure__helpers .mdc-tab:not(.mdc-tab--active){padding-left:.5rem;padding-right:.5rem}:host::ng-deep .ngm-calculated-measure__helpers .mdc-tab.mdc-tab--active{padding-left:2.5rem;padding-right:2.5rem}:host::ng-deep .ngm-calculated-measure__helpers .mat-mdc-tab-body-wrapper{flex:1}:host::ng-deep .ngm-calculated-measure__helpers .mat-mdc-tab-body-wrapper .mat-mdc-tab-body-content{display:flex}.mat-drawer-content{position:relative;display:flex;flex-direction:column;overflow:hidden}.mat-drawer-content .mat-toolbar{height:44px;font-size:1rem}.ngm-calculated-measure__helpers{--mdc-list-list-item-container-shape: .375rem;height:100%}.ngm-calculated-measure__helpers ngm-entity-member-select{flex:1;min-width:300px}#ngm-calculated-parameters .mat-mdc-list-item .ngm-calculated-measure__parameter-edit{opacity:0}#ngm-calculated-parameters .mat-mdc-list-item:hover .ngm-calculated-measure__parameter-edit{opacity:1}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: DragDropModule }, { kind: "directive", type: i3.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: i3.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: i3.CdkDragPlaceholder, selector: "ng-template[cdkDragPlaceholder]", inputs: ["data"] }, { kind: "ngmodule", type: MatSidenavModule }, { kind: "component", type: i4.MatDrawer, selector: "mat-drawer", inputs: ["position", "mode", "disableClose", "autoFocus", "opened"], outputs: ["openedChange", "opened", "openedStart", "closed", "closedStart", "positionChanged"], exportAs: ["matDrawer"] }, { kind: "component", type: i4.MatDrawerContainer, selector: "mat-drawer-container", inputs: ["autosize", "hasBackdrop"], outputs: ["backdropClick"], exportAs: ["matDrawerContainer"] }, { kind: "component", type: i4.MatDrawerContent, selector: "mat-drawer-content" }, { kind: "ngmodule", type: MatTabsModule }, { kind: "directive", type: i5.MatTabContent, selector: "[matTabContent]" }, { kind: "component", type: i5.MatTab, selector: "mat-tab", inputs: ["disabled", "label", "aria-label", "aria-labelledby", "labelClass", "bodyClass"], exportAs: ["matTab"] }, { kind: "component", type: i5.MatTabGroup, selector: "mat-tab-group", inputs: ["color", "fitInkBarToContent", "mat-stretch-tabs", "dynamicHeight", "selectedIndex", "headerPosition", "animationDuration", "contentTabIndex", "disablePagination", "disableRipple", "preserveContent", "backgroundColor"], outputs: ["selectedIndexChange", "focusChange", "animationDone", "selectedTabChange"], exportAs: ["matTabGroup"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i6.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i7.MatButton, selector: "    button[mat-button], button[mat-raised-button], button[mat-flat-button],    button[mat-stroked-button]  ", exportAs: ["matButton"] }, { kind: "component", type: i7.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "ngmodule", type: MatListModule }, { kind: "component", type: i8.MatList, selector: "mat-list", exportAs: ["matList"] }, { kind: "component", type: i8.MatListItem, selector: "mat-list-item, a[mat-list-item], button[mat-list-item]", inputs: ["activated"], exportAs: ["matListItem"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i9.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "ngmodule", type: MatExpansionModule }, { kind: "directive", type: i10.MatAccordion, selector: "mat-accordion", inputs: ["hideToggle", "displayMode", "togglePosition"], exportAs: ["matAccordion"] }, { kind: "component", type: i10.MatExpansionPanel, selector: "mat-expansion-panel", inputs: ["hideToggle", "togglePosition"], outputs: ["afterExpand", "afterCollapse"], exportAs: ["matExpansionPanel"] }, { kind: "component", type: i10.MatExpansionPanelHeader, selector: "mat-expansion-panel-header", inputs: ["expandedHeight", "collapsedHeight", "tabIndex"] }, { kind: "directive", type: i10.MatExpansionPanelTitle, selector: "mat-panel-title" }, { kind: "directive", type: i10.MatExpansionPanelContent, selector: "ng-template[matExpansionPanelContent]" }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i11.TranslatePipe, name: "translate" }, { kind: "ngmodule", type: MarkdownModule }, { kind: "component", type: i12.MarkdownComponent, selector: "markdown, [markdown]", inputs: ["data", "src", "disableSanitizer", "inline", "clipboard", "clipboardButtonComponent", "clipboardButtonTemplate", "emoji", "katex", "katexOptions", "mermaid", "mermaidOptions", "lineHighlight", "line", "lineOffset", "lineNumbers", "start", "commandLine", "filterOutput", "host", "prompt", "output", "user"], outputs: ["error", "load", "ready"] }, { kind: "ngmodule", type: OcapCoreModule }, { kind: "directive", type: i13.DensityDirective, selector: "[displayDensity]", inputs: ["displayDensity"] }, { kind: "directive", type: i13.AppearanceDirective, selector: "[ngmAppearance]", inputs: ["color", "ngmAppearance", "outline", "hero", "acrylic", "opacity", "dashed", "danger"] }, { kind: "ngmodule", type: NgmCommonModule }, { kind: "directive", type: i14.ResizerDirective, selector: "[ngmResizer]", inputs: ["resizerWidth", "resizerHeight", "ngmResizerDisabled"], outputs: ["resizerWidthChange", "resizerHeightChange"] }, { kind: "directive", type: i14.ResizerBarDirective, selector: "[ngmResizerBar]", inputs: ["resizerBarPosition"] }, { kind: "directive", type: i14.NgmHighlightDirective, selector: "[ngmHighlight]", inputs: ["ngmHighlight", "content", "caseSensitive", "customClasses"] }, { kind: "component", type: i14.NgmSearchComponent, selector: "ngm-search", inputs: ["formControl", "disabled", "displayDensity"] }, { kind: "component", type: i14.NgmDrawerTriggerComponent, selector: "ngm-drawer-trigger", inputs: ["opened", "side"], outputs: ["openedChange"] }, { kind: "ngmodule", type: ResizerModule }, { kind: "component", type: NgmEntityPropertyComponent, selector: "ngm-entity-property", inputs: ["property", "displayBehaviour", "displayDensity", "hiddenIcon", "highlight", "role"] }, { kind: "component", type: NgmEntitySchemaComponent, selector: "ngm-entity-schema", inputs: ["dsCoreService", "appearance", "selectedHierarchy", "capacities", "dragDisabled", "dataSettings"] }, { kind: "component", type: NgmMDXEditorComponent, selector: "ngm-mdx-editor", inputs: ["entityType"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NgmCalculatedMeasureComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [
                        CommonModule,
                        FormsModule,
                        ReactiveFormsModule,
                        DragDropModule,
                        MatSidenavModule,
                        MatTabsModule,
                        MatIconModule,
                        MatButtonModule,
                        MatListModule,
                        MatTooltipModule,
                        MatExpansionModule,
                        TranslateModule,
                        MarkdownModule,
                        OcapCoreModule,
                        NgmCommonModule,
                        ResizerModule,
                        NgmEntityPropertyComponent,
                        NgmEntitySchemaComponent,
                        NgmHighlightDirective,
                        NgmMDXEditorComponent
                    ], selector: 'ngm-calculated-measure', host: {
                        class: 'ngm-calculated-measure'
                    }, providers: [
                        {
                            provide: NG_VALUE_ACCESSOR,
                            multi: true,
                            useExisting: forwardRef(() => NgmCalculatedMeasureComponent)
                        }
                    ], template: "<mat-drawer-container class=\"flex flex-1\" [hasBackdrop]=\"false\" autosize>\n  <mat-drawer #drawer class=\"ngm-calculated-measure__drawer\"\n    mode=\"side\" position=\"end\" ngmResizer [resizerWidth]=\"330\"\n    [(opened)]=\"drawerOpened\"\n    (openedChange)=\"$event?helper.realignInkBar():''\">\n    <mat-tab-group #helper class=\"ngm-calculated-measure__helpers\" mat-stretch-tabs=\"false\" >\n      <mat-tab [label]=\"'Ngm.Calculation.DIMENSION_MEMBERS' | translate: {Default: 'Dimension Members'}\"\n        id=\"ngm-calculated-measure__entity-schema\"\n        cdkDropList\n        [cdkDropListData]=\"[]\"\n      >\n        <ngm-entity-schema class=\"flex-1 max-w-full w-full\"\n          [dsCoreService]=\"dsCoreService()\"\n          [dataSettings]=\"dataSettings()\"\n          [capacities]=\"[\n            EntityCapacity.Dimension,\n            EntityCapacity.Measure\n          ]\">\n        </ngm-entity-schema>\n      </mat-tab>\n\n      <mat-tab [label]=\"'Ngm.Calculation.CALCULATED_MEMBERS' | translate: {Default: 'Calculated Members'}\">\n        <div class=\"max-w-full w-full flex flex-col justify-start items-stretch overflow-hidden\">\n          <ngm-search class=\"m-1\" [formControl]=\"calculatedMemberSearch\"></ngm-search>\n          <mat-list role=\"list\" class=\"flex-1 max-w-full w-full overflow-auto\" displayDensity=\"cosy\"\n            id=\"ngm-calculated-calculations\"\n            cdkDropList\n            [cdkDropListData]=\"calculations\"\n            (cdkDropListDropped)=\"drop($event)\"\n            >\n            <mat-list-item role=\"listitem\" *ngFor=\"let property of calculations$ | async\" class=\"hover:bg-neutral-100 dark:hover:bg-neutral-800\"\n              cdkDrag\n              [cdkDragData]=\"property\"\n            >\n              <ngm-entity-property class=\"flex-1\" [property]=\"property\"></ngm-entity-property> <!-- [highlight]=\"calculatedMemberHighlight\" -->\n                <div *cdkDragPlaceholder></div>\n            </mat-list-item>\n          </mat-list>\n        </div>\n\n      </mat-tab>\n\n    @if (story) {\n      <mat-tab [label]=\"'Ngm.Calculation.PARAMETERS' | translate: {Default: 'Parameters'}\">\n        <ng-template matTabContent>\n          <div class=\"w-full flex flex-col justify-start items-stretch p-4\">\n            <button mat-button displayDensity=\"cosy\" ngmAppearance=\"dashed\" (click)=\"openCreateParameter()\">\n              <div class=\"flex justify-center items-center\">\n                <mat-icon fontSet=\"material-icons-round\">add</mat-icon>\n                {{ 'Ngm.Calculation.PARAMETERS' | translate: {Default: 'Parameters'} }}\n              </div>\n            </button>\n\n            <mat-list role=\"list\" displayDensity=\"compact\"\n              id=\"ngm-calculated-parameters\"\n              cdkDropList\n              [cdkDropListData]=\"calculations\"\n            >\n              <mat-list-item role=\"listitem\" *ngFor=\"let property of parameters$ | async\" class=\"rounded-lg overflow-hidden hover:bg-gray-100\"\n                cdkDrag\n                [cdkDragData]=\"property\"\n              >\n                <div class=\"flex justify-between items-center\">\n                  <ngm-entity-property class=\"flex-1\" [property]=\"property\"></ngm-entity-property>\n                  <button mat-icon-button class=\"ngm-calculated-measure__parameter-edit\" (click)=\"openCreateParameter(property)\">\n                    <mat-icon fontSet=\"material-icons-round\">edit</mat-icon>\n                  </button>\n                </div>\n\n                <div *cdkDragPlaceholder></div>\n              </mat-list-item>\n            </mat-list>\n          </div>\n        </ng-template>\n      </mat-tab>\n    }\n\n      <mat-tab [label]=\"'Ngm.Calculation.Formulas' | translate: {Default: 'Formulas'}\">\n        <ng-template matTabContent>\n          <div class=\"flex-1 flex flex-col justify-start items-stretch overflow-auto\">\n            <ngm-search class=\"p-2\" [formControl]=\"fnSearchControl\"></ngm-search>\n          \n            <mat-accordion id=\"ngm-calculated-functions\" cdkDropList\n              [cdkDropListData]=\"FUNCTIONS\">\n              @for (f of functions$ | async; track f) {\n                <mat-expansion-panel hideToggle class=\"mat-elevation-z\" style=\"background: transparent\">\n                  <mat-expansion-panel-header>\n                    <mat-panel-title cdkDrag\n                      [cdkDragData]=\"f.insertText\">\n                      <span [ngmHighlight]=\"fnHighlight\" [caseSensitive]=\"false\" customClasses=\"bg-transparent font-semibold text-amber-500\"\n                        [content]=\"f.label\">\n                      </span>\n                    </mat-panel-title>\n                  </mat-expansion-panel-header>\n        \n                  <ng-template matExpansionPanelContent>\n                    <div class=\"my-2 text-xs font-mono italic\">\n                      {{f.expression}}\n                    </div>\n                    <markdown [textContent]=\"f.documentation\" class=\"\"></markdown>\n                  </ng-template>\n                </mat-expansion-panel>\n              }\n            </mat-accordion>\n          </div>\n        </ng-template>\n      </mat-tab>\n    </mat-tab-group>\n\n    <div ngmResizerBar resizerBarPosition=\"left\" style=\"z-index: 1;\" class=\"absolute top-0\"\n      cdkDrag\n      cdkDragLockAxis=\"x\"\n    ></div>\n  </mat-drawer>\n\n  <mat-drawer-content class=\"flex flex-col justify-between items-stretch\">\n    <div class=\"p-2 flex justify-between items-center\">\n      <div class=\"flex items-center\">\n        <ng-content select=\"[icon]\"></ng-content>\n        <span class=\"text-lg font-medium\">\n          {{ 'Ngm.Calculation.EDIT_FORMULA' | translate: {Default: \"Edit Formula\"} }}\n        </span>\n      </div>\n\n      <div class=\"flex justify-around items-center gap-1\">\n        <ng-content select=\".ngm-calculated-measure__action\"></ng-content>\n\n        <button type=\"button\" class=\"action-btn action-btn-m w-7 h-7\"\n          [class.text-primary-500]=\"editorOptions().wordWrap\"\n          (click)=\"toggleWrap()\"\n        >\n          <i class=\"ri-text-wrap text-base\"></i>\n        </button>\n\n        <button type=\"button\" class=\"action-btn action-btn-m w-7 h-7\"\n          [class.text-primary-500]=\"drawerOpened()\"\n          [matTooltip]=\"'Ngm.Calculation.ToggleSidebar' | translate: {Default: 'Toggle Sidebar'}\"\n          matTooltipPosition=\"above\"\n          (click)=\"toggleSideMenu()\"\n        >\n          @if (drawerOpened()) {\n            <i class=\"ri-sidebar-unfold-line text-base\"></i>\n          } @else {\n            <i class=\"ri-sidebar-fold-line text-base\"></i>  \n          }\n        </button>\n      </div>\n    </div>\n\n    @if (syntax()===Syntax.MDX) {\n      <ngm-mdx-editor #editor class=\"ngm-calculated-measure__monaco-editor pac-cdk-drop__list pac-cdk-drop__area flex-1\"\n        id=\"ngm-calculated-editor\"\n        cdkDropList\n        [cdkDropListEnterPredicate]=\"dropPredicate\"\n        [cdkDropListData]=\"calculations\"\n        (cdkDropListDropped)=\"drop($event)\"\n        [entityType]=\"entityType()\"\n        [formControl]=\"statement\"\n        [options]=\"editorOptions()\"\n        (blur)=\"onBlur()\"\n      />\n    } @else if (syntax()===Syntax.SQL) {\n    <!-- <ngm-editor-sql class=\"ngm-calculated-measure__monaco-editor flex-1\"\n        id=\"ngm-calculated-editor\"\n        cdkDropList\n        [cdkDropListData]=\"calculations\"\n        (cdkDropListDropped)=\"drop($event)\"\n        [entityType]=\"entityType()\"\n        [formControl]=\"statement\"\n    >\n    </ngm-editor-sql> -->\n    }\n\n    <ngm-drawer-trigger class=\"absolute -right-2 top-1/2 -translate-y-1/2 z-40\"\n      side=\"right\"\n      [(opened)]=\"drawerOpened\"\n      [matTooltip]=\"'Ngm.Calculation.ToggleSidebar' | translate: {Default: 'Toggle Sidebar'}\"\n    />\n  </mat-drawer-content>\n</mat-drawer-container>\n", styles: [":host{--mat-sidenav-container-divider-color: var(--ngm-color-outline-variant);display:flex;flex-direction:row;align-items:stretch}:host .ngm-calculated-measure__drawer{overflow:visible}:host .ngm-calculated-measure__drawer .ngm-calculated-measure__drawer-anchor{position:absolute;left:-40px;top:0;opacity:.5}:host .ngm-calculated-measure__drawer .ngm-calculated-measure__drawer-anchor:hover{opacity:1}:host .ngm-calculated-measure__monaco-editor{flex:1}:host .ngm-calculated-measure__formula-functions{flex:1}:host .ngm-calculated-measure__formula-functions .ngm-mdx-functions__function-option .ngm-mdx-functions__help-trigger{opacity:0;visibility:hidden;transition:all .3s ease-in-out}:host .ngm-calculated-measure__formula-functions .ngm-mdx-functions__function-option:hover .ngm-mdx-functions__help-trigger{opacity:1;visibility:visible}:host::ng-deep .ngm-calculated-measure__helpers .mat-mdc-tab-header{--mdc-secondary-navigation-tab-container-height: 38px}:host::ng-deep .ngm-calculated-measure__helpers .mdc-tab{display:flex;min-width:0px;align-items:center;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:host::ng-deep .ngm-calculated-measure__helpers .mdc-tab:after{content:\"\";height:15px;width:2px;position:absolute;right:0;border-radius:2px;--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity))}:is(.dark :host::ng-deep .ngm-calculated-measure__helpers .mdc-tab):after{--tw-bg-opacity: 1;background-color:rgb(64 64 64 / var(--tw-bg-opacity))}:host::ng-deep .ngm-calculated-measure__helpers .mdc-tab:not(.mdc-tab--active){padding-left:.5rem;padding-right:.5rem}:host::ng-deep .ngm-calculated-measure__helpers .mdc-tab.mdc-tab--active{padding-left:2.5rem;padding-right:2.5rem}:host::ng-deep .ngm-calculated-measure__helpers .mat-mdc-tab-body-wrapper{flex:1}:host::ng-deep .ngm-calculated-measure__helpers .mat-mdc-tab-body-wrapper .mat-mdc-tab-body-content{display:flex}.mat-drawer-content{position:relative;display:flex;flex-direction:column;overflow:hidden}.mat-drawer-content .mat-toolbar{height:44px;font-size:1rem}.ngm-calculated-measure__helpers{--mdc-list-list-item-container-shape: .375rem;height:100%}.ngm-calculated-measure__helpers ngm-entity-member-select{flex:1;min-width:300px}#ngm-calculated-parameters .mat-mdc-list-item .ngm-calculated-measure__parameter-edit{opacity:0}#ngm-calculated-parameters .mat-mdc-list-item:hover .ngm-calculated-measure__parameter-edit{opacity:1}\n"] }]
        }], ctorParameters: () => [], propDecorators: { story: [{
                type: Input
            }], editor: [{
                type: ViewChild,
                args: ['editor']
            }] } });
//# sourceMappingURL=data:application/json;base64, 