{"version":3,"file":"lithent.mjs","sources":["../src/utils/universalRef.ts","../src/utils/index.ts","../src/utils/predicator.ts","../src/hook/internal/unmount.ts","../src/hook/mountCallback.ts","../src/hook/mountReadyCallback.ts","../src/hook/internal/useUpdate.ts","../src/render.ts","../src/diff.ts","../src/utils/redraw.ts","../src/utils/createWDom.ts","../src/hook/updateCallback.ts","../src/wDom.ts","../src/hook/ref.ts","../src/hook/useRenew.ts"],"sourcesContent":["import {\n  ComponentMap,\n  ComponentSubKey,\n  CompKey,\n  ComponentInfo,\n  TagFunction,\n} from '@/types';\n\nexport const wdomSymbol = Symbol.for('lithentWDomSymbol');\nexport const xmlnsRef: { value: string } = { value: '' };\nexport const compKeyRef: { value: CompKey | null } = { value: null };\nexport const needDiffRef: { value: boolean } = { value: false };\nexport const componentMap: ComponentMap = new WeakMap();\nexport const lmountComponentSet: WeakSet<Function> = new WeakSet();\nlet componentMapManualMode = false;\n\nconst setComponetRef = (compKey: CompKey, ctor?: TagFunction): void => {\n  componentMap.set(compKey, {\n    ctor,\n    vd: { value: null },\n    up: () => {},\n    upR: [],\n    upS: { value: 0 },\n    upD: [],\n    upCB: [],\n    mts: [],\n    umts: [],\n    wdCB: [], // WDom creation callback queue\n  });\n};\n\nexport const getComponentKey = (): CompKey | null => compKeyRef.value;\n\n/** The component whose setup or render is running (a WeakMap misses null). */\nexport const getCurrentComponent = () =>\n  componentMap.get(compKeyRef.value as CompKey);\n\nexport const getComponentSubInfo = <K extends ComponentSubKey>(\n  compKey: CompKey,\n  subKey: K\n): ComponentInfo[K] | null => {\n  const component = componentMap.get(compKey);\n  if (component) {\n    return component[subKey];\n  }\n  return null;\n};\n\nexport const initUpdateHookState = (compKey: CompKey): void => {\n  compKeyRef.value = compKey;\n};\n\nexport const initMountHookState = (\n  compKey: CompKey,\n  ctor?: TagFunction\n): void => {\n  compKeyRef.value = compKey;\n  setComponetRef(compKey, ctor);\n};\n\nexport const setComponentMapManualMode = (enabled: boolean): void => {\n  componentMapManualMode = enabled;\n};\n\nexport const isComponentMapManualMode = (): boolean => componentMapManualMode;\n\nexport const runUnmountEffects = (compKey: CompKey): void => {\n  const subInfo = componentMap.get(compKey);\n  if (subInfo) {\n    subInfo.umts.forEach(effect => effect());\n    subInfo.umts = [];\n  }\n};\n\nexport const disposeComponentEntry = (compKey: CompKey): void => {\n  runUnmountEffects(compKey);\n  componentMap.delete(compKey);\n};\n","import { WDom, Props } from '@/types';\n\nimport { wdomSymbol } from '@/utils/universalRef';\n\nexport const getParent = (vDom: WDom) =>\n  (vDom.getParent && vDom.getParent()) as WDom;\n\n// A separate scope keeps parent links from retaining a diff's old children.\nexport const makeParentGetter = (parent: WDom) => () => parent;\n\nexport const entries = Object.entries;\nexport const keys = Object.keys;\n\nexport const isEnumerableProp = (props: Props, key: string) =>\n  Object.prototype.propertyIsEnumerable.call(props, key);\n\n// DOM props use for...in, including inherited enumerable keys. A hidden own\n// key shadows the same name on the prototype and must not keep an old prop.\nexport const hasEnumerableProp = (props: Props, key: string): boolean => {\n  if (isEnumerableProp(props, key)) return true;\n  const prototype = Object.getPrototypeOf(props);\n  return (\n    !Object.prototype.hasOwnProperty.call(props, key) &&\n    !!prototype &&\n    hasEnumerableProp(prototype, key)\n  );\n};\n\nexport const isObject = (target: unknown): target is Record<string, unknown> =>\n  typeof target === 'object' && target !== null;\n\nexport const assign = Object.assign;\nexport const isPropType = (obj: unknown): obj is Props => {\n  return (\n    isObject(obj) &&\n    !Array.isArray(obj) &&\n    !Object.getOwnPropertySymbols(obj).includes(wdomSymbol)\n  );\n};\n","import { Fragment } from '@/wDom';\nimport {\n  WDom,\n  TagFunction,\n  TagFunctionResolver,\n  FragmentFunction,\n  WDomType,\n} from '@/types';\nimport { isObject } from '@/utils';\n\ntype WDomParam =\n  | string\n  | WDom\n  | TagFunction\n  | TagFunctionResolver\n  | FragmentFunction;\n\n/**\n * Predicator\n */\n\nconst checkSameCustomComponent = (\n  newWDom: WDom | TagFunction | TagFunctionResolver,\n  originalWDom?: WDom\n): boolean =>\n  'ctor' in newWDom\n    ? newWDom.ctor === (originalWDom && originalWDom.ctor)\n    : newWDom === (originalWDom && originalWDom.ctor);\n\n// The checks below are reached through checkSameWDomWithOriginal only: with\n// a plain node of that type (getWDomType) and an original.\nconst checkSameFragment = (newWDom: WDom, originalWDom: WDom): boolean =>\n  originalWDom.type === 'f' &&\n  // A component's node is a one-child fragment too: never update it in\n  // place as a plain fragment, or the component is never unmounted, nor\n  // update a plain fragment with one (a hoisted <Comp /> first drawn by a\n  // redraw), or it is never mounted.\n  !originalWDom.ctor &&\n  !newWDom.ctor &&\n  !!originalWDom.children &&\n  originalWDom.children.length ===\n    (newWDom.children && newWDom.children.length);\n\nconst checkSameTagElement = (newWDom: WDom, originalWDom: WDom): boolean =>\n  originalWDom.type === 'e' &&\n  originalWDom.tag === newWDom.tag &&\n  !!originalWDom.children &&\n  originalWDom.children.length ===\n    (newWDom.children && newWDom.children.length);\n\nconst checkNormalTypeElement = (newWDom: WDom, originalWDom: WDom): boolean =>\n  originalWDom.type === newWDom.type;\n\nconst checkLoopTypeElement = (newWDom: WDom, originalWDom: WDom): boolean =>\n  originalWDom.type === newWDom.type &&\n  ((checkKeyedChildren(newWDom) && checkKeyedChildren(originalWDom)) ||\n    (!!originalWDom.children &&\n      originalWDom.children.length ===\n        (newWDom.children && newWDom.children.length)));\n\nexport const getKey = (target: WDom) =>\n  (target && target.compProps && target.compProps.key) ??\n  (target && target.props && target.props.key);\n\n/**\n * Check if the type is virtual (fragment or loop)\n * Virtual types don't create real DOM elements themselves\n */\nexport const checkVirtualType = (\n  type?: string | null // 'f': fragment, 'l': loop\n) => type === 'f' || type === 'l';\n\nexport const checkCustemComponentFunction = (\n  target: WDomParam\n): target is TagFunction | TagFunctionResolver =>\n  (typeof target === 'function' && !checkFragmentFunction(target)) ||\n  (isObject(target) && 'resolve' in target);\n\nexport const checkFragmentFunction = (\n  target: unknown\n): target is FragmentFunction => target === Fragment;\n\n// A diffed node (resolved already): empty when it has no type.\nexport const checkEmptyElement = (wDom: WDom) => !wDom.type;\n\n// Whether the node's element is a portal target, which lies outside the\n// parent the portal sits in: a portal's own element, or the one a node\n// replacing or deleting a portal still holds, with that portal's props (op),\n// until it is drawn.\nexport const checkPortalElement = ({ el, op, props }: WDom) =>\n  !!el && (el === (op && op.portal) || el === (props && props.portal));\n\nexport const checkEventKey = (key: string) => key[0] === 'o' && key[1] === 'n';\n\nexport const checkExistyKey = (target: WDom) => checkExisty(getKey(target));\n\n// A list is keyed when any child has a key: a leading null or false (a hidden\n// row) must not turn key matching off for the rest.\nexport const checkKeyedChildren = (target?: WDom) =>\n  !!target && !!target.children && target.children.some(checkExistyKey);\n\nexport const checkExisty = (value: unknown) =>\n  value !== null && value !== undefined;\n\nexport const checkStyleData = (\n  dataKey: string,\n  dataValue: unknown\n): dataValue is Record<string, string> =>\n  dataKey === 'style' && isObject(dataValue);\n\nexport const checkRefData = (\n  dataKey: string,\n  dataValue: unknown\n): dataValue is {\n  value: HTMLElement | Element | DocumentFragment | Text | undefined;\n} => dataKey === 'ref' && isObject(dataValue);\n\n// Descriptor lookups are cached per prototype+key. Keying by prototype\n// rather than nodeName matters for custom elements: one rendered before its\n// definition is upgraded later and gets a new prototype, which must be looked\n// up again instead of reusing the \"no accessor\" answer for its tag name.\nconst accessorCache = new WeakMap<object, Map<string, boolean>>();\n\nexport const hasAccessorMethods = (target: unknown, dataKey: string) => {\n  const proto = target!.constructor.prototype;\n  let byKey = accessorCache.get(proto);\n  if (!byKey) accessorCache.set(proto, (byKey = new Map()));\n  let result = byKey.get(dataKey);\n\n  if (result === undefined) {\n    const descriptor = Object.getOwnPropertyDescriptor(proto, dataKey);\n    result = !!(descriptor && descriptor.get && descriptor.set);\n    byKey.set(dataKey, result);\n  }\n\n  return result;\n};\n\n// A custom element tag whose definition has not arrived, or whose instance\n// has not been upgraded yet: still a plain HTMLElement, with no accessors.\nexport const isPendingCustomElement = (target: unknown) =>\n  (target as Element).localName.includes('-') &&\n  (target as Element).constructor === HTMLElement;\n\n/**\n * Get WDom type as a single character code\n * 'c': component, 'f': fragment, 'e': element, 'l': loop, 't': text, 'et': empty/null\n */\nexport const getWDomType = (\n  wDom: WDom | TagFunction | TagFunctionResolver\n): WDomType =>\n  checkCustemComponentFunction(wDom)\n    ? 'c'\n    : ((wDom as WDom).type as WDomType) || 'et';\n\nexport const checkSameWDomWithOriginal = {\n  c: checkSameCustomComponent,\n  l: checkLoopTypeElement,\n  t: checkNormalTypeElement,\n  e: checkSameTagElement,\n  f: checkSameFragment,\n  et: checkNormalTypeElement,\n};\n","import { WDom, CompKey } from '@/types';\nimport { checkEventKey } from '@/utils/predicator';\nimport {\n  componentMap,\n  getCurrentComponent,\n  isComponentMapManualMode,\n  runUnmountEffects,\n} from '@/utils/universalRef';\n\nexport const unmount = (effectAction: () => void) => {\n  const comp = getCurrentComponent();\n  comp && comp.umts.push(effectAction);\n};\n\nexport const runUnmountQueueFromWDom = (newWDom: WDom) => {\n  const { compKey } = newWDom;\n\n  if (compKey) {\n    // A redraw queued before this removal still holds the node. Marking it\n    // retired makes that stale redraw a no-op instead of drawing it back in.\n    newWDom.il = true;\n    removeItem(compKey);\n  }\n  recursiveRunUnmount(newWDom);\n};\n\nconst recursiveRunUnmount = (wDom: WDom) => {\n  // A portal host belongs to the caller and survives removal. Release its\n  // handlers while leaving listeners on discarded ordinary DOM untouched.\n  if (wDom.tag === 'portal' && wDom.el) {\n    for (const key in wDom.props) {\n      if (checkEventKey(key)) {\n        wDom.el.removeEventListener(\n          key.slice(2).toLowerCase(),\n          wDom.props[key] as EventListener\n        );\n      }\n    }\n  }\n  (wDom.children || []).forEach(item => {\n    const childComKey = item.compKey;\n    if (childComKey) {\n      runUnmountQueueFromWDom(item);\n    } else {\n      recursiveRunUnmount(item);\n    }\n  });\n};\n\nconst removeItem = (compKey: CompKey) => {\n  runUnmountEffects(compKey);\n\n  if (!isComponentMapManualMode()) {\n    componentMap.delete(compKey);\n  }\n};\n","import { WDom } from '@/types';\nimport {\n  compKeyRef,\n  componentMap,\n  getCurrentComponent,\n} from '@/utils/universalRef';\nimport { unmount } from '@/hook/internal/unmount';\n\nlet mountedQueue: WDom[] = [];\n\n/**\n * WDom을 mountedQueue에 추가\n */\nexport const addMountedQueue = (wDom: WDom) => {\n  if (wDom.compKey) {\n    mountedQueue.push(wDom);\n  }\n};\n\n/**\n * DOM 렌더링 후 mountCallback 실행\n */\nexport const execMountedQueue = () => {\n  mountedQueue.forEach(runMountedQueueFromWDom);\n  mountedQueue = [];\n};\n\n/**\n * mountCallback 등록\n */\nexport const mountCallback = (effectAction: () => void) => {\n  const comp = getCurrentComponent();\n  comp && comp.mts.push(effectAction);\n};\n\n/**\n * mountCallback만 실행\n */\nconst runMountedQueueFromWDom = (newWDom: WDom) => {\n  const { compKey } = newWDom;\n  // Every entry has all its queues (setComponetRef).\n  const component = compKey && componentMap.get(compKey);\n\n  if (component) {\n    const mountQueue = component.mts;\n\n    compKeyRef.value = compKey;\n    component.upS.value = 0;\n    component.mts = [];\n\n    mountQueue.forEach((effect: Function) => {\n      const callback = effect();\n      if (callback) {\n        unmount(callback);\n      }\n    });\n  }\n};\n","import { WDom } from '@/types';\nimport {\n  compKeyRef,\n  componentMap,\n  getCurrentComponent,\n} from '@/utils/universalRef';\nimport { unmount } from '@/hook/internal/unmount';\n\n/**\n * WDom이 생성된 직후(DOM 마운트 전)에 실행될 콜백 등록\n */\nexport const mountReadyCallback = (effectAction: () => void | (() => void)) => {\n  const comp = getCurrentComponent();\n  comp && comp.wdCB.push(effectAction);\n};\n\n/**\n * 특정 WDom의 wdomCallback 즉시 실행\n * wDomToDom() 내부에서 각 WDom 생성 시점에 호출됨\n */\nexport const runWDomCallbacksFromWDom = (newWDom: WDom) => {\n  const { compKey } = newWDom;\n\n  if (compKey) {\n    const component = componentMap.get(compKey);\n    const wdCBQueue = component && component.wdCB;\n\n    compKeyRef.value = compKey;\n\n    if (wdCBQueue && wdCBQueue.length > 0) {\n      component.wdCB = [];\n\n      wdCBQueue.forEach((effect: Function) => {\n        const cleanup = effect();\n        if (typeof cleanup === 'function') {\n          unmount(cleanup);\n        }\n      });\n    }\n  }\n};\n","import { WDom } from '@/types';\nimport {\n  compKeyRef,\n  componentMap,\n  getCurrentComponent,\n} from '@/utils/universalRef';\n\ntype DependencyFactory = () => unknown[];\n\nexport const useUpdated = (\n  effectAction: () => (() => void) | void,\n  dependencies: DependencyFactory = () => []\n) => {\n  const component = getCurrentComponent();\n  if (!component) return;\n\n  const { upD, upS } = component;\n  const def = upD[upS.value];\n\n  const nextDependencies = dependencies();\n\n  if (def && checkNeedPushQueue(def, nextDependencies)) {\n    const callback = effectAction();\n    if (callback) {\n      component.upCB.push(callback);\n    }\n  }\n\n  upD[upS.value] = nextDependencies;\n  upS.value += 1;\n};\n\nexport const runUpdatedQueueFromWDom = (newWDom: WDom) => {\n  const { compKey } = newWDom;\n  // Every entry has all its queues (setComponetRef).\n  const component = compKey && componentMap.get(compKey);\n\n  if (component) {\n    const queue = component.upCB;\n\n    compKeyRef.value = compKey;\n    component.upS.value = 0;\n\n    if (newWDom.ctor) {\n      component.upCB = [];\n      queue.forEach((effect: Function) => effect());\n    }\n  }\n};\n\nconst checkNeedPushQueue = (originalDefs: unknown[], newDefs: unknown[]) =>\n  !originalDefs.length\n    ? true\n    : originalDefs.some((def, index) => def !== newDefs[index]);\n","import { WDom, Props } from '@/types';\nimport {\n  checkStyleData,\n  checkRefData,\n  checkExisty,\n  checkVirtualType,\n  hasAccessorMethods,\n  isPendingCustomElement,\n  checkEventKey,\n  checkPortalElement,\n} from '@/utils/predicator';\n\nimport { componentMap, xmlnsRef } from '@/utils/universalRef';\nimport { runUnmountQueueFromWDom } from '@/hook/internal/unmount';\nimport { execMountedQueue, addMountedQueue } from '@/hook/mountCallback';\nimport { runWDomCallbacksFromWDom } from '@/hook/mountReadyCallback';\nimport { runUpdatedQueueFromWDom } from '@/hook/internal/useUpdate';\nimport {\n  getParent,\n  isObject,\n  hasEnumerableProp,\n  makeParentGetter,\n} from '@/utils';\nimport { cloneWDom } from '@/wDom';\n\nconst DF = () => new DocumentFragment();\n\n// Into the root's wrapper: before its after element, in place of <html>, or\n// at the end.\nconst insertRoot = (\n  wrapElement: HTMLElement,\n  element: Node,\n  afterElement?: HTMLElement | null\n) =>\n  afterElement\n    ? wrapElement.insertBefore(element, afterElement)\n    : wrapElement.tagName === 'HTML'\n      ? wrapElement.replaceWith(element)\n      : wrapElement.appendChild(element);\nconst CE = (t: string) => document.createElement(t);\n\nexport const render = (\n  wDom: WDom,\n  wrapElement: HTMLElement | null,\n  afterElement?: HTMLElement | null,\n  isHydration?: boolean\n) => {\n  wDom.isRoot = true;\n  wrapElement = wrapElement || document.body;\n  wDom.we = wrapElement;\n\n  const Dom = wDomToDom(wDom, isHydration);\n\n  wDom.ae = afterElement as HTMLElement;\n  if (afterElement || !isHydration) {\n    insertRoot(wrapElement, Dom, afterElement);\n  }\n\n  execMountedQueue();\n\n  return () => {\n    const compData = componentMap.get(wDom.compProps as Props);\n    const comp = (compData && compData.vd.value) || wDom;\n    runUnmountQueueFromWDom(comp);\n    rootDelete(comp);\n  };\n};\n\nconst rootDelete = (newWDom: WDom) =>\n  deleteRealDom(newWDom, newWDom.we as HTMLElement);\n\nexport const typeDelete = (newWDom: WDom) => {\n  const parentWDom = getParent(newWDom);\n  deleteRealDom(\n    newWDom,\n    (newWDom.isRoot\n      ? newWDom.we\n      : parentWDom && findRealParentElement(parentWDom)) as HTMLElement\n  );\n};\n\nconst deleteRealDom = (newWDom: WDom, parent: HTMLElement) => {\n  if (parent && newWDom.el) {\n    const nt = newWDom.el.nodeType;\n    // A portal's children are in its target, which itself stays.\n    const isPortal = checkPortalElement(newWDom);\n    if (nt === 11 || isPortal) {\n      findChildWithRemoveElement(\n        newWDom,\n        isPortal ? (newWDom.el as HTMLElement) : parent\n      );\n    } else if (nt === 1 || nt === 3) {\n      parent.removeChild(newWDom.el);\n    }\n\n    newWDom.el = undefined;\n  }\n};\n\nconst findChildWithRemoveElement = (newWDom: WDom, parent: HTMLElement) => {\n  const items = newWDom.oc || newWDom.children || [];\n\n  // Clear only when these roots, through any Fragment/component wrappers,\n  // are exactly the parent's children. Stop at the first mismatch so removing\n  // one part of a larger list never walks its remaining siblings.\n  if (items.length > 1) {\n    let next = parent.firstChild;\n    const matches = (item: WDom): boolean => {\n      const el = item.el;\n      if (!el || checkPortalElement(item)) return !el;\n      if (el.nodeType === 11) {\n        return (item.oc || item.children || []).every(matches);\n      }\n      const same = el === next && (el as HTMLElement).tagName !== 'HTML';\n      next = el.nextSibling;\n      return same;\n    };\n\n    if (items.every(matches) && !next) {\n      parent.textContent = '';\n      items.forEach(item => (item.el = undefined));\n      return;\n    }\n  }\n\n  items.forEach(item => {\n    const nt = item.el && item.el.nodeType;\n    if (checkPortalElement(item)) {\n      findChildWithRemoveElement(item, item.el as HTMLElement);\n    } else if (nt === 1 || nt === 3) {\n      const el = item.el as HTMLElement;\n      el.tagName === 'HTML' ? (el.innerHTML = '') : el.remove();\n    } else if (nt === 11) {\n      findChildWithRemoveElement(item, parent);\n    }\n  });\n};\n\n/**\n * Unmount and remove unused keyed children. Listeners are left on the\n * discarded DOM and go away with it. The parent element is found from the\n * list they were in: a child's own parent link may have been moved on by\n * the same node being drawn in another place since.\n */\nexport const typeDeleteUnused = (items: WDom[], list: WDom) => {\n  const parentElement = findRealParentElement(list) as HTMLElement;\n  items.forEach(item => {\n    runUnmountQueueFromWDom(item);\n    deleteRealDom(item, parentElement);\n  });\n};\n\nconst typeSortedReplace = (newWDom: WDom) => {\n  typeDelete(newWDom);\n  typeAdd(newWDom);\n};\n\nconst typeAdd = (\n  newWDom: WDom,\n  newElement?: HTMLElement | DocumentFragment | Text\n) => {\n  newElement = newElement || wDomToDom(newWDom);\n\n  const parentWDom = getParent(newWDom);\n  if (!parentWDom || !parentWDom.type) {\n    if (newWDom.isRoot && newWDom.we && newWDom.tag !== 'portal') {\n      insertRoot(newWDom.we, newElement, newWDom.ae);\n      execMountedQueue();\n    }\n    return;\n  }\n\n  const parentEl = findRealParentElement(parentWDom);\n  // Children added or moved inside a loop are placed by updateChildren, so\n  // anything that reaches here (e.g. a replaced fragment or component in an\n  // unkeyed loop) goes right before its own next sibling.\n  const nextEl = startFindNextBrotherElement(newWDom, parentWDom);\n\n  if (parentEl) {\n    if (newWDom.tag !== 'portal') {\n      parentEl.insertBefore(newElement, nextEl || null);\n    }\n    execMountedQueue();\n  }\n};\n\nconst getElementFromFragment = (newWDom: WDom) => {\n  if (checkVirtualType(newWDom.type)) {\n    return (newWDom.children || []).reduce((acc, item) => {\n      const element = getElementFromFragment(item);\n\n      // A portal's target does not move with its siblings.\n      if (element && !checkPortalElement(item)) {\n        acc.appendChild(element);\n      }\n      return acc;\n    }, DF());\n  }\n\n  return newWDom.el;\n};\n\nconst startFindNextBrotherElement = (\n  wDom: WDom,\n  parentWDom: WDom\n): HTMLElement | DocumentFragment | Text | undefined => {\n  const brothers = parentWDom.children || [];\n\n  // After the brothers, a fragment or loop parent goes on with its own next\n  // brother, up to the root's after element.\n  return (\n    findChildFragmentNextElement(brothers.slice(brothers.indexOf(wDom) + 1)) ||\n    (checkVirtualType(parentWDom.type)\n      ? parentWDom.isRoot\n        ? parentWDom.ae\n        : startFindNextBrotherElement(parentWDom, getParent(parentWDom))\n      : undefined)\n  );\n};\n\n// Children of a list being updated that move or are added: until its\n// placement pass they are not where they will be, so they are no anchor for\n// content inserted meanwhile. Kept here rather than as a flag on the node,\n// which would give the nodes that get it another shape.\nconst moving = new Set<WDom>();\n\nconst findChildFragmentNextElement = (\n  candidiateBrothers: WDom[]\n): HTMLElement | DocumentFragment | Text | undefined =>\n  candidiateBrothers.reduce<HTMLElement | DocumentFragment | Text | undefined>(\n    (targetEl, bItem) => {\n      // A portal's target is not in the parent: no anchor there.\n      if (\n        targetEl ||\n        checkPortalElement(bItem) ||\n        (moving.size && moving.has(bItem))\n      )\n        return targetEl;\n      const { type, el } = bItem;\n      if (type && checkVirtualType(type)) {\n        const found = findChildFragmentNextElement(bItem.children || []);\n        if (found) return found;\n      }\n      if (el && el.nodeType !== 11) return el;\n      return targetEl;\n    },\n    undefined\n  );\n\nconst typeReplace = (newWDom: WDom) => {\n  const parentWDom = getParent(newWDom);\n  const orignalElement = newWDom.el;\n\n  if (orignalElement && (parentWDom ? parentWDom.type : newWDom.isRoot)) {\n    // A portal being replaced, or replacing: one side is drawn in the\n    // portal's target, not in the parent, so delete and add instead.\n    if (\n      !parentWDom ||\n      orignalElement.nodeType === 11 ||\n      checkPortalElement(newWDom) ||\n      newWDom.tag === 'portal'\n    ) {\n      typeSortedReplace(newWDom);\n    } else {\n      const parentElement = findRealParentElement(parentWDom);\n      const newElement = wDomToDom(newWDom);\n\n      if (parentElement) {\n        parentElement.replaceChild(newElement, orignalElement);\n      }\n      execMountedQueue();\n    }\n  }\n};\n\nconst typeUpdate = (newWDom: WDom) => {\n  if (newWDom.type === 't') {\n    updateText(newWDom);\n    return;\n  }\n\n  if (newWDom.el) {\n    const { op: oldProps, props } = newWDom;\n    updateProps(props, newWDom.el, oldProps);\n\n    if (newWDom.tag === 'input') {\n      (newWDom.el as HTMLInputElement).value = String(\n        (props && props.value) || ''\n      );\n    }\n  }\n\n  updateChildren(newWDom);\n  runUpdatedQueueFromWDom(newWDom);\n};\n\n/**\n * Process child updates. Loop parents with added/moved children are handled\n * in O(n): a left-to-right content pass (keeps lifecycle order), an LIS over\n * the matched original indices (oi, recorded by the diff phase) to pick the\n * children that can stay in place, and a right-to-left placement pass that\n * inserts only added children and non-LIS moves before a running anchor.\n */\nconst updateChildren = (newWDom: WDom) => {\n  const children = newWDom.children || [];\n\n  if (\n    newWDom.type !== 'l' ||\n    !children.some(\n      item => 'ATS'.includes(item.nr as string) || item.oi !== undefined\n    )\n  ) {\n    children.forEach(wDomUpdate);\n    return;\n  }\n\n  // The matched children that keep their place: an LIS over their original\n  // indexes (oi). Worked out before the content pass, because until the\n  // placement pass a child that moves is still where it was, and so is the\n  // old element of one replaced (S): neither may be the anchor for content\n  // inserted meanwhile (moving), such as a kept row whose fragment changed.\n  // An added child needs no such care: it has no element before the content\n  // pass reaches it, and anchors are looked for after the child at hand.\n  // Read up front: wDomUpdate clears oi on an unkeyed child matched by\n  // position.\n  const matchedIndexes: number[] = [];\n  const oiSeq: number[] = [];\n\n  // Replaced children, then the matched ones that move.\n  const movers: WDom[] = [];\n  let ordered = true;\n\n  children.forEach((item, index) => {\n    const oi = item.oi;\n    const nr = item.nr;\n    if (nr === 'S') {\n      movers.push(item);\n    } else if (nr !== 'A' && oi !== undefined) {\n      if (oi < oiSeq[oiSeq.length - 1]) {\n        ordered = false;\n      }\n      matchedIndexes.push(index);\n      oiSeq.push(oi);\n    }\n  });\n\n  // keep[i]: whether matched child i stays (unset when not matched).\n  // Matched children still in their original order all stay, as in a redraw\n  // that moves nothing: no LIS then. Only the children that move or are\n  // added are flagged, so a long list's children are usually untouched.\n  let keep: boolean[] | undefined;\n  if (!ordered) {\n    const lis: boolean[] = (keep = []);\n    getLisPositions(oiSeq).forEach(pos => (lis[matchedIndexes[pos]] = true));\n    matchedIndexes.forEach(\n      i => lis[i] || ((lis[i] = false), movers.push(children[i]))\n    );\n  }\n\n  // Content pass (left-to-right, keeps lifecycle order).\n  // Added children are created here but inserted in the placement pass.\n  const created: (HTMLElement | DocumentFragment | Text | undefined)[] = [];\n  let createdCount = 0;\n\n  movers.forEach(item => moving.add(item));\n  try {\n    children.forEach((item, index) => {\n      const nr = item.nr;\n\n      if (nr === 'A' || nr === 'S') {\n        if (nr === 'S') {\n          typeDelete(item);\n        }\n        created[index] = wDomToDom(item);\n        createdCount++;\n      } else {\n        wDomUpdate(item);\n      }\n    });\n  } finally {\n    movers.forEach(item => moving.delete(item));\n  }\n\n  const parentEl = findRealParentElement(newWDom);\n  const baseAnchor = newWDom.isRoot\n    ? newWDom.ae\n    : startFindNextBrotherElement(newWDom, getParent(newWDom));\n\n  // Fast-append the trailing run of added children in order\n  // (a null anchor makes insertBefore behave as appendChild).\n  let tail = children.length;\n  while (tail > 0 && created[tail - 1] !== undefined) {\n    tail--;\n  }\n\n  for (let i = tail; i < children.length; i++) {\n    const el = created[i];\n\n    if (el && parentEl && children[i].tag !== 'portal') {\n      parentEl.insertBefore(el, baseAnchor || null);\n    }\n  }\n\n  if (keep || createdCount > children.length - tail) {\n    // Placement pass (right-to-left): insert added children and non-LIS\n    // moves before a running anchor.\n    let anchor =\n      findChildFragmentNextElement(children.slice(tail)) || baseAnchor;\n\n    for (let i = tail - 1; i >= 0; i--) {\n      const item = children[i];\n      const isNew = created[i] !== undefined;\n      const needMove = !!keep && keep[i] === false;\n\n      if ((isNew || needMove) && parentEl && item.tag !== 'portal') {\n        const el = isNew ? created[i] : getElementFromFragment(item);\n\n        if (el) {\n          parentEl.insertBefore(el, anchor || null);\n        }\n      }\n\n      const first = findChildFragmentNextElement([item]);\n      if (first) {\n        anchor = first;\n      }\n    }\n  }\n\n  children.forEach(clearDiffMeta);\n  execMountedQueue();\n};\n\n// Assigned, not deleted: `delete` changes the object's shape, which makes\n// every later access to the node slower. nr goes back to 'N' (nothing to\n// do), not undefined: a node that has it is drawn (see makeNewWDomTree).\nconst clearDiffMeta = (item: WDom) => {\n  item.oi = item.oc = item.op = undefined;\n  item.nr = 'N';\n};\n\n/**\n * Longest increasing subsequence positions (binary search, O(n log n)).\n * Returns the positions in seq that form the LIS.\n */\nconst getLisPositions = (seq: number[]) => {\n  // tails[k]: the position ending the smallest-tailed increasing run of\n  // length k + 1. A value larger than the last tail just extends it.\n  const tails: number[] = [];\n  const prev: number[] = [];\n\n  seq.forEach((value, i) => {\n    let lo = 0;\n    let hi = tails.length;\n\n    if (hi && seq[tails[hi - 1]] < value) {\n      lo = hi;\n    } else {\n      while (lo < hi) {\n        const mid = (lo + hi) >> 1;\n        if (seq[tails[mid]] < value) {\n          lo = mid + 1;\n        } else {\n          hi = mid;\n        }\n      }\n    }\n\n    prev[i] = lo ? tails[lo - 1] : -1;\n    tails[lo] = i;\n  });\n\n  let i = tails.length;\n  let last = tails[i - 1];\n  while (i-- > 0) {\n    tails[i] = last;\n    last = prev[last];\n  }\n\n  return tails;\n};\n\nexport const wDomUpdate = (newWDomTree: WDom) => {\n  const { nr: needRerender } = newWDomTree;\n\n  if (needRerender && needRerender !== 'N') {\n    renderHandlers[needRerender](newWDomTree);\n    clearDiffMeta(newWDomTree);\n  }\n};\n\nconst renderHandlers = {\n  A: typeAdd,\n  D: typeDelete,\n  R: typeReplace,\n  U: typeUpdate,\n  S: typeSortedReplace,\n  // A keyed item reaches here only as a component redrawing itself: it has\n  // not moved, so it is updated in place. Re-inserting its nodes would blur a\n  // focused input inside it or reload an iframe. Moves within a list are\n  // placed by updateChildren.\n  T: typeUpdate,\n} as const;\n\nconst updateText = (newWDom: WDom) => {\n  if (newWDom.el) {\n    newWDom.el.nodeValue = String(newWDom.text);\n  }\n};\n\nconst updateProps = (\n  props?: Props,\n  element?: HTMLElement | Element | DocumentFragment | Text,\n  oldProps?: Props | null\n) => {\n  const originalProps = oldProps || {};\n\n  for (const dataKey in props) {\n    const dataValue: unknown = props[dataKey];\n\n    if (dataValue === originalProps[dataKey]) {\n      continue;\n    }\n\n    // An event key starts with \"on\", so it is none of the keys below.\n    if (checkEventKey(dataKey)) {\n      updateEvent(\n        element as HTMLElement,\n        dataKey,\n        dataValue as (e: Event) => void,\n        originalProps[dataKey] as (e: Event) => void\n      );\n    } else {\n      if (dataKey === 'key') {\n        // Do nothing\n      } else if (dataKey === 'portal' && isObject(dataValue)) {\n        // Do nothing\n      } else if (dataKey === 'innerHTML' && typeof dataValue === 'string') {\n        (element as HTMLElement).innerHTML = dataValue;\n      } else if (checkStyleData(dataKey, dataValue)) {\n        updateStyle(\n          dataValue,\n          checkStyleData(dataKey, originalProps.style)\n            ? originalProps.style\n            : {},\n          element\n        );\n      } else if (checkRefData(dataKey, dataValue)) {\n        dataValue.value = element;\n      } else if (dataKey) {\n        if (dataKey !== 'type' && hasAccessorMethods(element, dataKey)) {\n          (element as HTMLElement & Record<string, unknown>)[dataKey] =\n            dataValue;\n        } else {\n          setAttr(\n            dataKey === 'className' ? 'class' : dataKey,\n            element as HTMLElement,\n            dataValue as string\n          );\n          // Keep the real value too: once defined, the element absorbs own\n          // properties through its accessors, so an object or `false` is not\n          // left as the attribute string (B-3).\n          // Only keys HTMLElement lacks: `textContent` or `offsetWidth` would\n          // run a DOM setter or throw.\n          if (\n            isPendingCustomElement(element) &&\n            !(dataKey in HTMLElement.prototype)\n          ) {\n            (element as HTMLElement & Record<string, unknown>)[dataKey] =\n              dataValue;\n          }\n        }\n      }\n    }\n  }\n\n  // Props that are gone. The previous props object is left as it was: it may\n  // be the caller's own object.\n  for (const dataKey in originalProps) {\n    if (props && hasEnumerableProp(props, dataKey)) {\n      continue;\n    }\n\n    if (checkEventKey(dataKey)) {\n      updateEvent(\n        element as HTMLElement,\n        dataKey,\n        undefined,\n        originalProps[dataKey] as (e: Event) => void\n      );\n      continue;\n    }\n\n    (element as HTMLElement).removeAttribute(dataKey);\n    // A prop that went in as a custom element property is unset there too\n    // (B-4). Not upgraded yet: drop the value kept for it (B-3); `delete`\n    // never touches an inherited DOM property such as `title`. Upgraded:\n    // only through the element's own accessors, never built-in ones such as\n    // input.value, where `undefined` would read as \"undefined\".\n    if (isPendingCustomElement(element)) {\n      delete (element as HTMLElement & Record<string, unknown>)[dataKey];\n    } else if (\n      (element as Element).localName.includes('-') &&\n      hasAccessorMethods(element, dataKey)\n    ) {\n      (element as HTMLElement & Record<string, unknown>)[dataKey] = undefined;\n    }\n  }\n};\n\nconst setAttr = (k: string, el: HTMLElement, v: string) =>\n  xmlnsRef.value && k !== 'xmlns'\n    ? el.setAttributeNS(null, k, v)\n    : el.setAttribute(k, v);\n\nconst wDomToDom = (wDom: WDom, isHydration?: boolean): HTMLElement => {\n  let element;\n  const { type, tag, text, props, children = [] } = wDom;\n  const isVirtualType = checkVirtualType(type);\n\n  runWDomCallbacksFromWDom(wDom);\n\n  if (tag === 'svg') {\n    xmlnsRef.value = String(props && props.xmlns);\n  }\n\n  if (!isHydration) {\n    if (!type || isVirtualType) {\n      element = DF();\n    } else if (type === 'e' && tag) {\n      // element\n      if (tag === 'portal' && props && props.portal) {\n        element = props.portal as HTMLElement;\n      } else {\n        element = xmlnsRef.value\n          ? document.createElementNS(xmlnsRef.value, tag)\n          : CE(tag);\n      }\n    } else if (type === 't' && checkExisty(text)) {\n      // text node\n      element = document.createTextNode(String(text));\n    } else {\n      throw Error('Invalid wDom');\n    }\n\n    wDom.el = element as HTMLElement;\n  } else {\n    element = wDom.el;\n  }\n\n  wDomChildrenToDom(wDom, children, element, isHydration);\n\n  updateProps(props, element, null);\n\n  addMountedQueue(wDom);\n\n  if (tag === 'svg') {\n    xmlnsRef.value = '';\n  }\n\n  return element as HTMLElement;\n};\n\nconst wDomChildrenToDom = (\n  wDom: WDom,\n  children: WDom[],\n  parentElement?: HTMLElement | Element | DocumentFragment | Text,\n  isHydration?: boolean\n) => {\n  // The parent is not attached to the document yet, so children can be\n  // appended directly (no intermediate fragment allocation).\n  const getParent = makeParentGetter(wDom);\n  children.forEach((childItem: WDom, index: number) => {\n    // A child already drawn elsewhere (nr 'N': the same node twice, a\n    // hoisted constant in several components) is drawn here as its own copy.\n    // The children of an added subtree come from a diff, which copied those\n    // already (nr 'A'). Drawn, the child gets nr 'N' (see makeNewWDomTree).\n    if (childItem.nr === 'N' && !isHydration) {\n      const copy = cloneWDom(childItem);\n      childItem = children[index] = 'resolve' in copy ? copy.resolve() : copy;\n    }\n    // h() may have assigned a shared node to a later parent already. The\n    // first occurrence needs its actual owner too, not only the copies.\n    childItem.getParent = getParent;\n    childItem.nr = 'N';\n    if (childItem.type) {\n      const childElement = wDomToDom(childItem, isHydration);\n      if (childItem.tag !== 'portal' && !isHydration && parentElement) {\n        parentElement.appendChild(childElement);\n      }\n    }\n  });\n};\n\nconst updateEvent = (\n  element: HTMLElement,\n  eventKey: string,\n  newEventHandler: ((e: Event) => void) | undefined,\n  oldEventHandler: (e: Event) => void\n) => {\n  const eventName = eventKey.slice(2).toLowerCase();\n\n  if (oldEventHandler !== newEventHandler) {\n    if (oldEventHandler) {\n      element.removeEventListener(eventName, oldEventHandler);\n    }\n\n    if (newEventHandler) {\n      element.addEventListener(eventName, newEventHandler);\n    }\n  }\n};\n\nconst updateStyle = (\n  style: Record<string, string>,\n  oldStyle: Record<string, string>,\n  element?: HTMLElement | Element | DocumentFragment | Text\n) => {\n  const orig = { ...oldStyle };\n  if (!(element instanceof HTMLElement)) return;\n\n  const styleProxy = element.style as unknown as Record<string, string>;\n\n  for (const k in style) {\n    styleProxy[k] = style[k];\n    delete orig[k];\n  }\n\n  for (const k in orig) {\n    styleProxy[k] = '';\n  }\n};\n\nconst findRealParentElement = (\n  vDom: WDom\n): HTMLElement | DocumentFragment | Text | undefined =>\n  checkVirtualType(vDom.type)\n    ? vDom.isRoot\n      ? vDom.we\n      : findRealParentElement(getParent(vDom) as WDom)\n    : (vDom.el as HTMLElement);\n","import { WDom, TagFunctionResolver, RenderType, Props } from '@/types';\nimport { checkCustemComponentFunction, getKey } from '@/utils/predicator';\nimport { getParent, makeParentGetter } from '@/utils';\nimport { typeDeleteUnused } from '@/render';\nimport { cloneWDom, copyResolver } from '@/wDom';\nimport {\n  checkEmptyElement,\n  checkSameWDomWithOriginal,\n  getWDomType,\n  checkExistyKey,\n  checkExisty,\n  checkKeyedChildren,\n} from '@/utils/predicator';\n\nimport { runUnmountQueueFromWDom } from '@/hook/internal/unmount';\nimport { keys, isEnumerableProp } from '@/utils';\n\n/**\n * The starting point of the diffing process between the original virtual DOM and the new virtual DOM for re-rendering.\n */\nexport const makeNewWDomTree = (\n  newWDom: WDom | TagFunctionResolver,\n  originalWDom?: WDom\n) => {\n  // Already drawn or taken by a diff (it has nr, 'N' once drawn): the node\n  // belongs to another place, so this place draws a copy. The same node in the same place is still left\n  // alone as unchanged. A component made without a diff and not drawn yet\n  // (in a new component's output, or a hoisted <Comp />) is drawn as it is:\n  // a copy would be a second instance, leaving the one already set up behind.\n  if (newWDom !== originalWDom && (newWDom as WDom).nr) {\n    newWDom = cloneWDom(newWDom as WDom);\n  }\n\n  return remakeNewWDom(\n    newWDom,\n    !!originalWDom &&\n      checkSameWDomWithOriginal[getWDomType(newWDom)](newWDom, originalWDom),\n    originalWDom\n  );\n};\n\n/**\n * Create a new virtual DOM after comparing with the previous virtual DOM\n */\nconst remakeNewWDom = (\n  newWDom: WDom | TagFunctionResolver,\n  isSameType: boolean,\n  originalWDom?: WDom\n) => {\n  const remakeWDom = generalize(newWDom, isSameType, originalWDom);\n  const needRerender = addReRenderTypeProperty(\n    remakeWDom,\n    isSameType,\n    originalWDom\n  );\n  const isNoting = needRerender === 'N';\n\n  if (!isNoting) {\n    remakeWDom.children = remakeChildrenForDiff(\n      remakeWDom,\n      isSameType,\n      originalWDom\n    );\n  }\n\n  // NOTE: short-key metadata (nr = needRerender) keeps bundle size down\n  remakeWDom.nr = needRerender;\n  inheritPropForRender(remakeWDom, originalWDom, needRerender);\n\n  // A retired node keeps its children: it may be a hoisted constant the\n  // caller draws again later, which is then copied from them. A component's\n  // node is copied from its description instead (cloneWDom), so it lets go\n  // of its previous output: otherwise every row a list redraws keeps its old\n  // subtree reachable, for the GC to copy, until the whole redraw is done.\n  if (!isNoting && originalWDom) {\n    originalWDom.il = true;\n    if (originalWDom.ctor) {\n      originalWDom.children = undefined;\n    }\n  }\n  return remakeWDom;\n};\n\n/**\n * Handle what the new virtual DOM should inherit or reconcile from the original virtual DOM.\n */\nconst inheritPropForRender = (\n  remakeWDom: WDom,\n  originalWDom?: WDom,\n  needRerender?: RenderType\n) => {\n  if (needRerender !== 'A' && originalWDom) {\n    remakeWDom.el = originalWDom.el;\n  }\n\n  if (needRerender === 'D' || needRerender === 'R' || needRerender === 'S') {\n    if (originalWDom) {\n      runUnmountQueueFromWDom(originalWDom);\n    }\n    remakeWDom.oc = originalWDom && originalWDom.children;\n  }\n\n  remakeWDom.op = originalWDom && originalWDom.props;\n};\n\n/**\n * Determine the render operation type (Add/Delete/Replace/Update/etc)\n * based on comparison between new and original WDom\n */\nconst addReRenderTypeProperty = (\n  newWDom: WDom,\n  isSameType: boolean,\n  originalWDom?: WDom\n): RenderType | undefined => {\n  if (checkEmptyElement(newWDom)) return 'D';\n\n  if (\n    newWDom === originalWDom ||\n    (isSameType &&\n      newWDom.type === 't' &&\n      newWDom.text === (originalWDom as WDom).text)\n  ) {\n    return 'N';\n  }\n  if (!(originalWDom && originalWDom.type)) return 'A';\n\n  const parent = getParent(originalWDom);\n  const isKeyChecked =\n    !newWDom.isRoot && parent && parent.type === 'l' && checkExistyKey(newWDom);\n\n  return isSameType ? (isKeyChecked ? 'T' : 'U') : isKeyChecked ? 'S' : 'R';\n};\n\n/**\n * Handling virtual DOM attribute updates.\n */\nconst syncResolverProps = (props: Props, infoProps: Props) => {\n  if (props && infoProps !== props) {\n    // Only the keys that are gone: deleting and re-adding every key on every\n    // render changes the object's shape each time.\n    infoProps = infoProps || {};\n    keys(props).forEach(\n      key => isEnumerableProp(infoProps, key) || delete props[key]\n    );\n    keys(infoProps).forEach(key => (props[key] = infoProps[key]));\n  }\n};\n\n/**\n * Keep the existing component node while injecting the props/children from the freshly computed TagFunctionResolver.\n * originalWDom is the fully evaluated node from the previous render, whereas infoVdom is the intermediate resolver,\n * so updating compProps/compChild in place lets reRender() evaluate with the latest slots and props.\n * It is crucial that props and children references remain stable as nodes update—many ancestors/closures share these arrays,\n * so mutate the existing arrays instead of replacing their references.\n */\nconst runUpdate = (vDom: WDom, infoVdom: TagFunctionResolver) => {\n  const { compProps: props, compChild: children } = vDom;\n  const { props: infoProps, children: infoChidren } = infoVdom;\n\n  if (props) {\n    syncResolverProps(props, infoProps);\n  }\n\n  /**\n   * In runUpdate, the original DOM (vDom) is already fully evaluated and completed, whereas infoVdom represents an intermediate state. Therefore, vdom.compChild and infoVdom.children are indeed the correct counterparts to compare.\n\n   * Keep shared child array references intact (<= same slot array instance)\n   * When the reference changes, sync the stored compChild contents so reRender sees fresh nodes\n   * Only update children if they're different references\n   * If it's the same Fragment reference, the diff process will handle updating its children\n   */\n  if (children && infoChidren && children !== infoChidren) {\n    children.splice(0, children.length, ...infoChidren);\n  }\n\n  return (vDom.reRender && vDom.reRender()) as WDom;\n};\n\n/**\n * Replace the compared virtual DOM with the new virtual DOM or simply update it.\n */\nconst generalize = (\n  newWDom: WDom | TagFunctionResolver,\n  isSameType: boolean,\n  originalWDom?: WDom\n): WDom => {\n  return checkCustemComponentFunction(newWDom)\n    ? isSameType && originalWDom\n      ? runUpdate(originalWDom, newWDom)\n      : // Resolved before (children a component draws again somewhere else):\n        // the first instance owns its props, which are also its key, so the\n        // new instance is made from a copy.\n        (newWDom.rd\n          ? copyResolver(newWDom)\n          : ((newWDom.rd = true), newWDom)\n        ).resolve()\n    : newWDom;\n};\n\n/**\n * 자식 가상돔들도 전부 재귀처리하며 똑같은 처리를 해준다.\n */\nconst remakeChildrenForDiff = (\n  newWDom: WDom,\n  isSameType: boolean,\n  originalWDom?: WDom\n) =>\n  isSameType && originalWDom\n    ? remakeChildrenForUpdate(newWDom, originalWDom)\n    : remakeChildrenForAdd(newWDom);\n\n/**\n * Recursive handling for the creation of a new virtual DOM. Kept apart from\n * the update below: one function for both made creating 1,000 rows 6% slower.\n */\nconst remakeChildrenForAdd = (newWDom: WDom) => {\n  const getParent = makeParentGetter(newWDom);\n\n  return (newWDom.children || []).map((item: WDom) => {\n    const child = makeNewWDomTree(item);\n    child.getParent = getParent;\n    return child;\n  });\n};\n\n/**\n * Recursive handling for updates, not additions.\n * Uses key-based diffing for loops, index-based for others\n */\nconst remakeChildrenForUpdate = (newWDom: WDom, originalWDom: WDom) => {\n  if (newWDom.type === 'l' && checkKeyedChildren(newWDom)) {\n    return diffLoopChildren(newWDom, originalWDom);\n  }\n\n  const origChildren = originalWDom.children || [];\n  const getParent = makeParentGetter(newWDom);\n\n  return (newWDom.children || []).map((item: WDom, index: number) => {\n    const child = makeNewWDomTree(item, origChildren[index]);\n    child.getParent = getParent;\n    return child;\n  });\n};\n\n/**\n * Recursive handling of loop-type virtual DOM elements.\n * Matches children against the originals by key via a Map in O(n) and\n * records each match's original index (oi) for the render phase to\n * minimize moves via LIS. The originals left unmatched are deleted.\n */\nconst diffLoopChildren = (newWDom: WDom, originalWDom: WDom) => {\n  const origChildren = originalWDom.children || [];\n  const keyMap = new Map<unknown, number>();\n  origChildren.forEach((item, index) => {\n    const key = getKey(item);\n    if (checkExisty(key) && !keyMap.has(key)) {\n      keyMap.set(key, index);\n    }\n  });\n\n  const used: boolean[] = [];\n  const getParent = makeParentGetter(newWDom);\n  const remaked = (newWDom.children || []).map((item, index) => {\n    const key = getKey(item);\n    // Unkeyed items among keyed ones (a hidden row's null, a nested array)\n    // pair with the unkeyed original at the same index, as in React.\n    const origIndex = checkExisty(key)\n      ? keyMap.get(key)\n      : index < origChildren.length && !checkExistyKey(origChildren[index])\n        ? index\n        : undefined;\n    let original: WDom | undefined;\n\n    if (origIndex !== undefined) {\n      keyMap.delete(key);\n      used[origIndex] = true;\n      original = origChildren[origIndex];\n    }\n\n    const child = makeNewWDomTree(item, original);\n    if (original) {\n      child.oi = origIndex;\n    }\n    child.getParent = getParent;\n\n    return child;\n  });\n\n  // Originals left unmatched, including ones whose key was already taken\n  // (no key, or a duplicate) and so never made it into keyMap.\n  typeDeleteUnused(\n    origChildren.filter((_item, index) => !used[index]),\n    originalWDom\n  );\n\n  return remaked;\n};\n","import { Props, WDom } from '@/types';\nimport { componentMap } from '@/utils/universalRef';\n\nconst redrawQueue = new Map<Props, () => void>();\nlet redrawQueueTimeout: boolean = false;\n\nconst schedule = (compKey: Props, exec: () => void) => {\n  redrawQueue.set(compKey, exec);\n\n  if (!redrawQueueTimeout) {\n    redrawQueueTimeout = true;\n    queueMicrotask(execRedrawQueue);\n  }\n};\n\nexport const setRedrawAction = (compKey: Props, exec: () => void) => {\n  const comp = componentMap.get(compKey);\n  if (comp) {\n    comp.up = () => schedule(compKey, exec);\n  }\n};\n\n/**\n * Like setRedrawAction, but bound once per component instead of on every\n * render: the node to redraw is the component's current one when renew() is\n * called.\n */\nexport const bindRedraw = (compKey: Props, exec: (wDom: WDom) => void) => {\n  const comp = componentMap.get(compKey);\n  if (comp) {\n    comp.up = () => {\n      const wDom = comp.vd.value as WDom;\n      schedule(compKey, () => exec(wDom));\n    };\n  }\n};\n\nexport const componentUpdate = (compKey: Props) => () => {\n  const comp = componentMap.get(compKey);\n  const up = comp && comp.up;\n  if (up) {\n    up();\n    return true;\n  }\n  return false;\n};\n\n// Each entry is taken out before it runs, so a renew raised during the flush\n// (a new child's mountCallback renewing its parent) queues it again and this\n// same pass runs it. If a render throws, another microtask drains the rest\n// without requiring a new renew; the original error still propagates.\nconst execRedrawQueue = () => {\n  try {\n    redrawQueue.forEach((item: () => void, compKey: Props) => {\n      redrawQueue.delete(compKey);\n      item();\n    });\n  } finally {\n    redrawQueueTimeout = !!redrawQueue.size;\n    if (redrawQueueTimeout) queueMicrotask(execRedrawQueue);\n  }\n};\n","import type { WDom } from '@/types';\nimport { wdomSymbol } from '@/utils/universalRef';\n\n// Common hot fields share one layout; root/component metadata stays sparse.\nexport const createWDom = (\n  type: WDom['type'],\n  tag?: WDom['tag'],\n  props?: WDom['props'],\n  text?: WDom['text'],\n  children?: WDom['children'],\n  getParent?: WDom['getParent']\n): WDom => ({\n  type,\n  nr: undefined,\n  tag,\n  props,\n  text,\n  children,\n  getParent,\n  el: undefined,\n  oi: undefined,\n  oc: undefined,\n  op: undefined,\n  il: undefined,\n  [wdomSymbol]: true,\n});\n","import { getCurrentComponent } from '@/utils/universalRef';\n\nimport { useUpdated } from '@/hook/internal/useUpdate';\n\ntype DependencyFactory = () => unknown[];\n\nexport const updateCallback = (\n  effectAction: () => (() => void) | void,\n  dependencies: DependencyFactory = () => []\n) => {\n  const component = getCurrentComponent();\n  if (!component) return;\n\n  component.upR.push(() => useUpdated(effectAction, dependencies));\n  useUpdated(effectAction, dependencies);\n};\n\nexport const runUpdateCallback = () => {\n  const comp = getCurrentComponent();\n  const updateReqs = comp && comp.upR;\n\n  if (updateReqs && updateReqs.length) {\n    updateReqs.forEach(callback => callback());\n  }\n};\n","import {\n  WDom,\n  TagFunction,\n  TagFunctionResolver,\n  FragmentFunction,\n  Props,\n  MiddleStateWDomChildren,\n  MiddleStateWDom,\n  NodePointer,\n  Component,\n  LComponent,\n} from '@/types';\n\nimport { makeNewWDomTree } from '@/diff';\nimport { wDomUpdate } from '@/render';\nimport {\n  initUpdateHookState,\n  compKeyRef,\n  initMountHookState,\n  needDiffRef,\n  componentMap,\n  lmountComponentSet,\n} from '@/utils/universalRef';\nimport { bindRedraw, componentUpdate } from '@/utils/redraw';\nimport { createWDom } from '@/utils/createWDom';\nimport { runUpdateCallback } from '@/hook/updateCallback';\nimport {\n  checkFragmentFunction,\n  checkCustemComponentFunction,\n} from '@/utils/predicator';\n\n// ============================================================================\n// Public API - Highest Level (User-facing API)\n// ============================================================================\n\n/**\n * It allows grouping multiple elements together.\n */\nexport const Fragment = (_props: Props, ...children: WDom[]) =>\n  createWDom('f', undefined, undefined, undefined, children);\n\n/**\n * Element creation\n */\nexport const h = (\n  tag: TagFunction | FragmentFunction | string,\n  props: Props,\n  ...children: MiddleStateWDomChildren\n) => {\n  const nodeParentPointer: NodePointer = { value: undefined };\n  const newChildren = remakeChildren(nodeParentPointer, children);\n  const node = makeNode(tag, props || {}, newChildren);\n\n  if (!checkCustemComponentFunction(node)) {\n    nodeParentPointer.value = node;\n  }\n\n  return node;\n};\n\n/**\n * Enables portals\n */\nexport const portal = (wDom: WDom, portal: HTMLElement) =>\n  h('portal', { portal }, wDom);\n\n/**\n * It helps with component creation.\n */\nexport const mount =\n  <T>(component: Component<T>) =>\n  (_props: T, _children?: MiddleStateWDomChildren) =>\n    component;\n\n/**\n * It helps with component creation without renew parameter.\n * Use useRenew() hook to get renew function if needed.\n */\nexport const lmount =\n  <T>(component: LComponent<T>) =>\n  (_props: T, _children?: MiddleStateWDomChildren) => {\n    lmountComponentSet.add(component);\n    return component;\n  };\n\n/**\n * Maintain compChild references for upward updates (render props, slots, etc.).\n * JSX always returns a fresh children array, so when a subtree re-renders\n * bottom-up we must manually swap the old child instance out of each ancestor's\n * compChild.\n *\n * Fragment-wrapping solved this by keeping a stable wrapper node,\n * but that hides the actual child tree. We prefer this explicit sync for DX.\n *\n * In practice slot consumers rarely thread children more than a layer or two—\n * usually shallow composed pieces like dropdowns or drag-and-drop shells—so the\n * directed walk keeps DX high without introducing observable overhead.\n */\nconst syncAncestorComponentChildren = (\n  parent: WDom | undefined,\n  prevChild: WDom,\n  nextChild: WDom\n) => {\n  const walk = (node: WDom | undefined, visited: Set<WDom>): void => {\n    if (!node || visited.has(node)) {\n      return;\n    }\n\n    visited.add(node);\n\n    if (node.compChild) {\n      const childIndex = node.compChild.indexOf(prevChild);\n\n      if (childIndex !== -1) {\n        node.compChild.splice(childIndex, 1, nextChild);\n      }\n    }\n\n    walk(node.getParent ? node.getParent() : undefined, visited);\n  };\n\n  walk(parent, new Set<WDom>());\n};\n\n/**\n * It re-renders starting from a specific component.\n */\nexport const replaceWDom = (\n  tag: TagFunction,\n  props: Props,\n  children: WDom[],\n  originalWDom: WDom\n) => {\n  if (originalWDom.il) {\n    return;\n  }\n  needDiffRef.value = true;\n\n  let newWDomTree: WDom;\n  try {\n    const newWDom = makeWDomResolver(tag, props, children);\n    newWDomTree = makeNewWDomTree(newWDom, originalWDom);\n    // NOTE: we/ae are short for wrapElement/afterElement\n    const { isRoot, getParent, we, ae } = originalWDom;\n\n    newWDomTree.getParent = getParent;\n\n    if (!isRoot && getParent) {\n      const parent = getParent();\n      const brothers = (parent && parent.children) || [];\n      const index = brothers.indexOf(originalWDom);\n\n      if (index !== -1) {\n        brothers.splice(index, 1, newWDomTree);\n      }\n\n      syncAncestorComponentChildren(parent, originalWDom, newWDomTree);\n    } else {\n      newWDomTree.isRoot = true;\n      newWDomTree.we = we;\n      newWDomTree.ae = ae;\n    }\n  } finally {\n    needDiffRef.value = false;\n  }\n\n  wDomUpdate(newWDomTree);\n};\n\n// ============================================================================\n// Mid-Level - Virtual DOM Node Creation (Intermediate abstraction level)\n// ============================================================================\n\n/**\n * The starting point where the virtual DOM is created from the h function.\n */\nconst makeNode = (\n  tag: TagFunction | FragmentFunction | string,\n  props: Props,\n  children: WDom[]\n) => {\n  if (checkFragmentFunction(tag)) {\n    return Fragment(props, ...children);\n  } else if (checkCustemComponentFunction(tag)) {\n    const componetMakeResolver = makeWDomResolver(tag, props, children);\n\n    if (needDiffRef.value) {\n      return componetMakeResolver;\n    }\n\n    // Drawn right away, without a diff. Later updates sync the instance's\n    // props and children in place, so it gets copies; the node keeps the\n    // untouched description to be drawn again elsewhere (cloneWDom).\n    const node = copyResolver(componetMakeResolver).resolve();\n    node.rs = componetMakeResolver;\n    return node;\n  }\n\n  return createWDom('e', tag, props, undefined, children);\n};\n\n/**\n * The starting point for recursively processing the child virtual DOM elements.\n */\nconst remakeChildren = (\n  nodeParentPointer: NodePointer,\n  children: MiddleStateWDomChildren\n): WDom[] => {\n  // Siblings share a single getParent closure (one allocation per parent)\n  const getParent = () => nodeParentPointer.value;\n\n  return children.map((item: MiddleStateWDom) => {\n    const childItem = makeChildrenItem(item);\n    childItem.getParent = getParent;\n    return childItem;\n  });\n};\n\n/**\n * Recursively process the child virtual DOM elements.\n */\nconst makeChildrenItem = (item: MiddleStateWDom): WDom => {\n  if (item === null || item === undefined || typeof item === 'boolean') {\n    return createWDom(null);\n  } else if (Array.isArray(item)) {\n    const nodeParentPointer: NodePointer = { value: undefined };\n    const children = remakeChildren(nodeParentPointer, item);\n    const node = createWDom('l', undefined, undefined, undefined, children);\n    nodeParentPointer.value = node;\n\n    return node;\n  } else if (typeof item === 'string' || typeof item === 'number') {\n    return createWDom('t', undefined, undefined, item);\n  }\n\n  return item;\n};\n\n// ============================================================================\n// Component Lifecycle - Component Creation & Re-rendering\n// ============================================================================\n\n/**\n * Create component resolver function\n */\nconst createComponentResolver = (\n  tag: TagFunction,\n  props: Props,\n  wrappedChildren: WDom[]\n) => {\n  return (compKey = props) => {\n    // Diff mode sets needDiffRef to true so h()/makeNode return a resolver\n    // placeholder. During actual resolution we must force a real WDom tree,\n    // otherwise nested components leave only resolvers (no getParent/children)\n    // and CSR renders a blank area. Temporarily drop needDiffRef, then restore.\n    // Regression tests: src/tests/core-composedRenew.test.tsx,\n    // src/tests/core-component-remount.test.tsx\n    const prevNeedDiff = needDiffRef.value;\n    const previousKey = compKeyRef.value;\n    needDiffRef.value = false;\n    try {\n      initMountHookState(compKey, tag);\n\n      const initialComponent = tag(props, wrappedChildren);\n\n      let componentMaker: (nextProps: Props) => MiddleStateWDom;\n\n      if (typeof initialComponent === 'function') {\n        const component = initialComponent;\n        // Check if component is created with lmount (no renew parameter)\n        // TypeScript cannot infer that component is LComponent when has() returns true,\n        // because WeakSet.has() is a runtime check that doesn't narrow types.\n        // We use 'as any' since the runtime check guarantees type safety.\n        componentMaker = lmountComponentSet.has(component)\n          ? (component as any)(props, wrappedChildren)\n          : component(componentUpdate(compKey), props, wrappedChildren);\n      } else {\n        // For components that directly return a VDom, recreate it each render.\n        // The first call already rendered this stateless component. Repeating it\n        // creates orphan child instances and can register hooks under a child's key.\n        let firstRender = true;\n        componentMaker = (nextProps: Props) => {\n          if (firstRender) {\n            firstRender = false;\n            return initialComponent as MiddleStateWDom;\n          }\n          return tag(nextProps, wrappedChildren) as MiddleStateWDom;\n        };\n      }\n\n      return makeCustomNode(\n        componentMaker,\n        compKey,\n        tag,\n        props,\n        wrappedChildren\n      );\n    } finally {\n      compKeyRef.value = previousKey;\n      needDiffRef.value = prevNeedDiff;\n    }\n  };\n};\n\n/**\n * A fresh copy of a node that is already drawn somewhere: a hoisted constant,\n * children a component renders again in another place, the same node twice.\n * A node holds the state of the place it is drawn in (el, children, parent,\n * component instance), so a second place gets its own copy. A component\n * becomes a resolver for a new instance with its own props and children.\n */\nexport const cloneWDom = (wDom: WDom): WDom | TagFunctionResolver =>\n  wDom.ctor\n    ? copyResolver(\n        wDom.rs || {\n          ctor: wDom.ctor,\n          props: wDom.compProps as Props,\n          children: wDom.compChild as WDom[],\n        }\n      )\n    : createWDom(\n        wDom.type,\n        wDom.tag,\n        wDom.props,\n        wDom.text,\n        wDom.children && [...wDom.children],\n        wDom.getParent\n      );\n\nexport const copyResolver = ({\n  ctor,\n  props,\n  children,\n}: Omit<TagFunctionResolver, 'resolve'>) =>\n  makeWDomResolver(ctor as TagFunction, { ...props }, [...(children || [])]);\n\n/**\n * Create an intermediate step for diffing between the existing virtual DOM and the new one during re-rendering\n */\nconst makeWDomResolver = (\n  tag: TagFunction,\n  props: Props,\n  children: WDom[]\n) => ({\n  ctor: tag,\n  props,\n  children,\n  resolve: createComponentResolver(tag, props, children),\n});\n\n/**\n * Create the actual virtual DOM node from the component.\n */\nconst makeCustomNode = (\n  componentMaker: (props: Props) => MiddleStateWDom,\n  compKey: Props,\n  tag: TagFunction,\n  props: Props,\n  children: WDom[]\n) => {\n  const wrappedComponentMaker = wrapComponentMaker(componentMaker);\n  const customNode = wrappedComponentMaker(props);\n  const reRender = makeReRender(\n    wrappedComponentMaker,\n    compKey,\n    tag,\n    props,\n    children\n  );\n\n  addComponentProps(customNode, compKey, tag, props, children, reRender);\n  bindRedraw(compKey, wDom =>\n    replaceWDom(\n      tag,\n      (wDom.compProps as Props) || props,\n      (wDom.compChild as WDom[]) || children,\n      wDom\n    )\n  );\n  return customNode;\n};\n\n/**\n * When the virtual DOM is actually created from the component, generate a re-render method for future redraws.\n */\nconst makeReRender = (\n  componentMaker: (props: Props) => WDom,\n  compKey: Props,\n  tag: TagFunction,\n  props: Props,\n  children: WDom[]\n) => {\n  const reRender = (): WDom => {\n    const previousKey = compKeyRef.value;\n    try {\n      initUpdateHookState(compKey);\n      runUpdateCallback();\n\n      const customNode = componentMaker(props);\n      addComponentProps(customNode, compKey, tag, props, children, reRender);\n\n      return customNode;\n    } finally {\n      compKeyRef.value = previousKey;\n    }\n  };\n  return reRender;\n};\n\n// ============================================================================\n// Low-Level Utilities - Component Node Manipulation\n// ============================================================================\n\n/**\n * Wrap component output in a stable Fragment so component metadata lives on a\n * dedicated node. This prevents parent/child sharing when a component returns\n * another component and keeps updates stable even when output becomes empty.\n */\nconst wrapComponentMaker =\n  (componentMaker: (props: Props) => MiddleStateWDom) =>\n  (newProps: Props): WDom => {\n    const next = makeChildrenItem(componentMaker(newProps));\n    const wrapper = Fragment({}, next);\n    next.getParent = () => wrapper;\n    return wrapper;\n  };\n\n/**\n * When creating a custom component node, attach additional information attributes to the virtual DOM object.\n */\nconst addComponentProps = (\n  wDom: WDom,\n  compKey: Props,\n  tag: TagFunction,\n  props: Props,\n  children: WDom[],\n  reRender: () => WDom\n) => {\n  // Runs on every render of every component: plain assignments, and the\n  // redraw action is bound once in makeCustomNode.\n  wDom.compProps = props;\n  wDom.compChild = children;\n  wDom.ctor = tag;\n  wDom.compKey = compKey;\n  wDom.reRender = reRender;\n\n  const comp = componentMap.get(compKey);\n  if (comp) {\n    comp.vd.value = wDom;\n  }\n};\n","export const ref = <T>(initValue: T) => ({ value: initValue });\nexport const nextTick = () => Promise.resolve();\n","import { Renew } from '@/types';\nimport { getComponentKey } from '@/utils/universalRef';\nimport { componentUpdate } from '@/utils/redraw';\n\n/**\n * Hook to get the renew (component update) function.\n * Useful for lmount components that need to trigger updates.\n */\nexport const useRenew = (): Renew => {\n  const compKey = getComponentKey();\n\n  if (!compKey) {\n    return () => false;\n  }\n\n  return componentUpdate(compKey);\n};\n"],"names":["wdomSymbol","xmlnsRef","compKeyRef","needDiffRef","componentMap","lmountComponentSet","componentMapManualMode","setComponetRef","compKey","ctor","getComponentKey","getCurrentComponent","getComponentSubInfo","subKey","component","initUpdateHookState","initMountHookState","setComponentMapManualMode","enabled","isComponentMapManualMode","runUnmountEffects","subInfo","effect","disposeComponentEntry","getParent","vDom","makeParentGetter","parent","keys","isEnumerableProp","props","key","hasEnumerableProp","prototype","isObject","target","isPropType","obj","checkSameCustomComponent","newWDom","originalWDom","checkSameFragment","checkSameTagElement","checkNormalTypeElement","checkLoopTypeElement","checkKeyedChildren","getKey","checkVirtualType","type","checkCustemComponentFunction","checkFragmentFunction","Fragment","checkEmptyElement","wDom","checkPortalElement","el","op","checkEventKey","checkExistyKey","checkExisty","value","checkStyleData","dataKey","dataValue","checkRefData","accessorCache","hasAccessorMethods","proto","byKey","result","descriptor","isPendingCustomElement","getWDomType","checkSameWDomWithOriginal","unmount","effectAction","comp","runUnmountQueueFromWDom","removeItem","recursiveRunUnmount","item","mountedQueue","addMountedQueue","execMountedQueue","runMountedQueueFromWDom","mountCallback","mountQueue","callback","mountReadyCallback","runWDomCallbacksFromWDom","wdCBQueue","cleanup","useUpdated","dependencies","upD","upS","def","nextDependencies","checkNeedPushQueue","runUpdatedQueueFromWDom","queue","originalDefs","newDefs","index","DF","insertRoot","wrapElement","element","afterElement","CE","t","render","isHydration","Dom","wDomToDom","compData","rootDelete","deleteRealDom","typeDelete","parentWDom","findRealParentElement","nt","isPortal","findChildWithRemoveElement","items","next","matches","same","typeDeleteUnused","list","parentElement","typeSortedReplace","typeAdd","newElement","parentEl","nextEl","startFindNextBrotherElement","getElementFromFragment","acc","brothers","findChildFragmentNextElement","moving","candidiateBrothers","targetEl","bItem","found","typeReplace","orignalElement","typeUpdate","updateText","oldProps","updateProps","updateChildren","children","wDomUpdate","matchedIndexes","oiSeq","movers","ordered","oi","nr","keep","lis","getLisPositions","pos","i","created","createdCount","baseAnchor","tail","anchor","isNew","needMove","first","clearDiffMeta","seq","tails","prev","lo","hi","mid","last","newWDomTree","needRerender","renderHandlers","originalProps","updateEvent","updateStyle","setAttr","k","v","tag","text","isVirtualType","wDomChildrenToDom","childItem","copy","cloneWDom","childElement","eventKey","newEventHandler","oldEventHandler","eventName","style","oldStyle","orig","styleProxy","makeNewWDomTree","remakeNewWDom","isSameType","remakeWDom","generalize","addReRenderTypeProperty","isNoting","remakeChildrenForDiff","inheritPropForRender","isKeyChecked","syncResolverProps","infoProps","runUpdate","infoVdom","infoChidren","copyResolver","remakeChildrenForUpdate","remakeChildrenForAdd","child","diffLoopChildren","origChildren","keyMap","used","remaked","origIndex","original","_item","redrawQueue","redrawQueueTimeout","schedule","exec","execRedrawQueue","bindRedraw","componentUpdate","up","createWDom","updateCallback","runUpdateCallback","updateReqs","_props","h","nodeParentPointer","newChildren","remakeChildren","node","makeNode","portal","mount","_children","lmount","syncAncestorComponentChildren","prevChild","nextChild","walk","visited","childIndex","replaceWDom","makeWDomResolver","isRoot","we","ae","componetMakeResolver","makeChildrenItem","createComponentResolver","wrappedChildren","prevNeedDiff","previousKey","initialComponent","componentMaker","firstRender","nextProps","makeCustomNode","wrappedComponentMaker","wrapComponentMaker","customNode","reRender","makeReRender","addComponentProps","newProps","wrapper","ref","initValue","nextTick","useRenew"],"mappings":"AAQa,MAAAA,KAAa,OAAO,IAAI,mBAAmB,GAC3CC,IAA8B,EAAE,OAAO,MACvCC,IAAwC,EAAE,OAAO,QACjDC,IAAkC,EAAE,OAAO,MAC3CC,wBAAiC,QAAQ,GACzCC,yBAA4C,QAAQ;AACjE,IAAIC,KAAyB;AAE7B,MAAMC,KAAiB,CAACC,GAAkBC,MAA6B;AACrE,EAAAL,EAAa,IAAII,GAAS;AAAA,IACxB,MAAAC;AAAA,IACA,IAAI,EAAE,OAAO,KAAK;AAAA,IAClB,IAAI,MAAM;AAAA,IAAC;AAAA,IACX,KAAK,CAAC;AAAA,IACN,KAAK,EAAE,OAAO,EAAE;AAAA,IAChB,KAAK,CAAC;AAAA,IACN,MAAM,CAAC;AAAA,IACP,KAAK,CAAC;AAAA,IACN,MAAM,CAAC;AAAA,IACP,MAAM,CAAC;AAAA;AAAA,EAAA,CACR;AACH,GAEaC,KAAkB,MAAsBR,EAAW,OAGnDS,IAAsB,MACjCP,EAAa,IAAIF,EAAW,KAAgB,GAEjCU,KAAsB,CACjCJ,GACAK,MAC4B;AACtB,QAAAC,IAAYV,EAAa,IAAII,CAAO;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