{"version":3,"file":"DkujwcKg.mjs","sources":["../../../../../../node_modules/svelte/src/runtime/internal/globals.js","../../../../../../src/lib/components/Chat.svelte","../../../../../../src/lib/components/ChatWindow.svelte"],"sourcesContent":["/** @type {typeof globalThis} */\nexport const globals =\n\ttypeof window !== 'undefined'\n\t\t? window\n\t\t: typeof globalThis !== 'undefined'\n\t\t? globalThis\n\t\t: // @ts-ignore Node typings have this\n\t\t  global;\n","<script lang=\"ts\">\n  import { draggable } from \"@neodrag/svelte\";\n  import Notebook from \"$lib/components/notebook/Notebook.svelte\";\n  import WithTooltip from \"$lib/components/reusable/WithTooltip.svelte\";\n  import getPy from \"$lib/pyodide\";\n  import { cubicIn, cubicOut } from \"svelte/easing\";\n  import { scale } from \"svelte/transition\";\n\n  let input: string;\n\n  let ref: HTMLDivElement;\n\n  export let close: () => any;\n\n  let messages: { role: \"user\" | \"assistant\" | \"system\"; content: string }[] = [];\n\n  async function invokeChat() {\n    const py = await getPy({ chat: true });\n    const generate = py.pyimport(\"chat.utils.llm.generate\");\n    const groundings: string = await py.pyimport(\"chat.templates.groundings\").arender();\n    let content = \"\";\n    messages = [...messages, { role: \"user\", content: input }, { role: \"assistant\", content }];\n    input = \"\";\n    for await (const i of generate(py.toPy([{ role: \"system\", content: groundings }, ...messages]))) {\n      content += i;\n      messages = [...messages.slice(0, -1), { role: \"assistant\", content }];\n    }\n  }\n</script>\n\n<div class=\"mt-10 h-full max-w-[calc(100vw-40px)] w-full sm:mt-30vh lg:max-w-xl sm:max-w-lg sm:w-3/4\">\n  <div in:scale={{ start: 0.9, easing: cubicOut }} out:scale={{ start: 0.95, easing: cubicIn }} use:draggable={{ applyUserSelectHack: false, cancel: ref, bounds: { left: 20, top: 20, right: 20, bottom: 20 } }} class=\"relative max-h-[calc(100vh-40px)] cursor-grab overflow-y-scroll border-(1 white/10) rounded bg-neutral-8/60 ring-0.9 ring-white/20 ring-inset backdrop-blur-lg xl:max-w-3xl lg:ring-1.3 sm:ring-1.1\">\n    <div class=\"h-full w-full flex flex-col gap-3 bg-neutral-9/40 px-3 sm:gap-4 lg:px-4 sm:px-3.5\">\n      <div class=\"sticky top-0 z-1 flex flex-row select-none items-center justify-between bg-gradient-(from-neutral-9 via-neutral-9/80 to-neutral-9/0 to-b) p-3 -mx-3 -mb-6 lg:p-4 sm:p-3.5 !pb-6 lg:-mx-4 sm:-mx-3.5\">\n        <div class=\"flex flex-row items-center gap-2.5 rounded bg-emerald-3/10 px-1.5 py-1 text-emerald-3/80\">\n          <div class=\"i-majesticons-lightbulb-shine text-base text-emerald-3\" />\n          <div class=\"text-xs capitalize sm:text-sm\">\n            通用助手\n          </div>\n        </div>\n        <div class=\"flex flex-row [&>button:active]:scale-90 [&>button]:(rounded p-1.5 text-white/80 transition-colors)\">\n          <WithTooltip tips=\"关闭\" let:builder>\n            <button class=\"hover:(bg-red-3/10 text-red-3/80)\" on:click={close} {...builder} use:builder.action>\n              <div class=\"i-mingcute-close-fill\" />\n            </button>\n          </WithTooltip>\n        </div>\n      </div>\n      <div class=\"contents cursor-auto text-sm\" bind:this={ref}>\n        {#each messages as { role, content }}\n          {#if content}\n            <div class:user={role === \"user\"} class=\"[&>article_:where(h1,h2,h3,h4,h5,h6)]:(text-1.1em font-400) [&>article]:(<sm:text-xs lg:text-base)\">\n              <Notebook text={content} />\n            </div>\n          {/if}\n        {/each}\n        <div class=\"sticky bottom-0 flex flex-row gap-1.5 bg-gradient-(from-neutral-9 via-neutral-9/80 to-neutral-9/0 to-t) p-3 -mx-3 -mt-6 lg:p-4 sm:p-3.5 !pt-6 lg:-mx-4 sm:-mx-3.5\">\n          <!-- svelte-ignore a11y-autofocus -->\n          <input autofocus placeholder=\"问我任何事情\" class=\"w-full rounded bg-neutral-8/80 px-2 py-1 text-neutral-2 outline-none placeholder-neutral-6\" on:keydown={({ key }) => key === \"Enter\" && invokeChat()} bind:value={input} type=\"text\">\n          <button on:click={invokeChat}>\n            <div class=\"i-tabler-square-rounded-chevron-up-filled text-2xl text-neutral-4\"></div>\n          </button>\n        </div>\n      </div>\n    </div>\n  </div>\n</div>\n\n<style>\n  .user {\n    --uno: bg-white/5 px-3 py-1 -mx-3 lg:(px-4 -mx-4) sm:(px-3.5 -mx-3.5);\n  }\n</style>\n","<script context=\"module\" lang=\"ts\">\n  import Chat from \"./Chat.svelte\";\n  import { writable } from \"svelte/store\";\n\n  let index = 0;\n\n  const conversations = writable<number[]>([]);\n\n  export function newChat() {\n    conversations.update($conversations => [...$conversations, index++]);\n  }\n</script>\n\n{#each $conversations as i (i)}\n  <div class=\"pointer-events-none fixed inset-0 grid place-items-center [&>*]:pointer-events-auto\">\n    <Chat close={() => $conversations = $conversations.filter(index => (index !== i))} />\n  </div>\n{/each}\n"],"names":["globals","ctx","insert_hydration","target","button","anchor","append_hydration","div","is_function","toggle_class","create_if_block","div10","div9","div8","div4","div2","div3","div7","div6","input_1","i","each_blocks","div9_intro","create_in_transition","scale","cubicOut","div9_outro","create_out_transition","cubicIn","input","ref","close","$$props","messages","invokeChat","py","getPy","generate","groundings","content","$$invalidate","keydown_handler","key","$$value","index","conversations","writable","newChat","$conversations"],"mappings":"2mBACY,MAACA,GACZ,OAAO,OAAW,IACf,OACA,OAAO,WAAe,IACtB,WAEA,oKCmC+EC,EAAO,EAAA,2RAA9EC,EAEQC,EAAAC,EAAAC,CAAA,EADNC,EAAoCF,EAAAG,CAAA,uDADsBC,GAAAP,OAAAA,EAAK,CAAA,EAAA,MAAA,KAAA,SAAA,gHAAMA,EAAO,EAAA,+GAU5DA,EAAO,CAAA,CAAA,EAAA,kTADRQ,EAAAF,EAAA,OAAAN,OAAS,MAAM,UAAhCC,EAEKC,EAAAI,EAAAF,CAAA,mDADaJ,EAAO,CAAA,wBADRQ,EAAAF,EAAA,OAAAN,OAAS,MAAM,iHAD7BA,EAAO,CAAA,GAAAS,GAAAT,CAAA,4FAAPA,EAAO,CAAA,mkBADPA,EAAQ,CAAA,CAAA,uBAAb,OAAI,GAAA,+vEAnBdC,EAoCKC,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