{"version":3,"file":"flatten-cascader-paths.mjs","names":[],"sources":["../../../src/components/Cascader/flatten-cascader-paths.ts"],"sourcesContent":["import type { CascaderOption } from './Cascader';\n\nexport interface CascaderFlatPath {\n  /** Values from root to node */\n  path: string[];\n\n  /** Option chain from root to node */\n  options: CascaderOption[];\n\n  /** `true` if the node has no children */\n  leaf: boolean;\n\n  /** `true` if the node or any of its ancestors is disabled */\n  disabled: boolean;\n}\n\nexport function flattenCascaderPaths(data: CascaderOption[]): CascaderFlatPath[] {\n  const result: CascaderFlatPath[] = [];\n\n  const walk = (\n    nodes: CascaderOption[],\n    parentPath: string[],\n    parentOptions: CascaderOption[],\n    parentDisabled: boolean\n  ) => {\n    for (const node of nodes) {\n      const path = [...parentPath, node.value];\n      const options = [...parentOptions, node];\n      const disabled = parentDisabled || !!node.disabled;\n      const hasChildren = Array.isArray(node.children) && node.children.length > 0;\n\n      result.push({ path, options, leaf: !hasChildren, disabled });\n\n      if (hasChildren) {\n        walk(node.children!, path, options, disabled);\n      }\n    }\n  };\n\n  walk(data, [], [], false);\n\n  return result;\n}\n"],"mappings":";;AAgBA,SAAgB,qBAAqB,MAA4C;CAC/E,MAAM,SAA6B,CAAC;CAEpC,MAAM,QACJ,OACA,YACA,eACA,mBACG;EACH,KAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,OAAO,CAAC,GAAG,YAAY,KAAK,KAAK;GACvC,MAAM,UAAU,CAAC,GAAG,eAAe,IAAI;GACvC,MAAM,WAAW,kBAAkB,CAAC,CAAC,KAAK;GAC1C,MAAM,cAAc,MAAM,QAAQ,KAAK,QAAQ,KAAK,KAAK,SAAS,SAAS;GAE3E,OAAO,KAAK;IAAE;IAAM;IAAS,MAAM,CAAC;IAAa;GAAS,CAAC;GAE3D,IAAI,aACF,KAAK,KAAK,UAAW,MAAM,SAAS,QAAQ;EAEhD;CACF;CAEA,KAAK,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK;CAExB,OAAO;AACT"}