{"version":3,"file":"KnobEnvelopeProvider.js","names":[],"sources":["jsx/knobs/KnobEnvelopeProvider.js"],"sourcesContent":["import { useMemo } from \"react\";\nimport { TamaguiProvider, Theme } from \"tamagui\";\nimport { IntentContext, Preset, Surface } from \"@multiplatform.one/theme\";\nimport { knobsForEnvelope } from \"./envelope\";\nimport { Fragment, jsx } from \"react/jsx-runtime\";\nfunction resolveEnvelopeThemeName(envelope, themes) {\n  const wanted = envelope.themeName;\n  if (!themes) return wanted || void 0;\n  if (wanted && Object.hasOwn(themes, wanted)) return wanted;\n  if (Object.hasOwn(themes, envelope.scheme)) return envelope.scheme;\n  return void 0;\n}\nfunction KnobEnvelopeProvider({ envelope, config, children }) {\n  const knobs = useMemo(() => knobsForEnvelope(envelope), [envelope]);\n  const themeName = useMemo(\n    () => resolveEnvelopeThemeName(envelope, config?.themes),\n    [config, envelope]\n  );\n  let tree = /* @__PURE__ */ jsx(Preset, { preset: envelope.presetName, cascade: false, overrides: knobs, children: /* @__PURE__ */ jsx(Surface, { size: envelope.surface.size === \"unset\" ? void 0 : envelope.surface.size, children: /* @__PURE__ */ jsx(IntentContext.Provider, { value: envelope.intent, children }) }) });\n  if (themeName) {\n    tree = /* @__PURE__ */ jsx(Theme, { name: themeName, children: tree });\n  }\n  if (config) {\n    tree = /* @__PURE__ */ jsx(TamaguiProvider, { config, defaultTheme: themeName, children: tree });\n  }\n  return /* @__PURE__ */ jsx(Fragment, { children: tree });\n}\nexport {\n  KnobEnvelopeProvider,\n  resolveEnvelopeThemeName\n};\n//# sourceMappingURL=KnobEnvelopeProvider.js.map\n"],"mappings":";;;;;;;AAKA,SAAS,yBAAyB,UAAU,QAAQ;CAClD,MAAM,SAAS,SAAS;CACxB,IAAI,CAAC,QAAQ,OAAO,UAAU,KAAK;CACnC,IAAI,UAAU,OAAO,OAAO,QAAQ,MAAM,GAAG,OAAO;CACpD,IAAI,OAAO,OAAO,QAAQ,SAAS,MAAM,GAAG,OAAO,SAAS;CAC5D,OAAO,KAAK;AACd;AACA,SAAS,qBAAqB,EAAE,UAAU,QAAQ,YAAY;CAC5D,MAAM,QAAQ,cAAc,iBAAiB,QAAQ,GAAG,CAAC,QAAQ,CAAC;CAClE,MAAM,YAAY,cACV,yBAAyB,UAAU,QAAQ,MAAM,GACvD,CAAC,QAAQ,QAAQ,CACnB;CACA,IAAI,OAAuB,oBAAI,QAAQ;EAAE,QAAQ,SAAS;EAAY,SAAS;EAAO,WAAW;EAAO,UAA0B,oBAAI,SAAS;GAAE,MAAM,SAAS,QAAQ,SAAS,UAAU,KAAK,IAAI,SAAS,QAAQ;GAAM,UAA0B,oBAAI,cAAc,UAAU;IAAE,OAAO,SAAS;IAAQ;GAAS,CAAC;EAAE,CAAC;CAAE,CAAC;CAC3T,IAAI,WAAW;EACb,OAAuB,oBAAI,OAAO;GAAE,MAAM;GAAW,UAAU;EAAK,CAAC;CACvE;CACA,IAAI,QAAQ;EACV,OAAuB,oBAAI,iBAAiB;GAAE;GAAQ,cAAc;GAAW,UAAU;EAAK,CAAC;CACjG;CACA,OAAuB,oBAAI,UAAU,EAAE,UAAU,KAAK,CAAC;AACzD"}