{"version":3,"file":"index.cjs","sources":["../src/utils/generate-vm-id.ts","../src/config/utils/merge-vm-configs.ts","../src/config/global-config.ts","../src/config/utils/apply-observable.ts","../src/utils/typeguards.ts","../src/view-model/view-model.base.ts","../src/view-model/view-model.store.base.ts"],"sourcesContent":["import { createCounter } from 'yummies/complex';\nimport type { AnyObject } from 'yummies/types';\nimport type { GenerateViewModelIdFn } from '../config/index.js';\n\ndeclare const process: { env: { NODE_ENV?: string } };\n\nconst staticCounter = createCounter((counter) => counter.toString(16));\n\nexport const generateVmId: GenerateViewModelIdFn = (ctx: AnyObject) => {\n  if (!ctx.generateId) {\n    const staticId = staticCounter();\n    const counter = createCounter((counter) =>\n      counter.toString().padStart(5, '0'),\n    );\n\n    ctx.generateId = () =>\n      `${staticId}_${counter().toString().padStart(5, '0')}`;\n  }\n\n  if (process.env.NODE_ENV === 'production') {\n    return ctx.generateId();\n  } else {\n    const viewModelName = ctx.VM?.name ?? '';\n\n    if (viewModelName) {\n      return `${viewModelName}_${ctx.generateId()}`;\n    } else {\n      return ctx.generateId();\n    }\n  }\n};\n","import type { Maybe } from 'yummies/types';\n\nimport { viewModelsConfig as globalConfig } from '../global-config.js';\nimport type { ViewModelsConfig, ViewModelsRawConfig } from '../types.js';\n\n/**\n * [**Documentation**](https://js2me.github.io/mobx-view-model/api/view-models/view-models-config)\n */\nexport const mergeVMConfigs = (...configs: Maybe<ViewModelsRawConfig>[]) => {\n  const result: ViewModelsConfig = {\n    ...globalConfig,\n    startViewTransitions: structuredClone(globalConfig.startViewTransitions),\n    observable: {\n      viewModels: {\n        ...globalConfig.observable.viewModels,\n      },\n      viewModelStores: {\n        ...globalConfig.observable.viewModelStores,\n      },\n    },\n  };\n\n  configs.forEach((config) => {\n    if (!config) {\n      return;\n    }\n\n    const {\n      startViewTransitions,\n      comparePayload,\n      observable,\n      generateId,\n      ...otherConfigUpdates\n    } = config;\n\n    if (generateId) {\n      result.generateId = generateId;\n    }\n    if (startViewTransitions) {\n      const startViewTransitonsUpdate: Partial<\n        ViewModelsConfig['startViewTransitions']\n      > =\n        typeof startViewTransitions === 'boolean'\n          ? ({\n              mount: startViewTransitions,\n              payloadChange: startViewTransitions,\n              unmount: startViewTransitions,\n            } satisfies ViewModelsConfig['startViewTransitions'])\n          : startViewTransitions;\n\n      Object.assign(result.startViewTransitions, startViewTransitonsUpdate);\n    }\n    if (observable?.viewModels) {\n      Object.assign(result.observable.viewModels, observable.viewModels || {});\n    }\n    if (observable?.viewModelStores) {\n      Object.assign(\n        result.observable.viewModelStores,\n        observable.viewModelStores || {},\n      );\n    }\n\n    if (comparePayload != null) {\n      result.comparePayload = comparePayload;\n    }\n\n    Object.assign(result, otherConfigUpdates);\n  });\n\n  return result;\n};\n","import { createGlobalConfig, createPubSub } from 'yummies/complex';\nimport { generateVmId } from '../utils/generate-vm-id.js';\nimport type { ViewModelStore } from '../view-model/view-model.store.js';\nimport type { ViewModelsConfig } from './types.js';\nimport { mergeVMConfigs } from './utils/merge-vm-configs.js';\n\n/**\n * Global configuration options for view models\n */\nexport const viewModelsConfig = createGlobalConfig<ViewModelsConfig>(\n  {\n    comparePayload: false,\n    payloadComputed: 'struct',\n    payloadObservable: 'ref',\n    wrapViewsInObserver: true,\n    startViewTransitions: {\n      mount: false,\n      payloadChange: false,\n      unmount: false,\n    },\n    observable: {\n      viewModels: {\n        useDecorators: true,\n      },\n      viewModelStores: {\n        useDecorators: true,\n      },\n    },\n    generateId: generateVmId,\n    flushPendingReactions: 100,\n    factory: (config) => {\n      const VM = config.VM;\n      return new VM({\n        ...config,\n        vmConfig: mergeVMConfigs(config.vmConfig),\n      });\n    },\n    hooks: {\n      storeCreate: createPubSub<[ViewModelStore]>(),\n    },\n  },\n  Symbol.for('VIEW_MODELS_CONFIG'),\n);\n","import {\n  applyObservable as applyObservableLib,\n  type ObservableAnnotationsArray,\n} from 'yummies/mobx';\nimport type { AnyObject } from 'yummies/types';\n\nimport type { ViewModelObservableConfig } from '../index.js';\n\nexport const applyObservable = (\n  context: AnyObject,\n  annotationsArray: ObservableAnnotationsArray,\n  observableConfig: ViewModelObservableConfig,\n) => {\n  if (observableConfig.custom) {\n    return observableConfig.custom(context, annotationsArray);\n  }\n\n  if (observableConfig.disableWrapping) {\n    return;\n  }\n\n  applyObservableLib(context, annotationsArray, observableConfig.useDecorators);\n};\n","import type { AnyObject, Class, EmptyObject } from 'yummies/types';\nimport type {\n  AnyViewModel,\n  AnyViewModelSimple,\n  ViewModel,\n  ViewModelSimple,\n} from '../view-model/index.js';\n\nexport const isViewModel = <\n  TPayload extends AnyObject = EmptyObject,\n  ParentViewModel extends AnyViewModel | AnyViewModelSimple | null = null,\n>(\n  value: AnyObject,\n): value is ViewModel<TPayload, ParentViewModel> => value.payloadChanged;\n\nexport const isViewModelClass = <\n  TPayload extends AnyObject = EmptyObject,\n  ParentViewModel extends AnyViewModel | AnyViewModelSimple | null = null,\n>(\n  value: Function,\n): value is Class<ViewModel<TPayload, ParentViewModel>> =>\n  value.prototype.payloadChanged;\n\nexport const isViewModeSimpleClass = <\n  TPayload extends AnyObject = EmptyObject,\n  ParentViewModel extends AnyViewModel | AnyViewModelSimple | null = null,\n>(\n  value: Function,\n): value is Class<ViewModelSimple<TPayload, ParentViewModel>> =>\n  !isViewModelClass(value);\n","import { action, comparer, computed, observable, runInAction } from 'mobx';\nimport { isShallowEqual } from 'yummies/data';\nimport { startViewTransitionSafety } from 'yummies/html';\nimport type { ObservableAnnotationsArray } from 'yummies/mobx';\nimport type { AnyObject, EmptyObject, Maybe } from 'yummies/types';\nimport {\n  applyObservable,\n  mergeVMConfigs,\n  type ViewModelsConfig,\n} from '../config/index.js';\nimport type { ViewModel } from './view-model.js';\nimport type { ViewModelStore } from './view-model.store.js';\nimport type {\n  AnyViewModel,\n  AnyViewModelSimple,\n  PayloadCompareFn,\n  ViewModelParams,\n} from './view-model.types.js';\n\ndeclare const process: { env: { NODE_ENV?: string } };\n\nconst baseAnnotations: ObservableAnnotationsArray = [\n  [observable.ref, '_isMounted', '_isUnmounting'],\n  [computed, 'isMounted', 'isUnmounting', 'parentViewModel'],\n  [action, 'didMount', 'didUnmount', 'willUnmount', 'setPayload'],\n  [action.bound, 'mount', 'unmount'],\n];\n\nexport class ViewModelBase<\n  Payload extends AnyObject = EmptyObject,\n  ParentViewModel extends AnyViewModel | AnyViewModelSimple | null = null,\n  ComponentProps extends AnyObject = AnyObject,\n> implements ViewModel<Payload, ParentViewModel>\n{\n  private abortController: AbortController;\n\n  public unmountSignal: AbortSignal;\n\n  id: string;\n\n  private _isMounted = false;\n\n  private _isUnmounting = false;\n\n  private _payload: Payload;\n\n  public vmConfig: ViewModelsConfig;\n\n  protected isPayloadEqual?: PayloadCompareFn<Payload>;\n\n  protected props: ComponentProps;\n\n  constructor(\n    protected vmParams: ViewModelParams<\n      Payload,\n      ParentViewModel,\n      ComponentProps\n    >,\n  ) {\n    this.id = vmParams.id;\n    this.vmConfig = mergeVMConfigs(vmParams.vmConfig);\n    this._payload = vmParams.payload;\n    this.props = vmParams.props ?? ({} as ComponentProps);\n    this.abortController = new AbortController();\n    this.unmountSignal = this.abortController.signal;\n\n    if (this.vmConfig.comparePayload === 'strict') {\n      this.isPayloadEqual = comparer.structural;\n    } else if (this.vmConfig.comparePayload === 'shallow') {\n      this.isPayloadEqual = isShallowEqual;\n    } else if (typeof this.vmConfig.comparePayload === 'function') {\n      this.isPayloadEqual = this.vmConfig.comparePayload;\n    }\n\n    const annotations: ObservableAnnotationsArray = [...baseAnnotations];\n\n    if (this.vmConfig.payloadObservable !== false) {\n      annotations.push([\n        observable[this.vmConfig.payloadObservable],\n        '_payload',\n      ]);\n    }\n\n    if (this.vmConfig.payloadComputed) {\n      if (this.vmConfig.payloadComputed === 'struct') {\n        annotations.push([\n          computed({ equals: comparer.structural }),\n          'payload',\n        ]);\n      } else {\n        annotations.push([\n          computed({\n            equals:\n              this.vmConfig.payloadComputed === true\n                ? undefined\n                : this.vmConfig.payloadComputed,\n          }),\n          'payload',\n        ]);\n      }\n    }\n\n    applyObservable(this, annotations, this.vmConfig.observable.viewModels);\n  }\n\n  get payload() {\n    return this._payload;\n  }\n\n  protected get viewModels(): ViewModelStore {\n    if (process.env.NODE_ENV !== 'production' && !this.vmParams.viewModels) {\n      console.error(\n        `Error #3: No access to ViewModelStore.\\n` +\n          'This happened because [viewModels] param is not provided during to creating instance ViewModelBase.\\n' +\n          'More info: https://js2me.github.io/mobx-view-model/errors/3',\n      );\n    }\n\n    return this.vmParams.viewModels!;\n  }\n\n  get isMounted() {\n    return this._isMounted;\n  }\n\n  get isUnmounting() {\n    return this._isUnmounting;\n  }\n\n  protected willUnmount(): void {\n    /* Empty method to be overridden */\n  }\n\n  /**\n   * Empty method to be overridden\n   */\n  protected willMount(): void {\n    /* Empty method to be overridden */\n  }\n\n  /**\n   * The method is called when the view starts mounting\n   */\n  mount() {\n    this.willMount();\n    this.vmConfig.onMount?.(this);\n    startViewTransitionSafety(\n      () => {\n        runInAction(() => {\n          this._isMounted = true;\n        });\n      },\n      {\n        disabled: !this.vmConfig.startViewTransitions.mount,\n      },\n    );\n\n    this.didMount();\n  }\n\n  /**\n   * The method is called when the view was mounted\n   */\n  protected didMount() {\n    /* Empty method to be overridden */\n  }\n\n  /**\n   * The method is called when the view starts unmounting\n   */\n  unmount() {\n    this.beginUnmounting();\n    this.willUnmount();\n    this.vmConfig.onUnmount?.(this);\n    startViewTransitionSafety(\n      () => {\n        runInAction(() => {\n          this._isMounted = false;\n        });\n      },\n      {\n        disabled: !this.vmConfig.startViewTransitions.unmount,\n      },\n    );\n\n    this.didUnmount();\n    this.finalizeUnmount();\n  }\n\n  /**\n   * The method is called when the view was unmounted\n   */\n  protected didUnmount() {\n    /* Empty method to be overridden */\n  }\n\n  private finalizeUnmount() {\n    this.abortController.abort();\n    runInAction(() => {\n      this._isUnmounting = false;\n    });\n  }\n\n  private beginUnmounting() {\n    runInAction(() => {\n      this._isUnmounting = true;\n    });\n  }\n\n  /**\n   * Checks whether the given view model is a child of the current view model.\n   * When `deep` is `true`, checks the whole parent chain.\n   *\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/api/view-models/base-implementation#haschild-vm-anyviewmodel--anyviewmodelsimple-deep-boolean-boolean)\n   */\n  protected hasChild(vm: AnyViewModel | AnyViewModelSimple, deep?: boolean) {\n    if (deep) {\n      let usedVm: Maybe<AnyViewModel | AnyViewModelSimple> = vm;\n      while (usedVm) {\n        if (usedVm.parentViewModel === this) {\n          return true;\n        } else {\n          usedVm = usedVm.parentViewModel;\n        }\n      }\n\n      return false;\n    }\n\n    return vm.parentViewModel === this;\n  }\n\n  /**\n   * Checks whether the given view model is a parent of the current view model.\n   * When `deep` is `true`, checks the whole parent chain.\n   *\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/api/view-models/base-implementation#hasparent-vm-anyviewmodel--anyviewmodelsimple-deep-boolean-boolean)\n   */\n  protected hasParent(vm: AnyViewModel | AnyViewModelSimple, deep?: boolean) {\n    if (deep) {\n      let usedVm: Maybe<AnyViewModel | AnyViewModelSimple> =\n        this.parentViewModel;\n      while (usedVm) {\n        if (usedVm === vm) {\n          return true;\n        } else {\n          usedVm = usedVm.parentViewModel;\n        }\n      }\n\n      return false;\n    } else {\n      return this.parentViewModel === vm;\n    }\n  }\n\n  /**\n   * The method is called when the payload of the view model was changed\n   *\n   * The state - \"was changed\" is determined inside the setPayload method\n   */\n  payloadChanged(payload: Payload, prevPayload: Payload) {\n    /* Empty method to be overridden */\n  }\n\n  /**\n   * Returns the parent view model\n   */\n  get parentViewModel() {\n    if (this.vmParams.parentViewModel !== undefined) {\n      return this.vmParams.parentViewModel as ParentViewModel;\n    }\n\n    if (this.vmParams.parentViewModelId == null) {\n      return null as unknown as ParentViewModel;\n    }\n\n    return this.viewModels?.get(\n      this.vmParams.parentViewModelId,\n    ) as unknown as ParentViewModel;\n  }\n\n  /**\n   * The method is called when the payload changes in the react component\n   */\n  setPayload(payload: Payload) {\n    if (!this.isPayloadEqual?.(this._payload, payload)) {\n      startViewTransitionSafety(\n        () => {\n          runInAction(() => {\n            this.payloadChanged(payload, this._payload);\n            this._payload = payload;\n          });\n        },\n        {\n          disabled: !this.vmConfig.startViewTransitions.payloadChange,\n        },\n      );\n    }\n  }\n\n}\n","import { action, computed, observable, runInAction } from 'mobx';\nimport type { ObservableAnnotationsArray } from 'yummies/mobx';\nimport type { Class, Maybe, MaybePromise } from 'yummies/types';\nimport {\n  applyObservable,\n  mergeVMConfigs,\n  type ViewModelsConfig,\n} from '../config/index.js';\nimport type { ViewModelBase } from './view-model.base.js';\nimport type { ViewModelStore } from './view-model.store.js';\nimport type {\n  ViewModelCreateConfig,\n  ViewModelGenerateIdConfig,\n  ViewModelLookup,\n  ViewModelStoreConfig,\n} from './view-model.store.types.js';\nimport type {\n  AnyViewModel,\n  AnyViewModelSimple,\n  ViewModelParams,\n} from './view-model.types.js';\n\nconst baseAnnotations: ObservableAnnotationsArray = [\n  [computed, 'mountedViewsCount'],\n  [\n    action,\n    'mount',\n    'unmount',\n    'attachVMConstructor',\n    'attach',\n    'detach',\n    'link',\n    'unlink',\n  ],\n];\n\nexport class ViewModelStoreBase<VMBase extends AnyViewModel = AnyViewModel>\n  implements ViewModelStore<VMBase>\n{\n  protected viewModels: Map<string, VMBase | AnyViewModelSimple>;\n  protected linkedAnchorVMClasses: Map<unknown, Class<VMBase>>;\n  protected viewModelIdsByClasses: Map<\n    Class<VMBase> | Class<AnyViewModelSimple>,\n    string[]\n  >;\n  protected instanceAttachedCount: Map<string, number>;\n\n  /**\n   * It is temp heap which is needed to get access to view model instance before all initializations happens\n   */\n  protected viewModelsTempHeap: Map<string, VMBase>;\n\n  /**\n   * Views waiting for mount\n   */\n  protected mountingViews: Set<string>;\n\n  /**\n   * Views waiting for unmount\n   */\n  protected unmountingViews: Set<string>;\n\n  protected vmConfig: ViewModelsConfig;\n\n  constructor(protected config?: ViewModelStoreConfig) {\n    this.viewModels = observable.map([], { deep: false });\n    this.linkedAnchorVMClasses = observable.map([], { deep: false });\n    this.viewModelIdsByClasses = observable.map([], { deep: true });\n    this.instanceAttachedCount = observable.map([], { deep: false });\n    this.mountingViews = observable.set([], { deep: false });\n    this.unmountingViews = observable.set([], { deep: false });\n    this.vmConfig = mergeVMConfigs(config?.vmConfig);\n    this.viewModelsTempHeap = new Map();\n\n    applyObservable(\n      this,\n      baseAnnotations,\n      this.vmConfig.observable.viewModelStores,\n    );\n\n    this.vmConfig.hooks.storeCreate(this as ViewModelStore);\n  }\n\n  get mountedViewsCount() {\n    return [...this.instanceAttachedCount.values()].reduce(\n      (sum, count) => sum + count,\n      0,\n    );\n  }\n\n  /**\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/api/view-model-store/interface#processcreateconfig-config)\n   * Process the configuration for creating a view model.\n   * This method is called just before creating a new view model instance.\n   * It's useful for initializing the configuration, like linking anchors to the view model class.\n   * @param config - The configuration for creating the view model.\n   */\n  processCreateConfig<VM extends VMBase>(\n    config: ViewModelCreateConfig<VM>,\n  ): void {\n    const fromConfig = config.anchors ?? [];\n\n    this.link(config.VM, config.component, ...fromConfig);\n  }\n\n  /**\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/api/view-model-store/interface#createviewmodel-config)\n   * Creates a new view model instance based on the provided configuration.\n   * @param config - The configuration for creating the view model.\n   * @returns The newly created view model instance.\n   */\n  createViewModel<VM extends VMBase>(config: ViewModelCreateConfig<VM>): VM {\n    const VMConstructor = config.VM as unknown as typeof ViewModelBase;\n    const vmConfig = mergeVMConfigs(this.vmConfig, config.vmConfig);\n    const vmParams: ViewModelParams<any, any> & ViewModelCreateConfig<VM> = {\n      ...config,\n      vmConfig,\n    };\n\n    if (vmConfig.factory) {\n      return vmConfig.factory(vmParams) as VM;\n    }\n\n    return new VMConstructor(vmParams) as unknown as VM;\n  }\n\n  /**\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/api/view-model-store/interface#generateviewmodelid-config)\n   * Generates a unique ID for a view model based on the provided configuration.\n   * @param config - The configuration for generating the ID.\n   * @returns The generated unique ID.\n   */\n  generateViewModelId<VM extends VMBase>(\n    config: ViewModelGenerateIdConfig<VM>,\n  ): string {\n    if (config.id) {\n      return config.id;\n    } else {\n      return this.vmConfig.generateId(config.ctx);\n    }\n  }\n\n  /**\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/api/view-model-store/interface#link)\n   * Link anchors (React components) with view model class.\n   * @param VM - The view model class to link to.\n   * @param anchors - The anchors to link.\n   */\n  link(VM: Class<VMBase>, ...anchors: Maybe<unknown>[]): void {\n    anchors.forEach((anchor) => {\n      if (anchor && !this.linkedAnchorVMClasses.has(anchor)) {\n        this.linkedAnchorVMClasses.set(anchor, VM);\n      }\n    });\n  }\n\n  /**\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/api/view-model-store/interface#unlink)\n   * Unlink anchors (React components) with view model class.\n   * @param anchors - The anchors to unlink.\n   */\n  unlink(...anchors: Maybe<unknown>[]): void {\n    anchors.forEach((anchor) => {\n      if (anchor && this.linkedAnchorVMClasses.has(anchor)) {\n        this.linkedAnchorVMClasses.delete(anchor);\n      }\n    });\n  }\n\n  /**\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/api/view-model-store/interface#getids-vmlookup)\n   * @param vmLookup - The ID or class type of the view model. See {@link ViewModelLookup}.\n   * @returns The IDs of the view models\n   */\n  getIds<T extends VMBase | AnyViewModelSimple>(\n    vmLookup: Maybe<ViewModelLookup<T>>,\n  ): string[] {\n    if (!vmLookup) return [];\n\n    if (typeof vmLookup === 'string') {\n      return [vmLookup];\n    }\n\n    const viewModelClass = (this.linkedAnchorVMClasses.get(vmLookup as any) ||\n      vmLookup) as Class<T>;\n\n    const viewModelIds = this.viewModelIdsByClasses.get(viewModelClass) || [];\n\n    return viewModelIds;\n  }\n\n  /**\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/api/view-model-store/interface#getid-vmlookup)\n   * @param vmLookup - The ID or class type of the view model. See {@link ViewModelLookup}.\n   * @returns The ID of the view model, or null if not found.\n   */\n  getId<T extends VMBase | AnyViewModelSimple>(\n    vmLookup: Maybe<ViewModelLookup<T>>,\n  ): string | null {\n    const viewModelIds = this.getIds(vmLookup);\n\n    if (viewModelIds.length === 0) return null;\n\n    if (process.env.NODE_ENV !== 'production' && viewModelIds.length > 1) {\n      console.warn(\n        `Found more than 1 view model with the same identifier. Last instance will been returned`,\n      );\n    }\n\n    return viewModelIds.at(-1)!;\n  }\n\n  /**\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/api/view-model-store/interface#has-vmlookup)\n   * @param vmLookup - The ID or class type of the view model. See {@link ViewModelLookup}.\n   * @returns True if the instance exists, false otherwise.\n   */\n  has<T extends VMBase | AnyViewModelSimple>(\n    vmLookup: Maybe<ViewModelLookup<T>>,\n  ): boolean {\n    const id = this.getId(vmLookup);\n\n    if (!id) return false;\n\n    return this.viewModels.has(id);\n  }\n\n  /**\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/api/view-model-store/interface#get-vmlookup)\n   * @param vmLookup - The ID or class type of the view model. See {@link ViewModelLookup}.\n   * @returns The view model instance, or null if not found.\n   */\n  get<T extends VMBase | AnyViewModelSimple>(\n    vmLookup: Maybe<ViewModelLookup<T>>,\n  ): T | null {\n    // helps to users of this method to better observe changes in view models\n    // this.viewModels.keys();\n\n    const id = this.getId(vmLookup);\n\n    if (!id) return null;\n\n    const observedVM = this.viewModels.get(id) as Maybe<T>;\n\n    return observedVM ?? (this.viewModelsTempHeap.get(id) as Maybe<T>) ?? null;\n  }\n\n  /**\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/api/view-model-store/base-implementation#getorcreatevmid-model)\n   * @param model - View model instance whose `id` should be defined.\n   * @returns Stable id for the instance (existing or newly generated).\n   */\n  getOrCreateVmId(model: VMBase | AnyViewModelSimple): string {\n    if (!model.id) {\n      (model as AnyViewModelSimple).id = this.vmConfig.generateId({\n        VM: model.constructor,\n      });\n    }\n\n    return model.id!;\n  }\n\n  /**\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/api/view-model-store/interface#getall-vmlookup)\n   * @param vmLookup - The ID or class type of the view model. See {@link ViewModelLookup}.\n   * @returns All view model instances matching the lookup.\n   */\n  getAll<T extends VMBase | AnyViewModelSimple>(\n    vmLookup: Maybe<ViewModelLookup<T>>,\n  ): T[] {\n    const viewModelIds = this.getIds(vmLookup);\n\n    return viewModelIds.map((id) => this.viewModels.get(id) as T);\n  }\n\n  protected finalizeMount(modelId: string) {\n    runInAction(() => {\n      this.mountingViews.delete(modelId);\n    });\n  }\n\n  /**\n   * Puts the model in {@link mountingViews}, calls `model.mount()`, then {@link finalizeMount}.\n   * {@link attach} delegates here so sync `mount()` finishes in the same turn as `attach` (SSR / first paint).\n   *\n   * Returns `void` when `model.mount()` is synchronous, otherwise a promise that settles after async mount.\n   */\n  protected mount(model: VMBase | AnyViewModelSimple): MaybePromise<void> {\n    const modelId = this.getOrCreateVmId(model);\n\n    this.mountingViews.add(modelId);\n\n    try {\n      const maybePromise = model.mount?.();\n\n      if (maybePromise instanceof Promise) {\n        if (\n          process.env.NODE_ENV !== 'production' &&\n          typeof window === 'undefined'\n        ) {\n          console.warn(\n            'Warning #2: ViewModel.mount() returned a Promise during server render.\\n',\n            'HTML is emitted before the promise settles; the first server string may not reflect post-mount state (e.g. views using isAbleToRenderView).\\n',\n            'On the client, async mount() is normal and does not trigger this warning.\\n',\n            'More info: https://js2me.github.io/mobx-view-model/warnings/2',\n          );\n        }\n        return maybePromise\n          .then(() => undefined)\n          .finally(() => {\n            this.finalizeMount(modelId);\n          });\n      }\n\n      this.finalizeMount(modelId);\n    } catch (error) {\n      this.finalizeMount(modelId);\n      throw error;\n    }\n  }\n\n  protected async unmount(model: VMBase | AnyViewModelSimple) {\n    const modelId = this.getOrCreateVmId(model);\n\n    this.unmountingViews.add(modelId);\n\n    await model.unmount?.();\n\n    runInAction(() => {\n      this.unmountingViews.delete(modelId);\n    });\n  }\n\n  protected attachVMConstructor(model: VMBase | AnyViewModelSimple) {\n    const modelId = this.getOrCreateVmId(model);\n    const constructor = (model as any).constructor as Class<any, any>;\n\n    if (this.viewModelIdsByClasses.has(constructor)) {\n      const vmIds = this.viewModelIdsByClasses.get(constructor)!;\n      if (!vmIds.includes(modelId)) {\n        vmIds.push(modelId);\n      }\n    } else {\n      this.viewModelIdsByClasses.set(constructor, [modelId]);\n    }\n  }\n\n  protected dettachVMConstructor(model: VMBase | AnyViewModelSimple) {\n    const constructor = (model as any).constructor as Class<any, any>;\n\n    if (this.viewModelIdsByClasses.has(constructor)) {\n      const vmIds = this.viewModelIdsByClasses\n        .get(constructor)!\n        .filter((it) => it !== model.id);\n\n      if (vmIds.length > 0) {\n        this.viewModelIdsByClasses.set(constructor, vmIds);\n      } else {\n        this.viewModelIdsByClasses.delete(constructor);\n      }\n    }\n  }\n\n  markToBeAttached(model: VMBase | AnyViewModelSimple) {\n    const modelId = this.getOrCreateVmId(model);\n\n    this.viewModelsTempHeap.set(modelId, model as VMBase);\n\n    if ('attachViewModelStore' in model) {\n      model.attachViewModelStore!(this as ViewModelStore);\n    }\n\n    this.attachVMConstructor(model);\n  }\n\n  /**\n   * Registers the view model and runs `model.mount()` in the same stack when it is synchronous,\n   * so SSR and the first client render can match without a separate API.\n   *\n   * If `mount()` returns a thenable, returns a `Promise` that settles after mount; the first paint\n   * may still show fallback until then. Otherwise returns `void`.\n   */\n  attach(model: VMBase | AnyViewModelSimple): MaybePromise<void> {\n    const modelId = this.getOrCreateVmId(model);\n\n    const attachedCount = this.instanceAttachedCount.get(modelId) ?? 0;\n\n    this.instanceAttachedCount.set(modelId, attachedCount + 1);\n\n    if (this.viewModels.has(modelId)) {\n      return;\n    }\n\n    this.viewModels.set(modelId, model);\n\n    this.attachVMConstructor(model);\n\n    try {\n      const mount = this.mount(model);\n\n      if (mount instanceof Promise) {\n        return mount.finally(() => {\n          this.viewModelsTempHeap.delete(modelId);\n        });\n      }\n    } catch (error) {\n      this.viewModelsTempHeap.delete(modelId);\n      throw error;\n    }\n\n    this.viewModelsTempHeap.delete(modelId);\n  }\n\n  async detach(id: string) {\n    const attachedCount = this.instanceAttachedCount.get(id) ?? 0;\n\n    this.viewModelsTempHeap.delete(id);\n\n    const model = this.viewModels.get(id);\n\n    if (!model) {\n      return;\n    }\n\n    const nextInstanceAttachedCount = attachedCount - 1;\n\n    this.instanceAttachedCount.set(id, nextInstanceAttachedCount);\n\n    if (nextInstanceAttachedCount <= 0) {\n      this.instanceAttachedCount.delete(id);\n      this.viewModels.delete(id);\n      this.dettachVMConstructor(model);\n\n      await this.unmount(model);\n    }\n  }\n\n  isAbleToRenderView(id: Maybe<string>): boolean {\n    const isViewMounting = this.mountingViews.has(id!);\n    const hasViewModel = this.viewModels.has(id!);\n    return !!id && hasViewModel && !isViewMounting;\n  }\n\n  clean(): void {\n    this.viewModels.clear();\n    this.linkedAnchorVMClasses.clear();\n    this.viewModelIdsByClasses.clear();\n    this.instanceAttachedCount.clear();\n    this.mountingViews.clear();\n    this.unmountingViews.clear();\n    this.viewModelsTempHeap.clear();\n  }\n}\n"],"names":["createCounter","counter","globalConfig","createGlobalConfig","createPubSub","applyObservableLib","baseAnnotations","observable","computed","action","comparer","isShallowEqual","startViewTransitionSafety","runInAction"],"mappings":";;;;;;;;AAMA,MAAM,gBAAgBA,QAAAA,cAAc,CAAC,YAAY,QAAQ,SAAS,EAAE,CAAC;AAE9D,MAAM,eAAsC,CAAC,QAAmB;AACrE,MAAI,CAAC,IAAI,YAAY;AACnB,UAAM,WAAW,cAAA;AACjB,UAAM,UAAUA,QAAAA;AAAAA,MAAc,CAACC,aAC7BA,SAAQ,WAAW,SAAS,GAAG,GAAG;AAAA,IAAA;AAGpC,QAAI,aAAa,MACf,GAAG,QAAQ,IAAI,UAAU,SAAA,EAAW,SAAS,GAAG,GAAG,CAAC;AAAA,EACxD;AAEA,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAO,IAAI,WAAA;AAAA,EACb,OAAO;AACL,UAAM,gBAAgB,IAAI,IAAI,QAAQ;AAEtC,QAAI,eAAe;AACjB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