/**
 * @fileoverview Classify · Source + Content Type CRUD slide-in form dialog.
 *
 * Owns the entire add/edit slide-in form for BOTH content sources and content
 * types (the form renders one or the other depending on `FormMode`). Extracted
 * from the host monolith: the dialog owns ALL form state, the dropdown option
 * getters, the dynamic source-type field logic, and the open / populate / save /
 * close lifecycle. It reads cached reference metadata directly from
 * `KnowledgeHubMetadataEngine.Instance` / `AIEngineBase.Instance` (same as the
 * host did) and persists via the threaded provider.
 *
 * Contract with the host (data orchestrator):
 *   - The host calls the public `OpenAddSource()` / `OpenEditSource(card)` /
 *     `OpenAddType()` / `OpenEditType(card)` methods via `@ViewChild` in response
 *     to the Sources/Types tabs' add/edit events.
 *   - After a successful save the dialog closes itself and emits `(Saved)` with
 *     `{ kind: 'source' | 'type' }` so the host reloads the right shared data.
 *   - When a source save is blocked because no content type exists, it emits
 *     `(ContentTypeMissing)` so the host shows its no-content-type warning.
 *   - "Open advanced settings" navigates to the full entity form via the host's
 *     NavigationService through the `(NavigateToRecordRequested)` output.
 */
import { EventEmitter, OnDestroy } from '@angular/core';
import { CompositeKey } from '@memberjunction/core';
import { TreeBranchConfig, TreeLeafConfig } from '@memberjunction/ng-trees';
import { MJContentSourceEntity_IContentSourceConfiguration, MJContentSourceTypeEntity_IContentSourceTypeField } from '@memberjunction/core-entities';
import { BaseAngularComponent } from '@memberjunction/ng-base-types';
import { SourceCard, ContentTypeCard, DropdownOption, FormMode } from '../shared/classify.types';
import * as i0 from "@angular/core";
/** The taxonomy-mode literal union, derived from the typed config so it can never drift. */
type TaxonomyModeJson = NonNullable<MJContentSourceEntity_IContentSourceConfiguration['TagTaxonomyMode']>;
/** How the source-level domain context combines with the org / content-type scopes. */
export type ClassificationContextMode = 'additive' | 'substitutive';
/**
 * Source-level classification-context extension to the CodeGen-generated
 * {@link MJContentSourceEntity_IContentSourceConfiguration} interface. These two
 * keys are not yet in the generated JSON-type interface (a migration + CodeGen
 * pass is required to add them there); we model them as a typed extension so this
 * client code stays strongly typed without touching generated code. They are
 * persisted into the source's Configuration JSON and read by the server-side
 * `ClassificationContextResolver` during autotagging.
 */
export interface IContentSourceClassificationConfiguration extends MJContentSourceEntity_IContentSourceConfiguration {
    /** Free-text guidance injected into the autotagging prompt at the SOURCE scope. */
    ClassificationContext?: string;
    /** How this source's context combines with the org/type scopes. Defaults to 'additive'. */
    ClassificationContextMode?: ClassificationContextMode;
}
/**
 * Application name used to resolve the Knowledge Hub Application ID for the
 * org-level classification-context ApplicationSetting. Mirrors the server-side
 * `KNOWLEDGE_HUB_APPLICATION_NAME` constant.
 */
export declare const KNOWLEDGE_HUB_APPLICATION_NAME = "Knowledge Hub";
/** ApplicationSetting key under which the org-level classification context lives. */
export declare const CLASSIFY_ORG_CONTEXT_SETTING_KEY = "classify.org.context";
/** One selectable taxonomy-mode card (icon + name + one-line "best for"). */
interface TaxonomyModeOption {
    value: TaxonomyModeJson;
    label: string;
    icon: string;
    bestFor: string;
}
/** One row in the effective-values aside: the resolved value + where it came from. */
interface EffectiveValueRow {
    label: string;
    value: string;
    origin: 'source override' | 'default';
}
export declare class ClassifySourceTypeFormDialogComponent extends BaseAngularComponent implements OnDestroy {
    private cdr;
    private zone;
    /** Current slide-in panel width (px). Bound to the panel via [style.width.px]. */
    PanelWidth: number;
    /** Whether the inline "Effective values" panel is shown in the Classification section. */
    ShowEffectiveValues: boolean;
    /** Active-drag bookkeeping for the left-edge resize handle. */
    private isResizing;
    private resizeMoveListener;
    private resizeUpListener;
    /** Emitted after a successful save so the host reloads the relevant shared data. */
    Saved: EventEmitter<{
        kind: "source" | "type";
    }>;
    /** Emitted when a source save is blocked because no content type exists. */
    ContentTypeMissing: EventEmitter<void>;
    /** Emitted when the user opts into the full entity form (advanced settings). */
    NavigateToRecordRequested: EventEmitter<{
        entityName: string;
        key: CompositeKey;
    }>;
    FormMode: FormMode;
    FormSaving: boolean;
    FormSourceName: string;
    FormSourceTypeID: string;
    FormContentTypeID: string;
    FormFileTypeID: string;
    FormSourceURL: string;
    EditingSourceID: string;
    FormTypeName: string;
    FormTypeDescription: string;
    FormTypeAIModelID: string;
    FormTypeMinTags: number;
    FormTypeMaxTags: number;
    EditingTypeID: string;
    FormTypeEmbeddingModelID: string;
    FormTypeVectorIndexID: string;
    FormSourceEntityID: string;
    FormSourceEntityDocID: string;
    /** Whether the inline "Create Entity Document" sub-form is expanded. */
    ShowInlineEntityDocForm: boolean;
    /** Saving spinner for the inline Entity Document create. */
    EntityDocSaving: boolean;
    /** Name for the new Entity Document (auto-filled from the entity). */
    NewEntityDocName: string;
    /** Selected field names to include in the new Entity Document template. */
    NewEntityDocSelectedFields: Record<string, boolean>;
    FormSourceEmbeddingModelID: string;
    FormSourceVectorIndexID: string;
    FormMaxItemsPerRun: number | null;
    FormMaxDepth: number | null;
    FormCrawlSitesInLowerLevelDomain: boolean;
    FormCrawlOtherSitesInTopLevelDomain: boolean;
    private workingConfig;
    /** Selectable taxonomy-mode cards. Exactly the three modes the type allows — no 'hybrid'. */
    readonly TaxonomyModes: TaxonomyModeOption[];
    /** Tags eligible to be the taxonomy root (loaded from TagEngineBase). */
    TagRootOptions: {
        ID: string;
        Name: string;
    }[];
    /** The working classifier config — never null; defaults are applied by the typed getters below. */
    get Config(): IContentSourceClassificationConfiguration;
    /** Merge a partial patch into the working config (immutable spread, like the reference panel). */
    setConfig(patch: Partial<IContentSourceClassificationConfiguration>): void;
    get CurrentMode(): TaxonomyModeJson;
    SetMode(mode: TaxonomyModeJson): void;
    get MatchThresholdValue(): number;
    set MatchThresholdValue(v: number | string);
    get SuggestThresholdValue(): number;
    set SuggestThresholdValue(v: number | string);
    get ThresholdValidationMessage(): string | null;
    get TagRootIDValue(): string;
    set TagRootIDValue(v: string);
    get ShareTaxonomyValue(): boolean;
    set ShareTaxonomyValue(v: boolean);
    get EnableVectorizationValue(): boolean;
    set EnableVectorizationValue(v: boolean);
    /** Source-level domain-context free text. */
    get ClassificationContextValue(): string;
    set ClassificationContextValue(v: string);
    /** Whether this source's context is additive (concatenated) or substitutive (most-specific wins). */
    get ClassificationContextModeValue(): ClassificationContextMode;
    set ClassificationContextModeValue(v: ClassificationContextMode);
    /** Convenience boolean bound to the additive/substitutive mj-switch. On = substitutive. */
    get IsSubstitutiveMode(): boolean;
    set IsSubstitutiveMode(v: boolean);
    /**
     * The org-level domain context, resolved once from ApplicationSettingEngine
     * (Knowledge Hub app scope, GLOBAL fallback). Read-only here — the org editor
     * lives on the Content Types tab. Used for the effective-context preview.
     */
    OrgClassificationContext: string;
    /**
     * The effective domain-context preview the autotagger would assemble for this
     * source, mirroring the server-side `ClassificationContextResolver` combine
     * logic. Content-type scope is intentionally omitted here because the slide-in
     * doesn't load every content type's Configuration JSON — the preview shows the
     * org + source scopes (the two the operator edits in this flow).
     */
    get EffectiveContextPreview(): string;
    /** Normalize a raw context value: trim, treat empty as undefined. */
    private cleanContext;
    get MaxNewTagsPerRunValue(): number | null;
    set MaxNewTagsPerRunValue(v: number | string | null);
    get MaxNewTagsPerItemValue(): number | null;
    set MaxNewTagsPerItemValue(v: number | string | null);
    get MaxTokensPerRunValue(): number | null;
    set MaxTokensPerRunValue(v: number | string | null);
    get MaxCostPerRunValue(): number | null;
    set MaxCostPerRunValue(v: number | string | null);
    /**
     * Coerce a possibly-blank input into a typed number. Returning undefined
     * deletes the key from the persisted JSON when the setConfig spread is applied.
     */
    private normalizeNullableNumber;
    /** Human label for the currently-selected tag root (for the effective-values aside). */
    private get tagRootLabel();
    /**
     * The effective value of each key knob + where it comes from. Since the tag
     * classifier fields are source-level JSON (no content-type cascade), the
     * effective value is the configured override or the documented default.
     */
    get EffectiveValues(): EffectiveValueRow[];
    /** True when the form's selected source type is Website — gates the crawler knobs. */
    get IsWebsiteSourceTypeSelected(): boolean;
    /** Whether the selected source type is the Entity type (name-based check) */
    get IsEntitySourceTypeSelected(): boolean;
    /** Whether the selected source type requires Content Type / File Type selection */
    get SelectedSourceTypeRequiresContentType(): boolean;
    /** Entities that have at least one EntityDocument configured */
    get EntitiesWithDocuments(): {
        ID: string;
        Name: string;
    }[];
    /** Entity documents for the selected entity */
    get EntityDocOptionsForSelectedEntity(): {
        ID: string;
        Name: string;
    }[];
    /**
     * The entity ID currently selected for an Entity-type source. The dynamic
     * entity-picker stores its value under its field Key (conventionally
     * 'EntityID') in FormSourceSpecificConfig; fall back to FormSourceEntityID.
     */
    get SelectedEntityID(): string;
    /** EntityInfo for the currently-selected entity, or null. */
    private get selectedEntityInfo();
    /** Display name of the selected entity (for the callout + auto-filled doc name). */
    get SelectedEntityName(): string;
    /**
     * True when an Entity source type is selected, an entity is chosen, and that
     * entity has NO active Entity Document — the trigger for the inline create UI.
     */
    get SelectedEntityHasNoDocument(): boolean;
    /** Fields of the selected entity, for the field-picker in the inline create form. */
    get SelectedEntityFields(): {
        Name: string;
        DisplayName: string;
    }[];
    /** Open the inline Entity Document create sub-form, auto-filling sensible defaults. */
    OpenInlineEntityDocForm(): void;
    CancelInlineEntityDocForm(): void;
    /** Number of currently-selected fields (template-facing). */
    get SelectedEntityDocFieldCount(): number;
    /**
     * Create a new Entity Document for the selected entity, then select it on the
     * form. Builds a simple template body referencing the chosen fields. The
     * Entity Document entity has several NOT NULL FKs (Type, VectorDatabase,
     * Template, AIModel) populated from cached Knowledge Hub / AI metadata.
     */
    CreateInlineEntityDocument(): Promise<void>;
    /** Stores source-type-specific config values keyed by RequiredFields[].Key */
    FormSourceSpecificConfig: Record<string, string>;
    /** Available MJ Storage provider keys for the storage-provider-picker widget */
    StorageProviderOptions: string[];
    /**
     * The RequiredFields array from the selected source type's ConfigurationObject.
     * Drives dynamic form rendering — each field becomes a widget.
     */
    get SelectedSourceTypeFields(): MJContentSourceTypeEntity_IContentSourceTypeField[];
    /**
     * Get dependent options for a field (e.g., entity-doc-picker depends on entity-picker).
     * Returns entity documents for the entity selected in the dependent field.
     */
    GetDependentOptions(field: MJContentSourceTypeEntity_IContentSourceTypeField): {
        ID: string;
        Name: string;
    }[];
    /**
     * Handle a source-specific field value change.
     * For entity-picker: auto-select the first entity doc if only one exists.
     */
    OnSourceFieldChanged(fieldKey: string): void;
    SourceTypeOptions: DropdownOption[];
    ContentTypeOptions: DropdownOption[];
    FileTypeOptions: DropdownOption[];
    AIModelOptions: DropdownOption[];
    EmbeddingModelOptions: DropdownOption[];
    VectorIndexOptions: DropdownOption[];
    AIModelVendorBranch: TreeBranchConfig;
    AllModelsLeaf: TreeLeafConfig;
    /** Branch config filtered to only vendors that have at least one embedding model */
    EmbeddingVendorBranch: TreeBranchConfig;
    EmbeddingModelsLeaf: TreeLeafConfig;
    /** Convert a string ID to a CompositeKey for tree-dropdown binding */
    ToCompositeKey(id: string | null | undefined): CompositeKey | null;
    /** Extract the ID string from a CompositeKey (from tree-dropdown ValueChange) */
    FromCompositeKey(key: CompositeKey | CompositeKey[] | null): string;
    OpenAddSource(): Promise<void>;
    OpenEditSource(card: SourceCard): Promise<void>;
    OpenAddType(): Promise<void>;
    OpenEditType(card: ContentTypeCard): Promise<void>;
    /**
     * Open the full entity form for the source currently being edited in the
     * slide-in. Quick-edit covers the most-used knobs; the entity form (with
     * the dynamically-mounted BaseFormPanel slots) exposes everything else
     * — taxonomy mode, thresholds, all five run-budget caps, URL pattern,
     * root URL, etc. The host owns NavigationService, so navigation bubbles up.
     */
    OpenAdvancedSourceSettings(): void;
    SaveSource(): Promise<void>;
    SaveContentType(): Promise<void>;
    CloseForm(): void;
    /**
     * Raw `MJ: Content Sources` rows, forwarded by the host so `OpenEditSource`
     * can hydrate the quick-edit knobs from the source's Configuration JSON. The
     * card the Sources tab passes doesn't carry the full Configuration blob.
     */
    RawSources: Record<string, unknown>[];
    private ensureFormDropdownsLoaded;
    /**
     * Resolve the Knowledge Hub Application ID by name (cached per dialog instance).
     * Returns null when no such application exists.
     */
    private khApplicationID;
    private resolveKnowledgeHubApplicationID;
    /** Read the org-level classification context for the effective-context preview. */
    private loadOrgClassificationContext;
    private resetSourceForm;
    /** Show / hide the inline effective-values panel in the Classification section. */
    ToggleEffectiveValues(): void;
    /** Clamp a candidate width to the allowed range (min .. 90% of viewport). */
    private clampPanelWidth;
    /**
     * Restore the remembered panel width from UserInfoEngine (a synchronous cache
     * read), falling back to the default. Called when a source form is opened.
     */
    private restorePanelWidth;
    /**
     * Begin a left-edge resize drag. The panel slides in from the right, so the
     * resizable edge is its LEFT edge: dragging left widens the panel.
     */
    StartResize(event: MouseEvent): void;
    /** Tear down the active drag listeners and persist the final width. */
    private endResize;
    ngOnDestroy(): void;
    private resetTypeForm;
    static ɵfac: i0.ɵɵFactoryDeclaration<ClassifySourceTypeFormDialogComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<ClassifySourceTypeFormDialogComponent, "classify-source-type-form-dialog", never, {}, { "Saved": "Saved"; "ContentTypeMissing": "ContentTypeMissing"; "NavigateToRecordRequested": "NavigateToRecordRequested"; }, never, never, false, never>;
}
export {};
//# sourceMappingURL=source-type-form.dialog.component.d.ts.map