/*! For license information please see 17.8fcf96d89753cf41a861.js.LICENSE.txt */
"use strict";(self.webpackChunkjupyterpack=self.webpackChunkjupyterpack||[]).push([[17],{17:(e,t,n)=>{n.r(t),n.d(t,{createEndpoint:()=>a,expose:()=>l,finalizer:()=>i,proxy:()=>w,proxyMarker:()=>r,releaseProxy:()=>s,transfer:()=>v,transferHandlers:()=>u,windowEndpoint:()=>k,wrap:()=>f});const r=Symbol("Comlink.proxy"),a=Symbol("Comlink.endpoint"),s=Symbol("Comlink.releaseProxy"),i=Symbol("Comlink.finalizer"),o=Symbol("Comlink.thrown"),c=e=>"object"==typeof e&&null!==e||"function"==typeof e,u=new Map([["proxy",{canHandle:e=>c(e)&&e[r],serialize(e){const{port1:t,port2:n}=new MessageChannel;return l(e,t),[n,[n]]},deserialize:e=>(e.start(),f(e))}],["throw",{canHandle:e=>c(e)&&o in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function l(e,t=globalThis,n=["*"]){t.addEventListener("message",(function r(a){if(!a||!a.data)return;if(!function(e,t){for(const n of e){if(t===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(t))return!0}return!1}(n,a.origin))return void console.warn(`Invalid origin '${a.origin}' for comlink proxy`);const{id:s,type:c,path:u}=Object.assign({path:[]},a.data),f=(a.data.argumentList||[]).map(L);let g;try{const t=u.slice(0,-1).reduce(((e,t)=>e[t]),e),n=u.reduce(((e,t)=>e[t]),e);switch(c){case"GET":g=n;break;case"SET":t[u.slice(-1)[0]]=L(a.data.value),g=!0;break;case"APPLY":g=n.apply(t,f);break;case"CONSTRUCT":g=w(new n(...f));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;l(e,n),g=v(t,[t])}break;case"RELEASE":g=void 0;break;default:return}}catch(e){g={value:e,[o]:0}}Promise.resolve(g).catch((e=>({value:e,[o]:0}))).then((n=>{const[a,o]=S(n);t.postMessage(Object.assign(Object.assign({},a),{id:s}),o),"RELEASE"===c&&(t.removeEventListener("message",r),p(t),i in e&&"function"==typeof e[i]&&e[i]())})).catch((e=>{const[n,r]=S({value:new TypeError("Unserializable return value"),[o]:0});t.postMessage(Object.assign(Object.assign({},n),{id:s}),r)}))})),t.start&&t.start()}function p(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function f(e,t){const n=new Map;return e.addEventListener("message",(function(e){const{data:t}=e;if(!t||!t.id)return;const r=n.get(t.id);if(r)try{r(t)}finally{n.delete(t.id)}})),h(e,n,[],t)}function g(e){if(e)throw new Error("Proxy has been released and is not useable")}function d(e){return M(e,new Map,{type:"RELEASE"}).then((()=>{p(e)}))}const m=new WeakMap,y="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const t=(m.get(e)||0)-1;m.set(e,t),0===t&&d(e)}));function h(e,t,n=[],r=function(){}){let i=!1;const o=new Proxy(r,{get(r,a){if(g(i),a===s)return()=>{!function(e){y&&y.unregister(e)}(o),d(e),t.clear(),i=!0};if("then"===a){if(0===n.length)return{then:()=>o};const r=M(e,t,{type:"GET",path:n.map((e=>e.toString()))}).then(L);return r.then.bind(r)}return h(e,t,[...n,a])},set(r,a,s){g(i);const[o,c]=S(s);return M(e,t,{type:"SET",path:[...n,a].map((e=>e.toString())),value:o},c).then(L)},apply(r,s,o){g(i);const c=n[n.length-1];if(c===a)return M(e,t,{type:"ENDPOINT"}).then(L);if("bind"===c)return h(e,t,n.slice(0,-1));const[u,l]=E(o);return M(e,t,{type:"APPLY",path:n.map((e=>e.toString())),argumentList:u},l).then(L)},construct(r,a){g(i);const[s,o]=E(a);return M(e,t,{type:"CONSTRUCT",path:n.map((e=>e.toString())),argumentList:s},o).then(L)}});return function(e,t){const n=(m.get(t)||0)+1;m.set(t,n),y&&y.register(e,t,e)}(o,e),o}function E(e){const t=e.map(S);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const b=new WeakMap;function v(e,t){return b.set(e,t),e}function w(e){return Object.assign(e,{[r]:!0})}function k(e,t=globalThis,n="*"){return{postMessage:(t,r)=>e.postMessage(t,n,r),addEventListener:t.addEventListener.bind(t),removeEventListener:t.removeEventListener.bind(t)}}function S(e){for(const[t,n]of u)if(n.canHandle(e)){const[r,a]=n.serialize(e);return[{type:"HANDLER",name:t,value:r},a]}return[{type:"RAW",value:e},b.get(e)||[]]}function L(e){switch(e.type){case"HANDLER":return u.get(e.name).deserialize(e.value);case"RAW":return e.value}}function M(e,t,n,r){return new Promise((a=>{const s=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.set(s,a),e.start&&e.start(),e.postMessage(Object.assign({id:s},n),r)}))}}}]);