webapp.index.87a258c2.js.map Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of langgraph4j-studio Show documentation
Show all versions of langgraph4j-studio Show documentation
an **embed playground webapp** to run a Langgraph4j workflow in visual way
{"mappings":"A,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,E,Q,C,I,E,E,S,E,E,SCyBA,MAAM,EAAQ,MAAO,GAAQ,IAAI,QAAQ,AAAA,GAAW,WAAW,EAAS,IASxE,eAAgB,EAAkB,CAAQ,EAExC,IAAM,EAAS,EAAS,IAAI,EAAE,YAE9B,KAAe,GAAQ,CAErB,GAAM,CAAA,KAAE,CAAI,CAAA,MAAE,CAAK,CAAE,CAAG,MAAM,EAAO,IAAI,GAEzC,GAAI,EAAM,KAEV,OAAO,IAAI,cAAc,MAAM,CAAC,EAClC,CACF,CASO,MAAM,UAA4B,EAAA,UAAS,CAQhD,OAAO,OAAS,CAAC,EAAA,OAAO,CAAG,AAAA,CAAA,EAAA,EAAA,GAAE,AAAF,CAAG,CAAC;;;;;;;;;;;;;;;;;;;EAmB/B,CAAC,CAAC,AAAC,AASH,QAAO,WAAa,CAClB,IAAK,CAAE,KAAM,OAAQ,QAAS,CAAA,CAAM,EACpC,KAAM,CAAE,KAAM,QAAS,QAAS,CAAA,CAAK,EACrC,WAAY,CAAE,MAAO,CAAA,CAAK,CAE5B,CAAC,AAKD,CAAA,IAAM,IAAI,AAOV,EAAC,CAAc,AAAA,AAOf,EAAC,CAAY,CAAG,IAAI,AAQpB,cAAc,CACZ,KAAK,GACL,IAAI,CAAC,IAAI,CAAG,CAAA,EACZ,IAAI,CAA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EACA,QAAS,CAAA,EACT,SAAU,CAAA,EACV,WAAY,CAAA,CACd,IAEA,IAAI,CAAC,YAAY,CAAG,CAClB,MAAO,CAAE,KAAM,SAAU,SAAU,CAAA,CAAK,CAC1C,EAEA,IAAI,CAAC,aAAa,EAEpB,CAGA,MAAM,CAAC,CAAsB,GAE3B,IAAM,EAAS,IAAI,CAAC,CAAC,CAAc,CAE7B,EAAO,MAA8B,IACzC,MAAM,EAAO,KACb,IAAI,CAAC,aAAa,CAAE,IAAI,YAAa,SAAU,CAC7C,OAAQ,CAAE,EAAQ,CAChB,WAAY,AAAW,UAAX,GAAsB,AAAS,SAAT,EAAmB,KAAA,EAAY,CAAC,WAAW,EAAE,EAAO,CAAC,CACvF,KAAM,EACN,MAAO,CACL,MAAO,gBACP,UAAW,CAAE,MAAO,SAAU,MAAO,CAAA,CAAK,EAC1C,UAAW,CAAE,MAAO,SAAU,SAAU,CAAE,SAAU,CAAC,EAAE,EAAE,EAAE,AAAA,CAAE,CAAE,CAAC,EACjE,CACH,QAAS,CAAA,EACT,SAAU,CAAA,EACV,WAAY,CAAA,CACd,GACF,CAEA,OAAM,EAAM,SACZ,MAAM,EAAM,YACZ,MAAM,EAAM,mBACZ,MAAM,EAAM,mBACZ,MAAM,EAAM,YACZ,MAAM,EAAM,mBACZ,MAAM,EAAM,YACZ,MAAM,EAAM,OAEd,CAEF,CAGA,OAAO,cAAc,CAAC,MAAM,CAAC,gBAAiB","sources":["","src/lg4j-executor.js"],"sourcesContent":["\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequire0031\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequire0031\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\n\nvar $hNeh9 = parcelRequire(\"hNeh9\");\n\nvar $800sp = parcelRequire(\"800sp\");\n/**\n * @file\n * @typedef {import('./types.js').ResultData} ResultData * \n */ /**\n * @file\n * @typedef {import('./types.js').EditEvent} EditEvent\n */ /**\n * @file\n * @typedef {import('./types.js').UpdatedState} UpdatedState\n */ /**\n * Asynchronously waits for a specified number of milliseconds.\n * \n * @param {number} ms - The number of milliseconds to wait.\n * @returns {Promise} A promise that resolves after the specified delay.\n */ const $0ca21e1f1d158660$var$delay = async (ms)=>new Promise((resolve)=>setTimeout(resolve, ms));\n/**\n * Asynchronously fetches data from a given fetch call and yields the data in chunks.\n * @async\n * @generator\n * @param {Response} response\n * @yields {Promise} The decoded text chunk from the response stream.\n */ async function* $0ca21e1f1d158660$var$streamingResponse(response) {\n // Attach Reader\n const reader = response.body?.getReader();\n while(reader){\n // wait for next encoded chunk\n const { done: done, value: value } = await reader.read();\n // check if stream is done\n if (done) break;\n // Decodes data chunk and yields it\n yield new TextDecoder().decode(value);\n }\n}\nclass $0ca21e1f1d158660$export$2fe88ce002d9c04f extends (0, $800sp.LitElement) {\n /**\n * Styles applied to the component.\n * \n * @static\n * @type {Array}\n */ static styles = [\n (0, $hNeh9.default),\n (0, $800sp.css)`\n .container {\n display: flex;\n flex-direction: column;\n row-gap: 10px;\n }\n\n .commands {\n display: flex;\n flex-direction: row;\n column-gap: 10px;\n }\n\n .item1 {\n flex-grow: 2;\n }\n .item2 {\n flex-grow: 2;\n }\n `\n ];\n /**\n * Properties of the component.\n * \n * @static\n * @type { import('lit').PropertyDeclarations }\n */ static properties = {\n url: {\n type: String,\n reflect: true\n },\n test: {\n type: Boolean,\n reflect: true\n },\n _executing: {\n state: true\n }\n };\n /**\n * @type {string | null }\n */ url = null;\n /**\n * current selected thread\n * \n * @type {string|undefined} - thread id\n */ #selectedThread;\n /**\n * current state for update \n * \n * @type {UpdatedState|null}\n */ #updatedState = null;\n /**\n * Creates an instance of LG4JInputElement.\n * \n * @constructor\n */ constructor(){\n super();\n this.test = false;\n this.formMetaData = {};\n this._executing = false;\n }\n /**\n * Event handler for the 'update slected thread' event.\n * \n * @param {CustomEvent} e - The event object containing the updated data.\n */ #onThreadUpdated(e) {\n console.debug(\"thread-updated\", e.detail);\n this.#selectedThread = e.detail;\n this.#updatedState = null;\n this.requestUpdate();\n }\n /**\n * \n * @param {CustomEvent} e - The event object containing the result data.\n */ #onNodeUpdated(e) {\n console.debug(\"onNodeUpdated\", e);\n this.#updatedState = e.detail;\n this.requestUpdate();\n }\n /**\n * Lifecycle method called when the element is added to the document's DOM.\n */ connectedCallback() {\n super.connectedCallback();\n // @ts-ignore\n this.addEventListener(\"thread-updated\", this.#onThreadUpdated);\n // @ts-ignore\n this.addEventListener(\"node-updated\", this.#onNodeUpdated);\n if (this.test) {\n this.#_test_callInit();\n return;\n }\n this.#callInit();\n }\n disconnectedCallback() {\n super.disconnectedCallback();\n // @ts-ignore\n this.removeEventListener(\"thread-updated\", this.#onThreadUpdated);\n // @ts-ignore\n this.removeEventListener(\"node-updated\", this.#onNodeUpdated);\n }\n /**\n * Renders the HTML template for the component.\n * \n * @returns The rendered HTML template.\n */ render() {\n // console.debug( 'render', this.formMetaData )\n return (0, $800sp.html)`\n \n ${Object.entries(this.formMetaData).map(([key, _])=>(0, $800sp.html)``)}\n \n \n \n \n \n `;\n }\n async #callInit() {\n const initResponse = await fetch(`${this.url}/init`);\n const initData = await initResponse.json();\n console.debug(\"initData\", initData);\n this.dispatchEvent(new CustomEvent(\"init\", {\n detail: initData,\n bubbles: true,\n composed: true,\n cancelable: true\n }));\n this.formMetaData = initData.args;\n // this.#nodes = initData.nodes\n this.requestUpdate();\n }\n async #callResume() {\n this._executing = true;\n try {\n if (this.test) {\n await this.#_test_callSubmitAction();\n return;\n }\n await this.#callResumeAction();\n } finally{\n this._executing = false;\n }\n }\n async #callResumeAction() {\n const execResponse = await fetch(`${this.url}/stream?thread=${this.#selectedThread}&resume=true&node=${this.#updatedState?.node}&checkpoint=${this.#updatedState?.checkpoint}`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(this.#updatedState?.data)\n });\n this.#updatedState = null;\n for await (let chunk of $0ca21e1f1d158660$var$streamingResponse(execResponse)){\n console.debug(chunk);\n this.dispatchEvent(new CustomEvent(\"result\", {\n detail: JSON.parse(chunk),\n bubbles: true,\n composed: true,\n cancelable: true\n }));\n }\n }\n async #callSubmit() {\n this._executing = true;\n try {\n if (this.test) {\n await this.#_test_callSubmitAction();\n return;\n }\n await this.#callSubmitAction();\n } finally{\n this._executing = false;\n }\n }\n async #callSubmitAction() {\n // Get input as object\n /**\n * @type { Record } data\n */ const data = Object.keys(this.formMetaData).reduce((acc, key)=>{\n // @ts-ignore\n acc[key] = this.shadowRoot?.getElementById(key)?.value;\n return acc;\n }, {});\n const execResponse = await fetch(`${this.url}/stream?thread=${this.#selectedThread}`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify(data)\n });\n for await (let chunk of $0ca21e1f1d158660$var$streamingResponse(execResponse)){\n console.debug(chunk);\n this.dispatchEvent(new CustomEvent(\"result\", {\n detail: JSON.parse(chunk),\n bubbles: true,\n composed: true,\n cancelable: true\n }));\n }\n }\n ////////////////////////////////////////////////////////\n // TEST\n ///////////////////////////////////////////////////////\n async #_test_callInit() {\n await $0ca21e1f1d158660$var$delay(1000);\n this.dispatchEvent(new CustomEvent(\"init\", {\n detail: {\n threads: [\n [\n \"default\",\n []\n ]\n ],\n title: \"LangGraph4j : TEST\",\n graph: `\n---\ntitle: TEST\n--- \nflowchart TD\n start((start))\n stop((stop))\n web_search(\"web_search\")\n retrieve(\"retrieve\")\n grade_documents(\"grade_documents\")\n generate(\"generate\")\n transform_query(\"transform_query\")\n start:::start -->|web_search| web_search:::web_search\n start:::start -->|vectorstore| retrieve:::retrieve\n web_search:::web_search --> generate:::generate\n retrieve:::retrieve --> grade_documents:::grade_documents\n grade_documents:::grade_documents -->|transform_query| transform_query:::transform_query\n grade_documents:::grade_documents -->|generate| generate:::generate\n transform_query:::transform_query --> retrieve:::retrieve\n generate:::generate -->|not supported| generate:::generate\n generate:::generate -->|not useful| transform_query:::transform_query\n generate:::generate -->|useful| stop:::stop\n `\n },\n bubbles: true,\n composed: true,\n cancelable: true\n }));\n this.formMetaData = {\n input: {\n type: \"string\",\n required: true\n }\n };\n this.requestUpdate();\n }\n async #_test_callSubmitAction() {\n const thread = this.#selectedThread;\n const send = async (/** @type {string} */ nodeId)=>{\n await $0ca21e1f1d158660$var$delay(1000);\n this.dispatchEvent(new CustomEvent(\"result\", {\n detail: [\n thread,\n {\n checkpoint: nodeId === \"start\" || nodeId === \"stop\" ? undefined : `checkpoint-${nodeId}`,\n node: nodeId,\n state: {\n input: \"this is input\",\n property1: {\n value: \"value1\",\n valid: true\n },\n property2: {\n value: \"value2\",\n children: {\n elements: [\n 1,\n 2,\n 3\n ]\n }\n }\n }\n }\n ],\n bubbles: true,\n composed: true,\n cancelable: true\n }));\n };\n await send(\"start\");\n await send(\"retrieve\");\n await send(\"grade_documents\");\n await send(\"transform_query\");\n await send(\"retrieve\");\n await send(\"grade_documents\");\n await send(\"generate\");\n await send(\"stop\");\n }\n}\nwindow.customElements.define(\"lg4j-executor\", $0ca21e1f1d158660$export$2fe88ce002d9c04f);\n\n\n//# sourceMappingURL=index.87a258c2.js.map\n","import TWStyles from './twlit.js';\n\nimport { html, css, LitElement, CSSResult } from 'lit';\n\n/**\n * @file\n * @typedef {import('./types.js').ResultData} ResultData * \n */\n\n/**\n * @file\n * @typedef {import('./types.js').EditEvent} EditEvent\n */\n\n/**\n * @file\n * @typedef {import('./types.js').UpdatedState} UpdatedState\n */\n\n/**\n * Asynchronously waits for a specified number of milliseconds.\n * \n * @param {number} ms - The number of milliseconds to wait.\n * @returns {Promise} A promise that resolves after the specified delay.\n */\nconst delay = async (ms) => (new Promise(resolve => setTimeout(resolve, ms)));\n\n/**\n * Asynchronously fetches data from a given fetch call and yields the data in chunks.\n * @async\n * @generator\n * @param {Response} response\n * @yields {Promise} The decoded text chunk from the response stream.\n */\nasync function* streamingResponse(response) {\n // Attach Reader\n const reader = response.body?.getReader();\n\n while (true && reader) {\n // wait for next encoded chunk\n const { done, value } = await reader.read();\n // check if stream is done\n if (done) break;\n // Decodes data chunk and yields it\n yield (new TextDecoder().decode(value));\n }\n}\n\n/**\n * LG4JInputElement is a custom web component that extends LitElement.\n * It provides a styled input container with a placeholder.\n * \n * @class\n * @extends {LitElement}\n */\nexport class LG4JExecutorElement extends LitElement {\n\n /**\n * Styles applied to the component.\n * \n * @static\n * @type {Array}\n */\n static styles = [TWStyles, css`\n .container {\n display: flex;\n flex-direction: column;\n row-gap: 10px;\n }\n\n .commands {\n display: flex;\n flex-direction: row;\n column-gap: 10px;\n }\n\n .item1 {\n flex-grow: 2;\n }\n .item2 {\n flex-grow: 2;\n }\n `];\n\n\n /**\n * Properties of the component.\n * \n * @static\n * @type { import('lit').PropertyDeclarations }\n */\n static properties = {\n url: { type: String, reflect: true },\n test: { type: Boolean, reflect: true },\n _executing: { state: true }\n \n }\n\n /**\n * @type {string | null }\n */\n url = null\n\n /**\n * current selected thread\n * \n * @type {string|undefined} - thread id\n */\n #selectedThread\n\n /**\n * current state for update \n * \n * @type {UpdatedState|null}\n */\n #updatedState = null\n\n\n /**\n * Creates an instance of LG4JInputElement.\n * \n * @constructor\n */\n constructor() {\n super();\n this.test = false\n this.formMetaData = {}\n this._executing = false\n \n }\n\n /**\n * Event handler for the 'update slected thread' event.\n * \n * @param {CustomEvent} e - The event object containing the updated data.\n */\n #onThreadUpdated( e ) {\n console.debug( 'thread-updated', e.detail )\n this.#selectedThread = e.detail\n this.#updatedState = null\n this.requestUpdate()\n }\n\n /**\n * \n * @param {CustomEvent} e - The event object containing the result data.\n */\n #onNodeUpdated( e ) {\n console.debug( 'onNodeUpdated', e )\n this.#updatedState = e.detail\n this.requestUpdate()\n }\n\n /**\n * Lifecycle method called when the element is added to the document's DOM.\n */\n connectedCallback() {\n super.connectedCallback();\n\n // @ts-ignore\n this.addEventListener( \"thread-updated\", this.#onThreadUpdated );\n // @ts-ignore\n this.addEventListener( 'node-updated', this.#onNodeUpdated )\n\n if(this.test ) {\n this.#_test_callInit();\n return\n }\n\n this.#callInit()\n\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n // @ts-ignore\n this.removeEventListener( \"thread-updated\", this.#onThreadUpdated )\n // @ts-ignore\n this.removeEventListener( 'node-updated', this.#onNodeUpdated )\n\n }\n\n /**\n * Renders the HTML template for the component.\n * \n * @returns The rendered HTML template.\n */\n render() {\n\n // console.debug( 'render', this.formMetaData )\n return html`\n \n ${ Object.entries(this.formMetaData).map( ([key, _]) => \n html``\n )}\n \n \n \n \n \n `;\n }\n\n async #callInit() {\n\n const initResponse = await fetch( `${this.url}/init` )\n\n const initData = await initResponse.json()\n \n console.debug( 'initData', initData );\n\n this.dispatchEvent( new CustomEvent( 'init', { \n detail: initData,\n bubbles: true,\n composed: true,\n cancelable: true\n }));\n\n this.formMetaData = initData.args\n // this.#nodes = initData.nodes\n this.requestUpdate()\n }\n\n\nasync #callResume() {\n this._executing = true\n try {\n\n if(this.test ) {\n await this.#_test_callSubmitAction();\n return\n }\n\n await this.#callResumeAction()\n \n \n }\n finally {\n this._executing = false\n }\n\n} \n\nasync #callResumeAction() {\n\n const execResponse = await fetch(`${this.url}/stream?thread=${this.#selectedThread}&resume=true&node=${this.#updatedState?.node}&checkpoint=${this.#updatedState?.checkpoint}`, {\n method: 'POST', // *GET, POST, PUT, DELETE, etc.\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify(this.#updatedState?.data)\n });\n\n this.#updatedState = null\n\n for await (let chunk of streamingResponse( execResponse ) ) {\n console.debug( chunk )\n\n this.dispatchEvent( new CustomEvent( 'result', { \n detail: JSON.parse(chunk),\n bubbles: true,\n composed: true,\n cancelable: true\n } ) );\n\n }\n\n\n}\n\nasync #callSubmit() {\n\n this._executing = true\n try {\n\n if(this.test ) {\n await this.#_test_callSubmitAction();\n return\n }\n\n await this.#callSubmitAction()\n \n }\n finally {\n this._executing = false\n }\n}\n\nasync #callSubmitAction() {\n \n // Get input as object\n /**\n * @type { Record } data\n */\n const data = Object.keys(this.formMetaData).reduce( (acc, key) => {\n // @ts-ignore\n acc[key] = this.shadowRoot?.getElementById(key)?.value\n return acc\n }, {});\n\n const execResponse = await fetch(`${this.url}/stream?thread=${this.#selectedThread}`, {\n method: 'POST', // *GET, POST, PUT, DELETE, etc.\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify(data)\n });\n\n for await (let chunk of streamingResponse( execResponse ) ) {\n console.debug( chunk )\n\n this.dispatchEvent( new CustomEvent( 'result', { \n detail: JSON.parse(chunk),\n bubbles: true,\n composed: true,\n cancelable: true\n } ) );\n\n }\n \n}\n \n////////////////////////////////////////////////////////\n// TEST\n///////////////////////////////////////////////////////\n\n async #_test_callInit() {\n \n await delay( 1000 );\n this.dispatchEvent( new CustomEvent( 'init', { \n detail: { \n threads: [ ['default', [] ] ],\n title: 'LangGraph4j : TEST',\n graph:`\n---\ntitle: TEST\n--- \nflowchart TD\n start((start))\n stop((stop))\n web_search(\"web_search\")\n retrieve(\"retrieve\")\n grade_documents(\"grade_documents\")\n generate(\"generate\")\n transform_query(\"transform_query\")\n start:::start -->|web_search| web_search:::web_search\n start:::start -->|vectorstore| retrieve:::retrieve\n web_search:::web_search --> generate:::generate\n retrieve:::retrieve --> grade_documents:::grade_documents\n grade_documents:::grade_documents -->|transform_query| transform_query:::transform_query\n grade_documents:::grade_documents -->|generate| generate:::generate\n transform_query:::transform_query --> retrieve:::retrieve\n generate:::generate -->|not supported| generate:::generate\n generate:::generate -->|not useful| transform_query:::transform_query\n generate:::generate -->|useful| stop:::stop\n `\n },\n bubbles: true,\n composed: true,\n cancelable: true\n }));\n\n this.formMetaData = { \n input: { type: 'string', required: true }\n }\n \n this.requestUpdate()\n\n }\n\n\n async #_test_callSubmitAction( ) {\n\n const thread = this.#selectedThread\n \n const send = async ( /** @type {string} */ nodeId ) => {\n await delay( 1000 );\n this.dispatchEvent( new CustomEvent( 'result', { \n detail: [ thread, { \n checkpoint: ( nodeId==='start' || nodeId==='stop') ? undefined : `checkpoint-${nodeId}`,\n node: nodeId, \n state: { \n input: \"this is input\",\n property1: { value: \"value1\", valid: true } , \n property2: { value: \"value2\", children: { elements: [1,2,3]} } }}\n ],\n bubbles: true,\n composed: true,\n cancelable: true\n }));\n }\n\n await send( 'start' );\n await send( 'retrieve' );\n await send( 'grade_documents');\n await send( 'transform_query');\n await send( 'retrieve' );\n await send( 'grade_documents');\n await send( 'generate');\n await send( 'stop' );\n\n }\n\n}\n\n\nwindow.customElements.define('lg4j-executor', LG4JExecutorElement);\n"],"names":["$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","$hNeh9","$800sp","$0ca21e1f1d158660$var$delay","ms","Promise","resolve","setTimeout","$0ca21e1f1d158660$var$streamingResponse","response","reader","body","getReader","done","value","read","TextDecoder","decode","$0ca21e1f1d158660$export$2fe88ce002d9c04f","LitElement","styles","default","css","properties","url","type","String","reflect","test","Boolean","_executing","state","selectedThread","updatedState","constructor","formMetaData","onThreadUpdated","e","console","debug","detail","requestUpdate","onNodeUpdated","connectedCallback","addEventListener","_test_callInit","callInit","disconnectedCallback","removeEventListener","render","html","Object","entries","map","key","_","callSubmit","callResume","node","initResponse","fetch","initData","json","dispatchEvent","CustomEvent","bubbles","composed","cancelable","args","_test_callSubmitAction","callResumeAction","execResponse","checkpoint","method","headers","JSON","stringify","data","chunk","parse","callSubmitAction","keys","reduce","acc","shadowRoot","getElementById","threads","title","graph","input","required","thread","send","nodeId","undefined","property1","valid","property2","children","elements","window","customElements","define"],"version":3,"file":"index.87a258c2.js.map"}