{"version":3,"file":"install.mjs","sources":["../../../../../packages/utils/vue/install.ts"],"sourcesContent":["import { NOOP } from '@vue/shared'\n\nimport type { App, Directive } from 'vue'\nimport type { SFCInstallWithContext, SFCWithInstall } from './typescript'\n\nexport const withInstall = <T, E extends Record<string, any>>(\n  main: T,\n  extra?: E\n) => {\n  ;(main as SFCWithInstall<T>).install = (app: any): void => {\n    for (const comp of [main, ...Object.values(extra ?? {})]) {\n      app.component(comp.name, comp)\n    }\n  }\n\n  if (extra) {\n    for (const [key, comp] of Object.entries(extra)) {\n      ;(main as any)[key] = comp\n    }\n  }\n  return main as SFCWithInstall<T> & E\n}\n\nexport const withInstallFunction = <T>(fn: T, name: string) => {\n  ;(fn as SFCWithInstall<T>).install = (app: App) => {\n    ;(fn as SFCInstallWithContext<T>)._context = app._context\n    app.config.globalProperties[name] = fn\n  }\n\n  return fn as SFCInstallWithContext<T>\n}\n\nexport const withInstallDirective = <T extends Directive>(\n  directive: T,\n  name: string\n) => {\n  ;(directive as SFCWithInstall<T>).install = (app: App): void => {\n    app.directive(name, directive)\n  }\n\n  return directive as SFCWithInstall<T>\n}\n\nexport const withNoopInstall = <T>(component: T) => {\n  ;(component as SFCWithInstall<T>).install = NOOP\n\n  return component as SFCWithInstall<T>\n}\n"],"names":["withInstall","t","s","install","l","n","Object","values","component","name","entries","withInstallFunction","_context","config","globalProperties","withInstallDirective","directive","withNoopInstall","o"],"mappings":"mCAA+C,MAACA,EAAY,CAACC,EAAEC,KAAK,GAAGD,EAAEE,QAAQC,IAAI,IAAI,MAAMC,IAAI,CAACJ,KAAKK,OAAOC,OAAU,MAAHL,EAAQA,EAAE,KAAKE,EAAEI,UAAUH,EAAEI,KAAKJ,IAAIH,EAAE,IAAI,MAAME,EAAEC,KAAKC,OAAOI,QAAQR,GAAGD,EAAEG,GAAGC,EAAE,OAAOJ,GAAGU,EAAoB,CAACV,EAAEC,KAAKD,EAAEE,QAAQC,IAAIH,EAAEW,SAASR,EAAEQ,SAASR,EAAES,OAAOC,iBAAiBZ,GAAGD,GAAGA,GAAGc,EAAqB,CAACd,EAAEC,KAAKD,EAAEE,QAAQC,IAAIA,EAAEY,UAAUd,EAAED,IAAIA,GAAGgB,EAAgBhB,IAAIA,EAAEE,QAAQe,EAAEjB"}