{"version":3,"file":"angular-kit-cdk-template.mjs","sources":["../../../../libs/cdk/template/src/lib/rx-if-list/rx-if-list.directive.ts","../../../../libs/cdk/template/src/lib/fn/fn.pipe.ts","../../../../libs/cdk/template/src/lib/track-by/track-by-id.directive.ts","../../../../libs/cdk/template/src/lib/track-by/track-by-prop.directive.ts","../../../../libs/cdk/template/src/angular-kit-cdk-template.ts"],"sourcesContent":["import {\n  Directive,\n  EmbeddedViewRef,\n  Input,\n  OnDestroy,\n  TemplateRef,\n  ViewContainerRef,\n  ɵstringify as stringify\n} from '@angular/core';\nimport {distinctUntilChanged, mergeAll, Observable, ReplaySubject, Subscription} from \"rxjs\";\nimport {coerceObservable} from \"@angular-kit/cdk/coercing\";\n\n@Directive({\n  // eslint-disable-next-line @angular-eslint/directive-selector\n  selector: '[rxIfList]',\n  standalone: true\n})\nexport class RxIfListDirective implements OnDestroy{\n  /** @internal */\n  static rxIfListUseIfTypeGuard: void;\n\n  /**\n   * Assert the correct type of the expression bound to the `rxIfList` input within the template.\n   *\n   * The presence of this static field is a signal to the Ivy template type check compiler that\n   * when the `rxIfList` structural directive renders its template, the type of the expression bound\n   * to `rxIfList` should be narrowed in some way. For `rxIfList`, the binding expression itself is used to\n   * narrow its type, which allows the strictNullChecks feature of TypeScript to work with `rxIfList`.\n   */\n  static ngTemplateGuard_rxIfList: 'binding';\n\n  private readonly sub = new Subscription();\n  private readonly valueSource$$ = new ReplaySubject<Observable<ArrayLike<unknown> | null | undefined> >(1);\n  private _context: RxIfListContext = new RxIfListContext();\n  private _thenTemplateRef: TemplateRef<RxIfListContext>|null = null;\n  private _elseTemplateRef: TemplateRef<RxIfListContext>|null = null;\n  private _thenViewRef: EmbeddedViewRef<RxIfListContext>|null = null;\n  private _elseViewRef: EmbeddedViewRef<RxIfListContext>|null = null;\n\n\n  /**\n   * Asserts the correct type of the context for the template that `rxIfList` will render.\n   *\n   * The presence of this method is a signal to the Ivy template type-check compiler that the\n   * `rxIfList` structural directive renders its template with a specific context type.\n   */\n  static ngTemplateContextGuard<T>(dir: RxIfListDirective, ctx: any):\n    ctx is RxIfListContext{\n    return true;\n  }\n\n  constructor(private _viewContainer: ViewContainerRef, templateRef: TemplateRef<RxIfListContext>) {\n    this._thenTemplateRef = templateRef;\n    this.sub.add(\n      this.valueSource$$.asObservable().pipe(\n        distinctUntilChanged(),\n        mergeAll(),\n        distinctUntilChanged()\n      ).subscribe(value => {\n        this._context.$implicit = this._context.rxIfList = value;\n        this._updateView(this._context);\n      })\n    )\n  }\n  ngOnDestroy() {\n    this.sub.unsubscribe();\n  }\n\n  /**\n   * The Boolean expression to evaluate as the condition for showing a template.\n   */\n  @Input()\n  set rxIfList(value: ArrayLike<unknown> | Observable<ArrayLike<unknown>> | null | undefined) {\n    this.valueSource$$.next(coerceObservable(value));\n  }\n\n  /**\n   * A template to show if the condition expression evaluates to true.\n   */\n  @Input()\n  set rxIfListThen(templateRef: TemplateRef<RxIfListContext>|null) {\n    assertTemplate('rxIfListThen', templateRef);\n    this._thenTemplateRef = templateRef;\n    this._thenViewRef = null;  // clear previous view if any.\n    this._updateView(this._context);\n  }\n\n  /**\n   * A template to show if the condition expression evaluates to false.\n   */\n  @Input()\n  set rxIfListElse(templateRef: TemplateRef<RxIfListContext>|null) {\n    assertTemplate('rxIfListElse', templateRef);\n    this._elseTemplateRef = templateRef;\n    this._elseViewRef = null;  // clear previous view if any.\n    this._updateView(this._context);\n  }\n\n  private _updateView(ctx: RxIfListContext) {\n    // @ts-ignore\n    if (ctx.$implicit && (((ctx.$implicit as ArrayLike<any>)?.length ?? []) > 0)){\n      if (!this._thenViewRef) {\n        this._viewContainer.clear();\n        this._elseViewRef = null;\n        if (this._thenTemplateRef) {\n          this._thenViewRef =\n            this._viewContainer.createEmbeddedView(this._thenTemplateRef, ctx);\n        }\n      }\n    }  else {\n      if (!this._elseViewRef) {\n        this._viewContainer.clear();\n        this._thenViewRef = null;\n        if (this._elseTemplateRef) {\n          this._elseViewRef =\n            this._viewContainer.createEmbeddedView(this._elseTemplateRef, ctx);\n        }\n      }\n    }\n  }\n\n\n}\n\n/**\n * @publicApi\n */\nexport class RxIfListContext {\n   $implicit: ArrayLike<any> | null | undefined = null;\n   rxIfList: ArrayLike<any> | null | undefined = null;\n}\n\nfunction assertTemplate(property: string, templateRef: TemplateRef<any>|null): void {\n  const isTemplateRefOrNull = !!(!templateRef || templateRef.createEmbeddedView);\n  if (!isTemplateRefOrNull) {\n    throw new Error(`${property} must be a TemplateRef, but received '${stringify(templateRef)}'.`);\n  }\n}\n\n","import {Pipe, PipeTransform} from '@angular/core';\n\nexport type RunFnExpression<T> = (...args: any[]) => T\n\n@Pipe({\n  name: 'runFn',\n  standalone: true,\n})\nexport class RunFnPipe implements PipeTransform {\n  transform<T>(fn: RunFnExpression<T>, ...args: any[]): T {\n    if (!fn) {\n      throw new Error('fn is required');\n    }\n    return fn(...args);\n  }\n}\n","import {Directive, Host} from '@angular/core';\nimport {NgForOf} from '@angular/common';\n\n@Directive({\n  // eslint-disable-next-line @angular-eslint/directive-selector\n  selector: '[ngForTrackById]',\n  standalone: true,\n})\nexport class TrackByIdDirective<T extends {id: unknown}> {\n\n  constructor(@Host() private ngFor: NgForOf<T>) {\n    if (!ngFor){\n      throw new Error('ngForTrackById must be used with ngFor');\n    }\n    this.ngFor.ngForTrackBy = (index: number, item: T) => item.id;\n  }\n}\n\n","import {Directive, Host, Input} from '@angular/core';\nimport {NgForOf} from '@angular/common';\n\n@Directive({\n  // eslint-disable-next-line @angular-eslint/directive-selector\n  selector: '[ngForTrackByProp]',\n  standalone: true\n})\nexport class TrackByPropDirective<T> {\n  @Input() ngForTrackByProp!: keyof T;\n\n  constructor(@Host() private ngFor: NgForOf<T>) {\n    if (!ngFor){\n      throw new Error('ngForTrackByProp must be used with ngFor');\n    }\n\n    this.ngFor.ngForTrackBy = (index: number, item: T) =>\n      item[this.ngForTrackByProp];\n  }\n}\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["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